本文整理汇总了Java中com.amazonaws.services.dynamodbv2.document.Table.waitForActive方法的典型用法代码示例。如果您正苦于以下问题:Java Table.waitForActive方法的具体用法?Java Table.waitForActive怎么用?Java Table.waitForActive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.dynamodbv2.document.Table
的用法示例。
在下文中一共展示了Table.waitForActive方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTable
import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
protected Table createTable(CreateTableRequest request) throws InterruptedException {
DynamoDB dynamoDB = new DynamoDB(tables.getAsyncClient());
request.withProvisionedThroughput(new ProvisionedThroughput()
.withReadCapacityUnits(5L)
.withWriteCapacityUnits(6L));
if (request.getTableName() == null) {
String tableName = tables.getTestTableName();
tableName = tableName.replace('-', '_');
request.setTableName(tableName);
}
Table table = dynamoDB.createTable(request);
table.waitForActive();
return table;
}
示例2: createTable
import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
private void createTable(Class tableClass) {
CreateTableRequest createTableRequest = mapper.generateCreateTableRequest(tableClass);
createTableRequest.setProvisionedThroughput(new ProvisionedThroughput(dbReadCapacity, dbWriteCapacity));
if (tableExists(createTableRequest.getTableName())) {
LOG.info("Table {} already exists", createTableRequest.getTableName());
return;
}
try {
DynamoDB dynamoDB = new DynamoDB(amazonDynamoDB);
Table table = dynamoDB.createTable(createTableRequest);
LOG.info("Creating table {} ... ", createTableRequest.getTableName());
table.waitForActive();
LOG.info("Table {} was created successfully.", createTableRequest.getTableName());
} catch (Exception e) {
LOG.error("Failed to create table {}. ", createTableRequest.getTableName());
LOG.error(e);
throw new ConfigurationException("Failed to create table" + createTableRequest.getTableName(), e);
}
}
示例3: createTable
import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
private static Table createTable(final DynamoDBConnection dynamoDBConnection, final String tableName) throws InterruptedException
{
final CreateTableRequest createTableRequest = createCreateTableRequest(tableName);
final Table table = dynamoDBConnection.getDynamoDB().createTable(createTableRequest);
table.waitForActive();
return table;
}
示例4: waiterMethodsShouldWorkWithWrapper
import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
@Test
public void waiterMethodsShouldWorkWithWrapper() throws InterruptedException {
DynamoDBClientWithStubbedWaiter subject = new DynamoDBClientWithStubbedWaiter(
dynamoDbRule.getClient());
DynamoDB db = new DynamoDB(subject);
AttributeDefinition id = new AttributeDefinition("id", ScalarAttributeType.S);
List<KeySchemaElement> keySchema = new ArrayList<>();
keySchema.add(
new KeySchemaElement()
.withAttributeName(id.getAttributeName())
.withKeyType(KeyType.HASH)
);
ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput();
provisionedThroughput.setReadCapacityUnits(10L);
provisionedThroughput.setWriteCapacityUnits(10L);
CreateTableRequest request = new CreateTableRequest()
.withTableName("test_table")
.withKeySchema(keySchema)
.withAttributeDefinitions(singleton(id))
.withProvisionedThroughput(provisionedThroughput);
Table result = db.createTable(request);
TableDescription description = result.waitForActive();
assertThat(description.getTableName(), is("test_table"));
}
示例5: createTable
import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
@Override
public void createTable(String tableName, String primaryKey) throws Exception {
try {
// Create the key schema for the given primary key
ArrayList<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
keySchema.add(new KeySchemaElement()
.withAttributeName(primaryKey)
.withKeyType(KeyType.HASH));
// Create the attribute definitions
ArrayList<AttributeDefinition> attrDefs = new ArrayList<AttributeDefinition>();
attrDefs.add(new AttributeDefinition()
.withAttributeName(primaryKey)
.withAttributeType("N"));
// Create the table request given the table name, the key schema and the attribute definitios
CreateTableRequest tableRequest = new CreateTableRequest()
.withTableName(tableName)
.withKeySchema(keySchema)
.withAttributeDefinitions(attrDefs)
.withProvisionedThroughput(new ProvisionedThroughput()
.withReadCapacityUnits(5L)
.withWriteCapacityUnits(5L));
// Create the table
LOGGER.debug("Creating DynamoDB table " + tableName);
Table table = dynamoDB.createTable(tableRequest);
// Wait until the table is active
LOGGER.debug("Waiting until the DynamoDB table " + tableName + " becomes active");
table.waitForActive();
} catch (Exception e) {
LOGGER.error("Error while creating the DynamoDB table " + tableName
+ ". Details=" + e.getMessage());
} // try catch
}
示例6: createExampleTable
import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
static void createExampleTable() {
try {
ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
attributeDefinitions.add(new AttributeDefinition()
.withAttributeName("Id")
.withAttributeType("N"));
ArrayList<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
keySchema.add(new KeySchemaElement()
.withAttributeName("Id")
.withKeyType(KeyType.HASH));
CreateTableRequest request = new CreateTableRequest()
.withTableName(tableName)
.withKeySchema(keySchema)
.withAttributeDefinitions(attributeDefinitions)
.withProvisionedThroughput(new ProvisionedThroughput()
.withReadCapacityUnits(5L)
.withWriteCapacityUnits(6L));
System.out.println("Issuing CreateTable request for " + tableName);
Table table = dynamoDB.createTable(request);
System.out.println("Waiting for " + tableName
+ " to be created...this may take a while...");
table.waitForActive();
getTableInformation();
} catch (Exception e) {
System.err.println("CreateTable request failed for " + tableName);
System.err.println(e.getMessage());
}
}
示例7: updateExampleTable
import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
static void updateExampleTable() {
Table table = dynamoDB.getTable(tableName);
System.out.println("Modifying provisioned throughput for " + tableName);
try {
table.updateTable(new ProvisionedThroughput()
.withReadCapacityUnits(6L).withWriteCapacityUnits(7L));
table.waitForActive();
} catch (Exception e) {
System.err.println("UpdateTable request failed for " + tableName);
System.err.println(e.getMessage());
}
}
示例8: createTable
import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
public static TableDescription createTable(AmazonDynamoDB client, String tableName) throws InterruptedException {
CreateTableRequest tableReq = new CreateTableRequest().withTableName(tableName)
.withKeySchema(new KeySchemaElement("Id", KeyType.HASH))
.withAttributeDefinitions(new AttributeDefinition("Id", ScalarAttributeType.N))
.withProvisionedThroughput(new ProvisionedThroughput(10L, 10L))
.withStreamSpecification(new StreamSpecification().withStreamEnabled(true).withStreamViewType(StreamViewType.NEW_AND_OLD_IMAGES));
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.createTable(tableReq);
return table.waitForActive();
}
示例9: createTable
import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
private void createTable() {
try {
final ArrayList<KeySchemaElement> keySchema = new ArrayList<>();
keySchema.add(new KeySchemaElement()
.withAttributeName("id")
.withKeyType(KeyType.HASH));
final ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<>();
attributeDefinitions.add(new AttributeDefinition()
.withAttributeName("id")
.withAttributeType("S"));
final ArrayList<GlobalSecondaryIndex> globalSecondaryIndices = new ArrayList<>();
if (secondaryIndexNames != null) {
for (final String indexName : secondaryIndexNames) {
attributeDefinitions.add(new AttributeDefinition()
.withAttributeName(indexName)
.withAttributeType("S"));
globalSecondaryIndices.add(new GlobalSecondaryIndex()
.withIndexName(indexName + "-index")
.withKeySchema(new KeySchemaElement().withAttributeName(indexName).withKeyType(KeyType.HASH))
.withProjection(new Projection().withProjectionType(ProjectionType.ALL))
.withProvisionedThroughput(new ProvisionedThroughput()
.withReadCapacityUnits(readCapacityUnits)
.withWriteCapacityUnits(writeCapacityUnits)));
}
}
final CreateTableRequest request = new CreateTableRequest()
.withTableName(tableName)
.withKeySchema(keySchema)
.withProvisionedThroughput(new ProvisionedThroughput()
.withReadCapacityUnits(readCapacityUnits)
.withWriteCapacityUnits(writeCapacityUnits));
if (!globalSecondaryIndices.isEmpty()) {
request.withGlobalSecondaryIndexes(globalSecondaryIndices);
}
request.setAttributeDefinitions(attributeDefinitions);
logger.debug("Issuing CreateTable request for " + tableName);
final Table table = DynamoCommons.getInstance().getDb().createTable(request);
logger.debug("Waiting for table to be created...");
table.waitForActive();
} catch (final Exception e) {
logger.error("CreateTable request failed: " + e.getMessage());
}
}
示例10: loadFromDynamoDB
import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
@Test
public void loadFromDynamoDB()
throws Exception
{
DynamoDB dynamoDB = new DynamoDB(dynamoClient);
ArrayList<AttributeDefinition> attributeDefinitions= new ArrayList<>();
attributeDefinitions.add(new AttributeDefinition().withAttributeName("Id").withAttributeType("N"));
ArrayList<KeySchemaElement> keySchema = new ArrayList<>();
keySchema.add(new KeySchemaElement().withAttributeName("Id").withKeyType(KeyType.HASH));
CreateTableRequest request = new CreateTableRequest()
.withTableName(dynamoTableName)
.withKeySchema(keySchema)
.withAttributeDefinitions(attributeDefinitions)
.withProvisionedThroughput(new ProvisionedThroughput()
.withReadCapacityUnits(1L)
.withWriteCapacityUnits(1L));
ImmutableList<Item> items = ImmutableList.of(
new Item().withPrimaryKey("Id", 0).withString("Name", "foo").withNumber("Score", 3.14f),
new Item().withPrimaryKey("Id", 1).withString("Name", "bar").withNumber("Score", 1.23f),
new Item().withPrimaryKey("Id", 2).withString("Name", "baz").withNumber("Score", 5.0f)
);
ImmutableList<Map<String, Object>> expected = ImmutableList.of(
ImmutableMap.of("id", 0, "name", "foo", "score", 3.14f),
ImmutableMap.of("id", 1, "name", "bar", "score", 1.23f),
ImmutableMap.of("id", 2, "name", "baz", "score", 5.0f),
ImmutableMap.of("id", 9, "name", "zzz", "score", 9.99f)
);
Table table = null;
try {
table = dynamoDB.createTable(request);
table.waitForActive();
items.forEach(table::putItem);
runDigdagWithDynamoDB(configFile, "acceptance/redshift/load_from_dynamodb.dig", redshiftUser, Optional.absent());
assertTableContents(DEST_TABLE, expected);
}
finally {
if (table != null) {
table.delete();
table.waitForDelete();
}
}
}
示例11: createTable
import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
private static void createTable(
String tableName, long readCapacityUnits, long writeCapacityUnits,
String hashKeyName, String hashKeyType,
String rangeKeyName, String rangeKeyType) {
try {
ArrayList<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
keySchema.add(new KeySchemaElement()
.withAttributeName(hashKeyName)
.withKeyType(KeyType.HASH));
ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
attributeDefinitions.add(new AttributeDefinition()
.withAttributeName(hashKeyName)
.withAttributeType(hashKeyType));
if (rangeKeyName != null) {
keySchema.add(new KeySchemaElement()
.withAttributeName(rangeKeyName)
.withKeyType(KeyType.RANGE));
attributeDefinitions.add(new AttributeDefinition()
.withAttributeName(rangeKeyName)
.withAttributeType(rangeKeyType));
}
CreateTableRequest request = new CreateTableRequest()
.withTableName(tableName)
.withKeySchema(keySchema)
.withProvisionedThroughput( new ProvisionedThroughput()
.withReadCapacityUnits(readCapacityUnits)
.withWriteCapacityUnits(writeCapacityUnits));
// If this is the Reply table, define a local secondary index
if (replyTableName.equals(tableName)) {
attributeDefinitions.add(new AttributeDefinition()
.withAttributeName("PostedBy")
.withAttributeType("S"));
ArrayList<LocalSecondaryIndex> localSecondaryIndexes = new ArrayList<LocalSecondaryIndex>();
localSecondaryIndexes.add(new LocalSecondaryIndex()
.withIndexName("PostedBy-Index")
.withKeySchema(
new KeySchemaElement().withAttributeName(hashKeyName).withKeyType(KeyType.HASH),
new KeySchemaElement() .withAttributeName("PostedBy") .withKeyType(KeyType.RANGE))
.withProjection(new Projection() .withProjectionType(ProjectionType.KEYS_ONLY)));
request.setLocalSecondaryIndexes(localSecondaryIndexes);
}
request.setAttributeDefinitions(attributeDefinitions);
System.out.println("Issuing CreateTable request for " + tableName);
Table table = dynamoDB.createTable(request);
System.out.println("Waiting for " + tableName
+ " to be created...this may take a while...");
table.waitForActive();
} catch (Exception e) {
System.err.println("CreateTable request failed for " + tableName);
System.err.println(e.getMessage());
}
}
示例12: createTable
import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
private static void createTable(
String tableName, long readCapacityUnits, long writeCapacityUnits,
String hashKeyName, String hashKeyType,
String rangeKeyName, String rangeKeyType) {
try {
System.out.println("Creating table " + tableName);
List<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
keySchema.add(new KeySchemaElement()
.withAttributeName(hashKeyName)
.withKeyType(KeyType.HASH));
List<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
attributeDefinitions.add(new AttributeDefinition()
.withAttributeName(hashKeyName)
.withAttributeType(hashKeyType));
if (rangeKeyName != null){
keySchema.add(new KeySchemaElement()
.withAttributeName(rangeKeyName)
.withKeyType(KeyType.RANGE));
attributeDefinitions.add(new AttributeDefinition()
.withAttributeName(rangeKeyName)
.withAttributeType(rangeKeyType));
}
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);
}
}