Merge pull request #694 from ychunxue/v1.x
Stop passing latest shards to the next ShardSyncTask in ShardSyncTask…
This commit is contained in:
commit
e9e64f8511
3 changed files with 16 additions and 10 deletions
4
pom.xml
4
pom.xml
|
|
@ -6,7 +6,7 @@
|
|||
<artifactId>amazon-kinesis-client</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Amazon Kinesis Client Library for Java</name>
|
||||
<version>1.13.2</version>
|
||||
<version>1.13.3-SNAPSHOT</version>
|
||||
<description>The Amazon Kinesis Client Library for Java enables Java developers to easily consume and process data
|
||||
from Amazon Kinesis.
|
||||
</description>
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
</licenses>
|
||||
|
||||
<properties>
|
||||
<aws-java-sdk.version>1.11.655</aws-java-sdk.version>
|
||||
<aws-java-sdk.version>1.11.728</aws-java-sdk.version>
|
||||
<sqlite4java.version>1.0.392</sqlite4java.version>
|
||||
<sqlite4java.native>libsqlite4java</sqlite4java.native>
|
||||
<sqlite4java.libpath>${project.build.directory}/test-lib</sqlite4java.libpath>
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ import com.amazonaws.services.kinesis.metrics.interfaces.IMetricsFactory;
|
|||
cleanupLeasesUponShardCompletion, ignoreUnexpectedChildShards, shardSyncIdleTimeMillis,
|
||||
shardSyncer, latestShards), metricsFactory);
|
||||
future = CompletableFuture.supplyAsync(() -> currentTask.call(), executorService)
|
||||
.whenComplete((taskResult, exception) -> handlePendingShardSyncs(latestShards, exception));
|
||||
.whenComplete((taskResult, exception) -> handlePendingShardSyncs(exception, taskResult));
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Submitted new " + currentTask.getTaskType() + " task.");
|
||||
}
|
||||
|
|
@ -132,9 +132,9 @@ import com.amazonaws.services.kinesis.metrics.interfaces.IMetricsFactory;
|
|||
return submittedTaskFuture;
|
||||
}
|
||||
|
||||
private void handlePendingShardSyncs(List<Shard> latestShards, Throwable exception) {
|
||||
if (exception != null) {
|
||||
LOG.error("Caught exception running " + currentTask.getTaskType() + " task: ", exception);
|
||||
private void handlePendingShardSyncs(Throwable exception, TaskResult taskResult) {
|
||||
if (exception != null || taskResult.getException() != null) {
|
||||
LOG.error("Caught exception running " + currentTask.getTaskType() + " task: ", exception != null ? exception : taskResult.getException());
|
||||
}
|
||||
// Acquire lock here. If shardSyncRequestPending is false in this completionStage and
|
||||
// syncShardAndLeaseInfo is invoked, before completion stage exits (future completes)
|
||||
|
|
@ -150,7 +150,7 @@ import com.amazonaws.services.kinesis.metrics.interfaces.IMetricsFactory;
|
|||
// reset future to null, so next call creates a new one
|
||||
// without trying to get results from the old future.
|
||||
future = null;
|
||||
checkAndSubmitNextTask(latestShards);
|
||||
checkAndSubmitNextTask(null);
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ import java.util.concurrent.Executors;
|
|||
|
||||
import static org.mockito.AdditionalAnswers.delegatesTo;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.matches;
|
||||
import static org.mockito.Matchers.notNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
|
@ -91,10 +93,14 @@ public class ShardSyncTaskManagerTest {
|
|||
pausableNoOpShardSyncer.blockShardSyncLatch.countDown();
|
||||
// Wait for ShardSyncer to be initialized.
|
||||
pausableNoOpShardSyncer.waitForShardSyncerInitializationLatch.await();
|
||||
// There should be 1 more shardSyncer invocation after the previous shardSync completes.
|
||||
verify(mockShardSyncer, times(2))
|
||||
// There should be totally 2 invocation of shardSyncer. The first one should be triggered with an empty list the latestShards.
|
||||
// The second invocation should be the pending shard sync task, which should have null as the latestShards.
|
||||
verify(mockShardSyncer, times(1))
|
||||
.checkAndCreateLeasesForNewShards(Matchers.any(), Matchers.any(), Matchers.any(), anyBoolean(),
|
||||
anyBoolean(), Matchers.any());
|
||||
anyBoolean(), Matchers.eq(new ArrayList<>()));
|
||||
verify(mockShardSyncer, times(1))
|
||||
.checkAndCreateLeasesForNewShards(Matchers.any(), Matchers.any(), Matchers.any(), anyBoolean(),
|
||||
anyBoolean(), Matchers.eq(null));
|
||||
}
|
||||
|
||||
private static class PausableNoOpShardSyncer implements ShardSyncer {
|
||||
|
|
|
|||
Loading…
Reference in a new issue