@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); } }
public AmazonStatHandler(AmazonSimpleDBClient client, String domain) { this.client = client; this.domain = domain; int tries = 0; do { tries++; try { ListDomainsResult domainsL = client.listDomains(); if (!domainsL.getDomainNames().contains(domain)) { client.createDomain(new CreateDomainRequest(domain)); } return; } catch (Exception ase) { log.warn(ase); try { Thread.sleep(1000); } catch (InterruptedException e) { } log.warn(ase); } } while (tries < MAX_TRIES); throw new RuntimeException("Unable to connect to SDB " + domain); }
protected void createDomain(final String domainName, final AmazonSimpleDB sdb) { try { LOGGER.debug("Creating domain: {}", domainName); CreateDomainRequest request = new CreateDomainRequest(domainName); sdb.createDomain(request); LOGGER.debug("Created domain: {}", domainName); } catch(AmazonClientException amazonException) { throw SimpleDbExceptionTranslator.getTranslatorInstance().translateAmazonClientException(amazonException); } }
/** * * @{inheritDoc */ public void createTable(String tableName) { try { if (!hasTable(tableName)) { logger.info("Creating table: " + tableName); db.createDomain(new CreateDomainRequest(tableName)); } } catch (Exception t) { logger.error(t, t); } }
public void initialize(Map<String, String> params) throws WPBIOException { String accessKey = params.get(CONFIG_ACCESS_KEY); String secretkey = params.get(CONFIG_SECRET_KEY); BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretkey); ClientConfiguration clientConfig = new ClientConfiguration(); String protocolStr = params.get(CONFIG_PROTOCOL); if (protocolStr != null && protocolStr.length()>0) { Protocol protocol = Protocol.valueOf(params.get(CONFIG_PROTOCOL)); if (protocol != null) { clientConfig.setProtocol(protocol); } } sdbClient = new AmazonSimpleDBClient(awsCredentials, clientConfig); String endpoint = params.get(CONFIG_ENDPOINT); if (endpoint != null) { sdbClient.setEndpoint(endpoint); } domainName = params.get(CONFIG_DOMAIN); // create the domain if not exists CreateDomainRequest createDomainRequest = new CreateDomainRequest(); createDomainRequest.setDomainName(domainName); sdbClient.createDomain(createDomainRequest); }
@Override public void save(CassandraRing ring) { String domain = domain(ring); if (!ringsProvider.get().contains(domain)) { client.createDomain(new CreateDomainRequest().withDomainName(domain)); } for (CassandraInstance instance : ring.getInstances()) { instanceDao.save(ring.getName(), instance); } }
/** * {@inheritDoc} */ @Override public void create() { this.credentials.aws().createDomain( new CreateDomainRequest().withDomainName(this.table) ); }
public static void createDomain(AmazonSimpleDBClient client, String domainName) throws InterruptedException { client.createDomain(new CreateDomainRequest(domainName)); // Unfortunatly, there is no waiters for domain create int retries = 10; List<String> domainNames = client.listDomains().getDomainNames(); while (!domainNames.contains(domainName) && 0 < retries--) { Thread.sleep(500); domainNames = client.listDomains().getDomainNames(); } Assert.assertTrue(domainNames.contains(domainName)); }
@Override public CreateDomainResult createDomain(CreateDomainRequest createDomainRequest) throws AmazonServiceException, AmazonClientException { this.createDomainRequest = createDomainRequest; return new CreateDomainResult(); }
public static void createDomain(String domainName) { getInstance().createDomain(new CreateDomainRequest(domainName)); }