public class DynamoDBLeaseRefresher extends Object implements LeaseRefresher
LeaseRefresher that uses DynamoDB.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
consistentReads |
protected software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient |
dynamoDBClient |
protected LeaseSerializer |
serializer |
protected String |
table |
| Constructor and Description |
|---|
DynamoDBLeaseRefresher(String table,
software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDBClient,
LeaseSerializer serializer,
boolean consistentReads)
Deprecated.
|
DynamoDBLeaseRefresher(String table,
software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDBClient,
LeaseSerializer serializer,
boolean consistentReads,
@NonNull TableCreatorCallback tableCreatorCallback)
Deprecated.
|
DynamoDBLeaseRefresher(String table,
software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDBClient,
LeaseSerializer serializer,
boolean consistentReads,
@NonNull TableCreatorCallback tableCreatorCallback,
Duration dynamoDbRequestTimeout)
Deprecated.
|
DynamoDBLeaseRefresher(String table,
software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDBClient,
LeaseSerializer serializer,
boolean consistentReads,
@NonNull TableCreatorCallback tableCreatorCallback,
Duration dynamoDbRequestTimeout,
software.amazon.awssdk.services.dynamodb.model.BillingMode billingMode,
boolean leaseTableDeletionProtectionEnabled)
Deprecated.
|
DynamoDBLeaseRefresher(String table,
software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDBClient,
LeaseSerializer serializer,
boolean consistentReads,
@NonNull TableCreatorCallback tableCreatorCallback,
Duration dynamoDbRequestTimeout,
software.amazon.awssdk.services.dynamodb.model.BillingMode billingMode,
boolean leaseTableDeletionProtectionEnabled,
Collection<software.amazon.awssdk.services.dynamodb.model.Tag> tags)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected DependencyException |
convertAndRethrowExceptions(String operation,
String leaseKey,
Exception e) |
boolean |
createLeaseIfNotExists(@NonNull Lease lease)
Create a new lease.
|
boolean |
createLeaseTableIfNotExists()
Creates the table that will store leases.
|
boolean |
createLeaseTableIfNotExists(@NonNull Long readCapacity,
@NonNull Long writeCapacity)
Creates the table that will store leases.
|
void |
deleteAll()
Delete all leases from DynamoDB.
|
void |
deleteLease(@NonNull Lease lease)
Delete the given lease from DynamoDB.
|
boolean |
evictLease(@NonNull Lease lease)
Evict the current owner of lease by setting owner to null.
|
ExtendedSequenceNumber |
getCheckpoint(String leaseKey)
Gets the current checkpoint of the shard.
|
Lease |
getLease(@NonNull String leaseKey) |
boolean |
isLeaseTableEmpty()
Check (synchronously) if there are any leases in the lease table.
|
boolean |
leaseTableExists() |
List<Lease> |
listLeases()
List all objects in table synchronously.
|
List<Lease> |
listLeasesForStream(StreamIdentifier streamIdentifier)
List all leases for a given stream synchronously.
|
boolean |
renewLease(@NonNull Lease lease)
Renew a lease by incrementing the lease counter.
|
boolean |
takeLease(@NonNull Lease lease,
@NonNull String owner)
Take a lease for the given owner by incrementing its leaseCounter and setting its owner field.
|
boolean |
updateLease(@NonNull Lease lease)
Update application-specific fields of the given lease in DynamoDB.
|
void |
updateLeaseWithMetaInfo(Lease lease,
UpdateField updateField)
Update application-specific fields of the given lease in DynamoDB.
|
boolean |
waitUntilLeaseTableExists(long secondsBetweenPolls,
long timeoutSeconds)
Blocks until the lease table exists by polling leaseTableExists.
|
protected final String table
protected final software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDBClient
protected final LeaseSerializer serializer
protected final boolean consistentReads
@Deprecated public DynamoDBLeaseRefresher(String table, software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDBClient, LeaseSerializer serializer, boolean consistentReads)
NOTE: This constructor is deprecated and will be removed in a future release.
table - dynamoDBClient - serializer - consistentReads - @Deprecated public DynamoDBLeaseRefresher(String table, software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDBClient, LeaseSerializer serializer, boolean consistentReads, @NonNull @NonNull TableCreatorCallback tableCreatorCallback)
table - dynamoDBClient - serializer - consistentReads - tableCreatorCallback - @Deprecated public DynamoDBLeaseRefresher(String table, software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDBClient, LeaseSerializer serializer, boolean consistentReads, @NonNull @NonNull TableCreatorCallback tableCreatorCallback, Duration dynamoDbRequestTimeout)
table - dynamoDBClient - serializer - consistentReads - tableCreatorCallback - dynamoDbRequestTimeout - @Deprecated public DynamoDBLeaseRefresher(String table, software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDBClient, LeaseSerializer serializer, boolean consistentReads, @NonNull @NonNull TableCreatorCallback tableCreatorCallback, Duration dynamoDbRequestTimeout, software.amazon.awssdk.services.dynamodb.model.BillingMode billingMode, boolean leaseTableDeletionProtectionEnabled)
table - dynamoDBClient - serializer - consistentReads - tableCreatorCallback - dynamoDbRequestTimeout - billingMode - leaseTableDeletionProtectionEnabled - public DynamoDBLeaseRefresher(String table, software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDBClient, LeaseSerializer serializer, boolean consistentReads, @NonNull @NonNull TableCreatorCallback tableCreatorCallback, Duration dynamoDbRequestTimeout, software.amazon.awssdk.services.dynamodb.model.BillingMode billingMode, boolean leaseTableDeletionProtectionEnabled, Collection<software.amazon.awssdk.services.dynamodb.model.Tag> tags)
table - dynamoDBClient - serializer - consistentReads - tableCreatorCallback - dynamoDbRequestTimeout - billingMode - leaseTableDeletionProtectionEnabled - tags - public boolean createLeaseTableIfNotExists(@NonNull
@NonNull Long readCapacity,
@NonNull
@NonNull Long writeCapacity)
throws ProvisionedThroughputException,
DependencyException
LeaseRefresher.createLeaseTableIfNotExists().createLeaseTableIfNotExists in interface LeaseRefresherProvisionedThroughputException - if we cannot create the lease table due to per-AWS-account capacity
restrictions.DependencyException - if DynamoDB createTable fails in an unexpected waypublic boolean createLeaseTableIfNotExists()
throws ProvisionedThroughputException,
DependencyException
createLeaseTableIfNotExists in interface LeaseRefresherProvisionedThroughputException - if we cannot create the lease table due to per-AWS-account capacity
restrictions.DependencyException - if DynamoDB createTable fails in an unexpected waypublic boolean leaseTableExists()
throws DependencyException
leaseTableExists in interface LeaseRefresherDependencyException - if DynamoDB describeTable fails in an unexpected waypublic boolean waitUntilLeaseTableExists(long secondsBetweenPolls,
long timeoutSeconds)
throws DependencyException
LeaseRefresherwaitUntilLeaseTableExists in interface LeaseRefreshersecondsBetweenPolls - time to wait between polls in secondstimeoutSeconds - total time to wait in secondsDependencyException - if DynamoDB describeTable fails in an unexpected waypublic List<Lease> listLeasesForStream(StreamIdentifier streamIdentifier) throws DependencyException, InvalidStateException, ProvisionedThroughputException
listLeasesForStream in interface LeaseRefresherDependencyException - if DynamoDB scan fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB scan fails due to lack of capacitypublic List<Lease> listLeases() throws DependencyException, InvalidStateException, ProvisionedThroughputException
listLeases in interface LeaseRefresherDependencyException - if DynamoDB scan fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB scan fails due to lack of capacitypublic boolean isLeaseTableEmpty()
throws DependencyException,
InvalidStateException,
ProvisionedThroughputException
isLeaseTableEmpty in interface LeaseRefresherDependencyException - if DynamoDB scan fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB scan fails due to lack of capacitypublic boolean createLeaseIfNotExists(@NonNull
@NonNull Lease lease)
throws DependencyException,
InvalidStateException,
ProvisionedThroughputException
createLeaseIfNotExists in interface LeaseRefresherlease - the lease to createDependencyException - if DynamoDB put fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB put fails due to lack of capacitypublic Lease getLease(@NonNull @NonNull String leaseKey) throws DependencyException, InvalidStateException, ProvisionedThroughputException
getLease in interface LeaseRefresherleaseKey - Get the lease for this leasekeyDependencyException - if DynamoDB get fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB get fails due to lack of capacitypublic boolean renewLease(@NonNull
@NonNull Lease lease)
throws DependencyException,
InvalidStateException,
ProvisionedThroughputException
renewLease in interface LeaseRefresherlease - the lease to renewDependencyException - if DynamoDB update fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB update fails due to lack of capacitypublic boolean takeLease(@NonNull
@NonNull Lease lease,
@NonNull
@NonNull String owner)
throws DependencyException,
InvalidStateException,
ProvisionedThroughputException
takeLease in interface LeaseRefresherlease - the lease to takeowner - the new ownerDependencyException - if DynamoDB update fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB update fails due to lack of capacitypublic boolean evictLease(@NonNull
@NonNull Lease lease)
throws DependencyException,
InvalidStateException,
ProvisionedThroughputException
evictLease in interface LeaseRefresherlease - the lease to voidDependencyException - if DynamoDB update fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB update fails due to lack of capacitypublic void deleteAll()
throws DependencyException,
InvalidStateException,
ProvisionedThroughputException
deleteAll in interface LeaseRefresherDependencyException - if DynamoDB scan or delete fail in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB scan or delete fail due to lack of capacitypublic void deleteLease(@NonNull
@NonNull Lease lease)
throws DependencyException,
InvalidStateException,
ProvisionedThroughputException
deleteLease in interface LeaseRefresherlease - the lease to deleteDependencyException - if DynamoDB delete fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB delete fails due to lack of capacitypublic boolean updateLease(@NonNull
@NonNull Lease lease)
throws DependencyException,
InvalidStateException,
ProvisionedThroughputException
updateLease in interface LeaseRefresherDependencyException - if DynamoDB update fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB update fails due to lack of capacitypublic void updateLeaseWithMetaInfo(Lease lease, UpdateField updateField) throws DependencyException, InvalidStateException, ProvisionedThroughputException
LeaseRefresherupdateLeaseWithMetaInfo in interface LeaseRefresherDependencyException - if DynamoDB update fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB update fails due to lack of capacitypublic ExtendedSequenceNumber getCheckpoint(String leaseKey) throws ProvisionedThroughputException, InvalidStateException, DependencyException
getCheckpoint in interface LeaseRefresherleaseKey - Checkpoint of this shard will be returnedProvisionedThroughputException - if DynamoDB update fails due to lack of capacityInvalidStateException - if lease table does not existDependencyException - if DynamoDB update fails in an unexpected wayprotected DependencyException convertAndRethrowExceptions(String operation, String leaseKey, Exception e) throws ProvisionedThroughputException, InvalidStateException
Copyright © 2024. All rights reserved.