public class TableUtils
extends java.lang.Object
// ... create DynamoDB table ... try { waitUntilActive(dynamoDB, myTableName()); } catch (AmazonClientException e) { // table didn't become active } // ... start making calls to table ...
Modifier and Type | Class and Description |
---|---|
static class |
TableUtils.TableNeverTransitionedToStateException
Thrown by
TableUtils when a table never reaches a desired state |
Modifier and Type | Field and Description |
---|---|
private static int |
DEFAULT_WAIT_INTERVAL |
private static int |
DEFAULT_WAIT_TIMEOUT |
private static org.apache.commons.logging.Log |
LOG
The logging utility.
|
Constructor and Description |
---|
TableUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
createTableIfNotExists(AmazonDynamoDB dynamo,
CreateTableRequest createTableRequest)
Creates the table and ignores any errors if it already exists.
|
static boolean |
deleteTableIfExists(AmazonDynamoDB dynamo,
DeleteTableRequest deleteTableRequest)
Deletes the table and ignores any errors if it doesn't exist.
|
private static TableDescription |
waitForTableDescription(AmazonDynamoDB dynamo,
java.lang.String tableName,
TableStatus desiredStatus,
int timeout,
int interval)
Wait for the table to reach the desired status and returns the table
description
|
static void |
waitUntilActive(AmazonDynamoDB dynamo,
java.lang.String tableName)
Waits up to 10 minutes for a specified DynamoDB table to move into the
ACTIVE state. |
static void |
waitUntilActive(AmazonDynamoDB dynamo,
java.lang.String tableName,
int timeout,
int interval)
Waits up to a specified amount of time for a specified DynamoDB table to
move into the
ACTIVE state. |
static void |
waitUntilExists(AmazonDynamoDB dynamo,
java.lang.String tableName)
Waits up to 10 minutes for a specified DynamoDB table to resolve,
indicating that it exists.
|
static void |
waitUntilExists(AmazonDynamoDB dynamo,
java.lang.String tableName,
int timeout,
int interval)
Waits up to a specified amount of time for a specified DynamoDB table to
resolve, indicating that it exists.
|
private static final int DEFAULT_WAIT_TIMEOUT
private static final int DEFAULT_WAIT_INTERVAL
private static final org.apache.commons.logging.Log LOG
public static void waitUntilExists(AmazonDynamoDB dynamo, java.lang.String tableName) throws java.lang.InterruptedException
dynamo
- The DynamoDB client to use to make requests.tableName
- The name of the table being resolved.AmazonClientException
- If the specified table does not resolve before this method
times out and stops polling.java.lang.InterruptedException
- If the thread is interrupted while waiting for the table to
resolve.public static void waitUntilExists(AmazonDynamoDB dynamo, java.lang.String tableName, int timeout, int interval) throws java.lang.InterruptedException
dynamo
- The DynamoDB client to use to make requests.tableName
- The name of the table being resolved.timeout
- The maximum number of milliseconds to wait.interval
- The poll interval in milliseconds.AmazonClientException
- If the specified table does not resolve before this method
times out and stops polling.java.lang.InterruptedException
- If the thread is interrupted while waiting for the table to
resolve.public static void waitUntilActive(AmazonDynamoDB dynamo, java.lang.String tableName) throws java.lang.InterruptedException, TableUtils.TableNeverTransitionedToStateException
ACTIVE
state. If the table does not exist or does not
transition to the ACTIVE
state after this time, then an
AmazonClientException is thrown.dynamo
- The DynamoDB client to use to make requests.tableName
- The name of the table whose status is being checked.TableUtils.TableNeverTransitionedToStateException
- If the specified table does not exist or does not transition
into the ACTIVE
state before this method times
out and stops polling.java.lang.InterruptedException
- If the thread is interrupted while waiting for the table to
transition into the ACTIVE
state.public static void waitUntilActive(AmazonDynamoDB dynamo, java.lang.String tableName, int timeout, int interval) throws java.lang.InterruptedException, TableUtils.TableNeverTransitionedToStateException
ACTIVE
state. If the table does not exist or
does not transition to the ACTIVE
state after this time,
then an AmazonClientException is thrown.dynamo
- The DynamoDB client to use to make requests.tableName
- The name of the table whose status is being checked.timeout
- The maximum number of milliseconds to wait.interval
- The poll interval in milliseconds.TableUtils.TableNeverTransitionedToStateException
- If the specified table does not exist or does not transition
into the ACTIVE
state before this method times
out and stops polling.java.lang.InterruptedException
- If the thread is interrupted while waiting for the table to
transition into the ACTIVE
state.private static TableDescription waitForTableDescription(AmazonDynamoDB dynamo, java.lang.String tableName, TableStatus desiredStatus, int timeout, int interval) throws java.lang.InterruptedException, java.lang.IllegalArgumentException
dynamo
- Dynamo client to usetableName
- Table name to poll status ofdesiredStatus
- Desired TableStatus
to wait for. If null this method
simply waits until DescribeTable returns something non-null
(i.e. any status)timeout
- Timeout in milliseconds to continue to poll for desired statusinterval
- Time to wait in milliseconds between poll attemptsjava.lang.InterruptedException
{@link
- IllegalArgumentException} If timeout or interval is invalidjava.lang.IllegalArgumentException
public static final boolean createTableIfNotExists(AmazonDynamoDB dynamo, CreateTableRequest createTableRequest)
dynamo
- The Dynamo client to use.createTableRequest
- The create table request.public static final boolean deleteTableIfExists(AmazonDynamoDB dynamo, DeleteTableRequest deleteTableRequest)
dynamo
- The Dynamo client to use.deleteTableRequest
- The delete table request.