本文整理匯總了Java中com.amazonaws.services.dynamodbv2.model.CreateTableRequest.setProvisionedThroughput方法的典型用法代碼示例。如果您正苦於以下問題:Java CreateTableRequest.setProvisionedThroughput方法的具體用法?Java CreateTableRequest.setProvisionedThroughput怎麽用?Java CreateTableRequest.setProvisionedThroughput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.amazonaws.services.dynamodbv2.model.CreateTableRequest
的用法示例。
在下文中一共展示了CreateTableRequest.setProvisionedThroughput方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildCreateTableRequest
import com.amazonaws.services.dynamodbv2.model.CreateTableRequest; //導入方法依賴的package包/類
/**
* Builds the necessary requests to create tables
*
* @param tableName
* @param keySchema
* @param proThrou
* @param attrs
* @return
*/
public static CreateTableRequest buildCreateTableRequest(String tableName,
ArrayList<KeySchemaElement> keySchema, ProvisionedThroughput proThrou, Map<String, String> attrs) {
CreateTableRequest createTableRequest = new CreateTableRequest();
createTableRequest.setTableName(tableName);
createTableRequest.setKeySchema(keySchema);
ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
for (KeySchemaElement kEle : keySchema) {
AttributeDefinition attrDef = new AttributeDefinition();
attrDef.setAttributeName(kEle.getAttributeName());
attrDef.setAttributeType(attrs.get(kEle.getAttributeName()));
attributeDefinitions.add(attrDef);
}
createTableRequest.setAttributeDefinitions(attributeDefinitions);
createTableRequest.setProvisionedThroughput(proThrou);
return createTableRequest;
}
示例2: testCreateResourceTable
import com.amazonaws.services.dynamodbv2.model.CreateTableRequest; //導入方法依賴的package包/類
@Test
public void testCreateResourceTable() {
final AmazonDynamoDB dynamoDB = PowerMock.createMock(AmazonDynamoDB.class);
PowerMock.mockStatic(DynamoDBManager.class);
final CreateTableRequest request = new CreateTableRequest();
request.setAttributeDefinitions(MarsDynamoDBManager.RESOURCE_TABLE_ATTRIBUTE_DEFINITIONS);
request.setKeySchema(MarsDynamoDBManager.RESOURCE_TABLE_KEY_SCHEMA);
request.setProvisionedThroughput(PROVISIONED_THROUGHPUT);
request.setTableName(TABLE_NAME);
DynamoDBManager.createTable(dynamoDB, request);
PowerMock.expectLastCall().andReturn(null);
PowerMock.replayAll();
MarsDynamoDBManager.createResourceTable(dynamoDB, TABLE_NAME, PROVISIONED_THROUGHPUT);
PowerMock.verifyAll();
}
示例3: createSessionTable
import com.amazonaws.services.dynamodbv2.model.CreateTableRequest; //導入方法依賴的package包/類
public static void createSessionTable(AmazonDynamoDBClient dynamo,
String tableName,
long readCapacityUnits,
long writeCapacityUnits) {
CreateTableRequest request = new CreateTableRequest().withTableName(tableName);
request.withKeySchema(new KeySchemaElement().withAttributeName(DynamoSessionItem.SESSION_ID_ATTRIBUTE_NAME)
.withKeyType(KeyType.HASH));
request.withAttributeDefinitions(
new AttributeDefinition().withAttributeName(DynamoSessionItem.SESSION_ID_ATTRIBUTE_NAME)
.withAttributeType(ScalarAttributeType.S));
request.setProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(readCapacityUnits)
.withWriteCapacityUnits(writeCapacityUnits));
dynamo.createTable(request);
}
示例4: createImageTable
import com.amazonaws.services.dynamodbv2.model.CreateTableRequest; //導入方法依賴的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);
}
示例5: testCreateImageTable
import com.amazonaws.services.dynamodbv2.model.CreateTableRequest; //導入方法依賴的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();
}
示例6: execute
import com.amazonaws.services.dynamodbv2.model.CreateTableRequest; //導入方法依賴的package包/類
@Override
public Table execute() throws MetaModelException {
final MutableTable table = getTable();
final String tableName = table.getName();
final Collection<AttributeDefinition> attributes = new ArrayList<>();
final Collection<KeySchemaElement> keySchema = new ArrayList<>();
final Collection<GlobalSecondaryIndex> globalSecondaryIndices = new ArrayList<>();
final long readCapacity = Long.parseLong(System.getProperty(
DynamoDbDataContext.SYSTEM_PROPERTY_THROUGHPUT_READ_CAPACITY, "5"));
final long writeCapacity = Long.parseLong(System.getProperty(
DynamoDbDataContext.SYSTEM_PROPERTY_THROUGHPUT_WRITE_CAPACITY, "5"));
final ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput(readCapacity, writeCapacity);
for (Column column : table.getColumns()) {
if (column.isPrimaryKey()) {
final KeyType keyType = getKeyType(column.getRemarks());
keySchema.add(new KeySchemaElement(column.getName(), keyType));
attributes.add(new AttributeDefinition(column.getName(), DynamoDbUtils.toAttributeType(column
.getType())));
}
}
final CreateTableRequest createTableRequest = new CreateTableRequest();
createTableRequest.setTableName(tableName);
createTableRequest.setAttributeDefinitions(attributes);
createTableRequest.setGlobalSecondaryIndexes(globalSecondaryIndices);
createTableRequest.setKeySchema(keySchema);
createTableRequest.setProvisionedThroughput(provisionedThroughput);
final AmazonDynamoDB client = getUpdateCallback().getDataContext().getDynamoDb();
final CreateTableResult createTableResult = client.createTable(createTableRequest);
// await the table creation to be "done".
{
String tableStatus = createTableResult.getTableDescription().getTableStatus();
while (TableStatus.CREATING.name().equals(tableStatus)) {
logger.debug("Waiting for table status to be ACTIVE. Currently: {}", tableStatus);
try {
Thread.sleep(300);
} catch (InterruptedException e) {
getUpdateCallback().setInterrupted(true);
}
tableStatus = client.describeTable(tableName).getTable().getTableStatus();
}
}
return table;
}
示例7: createResourceTable
import com.amazonaws.services.dynamodbv2.model.CreateTableRequest; //導入方法依賴的package包/類
/**
* Creates the table that stores resources with an ETag.
*
* @param dynamoDB
* {@link AmazonDynamoDB} used to create DynamoDB table
* @param tableName
* name of the table to create
* @param provisionedThroughput
* initial provisioned throughput for the table
* @see <a
* href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ProvisionedThroughputIntro.html">Provisioned
* Througput in Amazon DynamoDB</a>
*/
public static void createResourceTable(final AmazonDynamoDB dynamoDB, final String tableName,
final ProvisionedThroughput provisionedThroughput) {
final CreateTableRequest request = new CreateTableRequest();
request.setAttributeDefinitions(RESOURCE_TABLE_ATTRIBUTE_DEFINITIONS);
request.setKeySchema(RESOURCE_TABLE_KEY_SCHEMA);
request.setProvisionedThroughput(provisionedThroughput);
request.setTableName(tableName);
LOGGER.info("Creating resource table: " + request);
DynamoDBManager.createTable(dynamoDB, request);
LOGGER.info("Resource table successfully created");
}