本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.DescribeTableResult.getTable方法的典型用法代码示例。如果您正苦于以下问题:Java DescribeTableResult.getTable方法的具体用法?Java DescribeTableResult.getTable怎么用?Java DescribeTableResult.getTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.dynamodbv2.model.DescribeTableResult
的用法示例。
在下文中一共展示了DescribeTableResult.getTable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: describeTable
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入方法依赖的package包/类
private void describeTable(String tableName) throws IllegalArgumentException {
try {
DescribeTableResult describeResult = dynamoDBClient.describeTable(tableName);
tableDescription = describeResult.getTable();
} catch (ResourceNotFoundException rnfe) {
throw new IllegalArgumentException("Error: given table " + tableName + " does not exist in given region.");
} catch (AmazonServiceException ase) {
if (ase.getErrorCode().equals("UnrecognizedClientException"))
throw new IllegalArgumentException("Error: Security token in credential file invalid.");
else
throw new IllegalArgumentException(ase.getMessage());
}
}
示例2: getTableStatus
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入方法依赖的package包/类
/***
* Get Table Status
* @param tableName
* @return status
*/
public String getTableStatus(final String tableName) throws ResourceNotFoundException{
final DescribeTableResult description = describeTable(tableName);
if(description.getTable()!=null){
return description.getTable().getTableStatus();
}
return null;
}
示例3: createTable
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult; //导入方法依赖的package包/类
/**
* Creates DynamoDB table. If the table already exists, it validates the key schema. If the key schemas match, a
* warning is logged, otherwise an exception is raised.
*
* @param dynamoDB
* {@link AmazonDynamoDB} used to create the table specified in the request.
* @param request
* Request for creating a table.
* @return TableDescription of the existing table or newly created table
*/
public static TableDescription createTable(final AmazonDynamoDB dynamoDB, final CreateTableRequest request) {
try {
final DescribeTableResult result = dynamoDB.describeTable(request.getTableName());
if (!request.getKeySchema().equals(result.getTable().getKeySchema())) {
throw new IllegalStateException("Table " + request.getTableName()
+ " already exists and has an invalid schema");
}
LOGGER.warning("Table " + request.getTableName() + " already exists");
return result.getTable();
} catch (final ResourceNotFoundException e) {
return dynamoDB.createTable(request).getTableDescription();
}
}