class DynamoDBManager {

    public static void waitForTableToBecomeActive(final AmazonDynamoDB dynamoDB, final String tableName) {
        int numTries = 0;
        TableStatus currentState;
        try {
            currentState = getTableStatus(dynamoDB, tableName);
        } catch (final ResourceNotFoundException e) {
            throw new IllegalStateException("Table " + tableName + " does not exist");
        }
        while (numTries < RETRY_COUNT) {
            try {
                Thread.sleep(RETRY_DELAY);
            } catch (final InterruptedException e) {
                LOGGER.severe(e.getMessage());
            }
            currentState = getTableStatus(dynamoDB, tableName);
            numTries++;
            LOGGER.info("Table " + tableName + " is in " + currentState + " state");
            switch (currentState) {
                case ACTIVE:
                    return;
                case DELETING:
                    throw new IllegalStateException("Table " + tableName
                        + " has DELETING status and will never become active");
                case UPDATING:
                    break;
                case CREATING:
                    break;
                default:
                    throw new IllegalStateException("Unknown table status: " + currentState);
            }
        }

        final DescribeTableResult result = dynamoDB.describeTable(tableName);
        throw new IllegalStateException("Table " + tableName + " never went ACTIVE" + result);
    }

    private  DynamoDBManager();

}