Class AWSDynamoUtils
java.lang.Object
com.erudika.para.server.persistence.AWSDynamoUtils
Helper utilities for connecting to AWS DynamoDB.
- Author:
- Alex Bogdanovski [[email protected]]
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancreateSharedTable(long readCapacity, long writeCapacity) Creates a table in AWS DynamoDB which will be shared between apps.static booleancreateTable(String appid) Creates a DynamoDB table.static booleancreateTable(String appid, int maxReadCapacity, int maxWriteCapacity) Creates a table in AWS DynamoDB.static voiddeleteAllFromSharedTable(String appid) Deletes all objects in a shared table, which belong to a given appid, by scanning the GSI.static booleandeleteTable(String appid) Deletes the main table from AWS DynamoDB.static booleanexistsTable(String appid) Checks if the main table exists in the database.static software.amazon.awssdk.services.dynamodb.DynamoDbClientReturns a client instance for AWS DynamoDB.static StringgetKeyForAppid(String key, String appIdentifier) Returns the correct key for an object given the appid (table name).Returns the list of regions where a table should be replicated (global table).static software.amazon.awssdk.services.dynamodb.model.GlobalSecondaryIndexDescriptionReturns the Index object for the shared table.static StringgetTableNameForAppid(String appIdentifier) Returns the table name for a given app id.getTableStatus(String appid) Gives basic information about a DynamoDB table (status, creation date, size).static booleanisSharedAppid(String appIdentifier) Returns true if appid starts with a space " ".Lists all table names for this account.static <P extends com.erudika.para.core.ParaObject>
List<P> readPageFromSharedTable(String appid, com.erudika.para.core.utils.Pager pager) Reads a page from a "shared" DynamoDB table.static <P extends com.erudika.para.core.ParaObject>
List<P> readPageFromTable(String appid, com.erudika.para.core.utils.Pager p) Reads a page from a standard DynamoDB table.static booleanupdateTable(String appid, long readCapacity, long writeCapacity) Updates the table settings (read and write capacities).
-
Method Details
-
getClient
public static software.amazon.awssdk.services.dynamodb.DynamoDbClient getClient()Returns a client instance for AWS DynamoDB.- Returns:
- a client that talks to DynamoDB
-
existsTable
Checks if the main table exists in the database.- Parameters:
appid- name of theApp- Returns:
- true if the table exists
-
createTable
Creates a DynamoDB table.- Parameters:
appid- name of theApp- Returns:
- true if created
-
createTable
Creates a table in AWS DynamoDB.- Parameters:
appid- name of theAppmaxReadCapacity- max read capacity for autoscaling (only applicable in PROVISIONED billing mode)maxWriteCapacity- max write capacity for autoscaling (only applicable in PROVISIONED billing mode)- Returns:
- true if created
-
updateTable
Updates the table settings (read and write capacities).- Parameters:
appid- name of theAppreadCapacity- read capacitywriteCapacity- write capacity- Returns:
- true if updated
-
deleteTable
Deletes the main table from AWS DynamoDB.- Parameters:
appid- name of theApp- Returns:
- true if deleted
-
getTableStatus
-
listAllTables
-
getTableNameForAppid
-
getKeyForAppid
-
readPageFromTable
public static <P extends com.erudika.para.core.ParaObject> List<P> readPageFromTable(String appid, com.erudika.para.core.utils.Pager p) Reads a page from a standard DynamoDB table.- Type Parameters:
P- type of object- Parameters:
appid- the app identifier (name)p- aPager- Returns:
- the last row key of the page, or null.
-
getReplicaRegions
-