本文整理汇总了Java中com.amazonaws.services.dynamodbv2.util.TableUtils类的典型用法代码示例。如果您正苦于以下问题:Java TableUtils类的具体用法?Java TableUtils怎么用?Java TableUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TableUtils类属于com.amazonaws.services.dynamodbv2.util包,在下文中一共展示了TableUtils类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createRecipientTable
import com.amazonaws.services.dynamodbv2.util.TableUtils; //导入依赖的package包/类
private void createRecipientTable() {
CreateTableRequest request
= new CreateTableRequest()
.withTableName(TABLE_NAME)
.withAttributeDefinitions(
new AttributeDefinition("_id", ScalarAttributeType.S)
)
.withKeySchema(
new KeySchemaElement("_id", KeyType.HASH)
)
.withProvisionedThroughput(new ProvisionedThroughput(10L, 10L));
ddb.createTable(request);
try {
TableUtils.waitUntilActive(ddb, TABLE_NAME);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:20,代码来源:CloudNoticeDAO.java
示例2: main
import com.amazonaws.services.dynamodbv2.util.TableUtils; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
client.setEndpoint("http://localhost:8000");
DynamoDB dynamoDB = new DynamoDB(client);
String tableName = "Movies";
Table table = dynamoDB.createTable(tableName,
Arrays.asList(
new KeySchemaElement("year", KeyType.HASH),
new KeySchemaElement("title", KeyType.RANGE)),
Arrays.asList(
new AttributeDefinition("year", ScalarAttributeType.N),
new AttributeDefinition("title", ScalarAttributeType.S)),
new ProvisionedThroughput(10L, 10L));
try {
TableUtils.waitUntilActive(client, tableName);
System.out.println("Table status: " + table.getDescription().getTableStatus());
} catch (AmazonClientException e) {
e.printStackTrace();
System.exit(1);
}
}
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:26,代码来源:MoviesCreateTable.java
示例3: createTicketTables
import com.amazonaws.services.dynamodbv2.util.TableUtils; //导入依赖的package包/类
/**
* Create ticket tables.
*
* @param deleteTables the delete tables
*/
public void createTicketTables(final boolean deleteTables) {
final Collection<TicketDefinition> metadata = this.ticketCatalog.findAll();
metadata.forEach(Unchecked.consumer(r -> {
final CreateTableRequest request = new CreateTableRequest()
.withAttributeDefinitions(new AttributeDefinition(ColumnNames.ID.getName(), ScalarAttributeType.S))
.withKeySchema(new KeySchemaElement(ColumnNames.ID.getName(), KeyType.HASH))
.withProvisionedThroughput(new ProvisionedThroughput(dynamoDbProperties.getReadCapacity(),
dynamoDbProperties.getWriteCapacity()))
.withTableName(r.getProperties().getStorageName());
if (deleteTables) {
final DeleteTableRequest delete = new DeleteTableRequest(r.getProperties().getStorageName());
LOGGER.debug("Sending delete request [{}] to remove table if necessary", delete);
TableUtils.deleteTableIfExists(amazonDynamoDBClient, delete);
}
LOGGER.debug("Sending delete request [{}] to create table", request);
TableUtils.createTableIfNotExists(amazonDynamoDBClient, request);
LOGGER.debug("Waiting until table [{}] becomes active...", request.getTableName());
TableUtils.waitUntilActive(amazonDynamoDBClient, request.getTableName());
final DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(request.getTableName());
LOGGER.debug("Sending request [{}] to obtain table description...", describeTableRequest);
final TableDescription tableDescription = amazonDynamoDBClient.describeTable(describeTableRequest).getTable();
LOGGER.debug("Located newly created table with description: [{}]", tableDescription);
}));
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:35,代码来源:DynamoDbTicketRegistryFacilitator.java
示例4: createServicesTable
import com.amazonaws.services.dynamodbv2.util.TableUtils; //导入依赖的package包/类
/**
* Create tables.
*
* @param deleteTables the delete tables
*/
public void createServicesTable(final boolean deleteTables) {
try {
final CreateTableRequest request = new CreateTableRequest()
.withAttributeDefinitions(new AttributeDefinition(ColumnNames.ID.getName(), ScalarAttributeType.S))
.withKeySchema(new KeySchemaElement(ColumnNames.ID.getName(), KeyType.HASH))
.withProvisionedThroughput(new ProvisionedThroughput(dynamoDbProperties.getReadCapacity(),
dynamoDbProperties.getWriteCapacity()))
.withTableName(TABLE_NAME);
if (deleteTables) {
final DeleteTableRequest delete = new DeleteTableRequest(request.getTableName());
LOGGER.debug("Sending delete request [{}] to remove table if necessary", delete);
TableUtils.deleteTableIfExists(amazonDynamoDBClient, delete);
}
LOGGER.debug("Sending delete request [{}] to create table", request);
TableUtils.createTableIfNotExists(amazonDynamoDBClient, request);
LOGGER.debug("Waiting until table [{}] becomes active...", request.getTableName());
TableUtils.waitUntilActive(amazonDynamoDBClient, request.getTableName());
final DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(request.getTableName());
LOGGER.debug("Sending request [{}] to obtain table description...", describeTableRequest);
final TableDescription tableDescription = amazonDynamoDBClient.describeTable(describeTableRequest).getTable();
LOGGER.debug("Located newly created table with description: [{}]", tableDescription);
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:35,代码来源:DynamoDbServiceRegistryFacilitator.java
示例5: createSettingsTable
import com.amazonaws.services.dynamodbv2.util.TableUtils; //导入依赖的package包/类
private static void createSettingsTable(final AmazonDynamoDBClient amazonDynamoDBClient, final boolean deleteTables) {
try {
final CreateTableRequest request = new CreateTableRequest()
.withAttributeDefinitions(new AttributeDefinition(ColumnNames.ID.getName(), ScalarAttributeType.S))
.withKeySchema(new KeySchemaElement(ColumnNames.ID.getName(), KeyType.HASH))
.withProvisionedThroughput(new ProvisionedThroughput(PROVISIONED_THROUGHPUT, PROVISIONED_THROUGHPUT))
.withTableName(TABLE_NAME);
if (deleteTables) {
final DeleteTableRequest delete = new DeleteTableRequest(request.getTableName());
LOGGER.debug("Sending delete request [{}] to remove table if necessary", delete);
TableUtils.deleteTableIfExists(amazonDynamoDBClient, delete);
}
LOGGER.debug("Sending delete request [{}] to create table", request);
TableUtils.createTableIfNotExists(amazonDynamoDBClient, request);
LOGGER.debug("Waiting until table [{}] becomes active...", request.getTableName());
TableUtils.waitUntilActive(amazonDynamoDBClient, request.getTableName());
final DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(request.getTableName());
LOGGER.debug("Sending request [{}] to obtain table description...", describeTableRequest);
final TableDescription tableDescription = amazonDynamoDBClient.describeTable(describeTableRequest).getTable();
LOGGER.debug("Located newly created table with description: [{}]", tableDescription);
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:29,代码来源:DynamoDbCloudConfigBootstrapConfiguration.java
示例6: createDDBTable
import com.amazonaws.services.dynamodbv2.util.TableUtils; //导入依赖的package包/类
private static void createDDBTable(String uuid, Properties props, String tableName, String tableKey, String tblPropName, String keyPropName) {
CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(tableName + uuid)
.withKeySchema(new KeySchemaElement().withAttributeName(tableKey).withKeyType(KeyType.HASH))
.withAttributeDefinitions(new AttributeDefinition().withAttributeName(tableKey)
.withAttributeType(ScalarAttributeType.S))
.withProvisionedThroughput(
new ProvisionedThroughput().withReadCapacityUnits(1L).withWriteCapacityUnits(1L));
TableUtils.createTableIfNotExists(getDynamoDB(), createTableRequest);
props.setProperty(tblPropName, tableName + uuid);
props.setProperty(keyPropName, tableKey);
}
开发者ID:shirubio,项目名称:game-of-life,代码行数:13,代码来源:CreateGameOfLifeEnvironment.java
示例7: deleteTable
import com.amazonaws.services.dynamodbv2.util.TableUtils; //导入依赖的package包/类
@AfterClass
public static void deleteTable() {
final DeleteTableRequest deleteTableRequest = new DeleteTableRequest(tableName);
// credentials need to be set in local environment
// see http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html
TableUtils.deleteTableIfExists(new AmazonDynamoDBClient(), deleteTableRequest);
}
开发者ID:KayLerch,项目名称:alexa-skills-kit-states-java,代码行数:8,代码来源:AWSDynamoStateHandlerIT.java
示例8: ensureTableExists
import com.amazonaws.services.dynamodbv2.util.TableUtils; //导入依赖的package包/类
private void ensureTableExists() throws AlexaStateException {
// given custom table is always assumed as existing so you can have this option to bypass existance checks
// for reason of least privileges on used AWS credentials or better performance
if (!tableExistenceApproved || !tableExists()) {
final ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<>();
// describe keys (both will be Strings)
attributeDefinitions.add(new AttributeDefinition()
.withAttributeName(pkUser)
.withAttributeType("S"));
attributeDefinitions.add(new AttributeDefinition()
.withAttributeName(pkModel)
.withAttributeType("S"));
// define keys with name and type
final ArrayList<KeySchemaElement> keySchema = new ArrayList<>();
keySchema.add(new KeySchemaElement()
.withAttributeName(pkUser)
.withKeyType(KeyType.HASH));
keySchema.add(new KeySchemaElement()
.withAttributeName(pkModel)
.withKeyType(KeyType.RANGE));
// prepare table creation request
final CreateTableRequest awsRequest = new CreateTableRequest()
.withTableName(tableName)
.withKeySchema(keySchema)
.withAttributeDefinitions(attributeDefinitions)
.withProvisionedThroughput(new ProvisionedThroughput()
.withReadCapacityUnits(readCapacityUnits)
.withWriteCapacityUnits(writeCapacityUnits));
// create on not existing table
if (TableUtils.createTableIfNotExists(awsClient, awsRequest)) {
log.info(String.format("Table '%1$s' is created in DynamoDB. Now standing by for up to ten minutes for this table to be in active state.", tableName));
// wait for table to be in ACTIVE state in order to proceed with read or write
// this could take up to possible ten minutes so be sure to run this code once before publishing your skill ;)
try {
TableUtils.waitUntilActive(awsClient, awsRequest.getTableName());
} catch (final InterruptedException e) {
final String message = String.format("Could not create DynamoDb-Table '%1$s' before writing state", tableName);
log.error(message, e);
throw AlexaStateException.create(message).withCause(e).withHandler(this).build();
}
}
}
}
开发者ID:KayLerch,项目名称:alexa-skills-kit-states-java,代码行数:44,代码来源:AWSDynamoStateHandler.java
注:本文中的com.amazonaws.services.dynamodbv2.util.TableUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论