Example usage for com.amazonaws.services.dynamodbv2.model TableDescription getTableName

List of usage examples for com.amazonaws.services.dynamodbv2.model TableDescription getTableName

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.model TableDescription getTableName.

Prototype


public String getTableName() 

Source Link

Document

The name of the table.

Usage

From source file:aws.example.dynamodb.DescribeTable.java

License:Open Source License

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);//from   www . j a  va2s  .  com
    }

    String table_name = args[0];
    System.out.format("Getting description for %s\n\n", table_name);

    final AmazonDynamoDBClient ddb = new AmazonDynamoDBClient();

    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!");
}

From source file:com.clicktravel.infrastructure.persistence.aws.dynamodb.manager.DynamoDbTemplateInfrastructureManager.java

License:Apache License

private boolean isTableCreated(final String tableName) {
    try {/*  www  .j  a  va 2  s  .  c  om*/
        final DescribeTableResult result = amazonDynamoDbClient
                .describeTable(new DescribeTableRequest(tableName));
        final TableDescription tableDescription = result.getTable();
        final String tableStatus = tableDescription.getTableStatus();
        final String returnedTableName = tableDescription.getTableName();
        return tableName.equals(returnedTableName) && TableStatus.ACTIVE.toString().equals(tableStatus);
    } catch (final ResourceNotFoundException e) {
        return false;
    }
}

From source file:com.haskins.cloudtrailviewer.dialog.resourcedetail.detailpanels.DbTableDetail.java

License:Open Source License

private void buildUI(DescribeTableResult detail) {

    this.add(primaryScrollPane, BorderLayout.CENTER);

    if (detail.getTable() != null) {

        TableDescription table = detail.getTable();

        if (table.getCreationDateTime() != null) {
            primaryTableModel.addRow(new Object[] { "Created", getDateString(table.getCreationDateTime()) });
        }//w w  w  . j a va 2s .  c o m
        if (table.getItemCount() != null) {
            primaryTableModel.addRow(new Object[] { "Item Count", table.getItemCount() });
        }
        if (table.getLatestStreamArn() != null) {
            primaryTableModel.addRow(new Object[] { "Latest Stream Arn", table.getLatestStreamArn() });
        }
        if (table.getLatestStreamLabel() != null) {
            primaryTableModel.addRow(new Object[] { "Latest Stream Label", table.getLatestStreamLabel() });
        }
        if (table.getTableArn() != null) {
            primaryTableModel.addRow(new Object[] { "Arn", table.getTableArn() });
        }
        if (table.getTableName() != null) {
            primaryTableModel.addRow(new Object[] { "Name", table.getTableName() });
        }
        if (table.getTableSizeBytes() != null) {
            primaryTableModel.addRow(new Object[] { "Size (bytes)", table.getTableSizeBytes() });
        }
        if (table.getTableStatus() != null) {
            primaryTableModel.addRow(new Object[] { "Status", table.getTableStatus() });
        }
    }
}

From source file:com.makariev.dynamodb.data.tables.CreateTableService.java

License:Apache License

public String createPredefinedTables() {
    final StringBuilder sb = new StringBuilder();
    for (Class<? extends TableRequestCreator> tableCreatorClass : tableCreators) {
        try {/*from w w w .j  a va 2  s .c  o m*/
            final TableRequestCreator tableCreator = tableCreatorClass.newInstance();
            final CreateTableRequest createTableRequest = tableCreator.getCreateTableRequest();
            final CreateTableResult result = client.createTable(createTableRequest);
            final TableDescription tableDescription = result.getTableDescription();
            sb.append(" table '").append(tableDescription.getTableName()).append("' SUCCESSFULLY CREATED;");
        } catch (AmazonClientException | InstantiationException | IllegalAccessException
                | UnsupportedOperationException ex) {
            sb.append("  FAILED ex:").append(ex.toString()).append(';');
        }
    }
    final String message = sb.toString();
    return message.isEmpty() ? "nothing is executed" : message;
}

From source file:com.makariev.dynamodb.data.tables.ModifyTablesService.java

License:Apache License

public void warnDelete(TableDescription tableDescription) {
    final String tableName = tableDescription.getTableName();
    final DeleteTableRequest deleteTableRequest = new DeleteTableRequest().withTableName(tableName);
    final DeleteTableResult requestResult = client.deleteTable(deleteTableRequest);
}

From source file:com.makariev.dynamodb.data.tables.ModifyTablesService.java

License:Apache License

public TableDescription updateThroughput(TableDescription tableDescription,
        ProvisionedThroughput provisionedThroughput) {
    final String tableName = tableDescription.getTableName();
    final UpdateTableRequest updateTableRequest = new UpdateTableRequest().withTableName(tableName)
            .withProvisionedThroughput(provisionedThroughput);

    final UpdateTableResult requestResult = client.updateTable(updateTableRequest);
    return requestResult.getTableDescription();
}

From source file:Database.TableFunctions.java

public static void getTableInformation() {
        TableDescription tableDescription = dynamoDB
                .describeTable(new DescribeTableRequest().withTableName(tablename)).getTable();
        System.out.format(/*from  ww  w .j  av a  2s  .c o m*/
                "Name: %s:\n" + "Status: %s \n" + "Provisioned Throughput (read capacity units/sec): %d \n"
                        + "Provisioned Throughput (write capacity units/sec): %d \n",
                tableDescription.getTableName(), tableDescription.getTableStatus(),
                tableDescription.getProvisionedThroughput().getReadCapacityUnits(),
                tableDescription.getProvisionedThroughput().getWriteCapacityUnits());
    }

From source file:dynamodb.CrudOperationsOnDynamoDBTable.java

License:Open Source License

static void getTableInformation() {

    System.out.println("Describing " + tableName);

    TableDescription tableDescription = dynamoDB.getTable(tableName).describe();
    System.out.format(//from w  w  w  . jav a  2 s  . co  m
            "Name: %s:\n" + "Status: %s \n" + "Provisioned Throughput (read capacity units/sec): %d \n"
                    + "Provisioned Throughput (write capacity units/sec): %d \n",
            tableDescription.getTableName(), tableDescription.getTableStatus(),
            tableDescription.getProvisionedThroughput().getReadCapacityUnits(),
            tableDescription.getProvisionedThroughput().getWriteCapacityUnits());
}

From source file:dynamok.source.DynamoDbSourceConnector.java

License:Apache License

@Override
public List<Map<String, String>> taskConfigs(int maxTasks) {
    return ConnectorUtils.groupPartitions(new ArrayList<>(streamShards.keySet()), maxTasks).stream()
            .map(taskShards -> {/*from  ww  w  . j a va  2 s  . c  o m*/
                final Map<String, String> taskConfig = new HashMap<>();
                taskConfig.put(TaskConfig.Keys.REGION, config.region.getName());
                taskConfig.put(TaskConfig.Keys.TOPIC_FORMAT, config.topicFormat);
                taskConfig.put(TaskConfig.Keys.SHARDS,
                        taskShards.stream().map(Shard::getShardId).collect(Collectors.joining(",")));
                taskShards.forEach(shard -> {
                    final TableDescription tableDesc = streamShards.get(shard);
                    taskConfig.put(shard.getShardId() + "." + TaskConfig.Keys.TABLE, tableDesc.getTableName());
                    taskConfig.put(shard.getShardId() + "." + TaskConfig.Keys.STREAM_ARN,
                            tableDesc.getLatestStreamArn());
                });
                return taskConfig;
            }).collect(Collectors.toList());
}

From source file:org.apache.beam.sdk.io.aws.dynamodb.DynamoDBIOTestHelper.java

License:Apache License

static void createTestTable(String tableName) {
    CreateTableResult res = createDynamoTable(tableName);

    TableDescription tableDesc = res.getTableDescription();

    Assert.assertEquals(tableName, tableDesc.getTableName());
    Assert.assertTrue(tableDesc.getKeySchema().toString().contains(ATTR_NAME_1));
    Assert.assertTrue(tableDesc.getKeySchema().toString().contains(ATTR_NAME_2));

    Assert.assertEquals(tableDesc.getProvisionedThroughput().getReadCapacityUnits(), Long.valueOf(1000));
    Assert.assertEquals(tableDesc.getProvisionedThroughput().getWriteCapacityUnits(), Long.valueOf(1000));
    Assert.assertEquals("ACTIVE", tableDesc.getTableStatus());
    Assert.assertEquals("arn:aws:dynamodb:us-east-1:000000000000:table/" + tableName, tableDesc.getTableArn());

    ListTablesResult tables = dynamoDBClient.listTables();
    Assert.assertEquals(1, tables.getTableNames().size());
}