use of com.amazonaws.services.simpledb.model.SelectResult in project siena by mandubian.
the class SdbPersistenceManager method rawGetByKeys.
protected <T> List<T> rawGetByKeys(Class<T> clazz, Iterable<?> keys) {
try {
StringBuffer domainBuf = new StringBuffer();
SelectRequest req = SdbMappingUtils.buildBatchGetQueryByKeys(clazz, keys, prefix, domainBuf);
checkDomain(domainBuf.toString());
req.setConsistentRead(isReadConsistent());
SelectResult res = sdb.select(req);
List<T> models = new ArrayList<T>();
SdbMappingUtils.mapSelectResultToListOrderedFromKeys(res, models, clazz, keys);
// join management
if (!ClassInfo.getClassInfo(clazz).joinFields.isEmpty()) {
mapJoins(models);
}
return models;
} catch (AmazonClientException ex) {
throw new SienaException(ex);
}
}
use of com.amazonaws.services.simpledb.model.SelectResult in project camel by apache.
the class AmazonSDBClientMock method select.
@Override
public SelectResult select(SelectRequest selectRequest) throws AmazonServiceException, AmazonClientException {
this.selectRequest = selectRequest;
SelectResult result = new SelectResult();
result.setNextToken("TOKEN2");
result.getItems().add(new Item("ITEM1", null));
result.getItems().add(new Item("ITEM2", null));
return result;
}
use of com.amazonaws.services.simpledb.model.SelectResult in project SimianArmy by Netflix.
the class SimpleDBConformityClusterTracker method querySimpleDBItems.
private List<Item> querySimpleDBItems(String query) {
Validate.notNull(query);
String nextToken = null;
List<Item> items = new ArrayList<Item>();
do {
SelectRequest request = new SelectRequest(query);
request.setNextToken(nextToken);
request.setConsistentRead(Boolean.TRUE);
SelectResult result = this.simpleDBClient.select(request);
items.addAll(result.getItems());
nextToken = result.getNextToken();
} while (nextToken != null);
return items;
}
use of com.amazonaws.services.simpledb.model.SelectResult in project SimianArmy by Netflix.
the class TestSimpleDBRecorder method mkSelectResult.
private SelectResult mkSelectResult(String id) {
Item item = new Item();
List<Attribute> attrs = new LinkedList<Attribute>();
attrs.add(new Attribute("id", id));
attrs.add(new Attribute("eventTime", "1330538400000"));
attrs.add(new Attribute("region", "region"));
attrs.add(new Attribute("recordType", "MonkeyEvent"));
attrs.add(new Attribute("monkeyType", "MONKEY|com.netflix.simianarmy.aws.TestSimpleDBRecorder$Type"));
attrs.add(new Attribute("eventType", "EVENT|com.netflix.simianarmy.aws.TestSimpleDBRecorder$EventTypes"));
attrs.add(new Attribute("field1", "value1"));
attrs.add(new Attribute("field2", "value2"));
item.setAttributes(attrs);
item.setName("MONKEY-" + id + "-region");
SelectResult result = new SelectResult();
result.setItems(Arrays.asList(item));
return result;
}
use of com.amazonaws.services.simpledb.model.SelectResult in project SimianArmy by Netflix.
the class TestSimpleDBRecorder method testFindEvent.
@Test
public void testFindEvent() {
SelectResult result1 = mkSelectResult("testId1");
result1.setNextToken("nextToken");
SelectResult result2 = mkSelectResult("testId2");
ArgumentCaptor<SelectRequest> arg = ArgumentCaptor.forClass(SelectRequest.class);
when(sdbMock.select(any(SelectRequest.class))).thenReturn(result1).thenReturn(result2);
Map<String, String> query = new LinkedHashMap<String, String>();
query.put("instanceId", "testId1");
verifyEvents(findEvents(query, new Date(0)));
verify(sdbMock, times(2)).select(arg.capture());
SelectRequest req = arg.getValue();
StringBuilder sb = new StringBuilder();
sb.append("select * from `DOMAIN` where region = 'region'");
sb.append(" and instanceId = 'testId1'");
Assert.assertEquals(req.getSelectExpression(), sb.toString() + " and eventTime > '0' order by eventTime desc");
// reset for next test
when(sdbMock.select(any(SelectRequest.class))).thenReturn(result1).thenReturn(result2);
verifyEvents(findEvents(Type.MONKEY, query, new Date(0)));
verify(sdbMock, times(4)).select(arg.capture());
req = arg.getValue();
sb.append(" and monkeyType = 'MONKEY|com.netflix.simianarmy.aws.TestSimpleDBRecorder$Type'");
Assert.assertEquals(req.getSelectExpression(), sb.toString() + " and eventTime > '0' order by eventTime desc");
// reset for next test
when(sdbMock.select(any(SelectRequest.class))).thenReturn(result1).thenReturn(result2);
verifyEvents(findEvents(Type.MONKEY, EventTypes.EVENT, query, new Date(0)));
verify(sdbMock, times(6)).select(arg.capture());
req = arg.getValue();
sb.append(" and eventType = 'EVENT|com.netflix.simianarmy.aws.TestSimpleDBRecorder$EventTypes'");
Assert.assertEquals(req.getSelectExpression(), sb.toString() + " and eventTime > '0' order by eventTime desc");
// reset for next test
when(sdbMock.select(any(SelectRequest.class))).thenReturn(result1).thenReturn(result2);
verifyEvents(findEvents(Type.MONKEY, EventTypes.EVENT, query, new Date(1330538400000L)));
verify(sdbMock, times(8)).select(arg.capture());
req = arg.getValue();
sb.append(" and eventTime > '1330538400000' order by eventTime desc");
Assert.assertEquals(req.getSelectExpression(), sb.toString());
}
Aggregations