Reverting some changes:
* Reverting the constructor, and adding chained constructor * Reverting support for initial iops methods * Adding deprecated tags and notes to javadoc
This commit is contained in:
parent
51ec96bf9a
commit
ca88ee9bc6
1 changed files with 60 additions and 4 deletions
|
|
@ -59,6 +59,8 @@ import software.amazon.kinesis.metrics.MetricsUtil;
|
||||||
public class DynamoDBLeaseCoordinator implements LeaseCoordinator {
|
public class DynamoDBLeaseCoordinator implements LeaseCoordinator {
|
||||||
// Time to wait for in-flight Runnables to finish when calling .stop();
|
// Time to wait for in-flight Runnables to finish when calling .stop();
|
||||||
private static final long STOP_WAIT_TIME_MILLIS = 2000L;
|
private static final long STOP_WAIT_TIME_MILLIS = 2000L;
|
||||||
|
private static final long DEFAULT_INITIAL_LEASE_TABLE_READ_CAPACITY = 10L;
|
||||||
|
private static final long DEFAULT_INITIAL_LEASE_TABLE_WRITE_CAPACITY = 10L;
|
||||||
private static final ThreadFactory LEASE_COORDINATOR_THREAD_FACTORY = new ThreadFactoryBuilder()
|
private static final ThreadFactory LEASE_COORDINATOR_THREAD_FACTORY = new ThreadFactoryBuilder()
|
||||||
.setNameFormat("LeaseCoordinator-%04d").setDaemon(true).build();
|
.setNameFormat("LeaseCoordinator-%04d").setDaemon(true).build();
|
||||||
private static final ThreadFactory LEASE_RENEWAL_THREAD_FACTORY = new ThreadFactoryBuilder()
|
private static final ThreadFactory LEASE_RENEWAL_THREAD_FACTORY = new ThreadFactoryBuilder()
|
||||||
|
|
@ -70,8 +72,8 @@ public class DynamoDBLeaseCoordinator implements LeaseCoordinator {
|
||||||
private final long takerIntervalMillis;
|
private final long takerIntervalMillis;
|
||||||
private final ExecutorService leaseRenewalThreadpool;
|
private final ExecutorService leaseRenewalThreadpool;
|
||||||
private final LeaseRefresher leaseRefresher;
|
private final LeaseRefresher leaseRefresher;
|
||||||
private final long initialLeaseTableReadCapacity;
|
private long initialLeaseTableReadCapacity;
|
||||||
private final long initialLeaseTableWriteCapacity;
|
private long initialLeaseTableWriteCapacity;
|
||||||
protected final MetricsFactory metricsFactory;
|
protected final MetricsFactory metricsFactory;
|
||||||
|
|
||||||
private final Object shutdownLock = new Object();
|
private final Object shutdownLock = new Object();
|
||||||
|
|
@ -81,6 +83,40 @@ public class DynamoDBLeaseCoordinator implements LeaseCoordinator {
|
||||||
|
|
||||||
private volatile boolean running = false;
|
private volatile boolean running = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* <p>NOTE: This constructor is deprecated and will be removed in a future release.</p>
|
||||||
|
*
|
||||||
|
* @param leaseRefresher
|
||||||
|
* LeaseRefresher instance to use
|
||||||
|
* @param workerIdentifier
|
||||||
|
* Identifies the worker (e.g. useful to track lease ownership)
|
||||||
|
* @param leaseDurationMillis
|
||||||
|
* Duration of a lease
|
||||||
|
* @param epsilonMillis
|
||||||
|
* Allow for some variance when calculating lease expirations
|
||||||
|
* @param maxLeasesForWorker
|
||||||
|
* Max leases this Worker can handle at a time
|
||||||
|
* @param maxLeasesToStealAtOneTime
|
||||||
|
* Steal up to these many leases at a time (for load balancing)
|
||||||
|
* @param metricsFactory
|
||||||
|
* Used to publish metrics about lease operations
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public DynamoDBLeaseCoordinator(final LeaseRefresher leaseRefresher,
|
||||||
|
final String workerIdentifier,
|
||||||
|
final long leaseDurationMillis,
|
||||||
|
final long epsilonMillis,
|
||||||
|
final int maxLeasesForWorker,
|
||||||
|
final int maxLeasesToStealAtOneTime,
|
||||||
|
final int maxLeaseRenewerThreadCount,
|
||||||
|
final MetricsFactory metricsFactory) {
|
||||||
|
this(leaseRefresher, workerIdentifier, leaseDurationMillis, epsilonMillis, maxLeasesForWorker,
|
||||||
|
maxLeasesToStealAtOneTime, maxLeaseRenewerThreadCount, DEFAULT_INITIAL_LEASE_TABLE_READ_CAPACITY,
|
||||||
|
DEFAULT_INITIAL_LEASE_TABLE_WRITE_CAPACITY, metricsFactory);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
|
@ -342,13 +378,33 @@ public class DynamoDBLeaseCoordinator implements LeaseCoordinator {
|
||||||
lease.checkpoint());
|
lease.checkpoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>NOTE: This method is deprecated. Please set the initial capacity through the constructor.</p>
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public DynamoDBLeaseCoordinator initialLeaseTableReadCapacity(long readCapacity) {
|
public DynamoDBLeaseCoordinator initialLeaseTableReadCapacity(long readCapacity) {
|
||||||
throw new UnsupportedOperationException("Please set read capacity using the constructor");
|
if (readCapacity <= 0) {
|
||||||
|
throw new IllegalArgumentException("readCapacity should be >= 1");
|
||||||
|
}
|
||||||
|
initialLeaseTableReadCapacity = readCapacity;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>NOTE: This method is deprecated. Please set the initial capacity through the constructor.</p>
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public DynamoDBLeaseCoordinator initialLeaseTableWriteCapacity(long writeCapacity) {
|
public DynamoDBLeaseCoordinator initialLeaseTableWriteCapacity(long writeCapacity) {
|
||||||
throw new UnsupportedOperationException("Please set write capacity using the constructor");
|
if (writeCapacity <= 0) {
|
||||||
|
throw new IllegalArgumentException("writeCapacity should be >= 1");
|
||||||
|
}
|
||||||
|
initialLeaseTableWriteCapacity = writeCapacity;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue