use of com.amazonaws.services.simpledb.model.CreateDomainRequest in project simplejpa by appoxy.
the class DomainHelperTests method findByIdTest.
@Test
public void findByIdTest() {
EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
AmazonSimpleDB sdbClient = em.getSimpleDb();
String domainName = "simplejpa-domainhelper-tests";
sdbClient.createDomain(new CreateDomainRequest().withDomainName(domainName));
try {
Assert.assertNull(DomainHelper.findItemById(sdbClient, domainName, "noexist"));
sdbClient.putAttributes(new PutAttributesRequest().withItemName("exist").withDomainName(domainName).withAttributes(new ReplaceableAttribute("name", "value", true)));
Assert.assertNotNull(DomainHelper.findItemById(sdbClient, domainName, "exist"));
} finally {
sdbClient.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
}
}
use of com.amazonaws.services.simpledb.model.CreateDomainRequest in project simplejpa by appoxy.
the class EntityManagerFactoryImpl method setupDbDomain.
public synchronized void setupDbDomain(String domainName) {
try {
if (!doesDomainExist(domainName)) {
logger.info("creating domain: " + domainName);
AmazonSimpleDB db = getSimpleDb();
db.createDomain(new CreateDomainRequest().withDomainName(domainName));
domainSet.add(domainName);
}
} catch (AmazonClientException e) {
throw new PersistenceException("Could not create SimpleDB domain.", e);
}
}
use of com.amazonaws.services.simpledb.model.CreateDomainRequest in project SimianArmy by Netflix.
the class SimpleDBRecorder method init.
/**
* Creates the SimpleDB domain, if it does not already exist.
*/
public void init() {
try {
if (this.region == null || this.region.equals("region-null")) {
// This is a mock with an invalid region; avoid a slow timeout
LOGGER.debug("Region=null; skipping SimpleDB domain creation");
return;
}
ListDomainsResult listDomains = sdbClient().listDomains();
for (String d : listDomains.getDomainNames()) {
if (d.equals(domain)) {
LOGGER.debug("SimpleDB domain found: {}", domain);
return;
}
}
LOGGER.info("Creating SimpleDB domain: {}", domain);
CreateDomainRequest createDomainRequest = new CreateDomainRequest(domain);
sdbClient().createDomain(createDomainRequest);
} catch (AmazonClientException e) {
LOGGER.warn("Error while trying to auto-create SimpleDB domain", e);
}
}
Aggregations