use of com.amazonaws.services.simpledb.model.NoSuchDomainException in project camel by apache.
the class SdbEndpoint method doStart.
@Override
public void doStart() throws Exception {
super.doStart();
sdbClient = configuration.getAmazonSDBClient() != null ? configuration.getAmazonSDBClient() : createSdbClient();
if (ObjectHelper.isNotEmpty(configuration.getAmazonSdbEndpoint())) {
sdbClient.setEndpoint(configuration.getAmazonSdbEndpoint());
}
String domainName = getConfiguration().getDomainName();
LOG.trace("Querying whether domain [{}] already exists...", domainName);
try {
sdbClient.domainMetadata(new DomainMetadataRequest(domainName));
LOG.trace("Domain [{}] already exists", domainName);
return;
} catch (NoSuchDomainException ase) {
LOG.trace("Domain [{}] doesn't exist yet", domainName);
LOG.trace("Creating domain [{}]...", domainName);
sdbClient.createDomain(new CreateDomainRequest(domainName));
LOG.trace("Domain [{}] created", domainName);
}
}
use of com.amazonaws.services.simpledb.model.NoSuchDomainException in project simplejpa by appoxy.
the class AbstractQuery method getResultList.
public List getResultList() {
// convert to amazon query
AmazonQueryString amazonQuery;
try {
amazonQuery = createAmazonQuery();
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
if (amazonQuery == null) {
return new ArrayList();
}
try {
// String qToSend = amazonQuery != null ? amazonQuery.toString() : null;
em.incrementQueryCount();
if (amazonQuery.isCount()) {
// String domainName = em.getDomainName(tClass);
String nextToken = null;
SelectResult qr;
long count = 0;
while ((qr = DomainHelper.selectItems(this.em.getSimpleDb(), amazonQuery.getValue(), nextToken)) != null) {
Map<String, List<Attribute>> itemMap = new HashMap<String, List<Attribute>>();
for (Item item : qr.getItems()) {
itemMap.put(item.getName(), item.getAttributes());
}
for (String id : itemMap.keySet()) {
List<Attribute> list = itemMap.get(id);
for (Attribute itemAttribute : list) {
if (itemAttribute.getName().equals("Count")) {
count += Long.parseLong(itemAttribute.getValue());
}
}
}
nextToken = qr.getNextToken();
if (nextToken == null) {
break;
}
}
return Arrays.asList(count);
} else {
LazyList ret = new LazyList(em, tClass, this);
return ret;
}
} catch (NoSuchDomainException e) {
// no need to throw here
return new ArrayList();
} catch (Exception e) {
throw new PersistenceException(e);
}
}
use of com.amazonaws.services.simpledb.model.NoSuchDomainException in project camel by apache.
the class AmazonSDBClientMock method domainMetadata.
@Override
public DomainMetadataResult domainMetadata(DomainMetadataRequest domainMetadataRequest) throws AmazonServiceException, AmazonClientException {
this.domainMetadataRequest = domainMetadataRequest;
if ("NonExistingDomain".equals(domainMetadataRequest.getDomainName())) {
throw new NoSuchDomainException("Domain 'NonExistingDomain' doesn't exist.");
}
DomainMetadataResult result = new DomainMetadataResult();
result.setTimestamp(new Integer(10));
result.setItemCount(new Integer(11));
result.setAttributeNameCount(new Integer(12));
result.setAttributeValueCount(new Integer(13));
result.setAttributeNamesSizeBytes(new Long(1000000));
result.setAttributeValuesSizeBytes(new Long(2000000));
result.setItemNamesSizeBytes(new Long(3000000));
return result;
}
Aggregations