public class LeaseRenewer<T extends Lease> extends Object implements ILeaseRenewer<T>
| Constructor and Description |
|---|
LeaseRenewer(ILeaseManager<T> leaseManager,
String workerIdentifier,
long leaseDurationMillis,
ExecutorService executorService)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLeasesToRenew(Collection<T> newLeases)
Adds leases to this LeaseRenewer's set of currently held leases.
|
void |
clearCurrentlyHeldLeases()
Clears this LeaseRenewer's set of currently held leases.
|
void |
dropLease(T lease)
Stops the lease renewer from continunig to maintain the given lease.
|
T |
getCurrentlyHeldLease(String leaseKey) |
Map<String,T> |
getCurrentlyHeldLeases() |
void |
initialize()
Bootstrap initial set of leases from the LeaseManager (e.g.
|
void |
renewLeases()
Attempt to renew all currently held leases.
|
boolean |
updateLease(T lease,
UUID concurrencyToken)
Update application-specific fields in a currently held lease.
|
public LeaseRenewer(ILeaseManager<T> leaseManager, String workerIdentifier, long leaseDurationMillis, ExecutorService executorService)
leaseManager - LeaseManager to useworkerIdentifier - identifier of this workerleaseDurationMillis - duration of a lease in millisecondsexecutorService - ExecutorService to use for renewing leases in parallelpublic void renewLeases()
throws DependencyException,
InvalidStateException
renewLeases in interface ILeaseRenewer<T extends Lease>DependencyException - on unexpected DynamoDB failuresInvalidStateException - if lease table does not existpublic Map<String,T> getCurrentlyHeldLeases()
getCurrentlyHeldLeases in interface ILeaseRenewer<T extends Lease>public T getCurrentlyHeldLease(String leaseKey)
getCurrentlyHeldLease in interface ILeaseRenewer<T extends Lease>leaseKey - key of the lease to retrievepublic boolean updateLease(T lease, UUID concurrencyToken) throws DependencyException, InvalidStateException, ProvisionedThroughputException
updateLease in interface ILeaseRenewer<T extends Lease>lease - lease object containing updated dataconcurrencyToken - obtained by calling Lease.getConcurrencyToken for a currently held leaseDependencyException - if DynamoDB update fails in an unexpected wayInvalidStateException - if lease table does not existProvisionedThroughputException - if DynamoDB update fails due to lack of capacitypublic void addLeasesToRenew(Collection<T> newLeases)
addLeasesToRenew in interface ILeaseRenewer<T extends Lease>newLeases - new leases.public void clearCurrentlyHeldLeases()
clearCurrentlyHeldLeases in interface ILeaseRenewer<T extends Lease>public void dropLease(T lease)
dropLease in interface ILeaseRenewer<T extends Lease>lease - the lease to drop.public void initialize()
throws DependencyException,
InvalidStateException,
ProvisionedThroughputException
initialize in interface ILeaseRenewer<T extends Lease>DependencyException - on unexpected DynamoDB failuresInvalidStateException - if lease table doesn't existProvisionedThroughputException - if DynamoDB reads fail due to insufficient capacityCopyright © 2017. All rights reserved.