public interface LeaseRefresher
| Modifier and Type | Method and Description |
|---|---|
default boolean |
assignLease(Lease lease,
String newOwner)
Assigns given lease to newOwner owner by incrementing its leaseCounter and setting its owner field.
|
boolean |
createLeaseIfNotExists(Lease lease)
Create a new lease.
|
default String |
createLeaseOwnerToLeaseKeyIndexIfNotExists()
Creates the LeaseOwnerToLeaseKey index on the lease table if it doesn't exist and returns the status of index.
|
boolean |
createLeaseTableIfNotExists()
Creates the table that will store leases.
|
boolean |
createLeaseTableIfNotExists(Long readCapacity,
Long writeCapacity)
Deprecated.
|
void |
deleteAll()
Delete all leases from DynamoDB.
|
void |
deleteLease(Lease lease)
Delete the given lease from DynamoDB.
|
boolean |
evictLease(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(String leaseKey) |
default boolean |
initiateGracefulLeaseHandoff(Lease lease,
String newOwner)
Initiates a graceful handoff of the given lease to the specified new owner, allowing the current owner
to complete its processing before transferring ownership.
|
boolean |
isLeaseOwnerToLeaseKeyIndexActive()
Check if leaseOwner GSI is ACTIVE
|
boolean |
isLeaseTableEmpty()
Check (synchronously) if there are any leases in the lease table.
|
boolean |
leaseTableExists() |
default List<String> |
listLeaseKeysForWorker(String workerIdentifier)
List all leases for a given workerIdentifier synchronously.
|
List<Lease> |
listLeases()
List all objects in table synchronously.
|
List<Lease> |
listLeasesForStream(StreamIdentifier streamIdentifier)
List all leases for a given stream synchronously.
|
default Map.Entry<List<Lease>,List<String>> |
listLeasesParallely(ExecutorService threadPool,
int parallelismFactor)
List all leases from the storage parallely and deserialize into Lease objects.
|
boolean |
renewLease(Lease lease)
Renew a lease by incrementing the lease counter.
|
boolean |
takeLease(Lease lease,
String owner)
Take a lease for the given owner by incrementing its leaseCounter and setting its owner field.
|
boolean |
updateLease(Lease lease)
Update application-specific fields of the given lease in DynamoDB.
|
default void |
updateLeaseWithMetaInfo(Lease lease,
UpdateField updateField)
Update application-specific fields of the given lease in DynamoDB.
|
default boolean |
waitUntilLeaseOwnerToLeaseKeyIndexExists(long secondsBetweenPolls,
long timeoutSeconds)
Blocks until the index exists by polling storage till either the index is ACTIVE or else timeout has
happened.
|
boolean |
waitUntilLeaseTableExists(long secondsBetweenPolls,
long timeoutSeconds)
Blocks until the lease table exists by polling leaseTableExists.
|
@Deprecated boolean createLeaseTableIfNotExists(Long readCapacity, Long writeCapacity) throws ProvisionedThroughputException, DependencyException
createLeaseTableIfNotExists().readCapacity - writeCapacity - ProvisionedThroughputException - if we cannot create the lease table due to per-AWS-account capacity
restrictions.DependencyException - if DynamoDB createTable fails in an unexpected wayboolean createLeaseTableIfNotExists()
throws ProvisionedThroughputException,
DependencyException
ProvisionedThroughputException - if we cannot create the lease table due to per-AWS-account capacity
restrictions.DependencyException - if DynamoDB createTable fails in an unexpected wayboolean leaseTableExists()
throws DependencyException
DependencyException - if DynamoDB describeTable fails in an unexpected wayboolean waitUntilLeaseTableExists(long secondsBetweenPolls,
long timeoutSeconds)
throws DependencyException
secondsBetweenPolls - time to wait between polls in secondstimeoutSeconds - total time to wait in secondsDependencyException - if DynamoDB describeTable fails in an unexpected waydefault String createLeaseOwnerToLeaseKeyIndexIfNotExists() throws DependencyException
DependencyException - if storage's describe API fails in an unexpected waydefault boolean waitUntilLeaseOwnerToLeaseKeyIndexExists(long secondsBetweenPolls,
long timeoutSeconds)
secondsBetweenPolls - time to wait between polls in secondstimeoutSeconds - total time to wait in secondsboolean isLeaseOwnerToLeaseKeyIndexActive()
throws DependencyException
DependencyException - if storage's describe API fails in an unexpected wayList<Lease> listLeasesForStream(StreamIdentifier streamIdentifier) throws DependencyException, InvalidStateException, ProvisionedThroughputException
DependencyException - if DynamoDB scan fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB scan fails due to lack of capacitydefault List<String> listLeaseKeysForWorker(String workerIdentifier) throws DependencyException, InvalidStateException, ProvisionedThroughputException
DependencyException - if DynamoDB scan fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB scan fails due to lack of capacityList<Lease> listLeases() throws DependencyException, InvalidStateException, ProvisionedThroughputException
DependencyException - if DynamoDB scan fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB scan fails due to lack of capacitydefault Map.Entry<List<Lease>,List<String>> listLeasesParallely(ExecutorService threadPool, int parallelismFactor) throws DependencyException, InvalidStateException, ProvisionedThroughputException
threadPool - threadpool to use for parallel scanparallelismFactor - no. of parallel scansDependencyException - if DynamoDB scan fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB scan fails due to lack of capacityboolean createLeaseIfNotExists(Lease lease) throws DependencyException, InvalidStateException, ProvisionedThroughputException
lease - 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 capacityLease getLease(String leaseKey) throws DependencyException, InvalidStateException, ProvisionedThroughputException
leaseKey - Get the lease for this leasekeyInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB get fails due to lack of capacityDependencyException - if DynamoDB get fails in an unexpected wayboolean renewLease(Lease lease) throws DependencyException, InvalidStateException, ProvisionedThroughputException
lease - the lease to renewInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB update fails due to lack of capacityDependencyException - if DynamoDB update fails in an unexpected wayboolean takeLease(Lease lease, String owner) throws DependencyException, InvalidStateException, ProvisionedThroughputException
lease - the lease to takeowner - the new ownerInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB update fails due to lack of capacityDependencyException - if DynamoDB update fails in an unexpected waydefault boolean assignLease(Lease lease, String newOwner) throws DependencyException, InvalidStateException, ProvisionedThroughputException
lease - the lease to be assignednewOwner - the new ownerInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB update fails due to lack of capacityDependencyException - if DynamoDB update fails in an unexpected waydefault boolean initiateGracefulLeaseHandoff(Lease lease, String newOwner) throws DependencyException, InvalidStateException, ProvisionedThroughputException
This method updates the lease with the new owner information but ensures that the current owner is given time to gracefully finish its work (e.g., processing records) before the lease is reassigned.
lease - the lease to be assignednewOwner - the new ownerInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB update fails due to lack of capacityDependencyException - if DynamoDB update fails in an unexpected wayboolean evictLease(Lease lease) throws DependencyException, InvalidStateException, ProvisionedThroughputException
lease - the lease to voidInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB update fails due to lack of capacityDependencyException - if DynamoDB update fails in an unexpected wayvoid deleteLease(Lease lease) throws DependencyException, InvalidStateException, ProvisionedThroughputException
lease - the lease to deleteInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB delete fails due to lack of capacityDependencyException - if DynamoDB delete fails in an unexpected wayvoid deleteAll()
throws DependencyException,
InvalidStateException,
ProvisionedThroughputException
InvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB scan or delete fail due to lack of capacityDependencyException - if DynamoDB scan or delete fail in an unexpected wayboolean updateLease(Lease lease) throws DependencyException, InvalidStateException, ProvisionedThroughputException
InvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB update fails due to lack of capacityDependencyException - if DynamoDB update fails in an unexpected waydefault void updateLeaseWithMetaInfo(Lease lease, UpdateField updateField) throws DependencyException, InvalidStateException, ProvisionedThroughputException
InvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB update fails due to lack of capacityDependencyException - if DynamoDB update fails in an unexpected wayboolean isLeaseTableEmpty()
throws DependencyException,
InvalidStateException,
ProvisionedThroughputException
DependencyException - if DynamoDB scan fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB scan fails due to lack of capacityExtendedSequenceNumber getCheckpoint(String leaseKey) throws ProvisionedThroughputException, InvalidStateException, DependencyException
leaseKey - 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 wayCopyright © 2024. All rights reserved.