Examples of TableDescription


Examples of com.amazonaws.services.dynamodb.model.TableDescription

   * @throws IOException
   */
  @Override
  public boolean schemaExists() {
    LOG.info("Verifying schemas.");
  TableDescription success = null;
  if (mapping.getTables().isEmpty())  throw new IllegalStateException("There are not tables defined.");
  if (preferredSchema == null){
    LOG.debug("Verifying schemas");
    if (mapping.getTables().isEmpty())  throw new IllegalStateException("There are not tables defined.");
    // read the mapping object
View Full Code Here

Examples of com.amazonaws.services.dynamodb.model.TableDescription

   * Retrieves the table description for the specific resource name
   * @param tableName
   * @return
   */
  private TableDescription getTableSchema(String tableName){
    TableDescription tableDescription = null;
    try{
      DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(tableName);
      tableDescription = dynamoDBClient.describeTable(describeTableRequest).getTable();
    }
    catch(ResourceNotFoundException e){
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.TableDescription

     * @return True if a table already exists with the specified name, otherwise
     *         false.
     */
    public static boolean doesTableExist(AmazonDynamoDB dynamo, String tableName) {
        try {
            TableDescription table = dynamo.describeTable(new DescribeTableRequest(tableName)).getTable();
            return TableStatus.ACTIVE.toString().equals(table.getTableStatus());
        } catch (ResourceNotFoundException rnfe) {
            // This means the table doesn't exist in the account yet
            return false;
        }
    }
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.TableDescription

    public static void waitForTableToBecomeActive(AmazonDynamoDB dynamo, String tableName) {
        long startTime = System.currentTimeMillis();
        long endTime = startTime + (10 * 60 * 1000);
        while (System.currentTimeMillis() < endTime) {
            try {
                TableDescription table = dynamo.describeTable(new DescribeTableRequest(tableName)).getTable();
                if (table != null && table.getTableStatus().equals(TableStatus.ACTIVE.toString()))
                    return;
            } catch (ResourceNotFoundException rnfe) {
                // ResourceNotFound means the table doesn't exist yet,
                // so ignore this error and just keep polling.
            }
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.TableDescription

     * @return True if a table already exists with the specified name, otherwise
     *         false.
     */
    public static boolean doesTableExist(AmazonDynamoDB dynamo, String tableName) {
        try {
            TableDescription table = dynamo.describeTable(new DescribeTableRequest(tableName)).getTable();
            return TableStatus.ACTIVE.toString().equals(table.getTableStatus());
        } catch (ResourceNotFoundException rnfe) {
            // This means the table doesn't exist in the account yet
            return false;
        }
    }
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.TableDescription

            throw new AmazonClientException("Interval must be > 0 and < timeout");
        long startTime = System.currentTimeMillis();
        long endTime = startTime + timeout;
        while (System.currentTimeMillis() < endTime) {
            try {
                TableDescription table = dynamo.describeTable(new DescribeTableRequest(tableName)).getTable();
                if (table != null && table.getTableStatus().equals(TableStatus.ACTIVE.toString()))
                    return;
            } catch (ResourceNotFoundException rnfe) {
                // ResourceNotFound means the table doesn't exist yet,
                // so ignore this error and just keep polling.
            }
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.TableDescription

//    @Test
    public void howToDeleteTable() throws InterruptedException {
        String TABLE_NAME = "myTableForMidLevelApi";
        Table table = dynamo.getTable(TABLE_NAME);
        // Wait for the table to become active or deleted
        TableDescription desc = table.waitForActiveOrDelete();
        if (desc == null) {
            System.out.println("Table " + table.getTableName()
                    + " does not exist.");
        } else {
            table.delete();
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.TableDescription

                // Create a table with a primary hash key named 'name', which holds a string
                CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(tableName)
                    .withKeySchema(new KeySchemaElement().withAttributeName("name").withKeyType(KeyType.HASH))
                    .withAttributeDefinitions(new AttributeDefinition().withAttributeName("name").withAttributeType(ScalarAttributeType.S))
                    .withProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(1L).withWriteCapacityUnits(1L));
                    TableDescription createdTableDescription = dynamoDB.createTable(createTableRequest).getTableDescription();
                System.out.println("Created Table: " + createdTableDescription);

                // Wait for it to become active
                System.out.println("Waiting for " + tableName + " to become ACTIVE...");
                Tables.waitForTableToBecomeActive(dynamoDB, tableName);
            }

            // Describe our new table
            DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(tableName);
            TableDescription tableDescription = dynamoDB.describeTable(describeTableRequest).getTable();
            System.out.println("Table Description: " + tableDescription);

            // Add an item
            Map<String, AttributeValue> item = newItem("Bill & Ted's Excellent Adventure", 1989, "****", "James", "Sara");
            PutItemRequest putItemRequest = new PutItemRequest(tableName, item);
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.TableDescription

        fillInData(dynamo);
    }

    private static void createTable(DynamoDB dynamo) throws InterruptedException {
        Table table = dynamo.getTable(TABLE_NAME);
        TableDescription desc = table.waitForActiveOrDelete();
        if (desc == null) {
            // table doesn't exist; let's create it
            KeySchemaElement hashKey =
                new KeySchemaElement(HASH_KEY, KeyType.HASH);
            KeySchemaElement rangeKey =
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.TableDescription

    @Test
    public void howToCreateTable() throws InterruptedException {
        String TABLE_NAME = "myTableForMidLevelApi";
        Table table = dynamo.getTable(TABLE_NAME);
        // check if table already exists, and if so wait for it to become active
        TableDescription desc = table.waitForActiveOrDelete();
        if (desc != null) {
            System.out.println("Skip creating table which already exists and ready for use: "
                    + desc);
            return;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.