use of com.amazonaws.services.simpledb.AmazonSimpleDB in project camel by apache.
the class SdbEndpoint method createSdbClient.
AmazonSimpleDB createSdbClient() {
AmazonSimpleDB client = null;
ClientConfiguration clientConfiguration = null;
boolean isClientConfigFound = false;
if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
clientConfiguration = new ClientConfiguration();
clientConfiguration.setProxyHost(configuration.getProxyHost());
clientConfiguration.setProxyPort(configuration.getProxyPort());
isClientConfigFound = true;
}
if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) {
AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
if (isClientConfigFound) {
client = new AmazonSimpleDBClient(credentials, clientConfiguration);
} else {
client = new AmazonSimpleDBClient(credentials);
}
} else {
if (isClientConfigFound) {
client = new AmazonSimpleDBClient();
} else {
client = new AmazonSimpleDBClient(clientConfiguration);
}
}
return client;
}
use of com.amazonaws.services.simpledb.AmazonSimpleDB in project simplejpa by appoxy.
the class EntityManagerFactoryImpl method loadDomains.
private synchronized void loadDomains() {
if (domainSet != null)
return;
try {
domainSet = new HashSet<String>();
logger.info("getting all domains");
AmazonSimpleDB db = getSimpleDb();
ListDomainsResult listDomainsResult = db.listDomains();
domainSet.addAll(listDomainsResult.getDomainNames());
while (listDomainsResult.getNextToken() != null) {
ListDomainsRequest request = new ListDomainsRequest().withNextToken(listDomainsResult.getNextToken());
listDomainsResult = db.listDomains(request);
domainSet.addAll(listDomainsResult.getDomainNames());
}
} catch (AmazonClientException e) {
throw new PersistenceException(e);
}
}
use of com.amazonaws.services.simpledb.AmazonSimpleDB in project simplejpa by appoxy.
the class ConcurrentRetriever method test.
public static List<ItemAndAttributes> test(EntityManagerSimpleJPA em, String domainName) throws AmazonClientException, ExecutionException, InterruptedException {
AmazonSimpleDB db = em.getSimpleDb();
SelectResult result = DomainHelper.selectItems(db, "select * from `" + domainName + "`", null);
List<SdbItem> list = new ArrayList<SdbItem>();
for (Item item : result.getItems()) {
list.add(new SdbItemImpl2(item));
}
return getAttributesFromSdb(list, em.getExecutor(), em);
}
use of com.amazonaws.services.simpledb.AmazonSimpleDB in project simplejpa by appoxy.
the class BaseTestClass method deleteAll.
@After
public void deleteAll() throws AmazonClientException {
printLog();
// todo: should just delete all items in the domain, would probably be faster
System.out.println("Deleting all objects created during test...");
EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
AmazonSimpleDB db = em.getSimpleDb();
deleteAll(em, db, MyTestObject.class);
// db.deleteDomain(d);
// d = db.getDomain(em.getDomainName(MyTestObject2.class));
deleteAll(em, db, MyTestObject2.class);
// db.deleteDomain(d);
// d = db.getDomain(em.getDomainName(MyTestObject3.class));
// db.deleteDomain(d);
deleteAll(em, db, MyTestObject3.class);
deleteAll(em, db, MyTestObject4.class);
// d = db.getDomain(em.getDomainName(MyInheritanceObject1.class));
// db.deleteDomain(d);
deleteAll(em, db, MyInheritanceObject1.class);
deleteAll(em, db, MyInheritanceObject2.class);
deleteAll(em, db, MyInheritanceObject3.class);
em.close();
}
use of com.amazonaws.services.simpledb.AmazonSimpleDB 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));
}
}
Aggregations