use of com.amazonaws.services.dynamodbv2.model.ProvisionedThroughputDescription in project camel by apache.
the class AmazonDDBClientMock method describeTable.
@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");
}
use of com.amazonaws.services.dynamodbv2.model.ProvisionedThroughputDescription in project camel by apache.
the class DeleteTableCommandTest method testExecute.
@Test
public void testExecute() {
command.execute();
assertEquals("DOMAIN1", ddbClient.deleteTableRequest.getTableName());
assertEquals(new ProvisionedThroughputDescription(), exchange.getIn().getHeader(DdbConstants.PROVISIONED_THROUGHPUT));
assertEquals(new Date(AmazonDDBClientMock.NOW), exchange.getIn().getHeader(DdbConstants.CREATION_DATE, Date.class));
assertEquals(Long.valueOf(10L), exchange.getIn().getHeader(DdbConstants.ITEM_COUNT, Long.class));
assertEquals(new ArrayList<KeySchemaElement>(), exchange.getIn().getHeader(DdbConstants.KEY_SCHEMA, ArrayList.class));
assertEquals(Long.valueOf(20L), exchange.getIn().getHeader(DdbConstants.TABLE_SIZE, Long.class));
assertEquals(TableStatus.ACTIVE, exchange.getIn().getHeader(DdbConstants.TABLE_STATUS, TableStatus.class));
}
use of com.amazonaws.services.dynamodbv2.model.ProvisionedThroughputDescription in project aws-doc-sdk-examples by awsdocs.
the class DescribeTable method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " DescribeTable <table>\n\n" + "Where:\n" + " table - the table to get information about.\n\n" + "Example:\n" + " DescribeTable HelloTable\n";
if (args.length < 1) {
System.out.println(USAGE);
System.exit(1);
}
String table_name = args[0];
System.out.format("Getting description for %s\n\n", table_name);
final AmazonDynamoDB ddb = AmazonDynamoDBClientBuilder.defaultClient();
try {
TableDescription table_info = ddb.describeTable(table_name).getTable();
if (table_info != null) {
System.out.format("Table name : %s\n", table_info.getTableName());
System.out.format("Table ARN : %s\n", table_info.getTableArn());
System.out.format("Status : %s\n", table_info.getTableStatus());
System.out.format("Item count : %d\n", table_info.getItemCount().longValue());
System.out.format("Size (bytes): %d\n", table_info.getTableSizeBytes().longValue());
ProvisionedThroughputDescription throughput_info = table_info.getProvisionedThroughput();
System.out.println("Throughput");
System.out.format(" Read Capacity : %d\n", throughput_info.getReadCapacityUnits().longValue());
System.out.format(" Write Capacity: %d\n", throughput_info.getWriteCapacityUnits().longValue());
List<AttributeDefinition> attributes = table_info.getAttributeDefinitions();
System.out.println("Attributes");
for (AttributeDefinition a : attributes) {
System.out.format(" %s (%s)\n", a.getAttributeName(), a.getAttributeType());
}
}
} catch (AmazonServiceException e) {
System.err.println(e.getErrorMessage());
System.exit(1);
}
System.out.println("\nDone!");
}
Aggregations