本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.DescribeTableResult类的典型用法代码示例。如果您正苦于以下问题:Java DescribeTableResult类的具体用法?Java DescribeTableResult怎么用?Java DescribeTableResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DescribeTableResult类属于com.amazonaws.services.dynamodbv2.model包,在下文中一共展示了DescribeTableResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateTableWithWait
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入依赖的package包/类
@Test
public void testCreateTableWithWait() throws Exception {
// Create fake responses from AWS. First response is still creating the table, second response the table
// has become active.
TableDescription creatingDescription = constructTableDescription(TableStatus.CREATING);
TableDescription createdDescription = constructTableDescription(TableStatus.ACTIVE);
CreateTableResult mockCreateResult = new CreateTableResult().withTableDescription(creatingDescription);
DescribeTableResult mockDescribeResultCreating = new DescribeTableResult().withTable(creatingDescription);
DescribeTableResult mockDescribeResultCreated = new DescribeTableResult().withTable(createdDescription);
// Create the table.
CreateTableRequest expectedRequest = dynamoDB.constructCreateTableRequest();
when(mockDynamoDBClient.createTable(expectedRequest)).thenReturn(mockCreateResult);
when(mockDynamoDBClient.describeTable(tableName)).thenReturn(mockDescribeResultCreating, mockDescribeResultCreated);
assertEquals(dynamoDB.create(), TEST_ARN);
verify(mockDynamoDBClient, times(1)).createTable(expectedRequest);
verify(mockDynamoDBClient, times(2)).describeTable(tableName);
}
示例2: waitForActiveTableStatus
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入依赖的package包/类
private static Task<TableDescription> waitForActiveTableStatus(final DynamoDBConnection dynamoDBConnection, final String tableName)
{
try
{
for (int i = 0; i < WAITING_FOR_ACTIVE_TABLE_STATUS_MAX_ATTEMPTS; i++)
{
final DescribeTableResult describe = dynamoDBConnection.getDynamoClient().describeTable(tableName);
if (describe.getTable().getTableStatus().equals(TableStatus.ACTIVE.name()))
{
return Task.fromValue(describe.getTable());
}
Thread.sleep(WAITING_FOR_ACTIVE_TABLE_STATUS_RETRY_DELAY_MILLIS);
}
}
catch (InterruptedException e)
{
throw new UncheckedException(e);
}
throw new UncheckedException("Hit max retry attempts while waiting for table to become active: " + tableName);
}
示例3: ensureTableIsActive
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入依赖的package包/类
private void ensureTableIsActive(final String tableName)
{
try
{
while (true)
{
final DescribeTableResult describe = dynamoDBConnection.getDynamoClient().describeTable(tableName);
if (describe.getTable().getTableStatus().equals(TableStatus.ACTIVE.name()))
{
return;
}
Thread.sleep(500);
}
}
catch (InterruptedException e)
{
throw new UncheckedException(e);
}
}
示例4: describeTable
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入依赖的package包/类
public TableDescription describeTable(String tableName) {
final DescribeTableRequest describeTablesRequest = new DescribeTableRequest()
.withTableName(tableName);
try {
RetryResult<DescribeTableResult> describeResult = getRetryDriver().runWithRetry(
new Callable<DescribeTableResult>() {
@Override
public DescribeTableResult call() {
DescribeTableResult result = dynamoDB.describeTable(describeTablesRequest);
log.info("Describe table output: " + result);
return result;
}
}, null, null);
return describeResult.result.getTable();
} catch (Exception e) {
throw new RuntimeException("Could not lookup table " + tableName + " in DynamoDB.", e);
}
}
示例5: execute
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入依赖的package包/类
@Override
public void execute() {
DescribeTableResult result = ddbClient.describeTable(new DescribeTableRequest()
.withTableName(determineTableName()));
Message msg = getMessageForResponse(exchange);
msg.setHeader(DdbConstants.TABLE_NAME, result.getTable().getTableName());
msg.setHeader(DdbConstants.TABLE_STATUS, result.getTable().getTableStatus());
msg.setHeader(DdbConstants.CREATION_DATE, result.getTable().getCreationDateTime());
msg.setHeader(DdbConstants.ITEM_COUNT, result.getTable().getItemCount());
msg.setHeader(DdbConstants.KEY_SCHEMA, result.getTable().getKeySchema());
msg.setHeader(DdbConstants.READ_CAPACITY,
result.getTable().getProvisionedThroughput().getReadCapacityUnits());
msg.setHeader(DdbConstants.WRITE_CAPACITY,
result.getTable().getProvisionedThroughput().getWriteCapacityUnits());
msg.setHeader(DdbConstants.TABLE_SIZE, result.getTable().getTableSizeBytes());
}
示例6: describeTable
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入依赖的package包/类
@Override
public DescribeTableResult describeTable(DescribeTableRequest describeTableRequest) {
this.describeTableRequest = describeTableRequest;
String tableName = describeTableRequest.getTableName();
if ("activeTable".equals(tableName)) {
return tableWithStatus(TableStatus.ACTIVE);
} else if ("creatibleTable".equals(tableName) && createTableRequest != null) {
return tableWithStatus(TableStatus.ACTIVE);
} else if ("FULL_DESCRIBE_TABLE".equals(tableName)) {
return new DescribeTableResult().withTable(new TableDescription()
.withTableName(tableName)
.withTableStatus(TableStatus.ACTIVE)
.withCreationDateTime(new Date(NOW))
.withItemCount(100L)
.withKeySchema(new KeySchemaElement().withAttributeName("name"))
.withProvisionedThroughput(new ProvisionedThroughputDescription()
.withReadCapacityUnits(20L)
.withWriteCapacityUnits(10L))
.withTableSizeBytes(1000L));
}
throw new ResourceNotFoundException(tableName + " is missing");
}
示例7: enableStreamForTable
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入依赖的package包/类
private String enableStreamForTable(AmazonDynamoDBClient client, StreamViewType viewType, String tableName) {
DescribeTableRequest describeTableRequest = new DescribeTableRequest()
.withTableName(tableName);
DescribeTableResult describeResult = client.describeTable(describeTableRequest);
if (describeResult.getTable().getStreamSpecification().isStreamEnabled()) {
//TODO: what if the viewtype doesn't match
return describeResult.getTable().getLatestStreamId();
}
StreamSpecification streamSpecification = new StreamSpecification();
streamSpecification.setStreamEnabled(true);
streamSpecification.setStreamViewType(viewType);
UpdateTableRequest updateTableRequest = new UpdateTableRequest()
.withTableName(tableName)
.withStreamSpecification(streamSpecification);
UpdateTableResult result = client.updateTable(updateTableRequest);
return result.getTableDescription().getLatestStreamId();
}
示例8: enableStreamForTable
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入依赖的package包/类
public static String enableStreamForTable(AmazonDynamoDBClient client, StreamViewType viewType, String tableName) {
DescribeTableRequest describeTableRequest = new DescribeTableRequest()
.withTableName(tableName);
DescribeTableResult describeResult = client.describeTable(describeTableRequest);
if (describeResult.getTable().getStreamSpecification().isStreamEnabled()) {
//TODO: what if the viewtype doesn't match
return describeResult.getTable().getLatestStreamId();
}
StreamSpecification streamSpecification = new StreamSpecification();
streamSpecification.setStreamEnabled(true);
streamSpecification.setStreamViewType(viewType);
UpdateTableRequest updateTableRequest = new UpdateTableRequest()
.withTableName(tableName)
.withStreamSpecification(streamSpecification);
UpdateTableResult result = client.updateTable(updateTableRequest);
return result.getTableDescription().getLatestStreamId();
}
示例9: awaitTableCreation
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入依赖的package包/类
public static void awaitTableCreation(AmazonDynamoDBClient dynamoDBClient, String tableName) {
Integer retries = 0;
Boolean created = false;
while(!created && retries < 100) {
DescribeTableResult result = StreamAdapterDemoHelper.describeTable(dynamoDBClient, tableName);
created = result.getTable().getTableStatus().equals("ACTIVE");
if (created) {
System.out.println("Table is active.");
return;
} else {
retries++;
try {
Thread.sleep(1000);
} catch(InterruptedException e) {
// do nothing
}
}
}
System.out.println("Timeout after table creation. Exiting...");
cleanupAndExit(dynamoDBClient, tableName, 1);
}
示例10: test_updateTable
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入依赖的package包/类
@Test
public void test_updateTable() throws Exception {
createTable();
DescribeTableResult describeResult = dynamoDb.describeTable(TEST_TABLE_NAME);
Long readUnits = describeResult.getTable().getProvisionedThroughput().getReadCapacityUnits();
assertThat(readUnits, equalTo(UNITS));
UpdateTableResult updateResult = dynamoDb.updateTable(TEST_TABLE_NAME, new ProvisionedThroughput()
.withReadCapacityUnits(new Long(200))
.withWriteCapacityUnits(new Long(200)));
String tableName = updateResult.getTableDescription().getTableName();
assertThat(tableName, equalTo(TEST_TABLE_NAME));
ListTablesResult listResult = listTables();
describeResult = dynamoDb.describeTable(TEST_TABLE_NAME);
readUnits = describeResult.getTable().getProvisionedThroughput().getReadCapacityUnits();
assertThat(readUnits, equalTo(new Long(200)));
}
示例11: safeDescribeTable
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入依赖的package包/类
/**
* Private interface for describing tables which handles any instances of
* Throttling of the API
*
* @param dynamoClient
* @param dynamoTable
* @return
* @throws Exception
*/
public static DescribeTableResult safeDescribeTable(
final AmazonDynamoDB dynamoClient, final String dynamoTable)
throws Exception {
DescribeTableResult res = null;
final int tryMax = 10;
int tries = 0;
while (true) {
try {
res = dynamoClient.describeTable(dynamoTable);
return res;
} catch (ResourceNotFoundException e) {
if (tries < tryMax) {
// sleep for a short time as this is potentially an eventual
// consistency issue with the table having been created ms
// ago
Thread.sleep(10);
tries++;
} else {
throw e;
}
}
}
}
示例12: waitForTableState
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入依赖的package包/类
/**
* Interface which will block until a dynamo table reaches a specified
* state. Also returns immediately if the object doesn't exist
*
* @param dynamoClient
* Dynamo DB Client to use for connection to Dynamo DB.
* @param dynamoTable
* The table name to check.
* @param status
* The status to wait for
* @throws Exception
*/
private static void waitForTableState(final AmazonDynamoDB dynamoClient,
final String dynamoTable, TableStatus status) throws Exception {
DescribeTableResult tableRequest = null;
while (true) {
try {
tableRequest = dynamoClient.describeTable(dynamoTable);
if (tableRequest.getTable().getTableStatus()
.equals(status.name()))
break;
Thread.sleep(1000);
} catch (InterruptedException e) {
return;
}
}
}
示例13: awaitTableCreation
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入依赖的package包/类
private static void awaitTableCreation(String tableName) {
Integer retries = 0;
Boolean created = false;
while(!created && retries < 100) {
DescribeTableResult result = StreamsAdapterDemoHelper.describeTable(dynamoDBClient, tableName);
created = result.getTable().getTableStatus().equals("ACTIVE");
if (created) {
System.out.println("Table is active.");
return;
} else {
retries++;
try {
Thread.sleep(1000);
} catch(InterruptedException e) {
// do nothing
}
}
}
System.out.println("Timeout after table creation. Exiting...");
cleanupAndExit(1);
}
示例14: create
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入依赖的package包/类
/**
* Create table.
* @throws InterruptedException If something fails
*/
public void create() throws InterruptedException {
final AmazonDynamoDB aws = this.region.aws();
final String name = this.request.getTableName();
aws.createTable(this.request);
Logger.info(this, "DynamoDB table '%s' creation requested...", name);
final DescribeTableRequest req = new DescribeTableRequest()
.withTableName(name);
while (true) {
final DescribeTableResult result = aws.describeTable(req);
if ("ACTIVE".equals(result.getTable().getTableStatus())) {
Logger.info(
this,
"DynamoDB table '%s' is %s",
name, result.getTable().getTableStatus()
);
break;
}
Logger.info(
this,
"waiting for DynamoDB table '%s': %s",
name, result.getTable().getTableStatus()
);
TimeUnit.SECONDS.sleep((long) Tv.TEN);
}
}
示例15: getTestTableStatus
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入依赖的package包/类
public static String getTestTableStatus() {
try {
AmazonDynamoDBClient ddb = UserPreferenceDemoActivity.clientManager
.ddb();
DescribeTableRequest request = new DescribeTableRequest()
.withTableName(Constants.TEST_TABLE_NAME);
DescribeTableResult result = ddb.describeTable(request);
String status = result.getTable().getTableStatus();
return status == null ? "" : status;
} catch (ResourceNotFoundException e) {
} catch (AmazonServiceException ex) {
UserPreferenceDemoActivity.clientManager
.wipeCredentialsOnAuthError(ex);
}
return "";
}