public interface LeaseCoordinator
Modifier and Type | Method and Description |
---|---|
default List<Lease> |
allLeases()
Default implementation returns an empty list and concrete implementation is expected to return all leases
for the application that are in the lease table.
|
void |
dropLease(Lease lease)
Requests that renewals for the given lease are stopped.
|
Collection<Lease> |
getAssignments() |
List<ShardInfo> |
getCurrentAssignments() |
Lease |
getCurrentlyHeldLease(String leaseKey) |
void |
initialize()
Initialize the lease coordinator (create the lease table if needed).
|
DynamoDBLeaseCoordinator |
initialLeaseTableReadCapacity(long readCapacity) |
DynamoDBLeaseCoordinator |
initialLeaseTableWriteCapacity(long writeCapacity) |
boolean |
isRunning() |
LeaseRefresher |
leaseRefresher() |
void |
runLeaseRenewer()
Runs a single iteration of the lease renewer - used by integration tests.
|
void |
runLeaseTaker()
Runs a single iteration of the lease taker - used by integration tests.
|
void |
start()
Start background LeaseHolder and LeaseTaker threads.
|
void |
stop()
Stops background threads and waits for specific amount of time for all background tasks to complete.
|
void |
stopLeaseTaker()
Requests the cancellation of the lease taker.
|
boolean |
updateLease(Lease lease,
UUID concurrencyToken,
String operation,
String singleStreamShardId)
Updates application-specific lease values in DynamoDB.
|
String |
workerIdentifier() |
void initialize() throws ProvisionedThroughputException, DependencyException, IllegalStateException
void start() throws DependencyException, InvalidStateException, ProvisionedThroughputException
ProvisionedThroughputException
- If we can't talk to DynamoDB due to insufficient capacity.InvalidStateException
- If the lease table doesn't existDependencyException
- If we encountered exception taking to DynamoDBvoid runLeaseTaker() throws DependencyException, InvalidStateException
void runLeaseRenewer() throws DependencyException, InvalidStateException
boolean isRunning()
String workerIdentifier()
LeaseRefresher leaseRefresher()
LeaseRefresher
Collection<Lease> getAssignments()
Lease getCurrentlyHeldLease(String leaseKey)
leaseKey
- lease key to fetch currently held lease forboolean updateLease(Lease lease, UUID concurrencyToken, String operation, String singleStreamShardId) throws DependencyException, InvalidStateException, ProvisionedThroughputException
lease
- lease object containing updated valuesconcurrencyToken
- obtained by calling Lease.concurrencyToken for a currently held leaseoperation
- that performs updateLeasesingleStreamShardId
- for metrics emission in single stream mode. MultiStream mode will get the
shardId from the lease objectInvalidStateException
- if lease table does not existProvisionedThroughputException
- if DynamoDB update fails due to lack of capacityDependencyException
- if DynamoDB update fails in an unexpected wayvoid stopLeaseTaker()
void dropLease(Lease lease)
lease
- the lease to stop renewing.void stop()
List<ShardInfo> getCurrentAssignments()
default List<Lease> allLeases()
DynamoDBLeaseCoordinator initialLeaseTableWriteCapacity(long writeCapacity)
writeCapacity
- The DynamoDB table used for tracking leases will be provisioned with the specified initial
write capacityDynamoDBLeaseCoordinator initialLeaseTableReadCapacity(long readCapacity)
readCapacity
- The DynamoDB table used for tracking leases will be provisioned with the specified initial
read capacityCopyright © 2020. All rights reserved.