當前位置: 首頁>>代碼示例>>Java>>正文


Java AmazonDynamoDB.setRegion方法代碼示例

本文整理匯總了Java中com.amazonaws.services.dynamodbv2.AmazonDynamoDB.setRegion方法的典型用法代碼示例。如果您正苦於以下問題:Java AmazonDynamoDB.setRegion方法的具體用法?Java AmazonDynamoDB.setRegion怎麽用?Java AmazonDynamoDB.setRegion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.amazonaws.services.dynamodbv2.AmazonDynamoDB的用法示例。


在下文中一共展示了AmazonDynamoDB.setRegion方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: scanDynamoDB

import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; //導入方法依賴的package包/類
/**
 * Collect data for DynamoDB.
 *
 * @param stats
 *            current statistics object.
 * @param account
 *            currently used credentials object.
 * @param region
 *            currently used aws region.
 */
public static void scanDynamoDB(AwsStats stats, AwsAccount account, Regions region) {
	LOG.debug("Scan for DynamoDB in region " + region.getName() + " in account " + account.getAccountId());

	/*
	 * Amazon DynamoDB
	 */
	try {
		AmazonDynamoDB dynamoDB = new AmazonDynamoDBClient(account.getCredentials());
		dynamoDB.setRegion(Region.getRegion(region));

		List<String> list = dynamoDB.listTables().getTableNames();

		int totalItems = list.size();
		for (String tableName : list) {
			AwsResource res = new AwsResource(tableName, account.getAccountId(), AwsResourceType.DynamoDB, region);
			stats.add(res);
		}

		LOG.info(totalItems + " DynamoDB tables in region " + region.getName() + " in account " + account.getAccountId());
	} catch (AmazonServiceException ase) {
		LOG.error("Exception of DynamoDB: " + ase.getMessage());
	}
}
 
開發者ID:janloeffler,項目名稱:aws-utilization-monitor,代碼行數:34,代碼來源:AwsScan.java

示例2: init

import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; //導入方法依賴的package包/類
private void init() {
    InstanceProfileCredentialsProvider credentialsProvider = new InstanceProfileCredentialsProvider();
    AmazonDynamoDB amazonDynamoDB = new AmazonDynamoDBClient(credentialsProvider);
    amazonDynamoDB.setRegion(Regions.getCurrentRegion());
    dynamoDBMapper = new DynamoDBMapper(amazonDynamoDB, dynamoDBMapperConfig());
    amazonS3 = new AmazonS3Client(credentialsProvider);
    Region current = Regions.getCurrentRegion();
    if (!current.equals(Region.getRegion(Regions.US_EAST_1))) {
        amazonS3.setRegion(current);
    }
    systemUpgrade = new UpgradeSystemTo003();
}
 
開發者ID:SungardAS,項目名稱:enhanced-snapshots,代碼行數:13,代碼來源:SystemRestoreServiceImpl.java

示例3: cleanupAggTable

import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; //導入方法依賴的package包/類
public static void cleanupAggTable(AWSCredentialsProvider credentials,
		Region region, final String dynamoTable, final String toSeq)
		throws Exception {
	final Double deleteBelow = Double.parseDouble(toSeq);

	// create two clients - one synchronous for the read of all candidate
	// values, and another for the delete operations
	final AmazonDynamoDB dynamoClient = new AmazonDynamoDBClient(
			credentials);
	if (region != null)
		dynamoClient.setRegion(region);
	final AmazonDynamoDBAsyncClient deleteCli = new AmazonDynamoDBAsyncClient(
			credentials);
	deleteCli.setRegion(region);
	Map<String, AttributeValue> lastKey = null;
	Map<String, AttributeValue> deleteKey = null;

	// work out what the key and date column name is
	String keyColumn = null;
	String dateColumn = null;

	List<KeySchemaElement> keySchema = dynamoClient
			.describeTable(dynamoTable).getTable().getKeySchema();
	for (KeySchemaElement element : keySchema) {
		if (element.getKeyType().equals(KeyType.HASH.name()))
			keyColumn = element.getAttributeName();

		if (element.getKeyType().equals(KeyType.RANGE.name()))
			dateColumn = element.getAttributeName();
	}

	LOG.info(String.format(
			"Deleting data from %s where %s values are below %s",
			dynamoTable, StreamAggregator.LAST_WRITE_SEQ, deleteBelow));
	int deleteCount = 0;

	do {
		// read data from the table
		ScanRequest scan = new ScanRequest()
				.withTableName(dynamoTable)
				.withAttributesToGet(keyColumn, dateColumn,
						StreamAggregator.LAST_WRITE_SEQ)
				.withExclusiveStartKey(lastKey);

		ScanResult results = dynamoClient.scan(scan);

		// delete everything up to the system provided change number
		for (Map<String, AttributeValue> map : results.getItems()) {
			deleteKey = new HashMap<>();
			deleteKey.put(keyColumn, map.get(keyColumn));
			deleteKey.put(dateColumn, map.get(dateColumn));

			if (Double.parseDouble(map.get(StreamAggregator.LAST_WRITE_SEQ)
					.getS()) < deleteBelow) {
				deleteCli.deleteItem(dynamoTable, deleteKey);
				deleteCount++;
			}
		}
		lastKey = results.getLastEvaluatedKey();
	} while (lastKey != null);

	LOG.info(String.format(
			"Operation Complete - %s Records removed from Aggregate Store",
			deleteCount));
}
 
開發者ID:awslabs,項目名稱:amazon-kinesis-aggregators,代碼行數:66,代碼來源:DynamoUtils.java

示例4: configure

import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; //導入方法依賴的package包/類
@Override
protected void configure() {

    Region region = Region.getRegion(config.get(Regions.class, REGION_CONFIG_KEY));

    AmazonDynamoDB dynamoDBClient = new AmazonDynamoDBClient();
    dynamoDBClient.setRegion(region);

    bind(AmazonDynamoDB.class).toInstance(dynamoDBClient);
}
 
開發者ID:ScottMansfield,項目名稱:widow,代碼行數:11,代碼來源:DynamoDBModule.java


注:本文中的com.amazonaws.services.dynamodbv2.AmazonDynamoDB.setRegion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。