use of com.amazonaws.services.simpledb.model.CreateDomainRequest 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.CreateDomainRequest in project siena by mandubian.
the class SdbPersistenceManager method checkDomain.
public void checkDomain(String domainName) {
if (domains == null) {
domains = sdb.listDomains().getDomainNames();
}
if (!domains.contains(domainName)) {
sdb.createDomain(new CreateDomainRequest(domainName));
domains.add(domainName);
}
}
use of com.amazonaws.services.simpledb.model.CreateDomainRequest in project simplejpa by appoxy.
the class DomainHelperTests method selectItemsTests.
@Test
public void selectItemsTests() {
EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
AmazonSimpleDB sdbClient = em.getSimpleDb();
String domainName = "simplejpa-domainhelper-tests";
sdbClient.createDomain(new CreateDomainRequest().withDomainName(domainName));
try {
for (int i = 0; i < 10; i++) {
sdbClient.putAttributes(new PutAttributesRequest().withItemName("thing" + i).withDomainName(domainName).withAttributes(new ReplaceableAttribute("name", "value", true)));
}
SelectResult result = DomainHelper.selectItems(sdbClient, String.format("select * from `%s` LIMIT 3", domainName), null);
Assert.assertEquals(3, result.getItems().size());
Assert.assertNotNull(result.getNextToken());
result = DomainHelper.selectItems(sdbClient, String.format("select * from `%s` LIMIT 3", domainName), result.getNextToken());
Assert.assertEquals(3, result.getItems().size());
Assert.assertNotNull(result.getNextToken());
result = DomainHelper.selectItems(sdbClient, String.format("select * from `%s` LIMIT 3", domainName), result.getNextToken());
Assert.assertEquals(3, result.getItems().size());
Assert.assertNotNull(result.getNextToken());
result = DomainHelper.selectItems(sdbClient, String.format("select * from `%s` LIMIT 3", domainName), result.getNextToken());
Assert.assertEquals(1, result.getItems().size());
Assert.assertNull(result.getNextToken());
} finally {
sdbClient.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
}
}
use of com.amazonaws.services.simpledb.model.CreateDomainRequest in project simplejpa by appoxy.
the class DomainHelperTests method selectItemsWithWhereTests.
@Test
public void selectItemsWithWhereTests() {
EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
AmazonSimpleDB sdbClient = em.getSimpleDb();
String domainName = "simplejpa-domainhelper-tests";
sdbClient.createDomain(new CreateDomainRequest().withDomainName(domainName));
try {
for (int i = 0; i < 10; i++) {
sdbClient.putAttributes(new PutAttributesRequest().withItemName("thing" + i).withDomainName(domainName).withAttributes(new ReplaceableAttribute("name", "value", true)));
}
SelectResult result = DomainHelper.selectItems(sdbClient, domainName, "name = 'value' LIMIT 3", null);
Assert.assertEquals(3, result.getItems().size());
Assert.assertNotNull(result.getNextToken());
result = DomainHelper.selectItems(sdbClient, domainName, "name = 'value' LIMIT 3", result.getNextToken());
Assert.assertEquals(3, result.getItems().size());
Assert.assertNotNull(result.getNextToken());
result = DomainHelper.selectItems(sdbClient, domainName, "name = 'value' LIMIT 3", result.getNextToken());
Assert.assertEquals(3, result.getItems().size());
Assert.assertNotNull(result.getNextToken());
result = DomainHelper.selectItems(sdbClient, domainName, "name = 'value' LIMIT 3", result.getNextToken());
Assert.assertEquals(1, result.getItems().size());
Assert.assertNull(result.getNextToken());
} finally {
sdbClient.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
}
}
use of com.amazonaws.services.simpledb.model.CreateDomainRequest in project simplejpa by appoxy.
the class DomainHelperTests method listAllItemsTests.
@Test
public void listAllItemsTests() {
EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
AmazonSimpleDB sdbClient = em.getSimpleDb();
String domainName = "simplejpa-domainhelper-tests";
sdbClient.createDomain(new CreateDomainRequest().withDomainName(domainName));
try {
for (int i = 0; i < 3; i++) {
sdbClient.putAttributes(new PutAttributesRequest().withItemName("thing" + i).withDomainName(domainName).withAttributes(new ReplaceableAttribute("name", "value", true)));
}
List<Item> items = DomainHelper.listAllItems(sdbClient, domainName);
Assert.assertEquals(3, items.size());
} finally {
sdbClient.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
}
}
Aggregations