Search in sources :

Example 6 with CreateDomainRequest

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));
    }
}
Also used : DeleteDomainRequest(com.amazonaws.services.simpledb.model.DeleteDomainRequest) AmazonSimpleDB(com.amazonaws.services.simpledb.AmazonSimpleDB) CreateDomainRequest(com.amazonaws.services.simpledb.model.CreateDomainRequest) PutAttributesRequest(com.amazonaws.services.simpledb.model.PutAttributesRequest) ReplaceableAttribute(com.amazonaws.services.simpledb.model.ReplaceableAttribute) Test(org.junit.Test)

Example 7 with CreateDomainRequest

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);
    }
}
Also used : AmazonSimpleDB(com.amazonaws.services.simpledb.AmazonSimpleDB) AmazonClientException(com.amazonaws.AmazonClientException) CreateDomainRequest(com.amazonaws.services.simpledb.model.CreateDomainRequest) PersistenceException(javax.persistence.PersistenceException)

Example 8 with CreateDomainRequest

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);
    }
}
Also used : ListDomainsResult(com.amazonaws.services.simpledb.model.ListDomainsResult) AmazonClientException(com.amazonaws.AmazonClientException) CreateDomainRequest(com.amazonaws.services.simpledb.model.CreateDomainRequest)

Aggregations

CreateDomainRequest (com.amazonaws.services.simpledb.model.CreateDomainRequest)8 AmazonSimpleDB (com.amazonaws.services.simpledb.AmazonSimpleDB)5 DeleteDomainRequest (com.amazonaws.services.simpledb.model.DeleteDomainRequest)4 PutAttributesRequest (com.amazonaws.services.simpledb.model.PutAttributesRequest)4 ReplaceableAttribute (com.amazonaws.services.simpledb.model.ReplaceableAttribute)4 Test (org.junit.Test)4 AmazonClientException (com.amazonaws.AmazonClientException)2 SelectResult (com.amazonaws.services.simpledb.model.SelectResult)2 DomainMetadataRequest (com.amazonaws.services.simpledb.model.DomainMetadataRequest)1 Item (com.amazonaws.services.simpledb.model.Item)1 ListDomainsResult (com.amazonaws.services.simpledb.model.ListDomainsResult)1 NoSuchDomainException (com.amazonaws.services.simpledb.model.NoSuchDomainException)1 PersistenceException (javax.persistence.PersistenceException)1