本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.GlobalSecondaryIndex.setProvisionedThroughput方法的典型用法代码示例。如果您正苦于以下问题:Java GlobalSecondaryIndex.setProvisionedThroughput方法的具体用法?Java GlobalSecondaryIndex.setProvisionedThroughput怎么用?Java GlobalSecondaryIndex.setProvisionedThroughput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.dynamodbv2.model.GlobalSecondaryIndex
的用法示例。
在下文中一共展示了GlobalSecondaryIndex.setProvisionedThroughput方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTable
import com.amazonaws.services.dynamodbv2.model.GlobalSecondaryIndex; //导入方法依赖的package包/类
public void createTable(Class<? extends IDomain> domain){
CreateTableRequest tableRequest = dynamoDBMapper.generateCreateTableRequest(domain);
tableRequest = tableRequest.withProvisionedThroughput(new ProvisionedThroughput(5L,5L));
//check whether or not we need to add a provisioning throughput value for GSI
for (Method method : domain.getMethods()) {
if(method.isAnnotationPresent(DynamoDBIndexHashKey.class)){
String tempGSI = method.getAnnotation(DynamoDBIndexHashKey.class).globalSecondaryIndexName();
for (GlobalSecondaryIndex globalSecondaryIndex : tableRequest.getGlobalSecondaryIndexes()) {
if(globalSecondaryIndex.getIndexName().equals(tempGSI)){
globalSecondaryIndex.setProvisionedThroughput(new ProvisionedThroughput(5L,5L));
}
}
}
}
amazonDynamoDBClient.createTable(tableRequest);
}
示例2: createImageTable
import com.amazonaws.services.dynamodbv2.model.GlobalSecondaryIndex; //导入方法依赖的package包/类
/**
* Creates the table that stores images.
*
* @param dynamoDB
* {@link AmazonDynamoDB} used to create the image table
* @param tableName
* name of the table to create
* @param tableProvisionedThroughput
* initial provisioned throughput for the table
* @param timeGSIProvisionedThroughput
* initial provisioned throughput for the time-based global secondary index
* @param voteGSIProvisionedThroughput
* initial provisioned throughput for the vote-based global secondary index
* @see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html">Global Secondary
* Indexes</a> ======= initial provisioned throughput for the time-based global secondary index
* @see <a
* href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ProvisionedThroughputIntro.html">Provisioned
* Throughput in Amazon DynamoDB</a>
*/
public static void createImageTable(final AmazonDynamoDB dynamoDB, final String tableName,
final ProvisionedThroughput tableProvisionedThroughput,
final ProvisionedThroughput timeGSIProvisionedThroughput,
final ProvisionedThroughput voteGSIProvisionedThroughput) {
// Set up time GSI
final GlobalSecondaryIndex timeGSI = new GlobalSecondaryIndex();
timeGSI.setIndexName(IMAGE_TABLE_TIME_GSI_NAME);
timeGSI.setKeySchema(Arrays.asList(IMAGE_TABLE_TIME_GSI_HASH_KSE, IMAGE_TABLE_TIME_GSI_RANGE_KSE));
timeGSI.setProjection(IMAGE_TABLE_TIME_GSI_PROJECTION);
timeGSI.setProvisionedThroughput(timeGSIProvisionedThroughput);
// Set up vote GSI
final GlobalSecondaryIndex voteGSI = new GlobalSecondaryIndex();
voteGSI.setIndexName(IMAGE_TABLE_VOTE_GSI_NAME);
voteGSI.setKeySchema(Arrays.asList(IMAGE_TABLE_VOTE_GSI_HASH_KSE, IMAGE_TABLE_VOTE_GSI_RANGE_KSE));
voteGSI.setProjection(IMAGE_TABLE_VOTE_GSI_PROJECTION);
voteGSI.setProvisionedThroughput(voteGSIProvisionedThroughput);
// Create table
final CreateTableRequest request = new CreateTableRequest();
request.setAttributeDefinitions(IMAGE_TABLE_ATTRIBUTE_DEFINITIONS);
request.setKeySchema(IMAGE_TABLE_KEY_SCHEMA);
request.setGlobalSecondaryIndexes(Arrays.asList(timeGSI, voteGSI));
request.setProvisionedThroughput(tableProvisionedThroughput);
request.setTableName(tableName);
LOGGER.info("Creating image table: " + request);
final TableDescription result = DynamoDBManager.createTable(dynamoDB, request);
LOGGER.info("Image table successfully created: " + result);
}
示例3: testCreateImageTable
import com.amazonaws.services.dynamodbv2.model.GlobalSecondaryIndex; //导入方法依赖的package包/类
@Test
public void testCreateImageTable() {
final AmazonDynamoDB dynamoDB = PowerMock.createMock(AmazonDynamoDB.class);
PowerMock.mockStatic(DynamoDBManager.class);
final CreateTableRequest request = new CreateTableRequest();
request.setAttributeDefinitions(MarsDynamoDBManager.IMAGE_TABLE_ATTRIBUTE_DEFINITIONS);
request.setKeySchema(MarsDynamoDBManager.IMAGE_TABLE_KEY_SCHEMA);
final GlobalSecondaryIndex timeGSI = new GlobalSecondaryIndex();
timeGSI.setIndexName(MarsDynamoDBManager.IMAGE_TABLE_TIME_GSI_NAME);
timeGSI.setKeySchema(Arrays.asList(MarsDynamoDBManager.IMAGE_TABLE_TIME_GSI_HASH_KSE,
MarsDynamoDBManager.IMAGE_TABLE_TIME_GSI_RANGE_KSE));
timeGSI.setProjection(MarsDynamoDBManager.IMAGE_TABLE_TIME_GSI_PROJECTION);
timeGSI.setProvisionedThroughput(PROVISIONED_THROUGHPUT);
final GlobalSecondaryIndex voteGSI = new GlobalSecondaryIndex();
voteGSI.setIndexName(MarsDynamoDBManager.IMAGE_TABLE_VOTE_GSI_NAME);
voteGSI.setKeySchema(Arrays.asList(MarsDynamoDBManager.IMAGE_TABLE_VOTE_GSI_HASH_KSE,
MarsDynamoDBManager.IMAGE_TABLE_VOTE_GSI_RANGE_KSE));
voteGSI.setProjection(MarsDynamoDBManager.IMAGE_TABLE_VOTE_GSI_PROJECTION);
voteGSI.setProvisionedThroughput(PROVISIONED_THROUGHPUT);
request.setGlobalSecondaryIndexes(Arrays.asList(timeGSI, voteGSI));
request.setProvisionedThroughput(PROVISIONED_THROUGHPUT);
request.setTableName(TABLE_NAME);
DynamoDBManager.createTable(dynamoDB, request);
PowerMock.expectLastCall().andReturn(null);
PowerMock.replayAll();
MarsDynamoDBManager.createImageTable(dynamoDB, TABLE_NAME, PROVISIONED_THROUGHPUT, PROVISIONED_THROUGHPUT,
PROVISIONED_THROUGHPUT);
PowerMock.verifyAll();
}