public class DynamoDBLeaseTaker extends Object implements LeaseTaker
LeaseTaker
that uses DynamoDB via LeaseRefresher
.Constructor and Description |
---|
DynamoDBLeaseTaker(LeaseRefresher leaseRefresher,
String workerIdentifier,
long leaseDurationMillis,
MetricsFactory metricsFactory) |
Modifier and Type | Method and Description |
---|---|
List<Lease> |
allLeases()
Default implementation returns an empty list and concrete implementaion is expected to return all leases
for the application that are in the lease table either by reading lease table or from an internal cache.
|
String |
getWorkerIdentifier() |
Map<String,Lease> |
takeLeases()
Compute the set of leases available to be taken and attempt to take them.
|
DynamoDBLeaseTaker |
withMaxLeasesForWorker(int maxLeasesForWorker)
Worker will not acquire more than the specified max number of leases even if there are more
shards that need to be processed.
|
DynamoDBLeaseTaker |
withMaxLeasesToStealAtOneTime(int maxLeasesToStealAtOneTime)
Max leases to steal from a more loaded Worker at one time (for load balancing).
|
DynamoDBLeaseTaker |
withVeryOldLeaseDurationNanosMultipler(long veryOldLeaseDurationNanosMultipler)
Overrides the default very old lease duration nanos multiplier to increase the threshold for taking very old leases.
|
public DynamoDBLeaseTaker(LeaseRefresher leaseRefresher, String workerIdentifier, long leaseDurationMillis, MetricsFactory metricsFactory)
public DynamoDBLeaseTaker withMaxLeasesForWorker(int maxLeasesForWorker)
maxLeasesForWorker
- Max leases this Worker can handle at a timepublic DynamoDBLeaseTaker withVeryOldLeaseDurationNanosMultipler(long veryOldLeaseDurationNanosMultipler)
veryOldLeaseDurationNanosMultipler
- Very old lease duration multiplier for adjusting very old lease taking.public DynamoDBLeaseTaker withMaxLeasesToStealAtOneTime(int maxLeasesToStealAtOneTime)
maxLeasesToStealAtOneTime
- Steal up to this many leases at one time (for load balancing)public Map<String,Lease> takeLeases() throws DependencyException, InvalidStateException
takeLeases
in interface LeaseTaker
DependencyException
- on unexpected DynamoDB failuresInvalidStateException
- if lease table does not existpublic String getWorkerIdentifier()
getWorkerIdentifier
in interface LeaseTaker
public List<Lease> allLeases()
allLeases
in interface LeaseTaker
Copyright © 2020. All rights reserved.