Example usage for com.amazonaws.services.dynamodbv2.model CreateTableRequest toString

List of usage examples for com.amazonaws.services.dynamodbv2.model CreateTableRequest toString

Introduction

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

Prototype

@Override
public String toString() 

Source Link

Document

Returns a string representation of this object.

Usage

From source file:jp.classmethod.aws.dynamodb.DynamoDbRepository.java

License:Open Source License

public void open() {
    TableDescription desc = null;// w  w  w  .jav a  2s.  c o  m
    boolean tableNotFound = false;
    try {
        desc = table.describe();
    } catch (ResourceNotFoundException rnfe) {
        tableNotFound = true;
    }
    if (tableNotFound) {
        log.info("creating {}", table.getTableName());
        CreateTableRequest ctr = createTableRequest();
        try {
            dynamoDB.createTable(ctr);
        } catch (AmazonClientException e) {
            log.error(ctr.toString());
            throw convertDynamoDBException(e, "CreateTable", null /* conditionMessage */);
        }
        try {
            table.waitForActive();
            log.info("created {}", table.getTableName());
        } catch (InterruptedException ie) {
            throw new IllegalStateException("Unable to create table " + table.getTableName(), ie);
        }
    }
    log.debug("{} exists", table.getTableName());
    if (desc != null) { //if the table is not a newly created table
        if (null != updateTable(desc)) { //if there are updates
            log.info("updating {}", table.getTableName());
            try {
                table.waitForActive();
                log.info("updated {}", table.getTableName());
            } catch (InterruptedException e) {
                throw new IllegalStateException("Unable to patch table " + table.getTableName(), e);
            }
        }
    }
}