T
- Lease subclass, possibly Lease itself.public interface ILeaseManager<T extends Lease>
Modifier and Type | Method and Description |
---|---|
boolean |
createLeaseIfNotExists(T lease)
Create a new lease.
|
boolean |
createLeaseTableIfNotExists(java.lang.Long readCapacity,
java.lang.Long writeCapacity)
Creates the table that will store leases.
|
void |
deleteAll()
Delete all leases from DynamoDB.
|
void |
deleteLease(T lease)
Delete the given lease from DynamoDB.
|
boolean |
evictLease(T lease)
Evict the current owner of lease by setting owner to null.
|
T |
getLease(java.lang.String shardId) |
boolean |
leaseTableExists() |
java.util.List<T> |
listLeases()
List all objects in table synchronously.
|
boolean |
renewLease(T lease)
Renew a lease by incrementing the lease counter.
|
boolean |
takeLease(T lease,
java.lang.String owner)
Take a lease for the given owner by incrementing its leaseCounter and setting its owner field.
|
boolean |
updateLease(T lease)
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.
|
boolean createLeaseTableIfNotExists(java.lang.Long readCapacity, java.lang.Long writeCapacity) throws ProvisionedThroughputException, DependencyException
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 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 wayjava.util.List<T> 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 capacityboolean createLeaseIfNotExists(T 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 capacityT getLease(java.lang.String shardId) throws DependencyException, InvalidStateException, ProvisionedThroughputException
shardId
- Get the lease for this shardIdInvalidStateException
- if lease table does not existProvisionedThroughputException
- if DynamoDB get fails due to lack of capacityDependencyException
- if DynamoDB get fails in an unexpected wayboolean renewLease(T 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(T lease, java.lang.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 wayboolean evictLease(T 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(T 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(T 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 way