in iep-spring-leader-dynamodb/src/main/java/com/netflix/iep/leader/dynamodb/DynamoDbLeaderDatabase.java [166:211]
public void initialize() {
final Collection<AttributeDefinition> attributeDefinitions = Collections.singletonList(
AttributeDefinition
.builder()
.attributeName(hashKeyName)
.attributeType(ScalarAttributeType.S)
.build()
);
final Collection<KeySchemaElement> keySchemaElements = Collections.singletonList(
KeySchemaElement
.builder()
.attributeName(hashKeyName)
.keyType(KeyType.HASH)
.build()
);
final ProvisionedThroughput provisionedThroughput =
ProvisionedThroughput
.builder()
.readCapacityUnits(readCapacityUnits)
.writeCapacityUnits(writeCapacityUnits)
.build();
final CreateTableRequest createTableRequest =
CreateTableRequest
.builder()
.tableName(tableName)
.keySchema(keySchemaElements)
.attributeDefinitions(attributeDefinitions)
.provisionedThroughput(provisionedThroughput)
.build();
try {
CreateTableResponse tableResult = db.createTable(createTableRequest);
logger.info("Created table '{}': Table Status = {}, SDK HTTP Response = {}",
tableName,
tableResult.tableDescription().tableStatusAsString(),
tableResult.sdkHttpResponse().statusCode()
);
} catch (ResourceInUseException e) {
logger.debug("Did not create table '{}'; it already exists", tableName);
}
waitUntilTableIsActive(db, tableName, tableActiveTimeout);
}