本文整理汇总了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());
}
}
示例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();
}
示例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));
}
示例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);
}