List of usage examples for com.amazonaws.services.simpledb.model Item Item
public Item(String name, java.util.List<Attribute> attributes)
From source file:org.apache.camel.component.aws.sdb.AmazonSDBClientMock.java
License:Apache License
@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; }
From source file:org.grails.datastore.mapping.simpledb.util.SimpleDBTemplateImpl.java
License:Apache License
private Item getInternal(String domainName, String id, int attempt) { GetAttributesRequest request = new GetAttributesRequest(domainName, id); try {// w ww . j a v a 2s. co m List<Attribute> attributes = sdb.getAttributes(request).getAttributes(); if (attributes.isEmpty()) { return null; } return new Item(id, attributes); } catch (AmazonServiceException e) { if (SimpleDBUtil.AWS_ERR_CODE_NO_SUCH_DOMAIN.equals(e.getErrorCode())) { throw new IllegalArgumentException("no such domain: " + domainName, e); } else if (SimpleDBUtil.AWS_ERR_CODE_SERVICE_UNAVAILABLE.equals(e.getErrorCode())) { //retry after a small pause SimpleDBUtil.sleepBeforeRetry(attempt); attempt++; return getInternal(domainName, id, attempt); } else { throw e; } } }
From source file:org.grails.datastore.mapping.simpledb.util.SimpleDBTemplateImpl.java
License:Apache License
private Item getConsistentInternal(String domainName, String id, int attempt) { // String selectExpression = "select * from `" + domainName + "` where id = '"+id+"'"; //todo //todo - handle exceptions and retries GetAttributesRequest request = new GetAttributesRequest(domainName, id); request.setConsistentRead(true);// ww w . j a va2 s.c o m try { List<Attribute> attributes = sdb.getAttributes(request).getAttributes(); if (attributes.isEmpty()) { return null; } return new Item(id, attributes); } catch (AmazonServiceException e) { if (SimpleDBUtil.AWS_ERR_CODE_NO_SUCH_DOMAIN.equals(e.getErrorCode())) { throw new IllegalArgumentException("no such domain: " + domainName, e); } else if (SimpleDBUtil.AWS_ERR_CODE_SERVICE_UNAVAILABLE.equals(e.getErrorCode())) { //retry after a small pause SimpleDBUtil.sleepBeforeRetry(attempt); attempt++; return getConsistentInternal(domainName, id, attempt); } else { throw e; } } }