public class DynamoTableUtils extends Object
// ... create DynamoDB table ...
try {
waitUntilActive(dynamoDB, myTableName());
} catch (SdkClientException e) {
// table didn't become active
}
// ... start making calls to table ...
| Modifier and Type | Class and Description |
|---|---|
static class |
DynamoTableUtils.TableNeverTransitionedToStateException
Thrown by
DynamoTableUtils when a table never reaches a desired state |
| Constructor and Description |
|---|
DynamoTableUtils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
createTableIfNotExists(software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamo,
software.amazon.awssdk.services.dynamodb.model.CreateTableRequest createTableRequest)
Creates the table and ignores any errors if it already exists.
|
static boolean |
deleteTableIfExists(software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamo,
software.amazon.awssdk.services.dynamodb.model.DeleteTableRequest deleteTableRequest)
Deletes the table and ignores any errors if it doesn't exist.
|
static void |
waitUntilActive(software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamo,
String tableName)
Waits up to 10 minutes for a specified DynamoDB table to move into the
ACTIVE state. |
static void |
waitUntilActive(software.amazon.awssdk.services.dynamodb.DynamoDbClient 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(software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamo,
String tableName)
Waits up to 10 minutes for a specified DynamoDB table to resolve,
indicating that it exists.
|
static void |
waitUntilExists(software.amazon.awssdk.services.dynamodb.DynamoDbClient 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(software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamo,
String tableName)
throws InterruptedException
dynamo - The DynamoDB client to use to make requests.tableName - The name of the table being resolved.software.amazon.awssdk.core.exception.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(software.amazon.awssdk.services.dynamodb.DynamoDbClient 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.software.amazon.awssdk.core.exception.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(software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamo,
String tableName)
throws InterruptedException,
DynamoTableUtils.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.DynamoTableUtils.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(software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamo,
String tableName,
int timeout,
int interval)
throws InterruptedException,
DynamoTableUtils.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.DynamoTableUtils.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 boolean createTableIfNotExists(software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamo,
software.amazon.awssdk.services.dynamodb.model.CreateTableRequest createTableRequest)
dynamo - The Dynamo client to use.createTableRequest - The create table request.public static boolean deleteTableIfExists(software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamo,
software.amazon.awssdk.services.dynamodb.model.DeleteTableRequest deleteTableRequest)
dynamo - The Dynamo client to use.deleteTableRequest - The delete table request.Copyright © 2023 The Apache Software Foundation. All rights reserved.