public class TableUtils extends 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 |
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.
|
static void |
waitUntilActive(AmazonDynamoDB dynamo,
String tableName)
Waits up to 10 minutes for a specified DynamoDB table to move into the
ACTIVE state. |
static void |
waitUntilActive(AmazonDynamoDB dynamo,
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,
String tableName)
Waits up to 10 minutes for a specified DynamoDB table to resolve,
indicating that it exists.
|
static void |
waitUntilExists(AmazonDynamoDB dynamo,
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.
|
public static void waitUntilExists(AmazonDynamoDB dynamo, String tableName) throws InterruptedException
dynamo
- The DynamoDB client to use to make requests.tableName
- The name of the table being resolved.SdkClientException
- If the specified table does not resolve before this method
times out and stops polling.InterruptedException
- If the thread is interrupted while waiting for the table to
resolve.public static void waitUntilExists(AmazonDynamoDB dynamo, String tableName, int timeout, int interval) throws 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.SdkClientException
- If the specified table does not resolve before this method
times out and stops polling.InterruptedException
- If the thread is interrupted while waiting for the table to
resolve.public static void waitUntilActive(AmazonDynamoDB dynamo, String tableName) throws InterruptedException, TableUtils.TableNeverTransitionedToStateException
ACTIVE
state. If the table does not exist or does not
transition to the ACTIVE
state after this time, then
SdkClientException 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.InterruptedException
- If the thread is interrupted while waiting for the table to
transition into the ACTIVE
state.public static void waitUntilActive(AmazonDynamoDB dynamo, String tableName, int timeout, int interval) throws InterruptedException, TableUtils.TableNeverTransitionedToStateException
ACTIVE
state. If the table does not exist or
does not transition to the ACTIVE
state after this time,
then a SdkClientException 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.InterruptedException
- If the thread is interrupted while waiting for the table to
transition into the ACTIVE
state.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.Copyright © 2017. All rights reserved.