Adding bootstrap sync strategy with list shards with filter.
This commit is contained in:
parent
b3bcc59697
commit
06c716ccea
20 changed files with 141 additions and 61 deletions
|
|
@ -36,6 +36,7 @@ import lombok.NoArgsConstructor;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
import software.amazon.kinesis.checkpoint.CheckpointConfig;
|
import software.amazon.kinesis.checkpoint.CheckpointConfig;
|
||||||
import software.amazon.kinesis.checkpoint.ShardRecordProcessorCheckpointer;
|
import software.amazon.kinesis.checkpoint.ShardRecordProcessorCheckpointer;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
||||||
|
|
@ -120,6 +121,8 @@ public class Scheduler implements Runnable {
|
||||||
private final HierarchicalShardSyncer hierarchicalShardSyncer;
|
private final HierarchicalShardSyncer hierarchicalShardSyncer;
|
||||||
private final long schedulerInitializationBackoffTimeMillis;
|
private final long schedulerInitializationBackoffTimeMillis;
|
||||||
|
|
||||||
|
private final ShardFilter bootstrapShardFilter;
|
||||||
|
|
||||||
// Holds consumers for shards the worker is currently tracking. Key is shard
|
// Holds consumers for shards the worker is currently tracking. Key is shard
|
||||||
// info, value is ShardConsumer.
|
// info, value is ShardConsumer.
|
||||||
private ConcurrentMap<ShardInfo, ShardConsumer> shardInfoShardConsumerMap = new ConcurrentHashMap<>();
|
private ConcurrentMap<ShardInfo, ShardConsumer> shardInfoShardConsumerMap = new ConcurrentHashMap<>();
|
||||||
|
|
@ -222,6 +225,7 @@ public class Scheduler implements Runnable {
|
||||||
this.aggregatorUtil = this.lifecycleConfig.aggregatorUtil();
|
this.aggregatorUtil = this.lifecycleConfig.aggregatorUtil();
|
||||||
this.hierarchicalShardSyncer = leaseManagementConfig.hierarchicalShardSyncer();
|
this.hierarchicalShardSyncer = leaseManagementConfig.hierarchicalShardSyncer();
|
||||||
this.schedulerInitializationBackoffTimeMillis = this.coordinatorConfig.schedulerInitializationBackoffTimeMillis();
|
this.schedulerInitializationBackoffTimeMillis = this.coordinatorConfig.schedulerInitializationBackoffTimeMillis();
|
||||||
|
this.bootstrapShardFilter = leaseManagementConfig.bootstrapShardFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -267,9 +271,10 @@ public class Scheduler implements Runnable {
|
||||||
TaskResult result = null;
|
TaskResult result = null;
|
||||||
if (!skipShardSyncAtWorkerInitializationIfLeasesExist || leaseRefresher.isLeaseTableEmpty()) {
|
if (!skipShardSyncAtWorkerInitializationIfLeasesExist || leaseRefresher.isLeaseTableEmpty()) {
|
||||||
log.info("Syncing Kinesis shard info");
|
log.info("Syncing Kinesis shard info");
|
||||||
|
|
||||||
ShardSyncTask shardSyncTask = new ShardSyncTask(shardDetector, leaseRefresher, initialPosition,
|
ShardSyncTask shardSyncTask = new ShardSyncTask(shardDetector, leaseRefresher, initialPosition,
|
||||||
cleanupLeasesUponShardCompletion, ignoreUnexpetedChildShards, 0L, hierarchicalShardSyncer,
|
cleanupLeasesUponShardCompletion, ignoreUnexpetedChildShards, 0L, hierarchicalShardSyncer,
|
||||||
metricsFactory);
|
metricsFactory, bootstrapShardFilter);
|
||||||
result = new MetricsCollectingTaskDecorator(shardSyncTask, metricsFactory).call();
|
result = new MetricsCollectingTaskDecorator(shardSyncTask, metricsFactory).call();
|
||||||
} else {
|
} else {
|
||||||
log.info("Skipping shard sync per configuration setting (and lease table is not empty)");
|
log.info("Skipping shard sync per configuration setting (and lease table is not empty)");
|
||||||
|
|
@ -611,7 +616,8 @@ public class Scheduler implements Runnable {
|
||||||
shardDetector,
|
shardDetector,
|
||||||
aggregatorUtil,
|
aggregatorUtil,
|
||||||
hierarchicalShardSyncer,
|
hierarchicalShardSyncer,
|
||||||
metricsFactory);
|
metricsFactory,
|
||||||
|
bootstrapShardFilter);
|
||||||
return new ShardConsumer(cache, executorService, shardInfo, lifecycleConfig.logWarningForTaskAfterMillis(),
|
return new ShardConsumer(cache, executorService, shardInfo, lifecycleConfig.logWarningForTaskAfterMillis(),
|
||||||
argument, lifecycleConfig.taskExecutionListener(),lifecycleConfig.readTimeoutsToIgnoreBeforeWarning());
|
argument, lifecycleConfig.taskExecutionListener(),lifecycleConfig.readTimeoutsToIgnoreBeforeWarning());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
@ -34,6 +35,7 @@ import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import software.amazon.awssdk.services.kinesis.model.Shard;
|
import software.amazon.awssdk.services.kinesis.model.Shard;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
import software.amazon.awssdk.utils.CollectionUtils;
|
import software.amazon.awssdk.utils.CollectionUtils;
|
||||||
import software.amazon.kinesis.annotations.KinesisClientInternalApi;
|
import software.amazon.kinesis.annotations.KinesisClientInternalApi;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStream;
|
import software.amazon.kinesis.common.InitialPositionInStream;
|
||||||
|
|
@ -76,9 +78,9 @@ public class HierarchicalShardSyncer {
|
||||||
public synchronized void checkAndCreateLeaseForNewShards(@NonNull final ShardDetector shardDetector,
|
public synchronized void checkAndCreateLeaseForNewShards(@NonNull final ShardDetector shardDetector,
|
||||||
final LeaseRefresher leaseRefresher, final InitialPositionInStreamExtended initialPosition,
|
final LeaseRefresher leaseRefresher, final InitialPositionInStreamExtended initialPosition,
|
||||||
final boolean cleanupLeasesOfCompletedShards, final boolean ignoreUnexpectedChildShards,
|
final boolean cleanupLeasesOfCompletedShards, final boolean ignoreUnexpectedChildShards,
|
||||||
final MetricsScope scope) throws DependencyException, InvalidStateException,
|
final MetricsScope scope, final ShardFilter shardFilter) throws DependencyException, InvalidStateException,
|
||||||
ProvisionedThroughputException, KinesisClientLibIOException {
|
ProvisionedThroughputException, KinesisClientLibIOException {
|
||||||
final List<Shard> latestShards = getShardList(shardDetector);
|
final List<Shard> latestShards = getShardList(shardDetector, shardFilter);
|
||||||
checkAndCreateLeaseForNewShards(shardDetector, leaseRefresher, initialPosition, cleanupLeasesOfCompletedShards,
|
checkAndCreateLeaseForNewShards(shardDetector, leaseRefresher, initialPosition, cleanupLeasesOfCompletedShards,
|
||||||
ignoreUnexpectedChildShards, scope, latestShards);
|
ignoreUnexpectedChildShards, scope, latestShards);
|
||||||
}
|
}
|
||||||
|
|
@ -253,7 +255,8 @@ public class HierarchicalShardSyncer {
|
||||||
return shardIdToChildShardIdsMap;
|
return shardIdToChildShardIdsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Shard> getShardList(@NonNull final ShardDetector shardDetector) throws KinesisClientLibIOException {
|
private static List<Shard> getShardList(@NonNull final ShardDetector shardDetector, @NonNull final ShardFilter shardFilter)
|
||||||
|
throws KinesisClientLibIOException {
|
||||||
final List<Shard> shards = shardDetector.listShards();
|
final List<Shard> shards = shardDetector.listShards();
|
||||||
if (shards == null) {
|
if (shards == null) {
|
||||||
throw new KinesisClientLibIOException(
|
throw new KinesisClientLibIOException(
|
||||||
|
|
@ -530,7 +533,10 @@ public class HierarchicalShardSyncer {
|
||||||
if (!CollectionUtils.isNullOrEmpty(garbageLeases)) {
|
if (!CollectionUtils.isNullOrEmpty(garbageLeases)) {
|
||||||
log.info("Found {} candidate leases for cleanup. Refreshing list of"
|
log.info("Found {} candidate leases for cleanup. Refreshing list of"
|
||||||
+ " Kinesis shards to pick up recent/latest shards", garbageLeases.size());
|
+ " Kinesis shards to pick up recent/latest shards", garbageLeases.size());
|
||||||
final Set<String> currentKinesisShardIds = getShardList(shardDetector).stream().map(Shard::shardId)
|
|
||||||
|
final ShardFilter allShardsFilter = ShardFilter.builder().build();
|
||||||
|
|
||||||
|
final Set<String> currentKinesisShardIds = getShardList(shardDetector, allShardsFilter).stream().map(Shard::shardId)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
for (Lease lease : garbageLeases) {
|
for (Lease lease : garbageLeases) {
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ import software.amazon.awssdk.services.kinesis.model.ListShardsRequest;
|
||||||
import software.amazon.awssdk.services.kinesis.model.ListShardsResponse;
|
import software.amazon.awssdk.services.kinesis.model.ListShardsResponse;
|
||||||
import software.amazon.awssdk.services.kinesis.model.ResourceInUseException;
|
import software.amazon.awssdk.services.kinesis.model.ResourceInUseException;
|
||||||
import software.amazon.awssdk.services.kinesis.model.Shard;
|
import software.amazon.awssdk.services.kinesis.model.Shard;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
import software.amazon.awssdk.utils.CollectionUtils;
|
import software.amazon.awssdk.utils.CollectionUtils;
|
||||||
import software.amazon.kinesis.annotations.KinesisClientInternalApi;
|
import software.amazon.kinesis.annotations.KinesisClientInternalApi;
|
||||||
import software.amazon.kinesis.common.FutureUtils;
|
import software.amazon.kinesis.common.FutureUtils;
|
||||||
|
|
@ -72,19 +73,21 @@ public class KinesisShardDetector implements ShardDetector {
|
||||||
private volatile Instant lastCacheUpdateTime;
|
private volatile Instant lastCacheUpdateTime;
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private AtomicInteger cacheMisses = new AtomicInteger(0);
|
private AtomicInteger cacheMisses = new AtomicInteger(0);
|
||||||
|
@NonNull
|
||||||
|
private final ShardFilter shardFilter;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public KinesisShardDetector(KinesisAsyncClient kinesisClient, String streamName, long listShardsBackoffTimeInMillis,
|
public KinesisShardDetector(KinesisAsyncClient kinesisClient, String streamName, long listShardsBackoffTimeInMillis,
|
||||||
int maxListShardsRetryAttempts, long listShardsCacheAllowedAgeInSeconds, int maxCacheMissesBeforeReload,
|
int maxListShardsRetryAttempts, long listShardsCacheAllowedAgeInSeconds, int maxCacheMissesBeforeReload,
|
||||||
int cacheMissWarningModulus) {
|
int cacheMissWarningModulus, ShardFilter shardFilter) {
|
||||||
this(kinesisClient, streamName, listShardsBackoffTimeInMillis, maxListShardsRetryAttempts,
|
this(kinesisClient, streamName, listShardsBackoffTimeInMillis, maxListShardsRetryAttempts,
|
||||||
listShardsCacheAllowedAgeInSeconds, maxCacheMissesBeforeReload, cacheMissWarningModulus,
|
listShardsCacheAllowedAgeInSeconds, maxCacheMissesBeforeReload, cacheMissWarningModulus,
|
||||||
LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT);
|
LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT, shardFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KinesisShardDetector(KinesisAsyncClient kinesisClient, String streamName, long listShardsBackoffTimeInMillis,
|
public KinesisShardDetector(KinesisAsyncClient kinesisClient, String streamName, long listShardsBackoffTimeInMillis,
|
||||||
int maxListShardsRetryAttempts, long listShardsCacheAllowedAgeInSeconds, int maxCacheMissesBeforeReload,
|
int maxListShardsRetryAttempts, long listShardsCacheAllowedAgeInSeconds, int maxCacheMissesBeforeReload,
|
||||||
int cacheMissWarningModulus, Duration kinesisRequestTimeout) {
|
int cacheMissWarningModulus, Duration kinesisRequestTimeout, ShardFilter shardFilter) {
|
||||||
this.kinesisClient = kinesisClient;
|
this.kinesisClient = kinesisClient;
|
||||||
this.streamName = streamName;
|
this.streamName = streamName;
|
||||||
this.listShardsBackoffTimeInMillis = listShardsBackoffTimeInMillis;
|
this.listShardsBackoffTimeInMillis = listShardsBackoffTimeInMillis;
|
||||||
|
|
@ -93,6 +96,7 @@ public class KinesisShardDetector implements ShardDetector {
|
||||||
this.maxCacheMissesBeforeReload = maxCacheMissesBeforeReload;
|
this.maxCacheMissesBeforeReload = maxCacheMissesBeforeReload;
|
||||||
this.cacheMissWarningModulus = cacheMissWarningModulus;
|
this.cacheMissWarningModulus = cacheMissWarningModulus;
|
||||||
this.kinesisRequestTimeout = kinesisRequestTimeout;
|
this.kinesisRequestTimeout = kinesisRequestTimeout;
|
||||||
|
this.shardFilter = shardFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -154,7 +158,7 @@ public class KinesisShardDetector implements ShardDetector {
|
||||||
String nextToken = null;
|
String nextToken = null;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
result = listShards(nextToken);
|
result = listShards(nextToken, shardFilter);
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
/*
|
/*
|
||||||
|
|
@ -172,7 +176,7 @@ public class KinesisShardDetector implements ShardDetector {
|
||||||
return shards;
|
return shards;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ListShardsResponse listShards(final String nextToken) {
|
private ListShardsResponse listShards(final String nextToken, final ShardFilter shardFilter) {
|
||||||
final AWSExceptionManager exceptionManager = new AWSExceptionManager();
|
final AWSExceptionManager exceptionManager = new AWSExceptionManager();
|
||||||
exceptionManager.add(LimitExceededException.class, t -> t);
|
exceptionManager.add(LimitExceededException.class, t -> t);
|
||||||
exceptionManager.add(ResourceInUseException.class, t -> t);
|
exceptionManager.add(ResourceInUseException.class, t -> t);
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ import lombok.experimental.Accessors;
|
||||||
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient;
|
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient;
|
||||||
import software.amazon.awssdk.services.dynamodb.model.BillingMode;
|
import software.amazon.awssdk.services.dynamodb.model.BillingMode;
|
||||||
import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
|
import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilterType;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStream;
|
import software.amazon.kinesis.common.InitialPositionInStream;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
||||||
import software.amazon.kinesis.leases.dynamodb.DynamoDBLeaseManagementFactory;
|
import software.amazon.kinesis.leases.dynamodb.DynamoDBLeaseManagementFactory;
|
||||||
|
|
@ -176,6 +178,17 @@ public class LeaseManagementConfig {
|
||||||
private InitialPositionInStreamExtended initialPositionInStream =
|
private InitialPositionInStreamExtended initialPositionInStream =
|
||||||
InitialPositionInStreamExtended.newInitialPosition(InitialPositionInStream.TRIM_HORIZON);
|
InitialPositionInStreamExtended.newInitialPosition(InitialPositionInStream.TRIM_HORIZON);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shard filter ot use for bootstrap. This needs to align with initialPositionInStreamExtended. i.e
|
||||||
|
*
|
||||||
|
* InitialPositionInStream.LATEST => ShardFilterType.AT_LATEST
|
||||||
|
* InitialPositionInStream.TRIM_HORIZON => ShardFilterType.FROM_TRIM_HORIZON
|
||||||
|
* InitialPositionInStream.AT_TIMESTAMP => ShardFilterType.FROM_TIMESTAMP
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
private ShardFilter bootstrapShardFilter = ShardFilter.builder().type(ShardFilterType.FROM_TRIM_HORIZON).build();
|
||||||
|
|
||||||
private int maxCacheMissesBeforeReload = 1000;
|
private int maxCacheMissesBeforeReload = 1000;
|
||||||
private long listShardsCacheAllowedAgeInSeconds = 30;
|
private long listShardsCacheAllowedAgeInSeconds = 30;
|
||||||
private int cacheMissWarningModulus = 250;
|
private int cacheMissWarningModulus = 250;
|
||||||
|
|
@ -270,7 +283,8 @@ public class LeaseManagementConfig {
|
||||||
initialLeaseTableReadCapacity(),
|
initialLeaseTableReadCapacity(),
|
||||||
initialLeaseTableWriteCapacity(),
|
initialLeaseTableWriteCapacity(),
|
||||||
hierarchicalShardSyncer(),
|
hierarchicalShardSyncer(),
|
||||||
tableCreatorCallback(), dynamoDbRequestTimeout(), billingMode());
|
tableCreatorCallback(), dynamoDbRequestTimeout(), billingMode(),
|
||||||
|
bootstrapShardFilter);
|
||||||
}
|
}
|
||||||
return leaseManagementFactory;
|
return leaseManagementFactory;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,10 @@
|
||||||
package software.amazon.kinesis.leases;
|
package software.amazon.kinesis.leases;
|
||||||
|
|
||||||
import software.amazon.awssdk.services.kinesis.model.Shard;
|
import software.amazon.awssdk.services.kinesis.model.Shard;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -26,5 +28,4 @@ public interface ShardDetector {
|
||||||
Shard shard(String shardId);
|
Shard shard(String shardId);
|
||||||
|
|
||||||
List<Shard> listShards();
|
List<Shard> listShards();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ package software.amazon.kinesis.leases;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilterType;
|
||||||
import software.amazon.kinesis.annotations.KinesisClientInternalApi;
|
import software.amazon.kinesis.annotations.KinesisClientInternalApi;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
||||||
import software.amazon.kinesis.lifecycle.ConsumerTask;
|
import software.amazon.kinesis.lifecycle.ConsumerTask;
|
||||||
|
|
@ -48,11 +50,13 @@ public class ShardSyncTask implements ConsumerTask {
|
||||||
private final boolean ignoreUnexpectedChildShards;
|
private final boolean ignoreUnexpectedChildShards;
|
||||||
private final long shardSyncTaskIdleTimeMillis;
|
private final long shardSyncTaskIdleTimeMillis;
|
||||||
@NonNull
|
@NonNull
|
||||||
private final HierarchicalShardSyncer hierarchicalShardSyncer;
|
private final HierarchicalShardSyncer hierarchicalShardSyncerShardSyncTask;
|
||||||
@NonNull
|
@NonNull
|
||||||
private final MetricsFactory metricsFactory;
|
private final MetricsFactory metricsFactory;
|
||||||
|
|
||||||
private final TaskType taskType = TaskType.SHARDSYNC;
|
private final TaskType taskType = TaskType.SHARDSYNC;
|
||||||
|
@NonNull
|
||||||
|
private final ShardFilter shardFilter;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
|
@ -64,8 +68,8 @@ public class ShardSyncTask implements ConsumerTask {
|
||||||
final MetricsScope scope = MetricsUtil.createMetricsWithOperation(metricsFactory, SHARD_SYNC_TASK_OPERATION);
|
final MetricsScope scope = MetricsUtil.createMetricsWithOperation(metricsFactory, SHARD_SYNC_TASK_OPERATION);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
hierarchicalShardSyncer.checkAndCreateLeaseForNewShards(shardDetector, leaseRefresher, initialPosition,
|
hierarchicalShardSyncerShardSyncTask.checkAndCreateLeaseForNewShards(shardDetector, leaseRefresher, initialPosition,
|
||||||
cleanupLeasesUponShardCompletion, ignoreUnexpectedChildShards, scope);
|
cleanupLeasesUponShardCompletion, ignoreUnexpectedChildShards, scope, shardFilter);
|
||||||
if (shardSyncTaskIdleTimeMillis > 0) {
|
if (shardSyncTaskIdleTimeMillis > 0) {
|
||||||
Thread.sleep(shardSyncTaskIdleTimeMillis);
|
Thread.sleep(shardSyncTaskIdleTimeMillis);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -53,6 +54,8 @@ public class ShardSyncTaskManager {
|
||||||
private final HierarchicalShardSyncer hierarchicalShardSyncer;
|
private final HierarchicalShardSyncer hierarchicalShardSyncer;
|
||||||
@NonNull
|
@NonNull
|
||||||
private final MetricsFactory metricsFactory;
|
private final MetricsFactory metricsFactory;
|
||||||
|
@NonNull
|
||||||
|
private final ShardFilter shardFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
|
@ -72,7 +75,7 @@ public class ShardSyncTaskManager {
|
||||||
public ShardSyncTaskManager(ShardDetector shardDetector, LeaseRefresher leaseRefresher,
|
public ShardSyncTaskManager(ShardDetector shardDetector, LeaseRefresher leaseRefresher,
|
||||||
InitialPositionInStreamExtended initialPositionInStream, boolean cleanupLeasesUponShardCompletion,
|
InitialPositionInStreamExtended initialPositionInStream, boolean cleanupLeasesUponShardCompletion,
|
||||||
boolean ignoreUnexpectedChildShards, long shardSyncIdleTimeMillis, ExecutorService executorService,
|
boolean ignoreUnexpectedChildShards, long shardSyncIdleTimeMillis, ExecutorService executorService,
|
||||||
MetricsFactory metricsFactory) {
|
MetricsFactory metricsFactory, ShardFilter shardFilter) {
|
||||||
this.shardDetector = shardDetector;
|
this.shardDetector = shardDetector;
|
||||||
this.leaseRefresher = leaseRefresher;
|
this.leaseRefresher = leaseRefresher;
|
||||||
this.initialPositionInStream = initialPositionInStream;
|
this.initialPositionInStream = initialPositionInStream;
|
||||||
|
|
@ -82,6 +85,7 @@ public class ShardSyncTaskManager {
|
||||||
this.executorService = executorService;
|
this.executorService = executorService;
|
||||||
this.hierarchicalShardSyncer = new HierarchicalShardSyncer();
|
this.hierarchicalShardSyncer = new HierarchicalShardSyncer();
|
||||||
this.metricsFactory = metricsFactory;
|
this.metricsFactory = metricsFactory;
|
||||||
|
this.shardFilter = shardFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -100,7 +104,7 @@ public class ShardSyncTaskManager {
|
||||||
public ShardSyncTaskManager(ShardDetector shardDetector, LeaseRefresher leaseRefresher,
|
public ShardSyncTaskManager(ShardDetector shardDetector, LeaseRefresher leaseRefresher,
|
||||||
InitialPositionInStreamExtended initialPositionInStream, boolean cleanupLeasesUponShardCompletion,
|
InitialPositionInStreamExtended initialPositionInStream, boolean cleanupLeasesUponShardCompletion,
|
||||||
boolean ignoreUnexpectedChildShards, long shardSyncIdleTimeMillis, ExecutorService executorService,
|
boolean ignoreUnexpectedChildShards, long shardSyncIdleTimeMillis, ExecutorService executorService,
|
||||||
HierarchicalShardSyncer hierarchicalShardSyncer, MetricsFactory metricsFactory) {
|
HierarchicalShardSyncer hierarchicalShardSyncer, MetricsFactory metricsFactory, ShardFilter shardFilter) {
|
||||||
this.shardDetector = shardDetector;
|
this.shardDetector = shardDetector;
|
||||||
this.leaseRefresher = leaseRefresher;
|
this.leaseRefresher = leaseRefresher;
|
||||||
this.initialPositionInStream = initialPositionInStream;
|
this.initialPositionInStream = initialPositionInStream;
|
||||||
|
|
@ -110,6 +114,7 @@ public class ShardSyncTaskManager {
|
||||||
this.executorService = executorService;
|
this.executorService = executorService;
|
||||||
this.hierarchicalShardSyncer = hierarchicalShardSyncer;
|
this.hierarchicalShardSyncer = hierarchicalShardSyncer;
|
||||||
this.metricsFactory = metricsFactory;
|
this.metricsFactory = metricsFactory;
|
||||||
|
this.shardFilter = shardFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConsumerTask currentTask;
|
private ConsumerTask currentTask;
|
||||||
|
|
@ -143,7 +148,8 @@ public class ShardSyncTaskManager {
|
||||||
ignoreUnexpectedChildShards,
|
ignoreUnexpectedChildShards,
|
||||||
shardSyncIdleTimeMillis,
|
shardSyncIdleTimeMillis,
|
||||||
hierarchicalShardSyncer,
|
hierarchicalShardSyncer,
|
||||||
metricsFactory),
|
metricsFactory,
|
||||||
|
shardFilter),
|
||||||
metricsFactory);
|
metricsFactory);
|
||||||
future = executorService.submit(currentTask);
|
future = executorService.submit(currentTask);
|
||||||
submittedNewTask = true;
|
submittedNewTask = true;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import lombok.NonNull;
|
||||||
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient;
|
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient;
|
||||||
import software.amazon.awssdk.services.dynamodb.model.BillingMode;
|
import software.amazon.awssdk.services.dynamodb.model.BillingMode;
|
||||||
import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
|
import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
import software.amazon.kinesis.annotations.KinesisClientInternalApi;
|
import software.amazon.kinesis.annotations.KinesisClientInternalApi;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
||||||
import software.amazon.kinesis.leases.HierarchicalShardSyncer;
|
import software.amazon.kinesis.leases.HierarchicalShardSyncer;
|
||||||
|
|
@ -57,6 +58,8 @@ public class DynamoDBLeaseManagementFactory implements LeaseManagementFactory {
|
||||||
private final InitialPositionInStreamExtended initialPositionInStream;
|
private final InitialPositionInStreamExtended initialPositionInStream;
|
||||||
@NonNull
|
@NonNull
|
||||||
private final HierarchicalShardSyncer hierarchicalShardSyncer;
|
private final HierarchicalShardSyncer hierarchicalShardSyncer;
|
||||||
|
@NonNull
|
||||||
|
private final ShardFilter shardFilter;
|
||||||
|
|
||||||
private final long failoverTimeMillis;
|
private final long failoverTimeMillis;
|
||||||
private final long epsilonMillis;
|
private final long epsilonMillis;
|
||||||
|
|
@ -114,14 +117,14 @@ public class DynamoDBLeaseManagementFactory implements LeaseManagementFactory {
|
||||||
final boolean cleanupLeasesUponShardCompletion, final boolean ignoreUnexpectedChildShards,
|
final boolean cleanupLeasesUponShardCompletion, final boolean ignoreUnexpectedChildShards,
|
||||||
final long shardSyncIntervalMillis, final boolean consistentReads, final long listShardsBackoffTimeMillis,
|
final long shardSyncIntervalMillis, final boolean consistentReads, final long listShardsBackoffTimeMillis,
|
||||||
final int maxListShardsRetryAttempts, final int maxCacheMissesBeforeReload,
|
final int maxListShardsRetryAttempts, final int maxCacheMissesBeforeReload,
|
||||||
final long listShardsCacheAllowedAgeInSeconds, final int cacheMissWarningModulus) {
|
final long listShardsCacheAllowedAgeInSeconds, final int cacheMissWarningModulus, final ShardFilter shardFilter) {
|
||||||
this(kinesisClient, streamName, dynamoDBClient, tableName, workerIdentifier, executorService,
|
this(kinesisClient, streamName, dynamoDBClient, tableName, workerIdentifier, executorService,
|
||||||
initialPositionInStream, failoverTimeMillis, epsilonMillis, maxLeasesForWorker,
|
initialPositionInStream, failoverTimeMillis, epsilonMillis, maxLeasesForWorker,
|
||||||
maxLeasesToStealAtOneTime, maxLeaseRenewalThreads, cleanupLeasesUponShardCompletion,
|
maxLeasesToStealAtOneTime, maxLeaseRenewalThreads, cleanupLeasesUponShardCompletion,
|
||||||
ignoreUnexpectedChildShards, shardSyncIntervalMillis, consistentReads, listShardsBackoffTimeMillis,
|
ignoreUnexpectedChildShards, shardSyncIntervalMillis, consistentReads, listShardsBackoffTimeMillis,
|
||||||
maxListShardsRetryAttempts, maxCacheMissesBeforeReload, listShardsCacheAllowedAgeInSeconds,
|
maxListShardsRetryAttempts, maxCacheMissesBeforeReload, listShardsCacheAllowedAgeInSeconds,
|
||||||
cacheMissWarningModulus, TableConstants.DEFAULT_INITIAL_LEASE_TABLE_READ_CAPACITY,
|
cacheMissWarningModulus, TableConstants.DEFAULT_INITIAL_LEASE_TABLE_READ_CAPACITY,
|
||||||
TableConstants.DEFAULT_INITIAL_LEASE_TABLE_WRITE_CAPACITY);
|
TableConstants.DEFAULT_INITIAL_LEASE_TABLE_WRITE_CAPACITY, shardFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -165,7 +168,7 @@ public class DynamoDBLeaseManagementFactory implements LeaseManagementFactory {
|
||||||
final long shardSyncIntervalMillis, final boolean consistentReads, final long listShardsBackoffTimeMillis,
|
final long shardSyncIntervalMillis, final boolean consistentReads, final long listShardsBackoffTimeMillis,
|
||||||
final int maxListShardsRetryAttempts, final int maxCacheMissesBeforeReload,
|
final int maxListShardsRetryAttempts, final int maxCacheMissesBeforeReload,
|
||||||
final long listShardsCacheAllowedAgeInSeconds, final int cacheMissWarningModulus,
|
final long listShardsCacheAllowedAgeInSeconds, final int cacheMissWarningModulus,
|
||||||
final long initialLeaseTableReadCapacity, final long initialLeaseTableWriteCapacity) {
|
final long initialLeaseTableReadCapacity, final long initialLeaseTableWriteCapacity, final ShardFilter shardFilter) {
|
||||||
this(kinesisClient, streamName, dynamoDBClient, tableName, workerIdentifier, executorService,
|
this(kinesisClient, streamName, dynamoDBClient, tableName, workerIdentifier, executorService,
|
||||||
initialPositionInStream, failoverTimeMillis, epsilonMillis, maxLeasesForWorker,
|
initialPositionInStream, failoverTimeMillis, epsilonMillis, maxLeasesForWorker,
|
||||||
maxLeasesToStealAtOneTime, maxLeaseRenewalThreads, cleanupLeasesUponShardCompletion,
|
maxLeasesToStealAtOneTime, maxLeaseRenewalThreads, cleanupLeasesUponShardCompletion,
|
||||||
|
|
@ -173,7 +176,7 @@ public class DynamoDBLeaseManagementFactory implements LeaseManagementFactory {
|
||||||
maxListShardsRetryAttempts, maxCacheMissesBeforeReload, listShardsCacheAllowedAgeInSeconds,
|
maxListShardsRetryAttempts, maxCacheMissesBeforeReload, listShardsCacheAllowedAgeInSeconds,
|
||||||
cacheMissWarningModulus, initialLeaseTableReadCapacity, initialLeaseTableWriteCapacity,
|
cacheMissWarningModulus, initialLeaseTableReadCapacity, initialLeaseTableWriteCapacity,
|
||||||
new HierarchicalShardSyncer(), TableCreatorCallback.NOOP_TABLE_CREATOR_CALLBACK,
|
new HierarchicalShardSyncer(), TableCreatorCallback.NOOP_TABLE_CREATOR_CALLBACK,
|
||||||
LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT);
|
LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT, shardFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -216,19 +219,20 @@ public class DynamoDBLeaseManagementFactory implements LeaseManagementFactory {
|
||||||
final int maxListShardsRetryAttempts, final int maxCacheMissesBeforeReload,
|
final int maxListShardsRetryAttempts, final int maxCacheMissesBeforeReload,
|
||||||
final long listShardsCacheAllowedAgeInSeconds, final int cacheMissWarningModulus,
|
final long listShardsCacheAllowedAgeInSeconds, final int cacheMissWarningModulus,
|
||||||
final long initialLeaseTableReadCapacity, final long initialLeaseTableWriteCapacity,
|
final long initialLeaseTableReadCapacity, final long initialLeaseTableWriteCapacity,
|
||||||
final HierarchicalShardSyncer hierarchicalShardSyncer, final TableCreatorCallback tableCreatorCallback) {
|
final HierarchicalShardSyncer hierarchicalShardSyncer, final TableCreatorCallback tableCreatorCallback,
|
||||||
|
ShardFilter shardFilter) {
|
||||||
this(kinesisClient, streamName, dynamoDBClient, tableName, workerIdentifier, executorService,
|
this(kinesisClient, streamName, dynamoDBClient, tableName, workerIdentifier, executorService,
|
||||||
initialPositionInStream, failoverTimeMillis, epsilonMillis, maxLeasesForWorker,
|
initialPositionInStream, failoverTimeMillis, epsilonMillis, maxLeasesForWorker,
|
||||||
maxLeasesToStealAtOneTime, maxLeaseRenewalThreads, cleanupLeasesUponShardCompletion,
|
maxLeasesToStealAtOneTime, maxLeaseRenewalThreads, cleanupLeasesUponShardCompletion,
|
||||||
ignoreUnexpectedChildShards, shardSyncIntervalMillis, consistentReads, listShardsBackoffTimeMillis,
|
ignoreUnexpectedChildShards, shardSyncIntervalMillis, consistentReads, listShardsBackoffTimeMillis,
|
||||||
maxListShardsRetryAttempts, maxCacheMissesBeforeReload, listShardsCacheAllowedAgeInSeconds,
|
maxListShardsRetryAttempts, maxCacheMissesBeforeReload, listShardsCacheAllowedAgeInSeconds,
|
||||||
cacheMissWarningModulus, initialLeaseTableReadCapacity, initialLeaseTableWriteCapacity,
|
cacheMissWarningModulus, initialLeaseTableReadCapacity, initialLeaseTableWriteCapacity,
|
||||||
hierarchicalShardSyncer, tableCreatorCallback, LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT);
|
hierarchicalShardSyncer, tableCreatorCallback, LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT, shardFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param kinesisClient
|
* @param kinesisClient
|
||||||
* @param streamName
|
* @param streamName
|
||||||
* @param dynamoDBClient
|
* @param dynamoDBClient
|
||||||
|
|
@ -268,14 +272,14 @@ public class DynamoDBLeaseManagementFactory implements LeaseManagementFactory {
|
||||||
final long listShardsCacheAllowedAgeInSeconds, final int cacheMissWarningModulus,
|
final long listShardsCacheAllowedAgeInSeconds, final int cacheMissWarningModulus,
|
||||||
final long initialLeaseTableReadCapacity, final long initialLeaseTableWriteCapacity,
|
final long initialLeaseTableReadCapacity, final long initialLeaseTableWriteCapacity,
|
||||||
final HierarchicalShardSyncer hierarchicalShardSyncer, final TableCreatorCallback tableCreatorCallback,
|
final HierarchicalShardSyncer hierarchicalShardSyncer, final TableCreatorCallback tableCreatorCallback,
|
||||||
Duration dynamoDbRequestTimeout) {
|
Duration dynamoDbRequestTimeout, ShardFilter shardFilter) {
|
||||||
this(kinesisClient, streamName, dynamoDBClient, tableName, workerIdentifier, executorService,
|
this(kinesisClient, streamName, dynamoDBClient, tableName, workerIdentifier, executorService,
|
||||||
initialPositionInStream, failoverTimeMillis, epsilonMillis, maxLeasesForWorker,
|
initialPositionInStream, failoverTimeMillis, epsilonMillis, maxLeasesForWorker,
|
||||||
maxLeasesToStealAtOneTime, maxLeaseRenewalThreads, cleanupLeasesUponShardCompletion,
|
maxLeasesToStealAtOneTime, maxLeaseRenewalThreads, cleanupLeasesUponShardCompletion,
|
||||||
ignoreUnexpectedChildShards, shardSyncIntervalMillis, consistentReads, listShardsBackoffTimeMillis,
|
ignoreUnexpectedChildShards, shardSyncIntervalMillis, consistentReads, listShardsBackoffTimeMillis,
|
||||||
maxListShardsRetryAttempts, maxCacheMissesBeforeReload, listShardsCacheAllowedAgeInSeconds,
|
maxListShardsRetryAttempts, maxCacheMissesBeforeReload, listShardsCacheAllowedAgeInSeconds,
|
||||||
cacheMissWarningModulus, initialLeaseTableReadCapacity, initialLeaseTableWriteCapacity,
|
cacheMissWarningModulus, initialLeaseTableReadCapacity, initialLeaseTableWriteCapacity,
|
||||||
hierarchicalShardSyncer, tableCreatorCallback, dynamoDbRequestTimeout, BillingMode.PROVISIONED);
|
hierarchicalShardSyncer, tableCreatorCallback, dynamoDbRequestTimeout, BillingMode.PROVISIONED, shardFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -320,7 +324,7 @@ public class DynamoDBLeaseManagementFactory implements LeaseManagementFactory {
|
||||||
final long listShardsCacheAllowedAgeInSeconds, final int cacheMissWarningModulus,
|
final long listShardsCacheAllowedAgeInSeconds, final int cacheMissWarningModulus,
|
||||||
final long initialLeaseTableReadCapacity, final long initialLeaseTableWriteCapacity,
|
final long initialLeaseTableReadCapacity, final long initialLeaseTableWriteCapacity,
|
||||||
final HierarchicalShardSyncer hierarchicalShardSyncer, final TableCreatorCallback tableCreatorCallback,
|
final HierarchicalShardSyncer hierarchicalShardSyncer, final TableCreatorCallback tableCreatorCallback,
|
||||||
Duration dynamoDbRequestTimeout, BillingMode billingMode) {
|
Duration dynamoDbRequestTimeout, BillingMode billingMode, ShardFilter shardFilter) {
|
||||||
this.kinesisClient = kinesisClient;
|
this.kinesisClient = kinesisClient;
|
||||||
this.streamName = streamName;
|
this.streamName = streamName;
|
||||||
this.dynamoDBClient = dynamoDBClient;
|
this.dynamoDBClient = dynamoDBClient;
|
||||||
|
|
@ -348,6 +352,7 @@ public class DynamoDBLeaseManagementFactory implements LeaseManagementFactory {
|
||||||
this.tableCreatorCallback = tableCreatorCallback;
|
this.tableCreatorCallback = tableCreatorCallback;
|
||||||
this.dynamoDbRequestTimeout = dynamoDbRequestTimeout;
|
this.dynamoDbRequestTimeout = dynamoDbRequestTimeout;
|
||||||
this.billingMode = billingMode;
|
this.billingMode = billingMode;
|
||||||
|
this.shardFilter = shardFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -374,7 +379,8 @@ public class DynamoDBLeaseManagementFactory implements LeaseManagementFactory {
|
||||||
shardSyncIntervalMillis,
|
shardSyncIntervalMillis,
|
||||||
executorService,
|
executorService,
|
||||||
hierarchicalShardSyncer,
|
hierarchicalShardSyncer,
|
||||||
metricsFactory);
|
metricsFactory,
|
||||||
|
shardFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -387,6 +393,6 @@ public class DynamoDBLeaseManagementFactory implements LeaseManagementFactory {
|
||||||
public ShardDetector createShardDetector() {
|
public ShardDetector createShardDetector() {
|
||||||
return new KinesisShardDetector(kinesisClient, streamName, listShardsBackoffTimeMillis,
|
return new KinesisShardDetector(kinesisClient, streamName, listShardsBackoffTimeMillis,
|
||||||
maxListShardsRetryAttempts, listShardsCacheAllowedAgeInSeconds, maxCacheMissesBeforeReload,
|
maxListShardsRetryAttempts, listShardsCacheAllowedAgeInSeconds, maxCacheMissesBeforeReload,
|
||||||
cacheMissWarningModulus, dynamoDbRequestTimeout);
|
cacheMissWarningModulus, dynamoDbRequestTimeout, shardFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package software.amazon.kinesis.leases.exceptions;
|
package software.amazon.kinesis.leases.exceptions;
|
||||||
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
||||||
import software.amazon.kinesis.exceptions.internal.KinesisClientLibIOException;
|
import software.amazon.kinesis.exceptions.internal.KinesisClientLibIOException;
|
||||||
import software.amazon.kinesis.leases.HierarchicalShardSyncer;
|
import software.amazon.kinesis.leases.HierarchicalShardSyncer;
|
||||||
|
|
@ -38,9 +39,9 @@ public class ShardSyncer {
|
||||||
public static synchronized void checkAndCreateLeasesForNewShards(@NonNull final ShardDetector shardDetector,
|
public static synchronized void checkAndCreateLeasesForNewShards(@NonNull final ShardDetector shardDetector,
|
||||||
final LeaseRefresher leaseRefresher, final InitialPositionInStreamExtended initialPosition,
|
final LeaseRefresher leaseRefresher, final InitialPositionInStreamExtended initialPosition,
|
||||||
final boolean cleanupLeasesOfCompletedShards, final boolean ignoreUnexpectedChildShards,
|
final boolean cleanupLeasesOfCompletedShards, final boolean ignoreUnexpectedChildShards,
|
||||||
final MetricsScope scope) throws DependencyException, InvalidStateException, ProvisionedThroughputException,
|
final MetricsScope scope, final ShardFilter shardFilter) throws DependencyException, InvalidStateException, ProvisionedThroughputException,
|
||||||
KinesisClientLibIOException {
|
KinesisClientLibIOException {
|
||||||
HIERARCHICAL_SHARD_SYNCER.checkAndCreateLeaseForNewShards(shardDetector, leaseRefresher, initialPosition,
|
HIERARCHICAL_SHARD_SYNCER.checkAndCreateLeaseForNewShards(shardDetector, leaseRefresher, initialPosition,
|
||||||
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, scope);
|
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, scope, shardFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,8 @@ class ConsumerStates {
|
||||||
input,
|
input,
|
||||||
argument.shouldCallProcessRecordsEvenForEmptyRecordList(),
|
argument.shouldCallProcessRecordsEvenForEmptyRecordList(),
|
||||||
argument.idleTimeInMilliseconds(),
|
argument.idleTimeInMilliseconds(),
|
||||||
argument.aggregatorUtil(), argument.metricsFactory()
|
argument.aggregatorUtil(), argument.metricsFactory(),
|
||||||
|
argument.shardFilter()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -496,7 +497,8 @@ class ConsumerStates {
|
||||||
argument.taskBackoffTimeMillis(),
|
argument.taskBackoffTimeMillis(),
|
||||||
argument.recordsPublisher(),
|
argument.recordsPublisher(),
|
||||||
argument.hierarchicalShardSyncer(),
|
argument.hierarchicalShardSyncer(),
|
||||||
argument.metricsFactory());
|
argument.metricsFactory(),
|
||||||
|
argument.shardFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import lombok.NonNull;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import software.amazon.awssdk.services.cloudwatch.model.StandardUnit;
|
import software.amazon.awssdk.services.cloudwatch.model.StandardUnit;
|
||||||
import software.amazon.awssdk.services.kinesis.model.Shard;
|
import software.amazon.awssdk.services.kinesis.model.Shard;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
import software.amazon.kinesis.annotations.KinesisClientInternalApi;
|
import software.amazon.kinesis.annotations.KinesisClientInternalApi;
|
||||||
import software.amazon.kinesis.checkpoint.ShardRecordProcessorCheckpointer;
|
import software.amazon.kinesis.checkpoint.ShardRecordProcessorCheckpointer;
|
||||||
import software.amazon.kinesis.leases.ShardDetector;
|
import software.amazon.kinesis.leases.ShardDetector;
|
||||||
|
|
@ -60,6 +61,7 @@ public class ProcessTask implements ConsumerTask {
|
||||||
private final ProcessRecordsInput processRecordsInput;
|
private final ProcessRecordsInput processRecordsInput;
|
||||||
private final MetricsFactory metricsFactory;
|
private final MetricsFactory metricsFactory;
|
||||||
private final AggregatorUtil aggregatorUtil;
|
private final AggregatorUtil aggregatorUtil;
|
||||||
|
private final ShardFilter shardFilter;
|
||||||
|
|
||||||
public ProcessTask(@NonNull ShardInfo shardInfo,
|
public ProcessTask(@NonNull ShardInfo shardInfo,
|
||||||
@NonNull ShardRecordProcessor shardRecordProcessor,
|
@NonNull ShardRecordProcessor shardRecordProcessor,
|
||||||
|
|
@ -72,7 +74,8 @@ public class ProcessTask implements ConsumerTask {
|
||||||
boolean shouldCallProcessRecordsEvenForEmptyRecordList,
|
boolean shouldCallProcessRecordsEvenForEmptyRecordList,
|
||||||
long idleTimeInMilliseconds,
|
long idleTimeInMilliseconds,
|
||||||
@NonNull AggregatorUtil aggregatorUtil,
|
@NonNull AggregatorUtil aggregatorUtil,
|
||||||
@NonNull MetricsFactory metricsFactory) {
|
@NonNull MetricsFactory metricsFactory,
|
||||||
|
@NonNull ShardFilter shardFilter) {
|
||||||
this.shardInfo = shardInfo;
|
this.shardInfo = shardInfo;
|
||||||
this.shardRecordProcessor = shardRecordProcessor;
|
this.shardRecordProcessor = shardRecordProcessor;
|
||||||
this.recordProcessorCheckpointer = recordProcessorCheckpointer;
|
this.recordProcessorCheckpointer = recordProcessorCheckpointer;
|
||||||
|
|
@ -82,6 +85,7 @@ public class ProcessTask implements ConsumerTask {
|
||||||
this.shouldCallProcessRecordsEvenForEmptyRecordList = shouldCallProcessRecordsEvenForEmptyRecordList;
|
this.shouldCallProcessRecordsEvenForEmptyRecordList = shouldCallProcessRecordsEvenForEmptyRecordList;
|
||||||
this.idleTimeInMilliseconds = idleTimeInMilliseconds;
|
this.idleTimeInMilliseconds = idleTimeInMilliseconds;
|
||||||
this.metricsFactory = metricsFactory;
|
this.metricsFactory = metricsFactory;
|
||||||
|
this.shardFilter = shardFilter;
|
||||||
|
|
||||||
if (!skipShardSyncAtWorkerInitializationIfLeasesExist) {
|
if (!skipShardSyncAtWorkerInitializationIfLeasesExist) {
|
||||||
this.shard = shardDetector.shard(shardInfo.shardId());
|
this.shard = shardDetector.shard(shardInfo.shardId());
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package software.amazon.kinesis.lifecycle;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
import software.amazon.kinesis.annotations.KinesisClientInternalApi;
|
import software.amazon.kinesis.annotations.KinesisClientInternalApi;
|
||||||
import software.amazon.kinesis.checkpoint.ShardRecordProcessorCheckpointer;
|
import software.amazon.kinesis.checkpoint.ShardRecordProcessorCheckpointer;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
||||||
|
|
@ -71,4 +72,6 @@ public class ShardConsumerArgument {
|
||||||
private final HierarchicalShardSyncer hierarchicalShardSyncer;
|
private final HierarchicalShardSyncer hierarchicalShardSyncer;
|
||||||
@NonNull
|
@NonNull
|
||||||
private final MetricsFactory metricsFactory;
|
private final MetricsFactory metricsFactory;
|
||||||
|
@NonNull
|
||||||
|
private final ShardFilter shardFilter;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import software.amazon.awssdk.services.kinesis.model.Shard;
|
import software.amazon.awssdk.services.kinesis.model.Shard;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
import software.amazon.awssdk.utils.CollectionUtils;
|
import software.amazon.awssdk.utils.CollectionUtils;
|
||||||
import software.amazon.kinesis.annotations.KinesisClientInternalApi;
|
import software.amazon.kinesis.annotations.KinesisClientInternalApi;
|
||||||
import software.amazon.kinesis.checkpoint.ShardRecordProcessorCheckpointer;
|
import software.amazon.kinesis.checkpoint.ShardRecordProcessorCheckpointer;
|
||||||
|
|
@ -79,6 +80,8 @@ public class ShutdownTask implements ConsumerTask {
|
||||||
private final HierarchicalShardSyncer hierarchicalShardSyncer;
|
private final HierarchicalShardSyncer hierarchicalShardSyncer;
|
||||||
@NonNull
|
@NonNull
|
||||||
private final MetricsFactory metricsFactory;
|
private final MetricsFactory metricsFactory;
|
||||||
|
@NonNull
|
||||||
|
private final ShardFilter shardFilter;
|
||||||
|
|
||||||
private final TaskType taskType = TaskType.SHUTDOWN;
|
private final TaskType taskType = TaskType.SHUTDOWN;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ import lombok.Data;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
|
import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilterType;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStream;
|
import software.amazon.kinesis.common.InitialPositionInStream;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
||||||
import software.amazon.kinesis.retrieval.fanout.FanOutConfig;
|
import software.amazon.kinesis.retrieval.fanout.FanOutConfig;
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,8 @@ import org.mockito.runners.MockitoJUnitRunner;
|
||||||
import software.amazon.awssdk.services.kinesis.model.HashKeyRange;
|
import software.amazon.awssdk.services.kinesis.model.HashKeyRange;
|
||||||
import software.amazon.awssdk.services.kinesis.model.SequenceNumberRange;
|
import software.amazon.awssdk.services.kinesis.model.SequenceNumberRange;
|
||||||
import software.amazon.awssdk.services.kinesis.model.Shard;
|
import software.amazon.awssdk.services.kinesis.model.Shard;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilterType;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStream;
|
import software.amazon.kinesis.common.InitialPositionInStream;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
||||||
import software.amazon.kinesis.exceptions.internal.KinesisClientLibIOException;
|
import software.amazon.kinesis.exceptions.internal.KinesisClientLibIOException;
|
||||||
|
|
@ -77,6 +79,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
|
|
||||||
private final boolean cleanupLeasesOfCompletedShards = true;
|
private final boolean cleanupLeasesOfCompletedShards = true;
|
||||||
private final boolean ignoreUnexpectedChildShards = false;
|
private final boolean ignoreUnexpectedChildShards = false;
|
||||||
|
private final ShardFilter shardFilter = ShardFilter.builder().type(ShardFilterType.AT_LATEST).build();
|
||||||
|
|
||||||
private HierarchicalShardSyncer hierarchicalShardSyncer;
|
private HierarchicalShardSyncer hierarchicalShardSyncer;
|
||||||
|
|
||||||
|
|
@ -186,7 +189,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
|
|
||||||
hierarchicalShardSyncer
|
hierarchicalShardSyncer
|
||||||
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, INITIAL_POSITION_LATEST,
|
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, INITIAL_POSITION_LATEST,
|
||||||
cleanupLeasesOfCompletedShards, false, SCOPE);
|
cleanupLeasesOfCompletedShards, false, SCOPE, shardFilter);
|
||||||
|
|
||||||
final Set<String> expectedShardIds = new HashSet<>(
|
final Set<String> expectedShardIds = new HashSet<>(
|
||||||
Arrays.asList("shardId-4", "shardId-8", "shardId-9", "shardId-10"));
|
Arrays.asList("shardId-4", "shardId-8", "shardId-9", "shardId-10"));
|
||||||
|
|
@ -299,7 +302,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
hierarchicalShardSyncer.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher,
|
hierarchicalShardSyncer.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher,
|
||||||
INITIAL_POSITION_TRIM_HORIZON, cleanupLeasesOfCompletedShards, false, SCOPE);
|
INITIAL_POSITION_TRIM_HORIZON, cleanupLeasesOfCompletedShards, false, SCOPE, shardFilter);
|
||||||
} finally {
|
} finally {
|
||||||
verify(shardDetector).listShards();
|
verify(shardDetector).listShards();
|
||||||
verify(dynamoDBLeaseRefresher, never()).listLeases();
|
verify(dynamoDBLeaseRefresher, never()).listLeases();
|
||||||
|
|
@ -334,7 +337,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
|
|
||||||
hierarchicalShardSyncer
|
hierarchicalShardSyncer
|
||||||
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, INITIAL_POSITION_LATEST,
|
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, INITIAL_POSITION_LATEST,
|
||||||
cleanupLeasesOfCompletedShards, true, SCOPE);
|
cleanupLeasesOfCompletedShards, true, SCOPE, shardFilter);
|
||||||
|
|
||||||
final List<Lease> leases = leaseCaptor.getAllValues();
|
final List<Lease> leases = leaseCaptor.getAllValues();
|
||||||
final Set<String> leaseKeys = leases.stream().map(Lease::leaseKey).collect(Collectors.toSet());
|
final Set<String> leaseKeys = leases.stream().map(Lease::leaseKey).collect(Collectors.toSet());
|
||||||
|
|
@ -390,7 +393,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
|
|
||||||
// Initial call: No leases present, create leases.
|
// Initial call: No leases present, create leases.
|
||||||
hierarchicalShardSyncer.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
hierarchicalShardSyncer.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
||||||
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE);
|
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE, shardFilter);
|
||||||
|
|
||||||
final Set<Lease> createLeases = new HashSet<>(leaseCreateCaptor.getAllValues());
|
final Set<Lease> createLeases = new HashSet<>(leaseCreateCaptor.getAllValues());
|
||||||
|
|
||||||
|
|
@ -405,7 +408,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
|
|
||||||
// Second call: Leases present, with shardId-0 being at ShardEnd causing cleanup.
|
// Second call: Leases present, with shardId-0 being at ShardEnd causing cleanup.
|
||||||
hierarchicalShardSyncer.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
hierarchicalShardSyncer.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
||||||
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE);
|
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE, shardFilter);
|
||||||
final List<Lease> deleteLeases = leaseDeleteCaptor.getAllValues();
|
final List<Lease> deleteLeases = leaseDeleteCaptor.getAllValues();
|
||||||
final Set<String> shardIds = deleteLeases.stream().map(Lease::leaseKey).collect(Collectors.toSet());
|
final Set<String> shardIds = deleteLeases.stream().map(Lease::leaseKey).collect(Collectors.toSet());
|
||||||
final Set<ExtendedSequenceNumber> sequenceNumbers = deleteLeases.stream().map(Lease::checkpoint)
|
final Set<ExtendedSequenceNumber> sequenceNumbers = deleteLeases.stream().map(Lease::checkpoint)
|
||||||
|
|
@ -465,7 +468,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
|
|
||||||
// Initial call: Call to create leases.
|
// Initial call: Call to create leases.
|
||||||
hierarchicalShardSyncer.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
hierarchicalShardSyncer.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
||||||
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE);
|
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE, shardFilter);
|
||||||
|
|
||||||
final Set<Lease> createLeases = new HashSet<>(leaseCreateCaptor.getAllValues());
|
final Set<Lease> createLeases = new HashSet<>(leaseCreateCaptor.getAllValues());
|
||||||
|
|
||||||
|
|
@ -482,7 +485,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
// Second call: Leases already present. ShardId-0 is at ShardEnd and needs to be cleaned up. Delete fails.
|
// Second call: Leases already present. ShardId-0 is at ShardEnd and needs to be cleaned up. Delete fails.
|
||||||
hierarchicalShardSyncer
|
hierarchicalShardSyncer
|
||||||
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
||||||
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE);
|
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE, shardFilter);
|
||||||
} finally {
|
} finally {
|
||||||
List<Lease> deleteLeases = leaseDeleteCaptor.getAllValues();
|
List<Lease> deleteLeases = leaseDeleteCaptor.getAllValues();
|
||||||
Set<String> shardIds = deleteLeases.stream().map(Lease::leaseKey).collect(Collectors.toSet());
|
Set<String> shardIds = deleteLeases.stream().map(Lease::leaseKey).collect(Collectors.toSet());
|
||||||
|
|
@ -506,7 +509,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
// Final call: Leases already present. ShardId-0 is at ShardEnd and needs to be cleaned up. Delete passes.
|
// Final call: Leases already present. ShardId-0 is at ShardEnd and needs to be cleaned up. Delete passes.
|
||||||
hierarchicalShardSyncer
|
hierarchicalShardSyncer
|
||||||
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
||||||
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE);
|
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE, shardFilter);
|
||||||
|
|
||||||
deleteLeases = leaseDeleteCaptor.getAllValues();
|
deleteLeases = leaseDeleteCaptor.getAllValues();
|
||||||
|
|
||||||
|
|
@ -567,7 +570,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
// Initial call: Call to create leases. Fails on ListLeases
|
// Initial call: Call to create leases. Fails on ListLeases
|
||||||
hierarchicalShardSyncer
|
hierarchicalShardSyncer
|
||||||
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
||||||
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE);
|
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE, shardFilter);
|
||||||
} finally {
|
} finally {
|
||||||
verify(shardDetector, times(1)).listShards();
|
verify(shardDetector, times(1)).listShards();
|
||||||
verify(dynamoDBLeaseRefresher, times(1)).listLeases();
|
verify(dynamoDBLeaseRefresher, times(1)).listLeases();
|
||||||
|
|
@ -577,7 +580,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
// Second call: Leases not present, leases will be created.
|
// Second call: Leases not present, leases will be created.
|
||||||
hierarchicalShardSyncer
|
hierarchicalShardSyncer
|
||||||
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
||||||
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE);
|
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE, shardFilter);
|
||||||
|
|
||||||
final Set<Lease> createLeases = new HashSet<>(leaseCreateCaptor.getAllValues());
|
final Set<Lease> createLeases = new HashSet<>(leaseCreateCaptor.getAllValues());
|
||||||
final Set<Lease> expectedCreateLeases = new HashSet<>(createLeasesFromShards(shards, sequenceNumber, null));
|
final Set<Lease> expectedCreateLeases = new HashSet<>(createLeasesFromShards(shards, sequenceNumber, null));
|
||||||
|
|
@ -592,7 +595,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
// Final call: Leases present, belongs to TestOwner, shardId-0 is at ShardEnd should be cleaned up.
|
// Final call: Leases present, belongs to TestOwner, shardId-0 is at ShardEnd should be cleaned up.
|
||||||
hierarchicalShardSyncer
|
hierarchicalShardSyncer
|
||||||
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
||||||
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE);
|
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE, shardFilter);
|
||||||
|
|
||||||
final List<Lease> deleteLeases = leaseDeleteCaptor.getAllValues();
|
final List<Lease> deleteLeases = leaseDeleteCaptor.getAllValues();
|
||||||
final Set<String> shardIds = deleteLeases.stream().map(Lease::leaseKey).collect(Collectors.toSet());
|
final Set<String> shardIds = deleteLeases.stream().map(Lease::leaseKey).collect(Collectors.toSet());
|
||||||
|
|
@ -658,7 +661,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
// Initial call: No leases present, create leases. Create lease Fails
|
// Initial call: No leases present, create leases. Create lease Fails
|
||||||
hierarchicalShardSyncer
|
hierarchicalShardSyncer
|
||||||
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
||||||
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE);
|
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE, shardFilter);
|
||||||
} finally {
|
} finally {
|
||||||
verify(shardDetector, times(1)).listShards();
|
verify(shardDetector, times(1)).listShards();
|
||||||
verify(dynamoDBLeaseRefresher, times(1)).listLeases();
|
verify(dynamoDBLeaseRefresher, times(1)).listLeases();
|
||||||
|
|
@ -667,7 +670,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
|
|
||||||
hierarchicalShardSyncer
|
hierarchicalShardSyncer
|
||||||
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
||||||
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE);
|
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE, shardFilter);
|
||||||
|
|
||||||
final Set<Lease> createLeases = new HashSet<>(leaseCreateCaptor.getAllValues());
|
final Set<Lease> createLeases = new HashSet<>(leaseCreateCaptor.getAllValues());
|
||||||
final Set<Lease> expectedCreateLeases = new HashSet<>(createLeasesFromShards(shards, sequenceNumber, null));
|
final Set<Lease> expectedCreateLeases = new HashSet<>(createLeasesFromShards(shards, sequenceNumber, null));
|
||||||
|
|
@ -682,7 +685,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
// Final call: Leases are present, shardId-0 is at ShardEnd needs to be cleaned up.
|
// Final call: Leases are present, shardId-0 is at ShardEnd needs to be cleaned up.
|
||||||
hierarchicalShardSyncer
|
hierarchicalShardSyncer
|
||||||
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, position,
|
||||||
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE);
|
cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE, shardFilter);
|
||||||
|
|
||||||
final List<Lease> deleteLeases = leaseDeleteCaptor.getAllValues();
|
final List<Lease> deleteLeases = leaseDeleteCaptor.getAllValues();
|
||||||
final Set<String> shardIds = deleteLeases.stream().map(Lease::leaseKey).collect(Collectors.toSet());
|
final Set<String> shardIds = deleteLeases.stream().map(Lease::leaseKey).collect(Collectors.toSet());
|
||||||
|
|
@ -744,7 +747,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
doNothing().when(dynamoDBLeaseRefresher).deleteLease(leaseCaptor.capture());
|
doNothing().when(dynamoDBLeaseRefresher).deleteLease(leaseCaptor.capture());
|
||||||
|
|
||||||
hierarchicalShardSyncer.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher,
|
hierarchicalShardSyncer.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher,
|
||||||
INITIAL_POSITION_TRIM_HORIZON, cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE);
|
INITIAL_POSITION_TRIM_HORIZON, cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, SCOPE, shardFilter);
|
||||||
|
|
||||||
assertThat(leaseCaptor.getAllValues().size(), equalTo(1));
|
assertThat(leaseCaptor.getAllValues().size(), equalTo(1));
|
||||||
assertThat(leaseCaptor.getValue(), equalTo(garbageLease));
|
assertThat(leaseCaptor.getValue(), equalTo(garbageLease));
|
||||||
|
|
@ -776,7 +779,7 @@ public class HierarchicalShardSyncerTest {
|
||||||
|
|
||||||
hierarchicalShardSyncer
|
hierarchicalShardSyncer
|
||||||
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, initialPosition,
|
.checkAndCreateLeaseForNewShards(shardDetector, dynamoDBLeaseRefresher, initialPosition,
|
||||||
cleanupLeasesOfCompletedShards, false, SCOPE);
|
cleanupLeasesOfCompletedShards, false, SCOPE, shardFilter);
|
||||||
|
|
||||||
final List<Lease> leases = leaseCaptor.getAllValues();
|
final List<Lease> leases = leaseCaptor.getAllValues();
|
||||||
final Set<String> leaseKeys = leases.stream().map(Lease::leaseKey).collect(Collectors.toSet());
|
final Set<String> leaseKeys = leases.stream().map(Lease::leaseKey).collect(Collectors.toSet());
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,8 @@ import software.amazon.awssdk.services.kinesis.model.ListShardsResponse;
|
||||||
import software.amazon.awssdk.services.kinesis.model.ResourceInUseException;
|
import software.amazon.awssdk.services.kinesis.model.ResourceInUseException;
|
||||||
import software.amazon.awssdk.services.kinesis.model.ResourceNotFoundException;
|
import software.amazon.awssdk.services.kinesis.model.ResourceNotFoundException;
|
||||||
import software.amazon.awssdk.services.kinesis.model.Shard;
|
import software.amazon.awssdk.services.kinesis.model.Shard;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilterType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -67,6 +69,7 @@ public class KinesisShardDetectorTest {
|
||||||
private static final String SHARD_ID = "shardId-%012d";
|
private static final String SHARD_ID = "shardId-%012d";
|
||||||
|
|
||||||
private KinesisShardDetector shardDetector;
|
private KinesisShardDetector shardDetector;
|
||||||
|
private ShardFilter shardFilter = ShardFilter.builder().type(ShardFilterType.AT_LATEST).build();
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException expectedExceptionRule = ExpectedException.none();
|
public ExpectedException expectedExceptionRule = ExpectedException.none();
|
||||||
|
|
@ -80,7 +83,7 @@ public class KinesisShardDetectorTest {
|
||||||
public void setup() {
|
public void setup() {
|
||||||
shardDetector = new KinesisShardDetector(client, STREAM_NAME, LIST_SHARDS_BACKOFF_TIME_IN_MILLIS,
|
shardDetector = new KinesisShardDetector(client, STREAM_NAME, LIST_SHARDS_BACKOFF_TIME_IN_MILLIS,
|
||||||
MAX_LIST_SHARDS_RETRY_ATTEMPTS, LIST_SHARDS_CACHE_ALLOWED_AGE_IN_SECONDS,
|
MAX_LIST_SHARDS_RETRY_ATTEMPTS, LIST_SHARDS_CACHE_ALLOWED_AGE_IN_SECONDS,
|
||||||
MAX_CACHE_MISSES_BEFORE_RELOAD, CACHE_MISS_WARNING_MODULUS);
|
MAX_CACHE_MISSES_BEFORE_RELOAD, CACHE_MISS_WARNING_MODULUS, LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT, shardFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,8 @@ import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
|
||||||
import software.amazon.awssdk.services.kinesis.model.CreateStreamRequest;
|
import software.amazon.awssdk.services.kinesis.model.CreateStreamRequest;
|
||||||
import software.amazon.awssdk.services.kinesis.model.KinesisException;
|
import software.amazon.awssdk.services.kinesis.model.KinesisException;
|
||||||
import software.amazon.awssdk.services.kinesis.model.Shard;
|
import software.amazon.awssdk.services.kinesis.model.Shard;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilterType;
|
||||||
import software.amazon.awssdk.services.kinesis.model.StreamStatus;
|
import software.amazon.awssdk.services.kinesis.model.StreamStatus;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStream;
|
import software.amazon.kinesis.common.InitialPositionInStream;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
||||||
|
|
@ -60,6 +62,7 @@ public class ShardSyncTaskIntegrationTest {
|
||||||
private static final int CACHE_MISS_WARNING_MODULUS = 250;
|
private static final int CACHE_MISS_WARNING_MODULUS = 250;
|
||||||
private static final MetricsFactory NULL_METRICS_FACTORY = new NullMetricsFactory();
|
private static final MetricsFactory NULL_METRICS_FACTORY = new NullMetricsFactory();
|
||||||
private static KinesisAsyncClient kinesisClient;
|
private static KinesisAsyncClient kinesisClient;
|
||||||
|
private static ShardFilter shardFilter = ShardFilter.builder().type(ShardFilterType.AT_LATEST).build();
|
||||||
|
|
||||||
private LeaseRefresher leaseRefresher;
|
private LeaseRefresher leaseRefresher;
|
||||||
private ShardDetector shardDetector;
|
private ShardDetector shardDetector;
|
||||||
|
|
@ -97,7 +100,7 @@ public class ShardSyncTaskIntegrationTest {
|
||||||
USE_CONSISTENT_READS, TableCreatorCallback.NOOP_TABLE_CREATOR_CALLBACK);
|
USE_CONSISTENT_READS, TableCreatorCallback.NOOP_TABLE_CREATOR_CALLBACK);
|
||||||
|
|
||||||
shardDetector = new KinesisShardDetector(kinesisClient, STREAM_NAME, 500L, 50,
|
shardDetector = new KinesisShardDetector(kinesisClient, STREAM_NAME, 500L, 50,
|
||||||
LIST_SHARDS_CACHE_ALLOWED_AGE_IN_SECONDS, MAX_CACHE_MISSES_BEFORE_RELOAD, CACHE_MISS_WARNING_MODULUS);
|
LIST_SHARDS_CACHE_ALLOWED_AGE_IN_SECONDS, MAX_CACHE_MISSES_BEFORE_RELOAD, CACHE_MISS_WARNING_MODULUS, shardFilter);
|
||||||
hierarchicalShardSyncer = new HierarchicalShardSyncer();
|
hierarchicalShardSyncer = new HierarchicalShardSyncer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,7 +122,7 @@ public class ShardSyncTaskIntegrationTest {
|
||||||
Set<String> shardIds = shardDetector.listShards().stream().map(Shard::shardId).collect(Collectors.toSet());
|
Set<String> shardIds = shardDetector.listShards().stream().map(Shard::shardId).collect(Collectors.toSet());
|
||||||
ShardSyncTask syncTask = new ShardSyncTask(shardDetector, leaseRefresher,
|
ShardSyncTask syncTask = new ShardSyncTask(shardDetector, leaseRefresher,
|
||||||
InitialPositionInStreamExtended.newInitialPosition(InitialPositionInStream.LATEST), false, false, 0L,
|
InitialPositionInStreamExtended.newInitialPosition(InitialPositionInStream.LATEST), false, false, 0L,
|
||||||
hierarchicalShardSyncer, NULL_METRICS_FACTORY);
|
hierarchicalShardSyncer, NULL_METRICS_FACTORY, shardFilter);
|
||||||
syncTask.call();
|
syncTask.call();
|
||||||
List<Lease> leases = leaseRefresher.listLeases();
|
List<Lease> leases = leaseRefresher.listLeases();
|
||||||
Set<String> leaseKeys = new HashSet<>();
|
Set<String> leaseKeys = new HashSet<>();
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ import org.mockito.Mock;
|
||||||
import org.mockito.runners.MockitoJUnitRunner;
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
|
|
||||||
import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
|
import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilterType;
|
||||||
import software.amazon.kinesis.checkpoint.ShardRecordProcessorCheckpointer;
|
import software.amazon.kinesis.checkpoint.ShardRecordProcessorCheckpointer;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStream;
|
import software.amazon.kinesis.common.InitialPositionInStream;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
||||||
|
|
@ -66,6 +68,7 @@ public class ConsumerStatesTest {
|
||||||
|
|
||||||
private ShardConsumer consumer;
|
private ShardConsumer consumer;
|
||||||
private ShardConsumerArgument argument;
|
private ShardConsumerArgument argument;
|
||||||
|
private ShardFilter shardFilter = ShardFilter.builder().type(ShardFilterType.AT_LATEST).build();
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private ShardRecordProcessor shardRecordProcessor;
|
private ShardRecordProcessor shardRecordProcessor;
|
||||||
|
|
@ -119,7 +122,7 @@ public class ConsumerStatesTest {
|
||||||
taskBackoffTimeMillis, skipShardSyncAtWorkerInitializationIfLeasesExist, listShardsBackoffTimeInMillis,
|
taskBackoffTimeMillis, skipShardSyncAtWorkerInitializationIfLeasesExist, listShardsBackoffTimeInMillis,
|
||||||
maxListShardsRetryAttempts, shouldCallProcessRecordsEvenForEmptyRecordList, idleTimeInMillis,
|
maxListShardsRetryAttempts, shouldCallProcessRecordsEvenForEmptyRecordList, idleTimeInMillis,
|
||||||
INITIAL_POSITION_IN_STREAM, cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, shardDetector,
|
INITIAL_POSITION_IN_STREAM, cleanupLeasesOfCompletedShards, ignoreUnexpectedChildShards, shardDetector,
|
||||||
new AggregatorUtil(), hierarchicalShardSyncer, metricsFactory);
|
new AggregatorUtil(), hierarchicalShardSyncer, metricsFactory, shardFilter);
|
||||||
consumer = spy(new ShardConsumer(recordsPublisher, executorService, shardInfo, logWarningForTaskAfterMillis,
|
consumer = spy(new ShardConsumer(recordsPublisher, executorService, shardInfo, logWarningForTaskAfterMillis,
|
||||||
argument, taskExecutionListener, 0));
|
argument, taskExecutionListener, 0));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,8 @@ import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import software.amazon.awssdk.services.kinesis.model.HashKeyRange;
|
import software.amazon.awssdk.services.kinesis.model.HashKeyRange;
|
||||||
import software.amazon.awssdk.services.kinesis.model.Shard;
|
import software.amazon.awssdk.services.kinesis.model.Shard;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilterType;
|
||||||
import software.amazon.kinesis.checkpoint.ShardRecordProcessorCheckpointer;
|
import software.amazon.kinesis.checkpoint.ShardRecordProcessorCheckpointer;
|
||||||
import software.amazon.kinesis.leases.ShardDetector;
|
import software.amazon.kinesis.leases.ShardDetector;
|
||||||
import software.amazon.kinesis.leases.ShardInfo;
|
import software.amazon.kinesis.leases.ShardInfo;
|
||||||
|
|
@ -83,6 +85,7 @@ public class ProcessTaskTest {
|
||||||
private boolean shouldCallProcessRecordsEvenForEmptyRecordList = true;
|
private boolean shouldCallProcessRecordsEvenForEmptyRecordList = true;
|
||||||
private boolean skipShardSyncAtWorkerInitializationIfLeasesExist = true;
|
private boolean skipShardSyncAtWorkerInitializationIfLeasesExist = true;
|
||||||
private ShardInfo shardInfo;
|
private ShardInfo shardInfo;
|
||||||
|
private ShardFilter shardFilter = ShardFilter.builder().type(ShardFilterType.AT_LATEST).build();
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private ProcessRecordsInput processRecordsInput;
|
private ProcessRecordsInput processRecordsInput;
|
||||||
|
|
@ -122,7 +125,7 @@ public class ProcessTaskTest {
|
||||||
return new ProcessTask(shardInfo, shardRecordProcessor, checkpointer, taskBackoffTimeMillis,
|
return new ProcessTask(shardInfo, shardRecordProcessor, checkpointer, taskBackoffTimeMillis,
|
||||||
skipShardSync, shardDetector, throttlingReporter,
|
skipShardSync, shardDetector, throttlingReporter,
|
||||||
processRecordsInput, shouldCallProcessRecordsEvenForEmptyRecordList, IDLE_TIME_IN_MILLISECONDS,
|
processRecordsInput, shouldCallProcessRecordsEvenForEmptyRecordList, IDLE_TIME_IN_MILLISECONDS,
|
||||||
aggregatorUtil, new NullMetricsFactory());
|
aggregatorUtil, new NullMetricsFactory(), shardFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ import org.mockito.runners.MockitoJUnitRunner;
|
||||||
|
|
||||||
import software.amazon.awssdk.services.kinesis.model.SequenceNumberRange;
|
import software.amazon.awssdk.services.kinesis.model.SequenceNumberRange;
|
||||||
import software.amazon.awssdk.services.kinesis.model.Shard;
|
import software.amazon.awssdk.services.kinesis.model.Shard;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilter;
|
||||||
|
import software.amazon.awssdk.services.kinesis.model.ShardFilterType;
|
||||||
import software.amazon.kinesis.checkpoint.ShardRecordProcessorCheckpointer;
|
import software.amazon.kinesis.checkpoint.ShardRecordProcessorCheckpointer;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStream;
|
import software.amazon.kinesis.common.InitialPositionInStream;
|
||||||
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
|
||||||
|
|
@ -75,6 +77,7 @@ public class ShutdownTaskTest {
|
||||||
private boolean ignoreUnexpectedChildShards = false;
|
private boolean ignoreUnexpectedChildShards = false;
|
||||||
private ShardInfo shardInfo;
|
private ShardInfo shardInfo;
|
||||||
private ShutdownTask task;
|
private ShutdownTask task;
|
||||||
|
private ShardFilter shardFilter = ShardFilter.builder().type(ShardFilterType.AT_LATEST).build();
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private RecordsPublisher recordsPublisher;
|
private RecordsPublisher recordsPublisher;
|
||||||
|
|
@ -104,7 +107,7 @@ public class ShutdownTaskTest {
|
||||||
task = new ShutdownTask(shardInfo, shardDetector, shardRecordProcessor, recordProcessorCheckpointer,
|
task = new ShutdownTask(shardInfo, shardDetector, shardRecordProcessor, recordProcessorCheckpointer,
|
||||||
SHARD_END_SHUTDOWN_REASON, INITIAL_POSITION_TRIM_HORIZON, cleanupLeasesOfCompletedShards,
|
SHARD_END_SHUTDOWN_REASON, INITIAL_POSITION_TRIM_HORIZON, cleanupLeasesOfCompletedShards,
|
||||||
ignoreUnexpectedChildShards, leaseCoordinator, TASK_BACKOFF_TIME_MILLIS, recordsPublisher,
|
ignoreUnexpectedChildShards, leaseCoordinator, TASK_BACKOFF_TIME_MILLIS, recordsPublisher,
|
||||||
hierarchicalShardSyncer, NULL_METRICS_FACTORY);
|
hierarchicalShardSyncer, NULL_METRICS_FACTORY, shardFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -158,7 +161,7 @@ public class ShutdownTaskTest {
|
||||||
task = new ShutdownTask(shardInfo, shardDetector, shardRecordProcessor, recordProcessorCheckpointer,
|
task = new ShutdownTask(shardInfo, shardDetector, shardRecordProcessor, recordProcessorCheckpointer,
|
||||||
SHARD_END_SHUTDOWN_REASON, INITIAL_POSITION_TRIM_HORIZON, cleanupLeasesOfCompletedShards,
|
SHARD_END_SHUTDOWN_REASON, INITIAL_POSITION_TRIM_HORIZON, cleanupLeasesOfCompletedShards,
|
||||||
ignoreUnexpectedChildShards, leaseCoordinator, TASK_BACKOFF_TIME_MILLIS, recordsPublisher,
|
ignoreUnexpectedChildShards, leaseCoordinator, TASK_BACKOFF_TIME_MILLIS, recordsPublisher,
|
||||||
hierarchicalShardSyncer, NULL_METRICS_FACTORY);
|
hierarchicalShardSyncer, NULL_METRICS_FACTORY, shardFilter);
|
||||||
|
|
||||||
when(shardDetector.listShards()).thenReturn(constructShardListGraphA());
|
when(shardDetector.listShards()).thenReturn(constructShardListGraphA());
|
||||||
when(recordProcessorCheckpointer.lastCheckpointValue()).thenReturn(ExtendedSequenceNumber.SHARD_END);
|
when(recordProcessorCheckpointer.lastCheckpointValue()).thenReturn(ExtendedSequenceNumber.SHARD_END);
|
||||||
|
|
@ -183,7 +186,7 @@ public class ShutdownTaskTest {
|
||||||
task = new ShutdownTask(shardInfo, shardDetector, shardRecordProcessor, recordProcessorCheckpointer,
|
task = new ShutdownTask(shardInfo, shardDetector, shardRecordProcessor, recordProcessorCheckpointer,
|
||||||
SHARD_END_SHUTDOWN_REASON, INITIAL_POSITION_TRIM_HORIZON, cleanupLeasesOfCompletedShards,
|
SHARD_END_SHUTDOWN_REASON, INITIAL_POSITION_TRIM_HORIZON, cleanupLeasesOfCompletedShards,
|
||||||
ignoreUnexpectedChildShards, leaseCoordinator, TASK_BACKOFF_TIME_MILLIS, recordsPublisher,
|
ignoreUnexpectedChildShards, leaseCoordinator, TASK_BACKOFF_TIME_MILLIS, recordsPublisher,
|
||||||
hierarchicalShardSyncer, NULL_METRICS_FACTORY);
|
hierarchicalShardSyncer, NULL_METRICS_FACTORY, shardFilter);
|
||||||
|
|
||||||
when(shardDetector.listShards()).thenReturn(constructShardListGraphA());
|
when(shardDetector.listShards()).thenReturn(constructShardListGraphA());
|
||||||
|
|
||||||
|
|
@ -207,7 +210,7 @@ public class ShutdownTaskTest {
|
||||||
task = new ShutdownTask(shardInfo, shardDetector, shardRecordProcessor, recordProcessorCheckpointer,
|
task = new ShutdownTask(shardInfo, shardDetector, shardRecordProcessor, recordProcessorCheckpointer,
|
||||||
LEASE_LOST_SHUTDOWN_REASON, INITIAL_POSITION_TRIM_HORIZON, cleanupLeasesOfCompletedShards,
|
LEASE_LOST_SHUTDOWN_REASON, INITIAL_POSITION_TRIM_HORIZON, cleanupLeasesOfCompletedShards,
|
||||||
ignoreUnexpectedChildShards, leaseCoordinator, TASK_BACKOFF_TIME_MILLIS, recordsPublisher,
|
ignoreUnexpectedChildShards, leaseCoordinator, TASK_BACKOFF_TIME_MILLIS, recordsPublisher,
|
||||||
hierarchicalShardSyncer, NULL_METRICS_FACTORY);
|
hierarchicalShardSyncer, NULL_METRICS_FACTORY, shardFilter);
|
||||||
|
|
||||||
when(shardDetector.listShards()).thenReturn(constructShardListGraphA());
|
when(shardDetector.listShards()).thenReturn(constructShardListGraphA());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue