@Test @Ignore public void getInstanceById() throws Exception { EsDailySnapshotStoreFactory factory = new EsDailySnapshotStoreFactory(); EsDailySnapshotStore store = (EsDailySnapshotStore) factory.getDailyStore(DateTime.parse("2016-07-14")); EsDailySnapshotInstance inst = store.getInstanceById("i-9909451f"); Assert.assertEquals("i-9909451f", inst.getId()); Assert.assertEquals("Growth", inst.getUsageTag()[0]); inst = store.getInstanceById("i-999c8b05"); Assert.assertEquals("SRE", inst.getSysTag()[0]); Assert.assertEquals("vpc-app-production", inst.getSecurityGroups().get(0)); }
@Override public EsDailySnapshotInstance getInstanceById(String instanceId) throws Exception { SearchResponse response = this.retrieveByField("_id", instanceId, EsDailySnapshotInstance.class); if (response.getHits().totalHits() > 0) { String str = response.getHits().getAt(0).getSourceAsString(); EsDailySnapshotInstance inst = essnapshotinstanceMapper.readValue(str, EsDailySnapshotInstance.class); inst.setId(response.getHits().getAt(0).getId()); inst.setVersion(response.getHits().getAt(0).getVersion()); return inst; } return null; }
EsDailySnapshotStore extends EsStore implements DailySnapshotStore { @Override public EsDailySnapshotInstance getInstanceById(String instanceId) throws Exception { SearchResponse response = this.retrieveByField("_id", instanceId, EsDailySnapshotInstance.class); if (response.getHits().totalHits() > 0) { String str = response.getHits().getAt(0).getSourceAsString(); EsDailySnapshotInstance inst = essnapshotinstanceMapper.readValue(str, EsDailySnapshotInstance.class); inst.setId(response.getHits().getAt(0).getId()); inst.setVersion(response.getHits().getAt(0).getVersion()); return inst; } return null; } }
EsDailySnapshotStore extends EsStore implements DailySnapshotStore { @Override public EsDailySnapshotInstance getInstanceById(String instanceId) throws Exception { SearchResponse response = this.retrieveByField("_id", instanceId, EsDailySnapshotInstance.class); if (response.getHits().totalHits() > 0) { String str = response.getHits().getAt(0).getSourceAsString(); EsDailySnapshotInstance inst = essnapshotinstanceMapper.readValue(str, EsDailySnapshotInstance.class); inst.setId(response.getHits().getAt(0).getId()); inst.setVersion(response.getHits().getAt(0).getVersion()); return inst; } return null; } EsDailySnapshotStore(DateTime day); }
EsDailySnapshotStore extends EsStore implements DailySnapshotStore { @Override public EsDailySnapshotInstance getInstanceById(String instanceId) throws Exception { SearchResponse response = this.retrieveByField("_id", instanceId, EsDailySnapshotInstance.class); if (response.getHits().totalHits() > 0) { String str = response.getHits().getAt(0).getSourceAsString(); EsDailySnapshotInstance inst = essnapshotinstanceMapper.readValue(str, EsDailySnapshotInstance.class); inst.setId(response.getHits().getAt(0).getId()); inst.setVersion(response.getHits().getAt(0).getVersion()); return inst; } return null; } EsDailySnapshotStore(DateTime day); @Override String getIndexName(); @Override String getDocTypeName(); @Override EsDailySnapshotInstance getInstanceById(String instanceId); @Override long updateOrInsert(EsDailySnapshotInstance instance); @Override long update(EsDailySnapshotInstance instance); @Override Iterator<EsDailySnapshotInstance> getSnapshotInstances(); @Override void bulkInsert(List<EsDailySnapshotInstance> instances); @Override void bulkUpdate(List<EsDailySnapshotInstance> instances); }
EsDailySnapshotStore extends EsStore implements DailySnapshotStore { @Override public EsDailySnapshotInstance getInstanceById(String instanceId) throws Exception { SearchResponse response = this.retrieveByField("_id", instanceId, EsDailySnapshotInstance.class); if (response.getHits().totalHits() > 0) { String str = response.getHits().getAt(0).getSourceAsString(); EsDailySnapshotInstance inst = essnapshotinstanceMapper.readValue(str, EsDailySnapshotInstance.class); inst.setId(response.getHits().getAt(0).getId()); inst.setVersion(response.getHits().getAt(0).getVersion()); return inst; } return null; } EsDailySnapshotStore(DateTime day); @Override String getIndexName(); @Override String getDocTypeName(); @Override EsDailySnapshotInstance getInstanceById(String instanceId); @Override long updateOrInsert(EsDailySnapshotInstance instance); @Override long update(EsDailySnapshotInstance instance); @Override Iterator<EsDailySnapshotInstance> getSnapshotInstances(); @Override void bulkInsert(List<EsDailySnapshotInstance> instances); @Override void bulkUpdate(List<EsDailySnapshotInstance> instances);  }