Search in sources :

Example 1 with ProvisionedThroughputDescription

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");
}
Also used : DescribeTableResult(com.amazonaws.services.dynamodbv2.model.DescribeTableResult) ProvisionedThroughputDescription(com.amazonaws.services.dynamodbv2.model.ProvisionedThroughputDescription) ResourceNotFoundException(com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException) TableDescription(com.amazonaws.services.dynamodbv2.model.TableDescription) Date(java.util.Date) KeySchemaElement(com.amazonaws.services.dynamodbv2.model.KeySchemaElement)

Example 2 with ProvisionedThroughputDescription

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));
}
Also used : ArrayList(java.util.ArrayList) TableStatus(com.amazonaws.services.dynamodbv2.model.TableStatus) ProvisionedThroughputDescription(com.amazonaws.services.dynamodbv2.model.ProvisionedThroughputDescription) Date(java.util.Date) KeySchemaElement(com.amazonaws.services.dynamodbv2.model.KeySchemaElement) Test(org.junit.Test)

Example 3 with ProvisionedThroughputDescription

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!");
}
Also used : AmazonServiceException(com.amazonaws.AmazonServiceException) AttributeDefinition(com.amazonaws.services.dynamodbv2.model.AttributeDefinition) AmazonDynamoDB(com.amazonaws.services.dynamodbv2.AmazonDynamoDB) ProvisionedThroughputDescription(com.amazonaws.services.dynamodbv2.model.ProvisionedThroughputDescription) TableDescription(com.amazonaws.services.dynamodbv2.model.TableDescription)

Aggregations

ProvisionedThroughputDescription (com.amazonaws.services.dynamodbv2.model.ProvisionedThroughputDescription)3 KeySchemaElement (com.amazonaws.services.dynamodbv2.model.KeySchemaElement)2 TableDescription (com.amazonaws.services.dynamodbv2.model.TableDescription)2 Date (java.util.Date)2 AmazonServiceException (com.amazonaws.AmazonServiceException)1 AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)1 AttributeDefinition (com.amazonaws.services.dynamodbv2.model.AttributeDefinition)1 DescribeTableResult (com.amazonaws.services.dynamodbv2.model.DescribeTableResult)1 ResourceNotFoundException (com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException)1 TableStatus (com.amazonaws.services.dynamodbv2.model.TableStatus)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1