Java 类com.amazonaws.services.simpledb.model.ListDomainsRequest 实例源码

项目:Tank    文件:AmazonSimpleDatabase.java   
/**
 * @{inheritDoc
 */
public Set<String> getTables(String regex) {
    Set<String> result = new HashSet<String>();
    ListDomainsResult listDomains = null;
    String nextToken = null;
    do {
        listDomains = db.listDomains(new ListDomainsRequest().withNextToken(nextToken));
        for (String s : listDomains.getDomainNames()) {
            if (s.matches(regex)) {
                result.add(s);
            }
        }
        nextToken = listDomains.getNextToken();
    } while (nextToken != null);
    return result;
}
项目:Tank    文件:AmazonSimpleDatabase.java   
/**
 * 
 * @{inheritDoc
 */
public boolean hasTable(@Nonnull String tableName) {
    boolean hasMore = true;
    String nextToken = null;
    while (hasMore) {
        ListDomainsResult listDomains = db.listDomains(new ListDomainsRequest().withNextToken(nextToken));
        for (String name : listDomains.getDomainNames()) {
            if (tableName.equalsIgnoreCase(name)) {
                return true;
            }
        }
        nextToken = listDomains.getNextToken();
        hasMore = !StringUtils.isEmpty(nextToken);
    }
    return false;
}
项目:Tank    文件:AmazonSimpleDatabase.java   
/**
 * 
 * @param tableName
 * @return
 */
public List<String> filterExisting(List<String> tableName) {
    boolean hasMore = true;
    String nextToken = null;

    List<String> ret = new ArrayList<String>(tableName.size());
    Set<String> tables = new HashSet<String>();
    while (hasMore) {
        ListDomainsResult listDomains = db.listDomains(new ListDomainsRequest().withNextToken(nextToken));
        tables.addAll(listDomains.getDomainNames());
        nextToken = listDomains.getNextToken();
        hasMore = !StringUtils.isEmpty(nextToken);
    }
    for (String name : tableName) {
        if (tables.contains(name)) {
            ret.add(name);
        }
    }
    return ret;
}
项目:agathon    文件:SdbDaoModule.java   
@Provides @Named(RINGS_PROPERTY)
Set<String> provideRings(AmazonSimpleDBClient client, CassandraDomainFactory domainFactory) {
  List<String> rings = Lists.newArrayList();
  String nextToken = null;

  do {
    ListDomainsRequest request = new ListDomainsRequest().withNextToken(nextToken);
    ListDomainsResult result = client.listDomains(request);
    for (String domain : result.getDomainNames()) {
      CassandraDomain cassandraDomain = domainFactory.createFromDomain(domain);
      if (cassandraDomain != null) {
        rings.add(cassandraDomain.getRing());
      }
    }
    nextToken = result.getNextToken();
  } while (nextToken != null);
  return ImmutableSet.copyOf(rings);
}
项目:spring-data-simpledb    文件:SimpleDbReferencesRepositoryTest.java   
@Test
public void manageDomains_should_create_domains_referred_by_repository() {
    AmazonSimpleDB sdb = operations.getDB();

    final String domainPrefix = operations.getSimpleDb().getDomainPrefix();

    ListDomainsResult listDomainsResult = sdb.listDomains(new ListDomainsRequest());
    List<String> domainNames = listDomainsResult.getDomainNames();
    String nextToken = listDomainsResult.getNextToken(); 
    while (nextToken != null && !nextToken.isEmpty()) {
        listDomainsResult = sdb.listDomains(new ListDomainsRequest().withNextToken(nextToken));
        domainNames.addAll(listDomainsResult.getDomainNames());
        nextToken = listDomainsResult.getNextToken();
    }

    assertThat(domainNames.contains(domainPrefix + ".simpleDbReferences"), is(true));
    assertThat(domainNames.contains(domainPrefix + ".firstNestedEntity"), is(true));
    assertThat(domainNames.contains(domainPrefix + ".secondNestedEntity"), is(true));

    Assert.assertNotNull(operations);
}
项目:Camel    文件:ListDomainsCommand.java   
public void execute() {
    ListDomainsRequest request = new ListDomainsRequest()
        .withMaxNumberOfDomains(determineMaxNumberOfDomains())
        .withNextToken(determineNextToken());
    log.trace("Sending request [{}] for exchange [{}]...", request, exchange);

    ListDomainsResult result = this.sdbClient.listDomains(request);

    log.trace("Received result [{}]", result);

    Message msg = getMessageForResponse(exchange);
    msg.setHeader(SdbConstants.NEXT_TOKEN, result.getNextToken());
    msg.setHeader(SdbConstants.DOMAIN_NAMES, result.getDomainNames());
}
项目:Camel    文件:AmazonSDBClientMock.java   
@Override
public ListDomainsResult listDomains(ListDomainsRequest listDomainsRequest) throws AmazonServiceException, AmazonClientException {
    this.listDomainsRequest = listDomainsRequest;

    ListDomainsResult result = new ListDomainsResult();
    result.getDomainNames().add("DOMAIN1");
    result.getDomainNames().add("DOMAIN2");
    result.setNextToken("TOKEN2");
    return result;
}
项目:olfs    文件:demo.java   
public static void simpleDB_demo(){


        System.out.println("- - - - - - - - - - - - - - - - - - - - - -");
        System.out.println("SimpleDB DEMO");

        /*
         * Amazon SimpleDB
         *
         * The AWS SimpleDB client allows you to query and manage your data
         * stored in SimpleDB domains (similar to tables in a relational DB).
         *
         * In this sample, we use a SimpleDB client to iterate over all the
         * domains owned by the current user, and add up the number of items
         * (similar to rows of data in a relational DB) in each domain.
         */
        try {
            ListDomainsRequest sdbRequest = new ListDomainsRequest().withMaxNumberOfDomains(100);
            ListDomainsResult sdbResult = sdb.listDomains(sdbRequest);

            int totalItems = 0;
            for (String domainName : sdbResult.getDomainNames()) {
                DomainMetadataRequest metadataRequest = new DomainMetadataRequest().withDomainName(domainName);
                DomainMetadataResult domainMetadata = sdb.domainMetadata(metadataRequest);
                totalItems += domainMetadata.getItemCount();
            }

            System.out.println("You have " + sdbResult.getDomainNames().size() + " Amazon SimpleDB domain(s)" +
                    "containing a total of " + totalItems + " items.");
        } catch (AmazonServiceException ase) {
                System.out.println("Caught Exception: " + ase.getMessage());
                System.out.println("Response Status Code: " + ase.getStatusCode());
                System.out.println("Error Code: " + ase.getErrorCode());
                System.out.println("Request ID: " + ase.getRequestId());
        }

    }
项目:QuotesSocial    文件:SimpleDB.java   
/**
 * @param numDomains
 * @param nextToken
 * @return list of domain names
 */
private static List<String> getDomainNames(int numDomains, String nextToken) {
    ListDomainsRequest req = new ListDomainsRequest();
    req.setMaxNumberOfDomains(numDomains);
    if (nextToken != null)
        req.setNextToken(nextToken);
    ListDomainsResult result = getInstance().listDomains(req);
    List<String> domains = result.getDomainNames();
    SimpleDB.nextToken = result.getNextToken();
    return domains;
}
项目:spring-data-simpledb    文件:DomainManager.java   
protected boolean exists(final String domainName, final AmazonSimpleDB sdb) {
    try {
        ListDomainsResult listDomainsResult = sdb.listDomains(new ListDomainsRequest());
        List<String> domainNames = listDomainsResult.getDomainNames();
        String nextToken = listDomainsResult.getNextToken(); 
        while (nextToken != null && !nextToken.isEmpty()) {
            listDomainsResult = sdb.listDomains(new ListDomainsRequest().withNextToken(nextToken));
            domainNames.addAll(listDomainsResult.getDomainNames());
            nextToken = listDomainsResult.getNextToken();
        }
        return domainNames.contains(domainName);
    } catch(AmazonClientException amazonException) {
        throw SimpleDbExceptionTranslator.getTranslatorInstance().translateAmazonClientException(amazonException);
    }
}
项目:aws-utilization-monitor    文件:AwsScan.java   
/**
 * Collect data for SimpleDB.
 *
 * @param stats
 *            current statistics object.
 * @param account
 *            currently used credentials object.
 * @param region
 *            currently used aws region.
 */
public static void scanSimpleDB(AwsStats stats, AwsAccount account, Regions region) {
    if (region == Regions.EU_CENTRAL_1)
        return;

    LOG.debug("Scan for SimpleDB in region " + region.getName() + " in account " + account.getAccountId());

    /*
     * Amazon SimpleDB
     * 
     * The AWS SimpleDB client allows you to query and manage your data
     * stored in SimpleDB domains (similar to tables in a relational DB).
     * 
     * In this sample, we use a SimpleDB client to iterate over all the
     * domains owned by the current user, and add up the number of items
     * (similar to rows of data in a relational DB) in each domain.
     */
    try {
        AmazonSimpleDB simpleDB = new AmazonSimpleDBClient(account.getCredentials());
        simpleDB.setRegion(Region.getRegion(region));

        ListDomainsRequest sdbRequest = new ListDomainsRequest().withMaxNumberOfDomains(100);
        ListDomainsResult sdbResult = simpleDB.listDomains(sdbRequest);

        int totalItems = 0;
        for (String domainName : sdbResult.getDomainNames()) {
            DomainMetadataRequest metadataRequest = new DomainMetadataRequest().withDomainName(domainName);
            DomainMetadataResult domainMetadata = simpleDB.domainMetadata(metadataRequest);
            int items = domainMetadata.getItemCount();
            totalItems += items;
            AwsResource res = new AwsResource(domainName, account.getAccountId(), AwsResourceType.SimpleDB, region);
            res.addInfo(AwsTag.Items, items);
            stats.add(res);
        }

        LOG.info(sdbResult.getDomainNames().size() + " SimpleDB domains containing a total of " + totalItems + " items in region " + region.getName()
                + " in account " + account.getAccountId());
    } catch (AmazonServiceException ase) {
        LOG.error("Exception of SimpleDB: " + ase.getMessage());
    } catch (Exception ex) {
        LOG.error("Exception of SimpleDB: " + ex.getMessage());
    }
}