use of com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput in project aws-doc-sdk-examples by awsdocs.
the class LowLevelTableExample method createExampleTable.
static void createExampleTable() {
// Provide the initial provisioned throughput values as Java long data
// types
ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput().withReadCapacityUnits(5L).withWriteCapacityUnits(6L);
CreateTableRequest request = new CreateTableRequest().withTableName(tableName).withProvisionedThroughput(provisionedThroughput);
ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
attributeDefinitions.add(new AttributeDefinition().withAttributeName("Id").withAttributeType("N"));
request.setAttributeDefinitions(attributeDefinitions);
ArrayList<KeySchemaElement> tableKeySchema = new ArrayList<KeySchemaElement>();
// Partition
tableKeySchema.add(new KeySchemaElement().withAttributeName("Id").withKeyType(KeyType.HASH));
// key
request.setKeySchema(tableKeySchema);
client.createTable(request);
waitForTableToBecomeAvailable(tableName);
getTableInformation();
}
use of com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput in project aws-doc-sdk-examples by awsdocs.
the class DocumentAPIParallelScan method createTable.
private static void createTable(String tableName, long readCapacityUnits, long writeCapacityUnits, String partitionKeyName, String partitionKeyType, String sortKeyName, String sortKeyType) {
try {
System.out.println("Creating table " + tableName);
List<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
// Partition
keySchema.add(new KeySchemaElement().withAttributeName(partitionKeyName).withKeyType(KeyType.HASH));
// key
List<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
attributeDefinitions.add(new AttributeDefinition().withAttributeName(partitionKeyName).withAttributeType(partitionKeyType));
if (sortKeyName != null) {
// Sort
keySchema.add(new KeySchemaElement().withAttributeName(sortKeyName).withKeyType(KeyType.RANGE));
// key
attributeDefinitions.add(new AttributeDefinition().withAttributeName(sortKeyName).withAttributeType(sortKeyType));
}
Table table = dynamoDB.createTable(tableName, keySchema, attributeDefinitions, new ProvisionedThroughput().withReadCapacityUnits(readCapacityUnits).withWriteCapacityUnits(writeCapacityUnits));
System.out.println("Waiting for " + tableName + " to be created...this may take a while...");
table.waitForActive();
} catch (Exception e) {
System.err.println("Failed to create table " + tableName);
e.printStackTrace(System.err);
}
}
Aggregations