Code cleanup to faciliate Checkstyle enforcement. (#1148)
No functional change.
This commit is contained in:
parent
53dbb4ea79
commit
3d6800874c
23 changed files with 101 additions and 77 deletions
|
|
@ -144,7 +144,8 @@ public class ShardRecordProcessorCheckpointer implements RecordProcessorCheckpoi
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PreparedCheckpointer prepareCheckpoint(byte[] applicationState) throws KinesisClientLibDependencyException, InvalidStateException, ThrottlingException, ShutdownException {
|
public PreparedCheckpointer prepareCheckpoint(byte[] applicationState)
|
||||||
|
throws KinesisClientLibDependencyException, InvalidStateException, ThrottlingException, ShutdownException {
|
||||||
return prepareCheckpoint(largestPermittedCheckpointValue.sequenceNumber(), applicationState);
|
return prepareCheckpoint(largestPermittedCheckpointValue.sequenceNumber(), applicationState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,7 +153,8 @@ public class ShardRecordProcessorCheckpointer implements RecordProcessorCheckpoi
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PreparedCheckpointer prepareCheckpoint(Record record, byte[] applicationState) throws KinesisClientLibDependencyException, InvalidStateException, ThrottlingException, ShutdownException {
|
public PreparedCheckpointer prepareCheckpoint(Record record, byte[] applicationState)
|
||||||
|
throws KinesisClientLibDependencyException, InvalidStateException, ThrottlingException, ShutdownException {
|
||||||
//
|
//
|
||||||
// TODO: UserRecord Deprecation
|
// TODO: UserRecord Deprecation
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,8 @@ public class DynamoDBCheckpointer implements Checkpointer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepareCheckpoint(String leaseKey, ExtendedSequenceNumber pendingCheckpoint, String concurrencyToken, byte[] pendingCheckpointState) throws KinesisClientLibException {
|
public void prepareCheckpoint(String leaseKey, ExtendedSequenceNumber pendingCheckpoint, String concurrencyToken,
|
||||||
|
byte[] pendingCheckpointState) throws KinesisClientLibException {
|
||||||
try {
|
try {
|
||||||
boolean wasSuccessful =
|
boolean wasSuccessful =
|
||||||
prepareCheckpoint(leaseKey, pendingCheckpoint, UUID.fromString(concurrencyToken), pendingCheckpointState);
|
prepareCheckpoint(leaseKey, pendingCheckpoint, UUID.fromString(concurrencyToken), pendingCheckpointState);
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,11 @@ import software.amazon.awssdk.services.kinesis.model.HashKeyRange;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
@Value @Accessors(fluent = true)
|
|
||||||
/**
|
/**
|
||||||
* Lease POJO to hold the starting hashkey range and ending hashkey range of kinesis shards.
|
* Lease POJO to hold the starting hashkey range and ending hashkey range of kinesis shards.
|
||||||
*/
|
*/
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@Value
|
||||||
public class HashKeyRangeForLease {
|
public class HashKeyRangeForLease {
|
||||||
|
|
||||||
private final BigInteger startingHashKey;
|
private final BigInteger startingHashKey;
|
||||||
|
|
|
||||||
|
|
@ -417,8 +417,9 @@ class PeriodicShardSyncManager {
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static List<Lease> sortLeasesByHashRange(List<Lease> leasesWithHashKeyRanges) {
|
static List<Lease> sortLeasesByHashRange(List<Lease> leasesWithHashKeyRanges) {
|
||||||
if (leasesWithHashKeyRanges.size() == 0 || leasesWithHashKeyRanges.size() == 1)
|
if (leasesWithHashKeyRanges.size() == 0 || leasesWithHashKeyRanges.size() == 1) {
|
||||||
return leasesWithHashKeyRanges;
|
return leasesWithHashKeyRanges;
|
||||||
|
}
|
||||||
Collections.sort(leasesWithHashKeyRanges, new HashKeyRangeComparator());
|
Collections.sort(leasesWithHashKeyRanges, new HashKeyRangeComparator());
|
||||||
return leasesWithHashKeyRanges;
|
return leasesWithHashKeyRanges;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -544,7 +544,8 @@ public class Scheduler implements Runnable {
|
||||||
final Map<Boolean, Set<StreamIdentifier>> staleStreamIdDeletionDecisionMap = staleStreamDeletionMap.keySet().stream().collect(Collectors
|
final Map<Boolean, Set<StreamIdentifier>> staleStreamIdDeletionDecisionMap = staleStreamDeletionMap.keySet().stream().collect(Collectors
|
||||||
.partitioningBy(newStreamConfigMap::containsKey, Collectors.toSet()));
|
.partitioningBy(newStreamConfigMap::containsKey, Collectors.toSet()));
|
||||||
final Set<StreamIdentifier> staleStreamIdsToBeDeleted = staleStreamIdDeletionDecisionMap.get(false).stream().filter(streamIdentifier ->
|
final Set<StreamIdentifier> staleStreamIdsToBeDeleted = staleStreamIdDeletionDecisionMap.get(false).stream().filter(streamIdentifier ->
|
||||||
Duration.between(staleStreamDeletionMap.get(streamIdentifier), Instant.now()).toMillis() >= waitPeriodToDeleteOldStreams.toMillis()).collect(Collectors.toSet());
|
Duration.between(staleStreamDeletionMap.get(streamIdentifier), Instant.now()).toMillis() >= waitPeriodToDeleteOldStreams.toMillis())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
// These are the streams which are deleted in Kinesis and we encounter resource not found during
|
// These are the streams which are deleted in Kinesis and we encounter resource not found during
|
||||||
// shardSyncTask. This is applicable in MultiStreamMode only, in case of SingleStreamMode, store will
|
// shardSyncTask. This is applicable in MultiStreamMode only, in case of SingleStreamMode, store will
|
||||||
// not have any data.
|
// not have any data.
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ public class HierarchicalShardSyncer {
|
||||||
|
|
||||||
private static final String MIN_HASH_KEY = BigInteger.ZERO.toString();
|
private static final String MIN_HASH_KEY = BigInteger.ZERO.toString();
|
||||||
private static final String MAX_HASH_KEY = new BigInteger("2").pow(128).subtract(BigInteger.ONE).toString();
|
private static final String MAX_HASH_KEY = new BigInteger("2").pow(128).subtract(BigInteger.ONE).toString();
|
||||||
private static final int retriesForCompleteHashRange = 3;
|
private static final int RETRIES_FOR_COMPLETE_HASH_RANGE = 3;
|
||||||
|
|
||||||
private static final long DELAY_BETWEEN_LIST_SHARDS_MILLIS = 1000;
|
private static final long DELAY_BETWEEN_LIST_SHARDS_MILLIS = 1000;
|
||||||
|
|
||||||
|
|
@ -98,7 +98,7 @@ public class HierarchicalShardSyncer {
|
||||||
this.deletedStreamListProvider = deletedStreamListProvider;
|
this.deletedStreamListProvider = deletedStreamListProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final BiFunction<Lease, MultiStreamArgs, String> shardIdFromLeaseDeducer =
|
private static final BiFunction<Lease, MultiStreamArgs, String> SHARD_ID_FROM_LEASE_DEDUCER =
|
||||||
(lease, multiStreamArgs) ->
|
(lease, multiStreamArgs) ->
|
||||||
multiStreamArgs.isMultiStreamMode() ?
|
multiStreamArgs.isMultiStreamMode() ?
|
||||||
((MultiStreamLease) lease).shardId() :
|
((MultiStreamLease) lease).shardId() :
|
||||||
|
|
@ -129,7 +129,9 @@ public class HierarchicalShardSyncer {
|
||||||
isLeaseTableEmpty);
|
isLeaseTableEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Provide a pre-collcted list of shards to avoid calling ListShards API
|
/**
|
||||||
|
* Provide a pre-collected list of shards to avoid calling ListShards API
|
||||||
|
*/
|
||||||
public synchronized boolean checkAndCreateLeaseForNewShards(@NonNull final ShardDetector shardDetector,
|
public synchronized boolean checkAndCreateLeaseForNewShards(@NonNull final ShardDetector shardDetector,
|
||||||
final LeaseRefresher leaseRefresher, final InitialPositionInStreamExtended initialPosition,
|
final LeaseRefresher leaseRefresher, final InitialPositionInStreamExtended initialPosition,
|
||||||
List<Shard> latestShards, final boolean ignoreUnexpectedChildShards, final MetricsScope scope, final boolean isLeaseTableEmpty)
|
List<Shard> latestShards, final boolean ignoreUnexpectedChildShards, final MetricsScope scope, final boolean isLeaseTableEmpty)
|
||||||
|
|
@ -268,7 +270,7 @@ public class HierarchicalShardSyncer {
|
||||||
|
|
||||||
List<Shard> shards;
|
List<Shard> shards;
|
||||||
|
|
||||||
for (int i = 0; i < retriesForCompleteHashRange; i++) {
|
for (int i = 0; i < RETRIES_FOR_COMPLETE_HASH_RANGE; i++) {
|
||||||
shards = shardDetector.listShardsWithFilter(shardFilter);
|
shards = shardDetector.listShardsWithFilter(shardFilter);
|
||||||
|
|
||||||
if (shards == null) {
|
if (shards == null) {
|
||||||
|
|
@ -284,7 +286,7 @@ public class HierarchicalShardSyncer {
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new KinesisClientLibIOException("Hash range of shards returned for " + streamName + " was incomplete after "
|
throw new KinesisClientLibIOException("Hash range of shards returned for " + streamName + " was incomplete after "
|
||||||
+ retriesForCompleteHashRange + " retries.");
|
+ RETRIES_FOR_COMPLETE_HASH_RANGE + " retries.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Shard> getShardList(@NonNull final ShardDetector shardDetector) throws KinesisClientLibIOException {
|
private List<Shard> getShardList(@NonNull final ShardDetector shardDetector) throws KinesisClientLibIOException {
|
||||||
|
|
@ -365,7 +367,8 @@ public class HierarchicalShardSyncer {
|
||||||
* @return List of new leases to create sorted by starting sequenceNumber of the corresponding shard
|
* @return List of new leases to create sorted by starting sequenceNumber of the corresponding shard
|
||||||
*/
|
*/
|
||||||
static List<Lease> determineNewLeasesToCreate(final LeaseSynchronizer leaseSynchronizer, final List<Shard> shards,
|
static List<Lease> determineNewLeasesToCreate(final LeaseSynchronizer leaseSynchronizer, final List<Shard> shards,
|
||||||
final List<Lease> currentLeases, final InitialPositionInStreamExtended initialPosition,final Set<String> inconsistentShardIds) {
|
final List<Lease> currentLeases, final InitialPositionInStreamExtended initialPosition,
|
||||||
|
final Set<String> inconsistentShardIds) {
|
||||||
return determineNewLeasesToCreate(leaseSynchronizer, shards, currentLeases, initialPosition, inconsistentShardIds,
|
return determineNewLeasesToCreate(leaseSynchronizer, shards, currentLeases, initialPosition, inconsistentShardIds,
|
||||||
new MultiStreamArgs(false, null));
|
new MultiStreamArgs(false, null));
|
||||||
}
|
}
|
||||||
|
|
@ -499,11 +502,13 @@ public class HierarchicalShardSyncer {
|
||||||
if (descendantParentShardIds.contains(parentShardId)
|
if (descendantParentShardIds.contains(parentShardId)
|
||||||
&& !initialPosition.getInitialPositionInStream()
|
&& !initialPosition.getInitialPositionInStream()
|
||||||
.equals(InitialPositionInStream.AT_TIMESTAMP)) {
|
.equals(InitialPositionInStream.AT_TIMESTAMP)) {
|
||||||
log.info("Setting Lease '{}' checkpoint to 'TRIM_HORIZON'. Checkpoint was previously set to {}", lease.leaseKey(), lease.checkpoint());
|
log.info("Setting Lease '{}' checkpoint to 'TRIM_HORIZON'. Checkpoint was previously set to {}",
|
||||||
|
lease.leaseKey(), lease.checkpoint());
|
||||||
lease.checkpoint(ExtendedSequenceNumber.TRIM_HORIZON);
|
lease.checkpoint(ExtendedSequenceNumber.TRIM_HORIZON);
|
||||||
} else {
|
} else {
|
||||||
final ExtendedSequenceNumber newCheckpoint = convertToCheckpoint(initialPosition);
|
final ExtendedSequenceNumber newCheckpoint = convertToCheckpoint(initialPosition);
|
||||||
log.info("Setting Lease '{}' checkpoint to '{}'. Checkpoint was previously set to {}", lease.leaseKey(), newCheckpoint, lease.checkpoint());
|
log.info("Setting Lease '{}' checkpoint to '{}'. Checkpoint was previously set to {}",
|
||||||
|
lease.leaseKey(), newCheckpoint, lease.checkpoint());
|
||||||
lease.checkpoint(newCheckpoint);
|
lease.checkpoint(newCheckpoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -728,8 +733,8 @@ public class HierarchicalShardSyncer {
|
||||||
@Override
|
@Override
|
||||||
public int compare(final Lease lease1, final Lease lease2) {
|
public int compare(final Lease lease1, final Lease lease2) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
final String shardId1 = shardIdFromLeaseDeducer.apply(lease1, multiStreamArgs);
|
final String shardId1 = SHARD_ID_FROM_LEASE_DEDUCER.apply(lease1, multiStreamArgs);
|
||||||
final String shardId2 = shardIdFromLeaseDeducer.apply(lease2, multiStreamArgs);
|
final String shardId2 = SHARD_ID_FROM_LEASE_DEDUCER.apply(lease2, multiStreamArgs);
|
||||||
final Shard shard1 = shardIdToShardMap.get(shardId1);
|
final Shard shard1 = shardIdToShardMap.get(shardId1);
|
||||||
final Shard shard2 = shardIdToShardMap.get(shardId2);
|
final Shard shard2 = shardIdToShardMap.get(shardId2);
|
||||||
|
|
||||||
|
|
@ -802,7 +807,7 @@ public class HierarchicalShardSyncer {
|
||||||
final Map<String, Shard> shardIdToShardMapOfAllKinesisShards = constructShardIdToShardMap(shards);
|
final Map<String, Shard> shardIdToShardMapOfAllKinesisShards = constructShardIdToShardMap(shards);
|
||||||
|
|
||||||
currentLeases.stream().peek(lease -> log.debug("{} : Existing lease: {}", streamIdentifier, lease))
|
currentLeases.stream().peek(lease -> log.debug("{} : Existing lease: {}", streamIdentifier, lease))
|
||||||
.map(lease -> shardIdFromLeaseDeducer.apply(lease, multiStreamArgs))
|
.map(lease -> SHARD_ID_FROM_LEASE_DEDUCER.apply(lease, multiStreamArgs))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
final List<Lease> newLeasesToCreate = getLeasesToCreateForOpenAndClosedShards(initialPosition, shards, multiStreamArgs, streamIdentifier);
|
final List<Lease> newLeasesToCreate = getLeasesToCreateForOpenAndClosedShards(initialPosition, shards, multiStreamArgs, streamIdentifier);
|
||||||
|
|
@ -908,7 +913,7 @@ public class HierarchicalShardSyncer {
|
||||||
.map(streamId -> streamId.serialize()).orElse("");
|
.map(streamId -> streamId.serialize()).orElse("");
|
||||||
final Set<String> shardIdsOfCurrentLeases = currentLeases.stream()
|
final Set<String> shardIdsOfCurrentLeases = currentLeases.stream()
|
||||||
.peek(lease -> log.debug("{} : Existing lease: {}", streamIdentifier, lease))
|
.peek(lease -> log.debug("{} : Existing lease: {}", streamIdentifier, lease))
|
||||||
.map(lease -> shardIdFromLeaseDeducer.apply(lease, multiStreamArgs))
|
.map(lease -> SHARD_ID_FROM_LEASE_DEDUCER.apply(lease, multiStreamArgs))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
final List<Shard> openShards = getOpenShards(shards, streamIdentifier);
|
final List<Shard> openShards = getOpenShards(shards, streamIdentifier);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import software.amazon.kinesis.metrics.MetricsUtil;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@KinesisClientInternalApi
|
@KinesisClientInternalApi
|
||||||
public class ShardSyncTask implements ConsumerTask {
|
public class ShardSyncTask implements ConsumerTask {
|
||||||
private final String SHARD_SYNC_TASK_OPERATION = "ShardSyncTask";
|
private static final String SHARD_SYNC_TASK_OPERATION = "ShardSyncTask";
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final ShardDetector shardDetector;
|
private final ShardDetector shardDetector;
|
||||||
|
|
|
||||||
|
|
@ -212,8 +212,10 @@ public class ProcessTask implements ConsumerTask {
|
||||||
log.debug("Calling application processRecords() with {} records from {}", records.size(),
|
log.debug("Calling application processRecords() with {} records from {}", records.size(),
|
||||||
shardInfoId);
|
shardInfoId);
|
||||||
|
|
||||||
final ProcessRecordsInput processRecordsInput = ProcessRecordsInput.builder().records(records).cacheExitTime(input.cacheExitTime()).cacheEntryTime(input.cacheEntryTime())
|
final ProcessRecordsInput processRecordsInput = ProcessRecordsInput.builder().records(records)
|
||||||
.isAtShardEnd(input.isAtShardEnd()).checkpointer(recordProcessorCheckpointer).millisBehindLatest(input.millisBehindLatest()).build();
|
.cacheExitTime(input.cacheExitTime()).cacheEntryTime(input.cacheEntryTime())
|
||||||
|
.isAtShardEnd(input.isAtShardEnd()).checkpointer(recordProcessorCheckpointer)
|
||||||
|
.millisBehindLatest(input.millisBehindLatest()).build();
|
||||||
|
|
||||||
final MetricsScope scope = MetricsUtil.createMetricsWithOperation(metricsFactory, PROCESS_TASK_OPERATION);
|
final MetricsScope scope = MetricsUtil.createMetricsWithOperation(metricsFactory, PROCESS_TASK_OPERATION);
|
||||||
shardInfo.streamIdentifierSerOpt()
|
shardInfo.streamIdentifierSerOpt()
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,6 @@ class ShardConsumerSubscriber implements Subscriber<RecordsRetrieved> {
|
||||||
this.shardInfoId = ShardInfo.getLeaseKey(shardConsumer.shardInfo());
|
this.shardInfoId = ShardInfo.getLeaseKey(shardConsumer.shardInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void startSubscriptions() {
|
void startSubscriptions() {
|
||||||
synchronized (lockObject) {
|
synchronized (lockObject) {
|
||||||
// Setting the lastRequestTime to allow for health checks to restart subscriptions if they failed to
|
// Setting the lastRequestTime to allow for health checks to restart subscriptions if they failed to
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,7 @@ import java.util.Objects;
|
||||||
import software.amazon.awssdk.services.cloudwatch.model.Dimension;
|
import software.amazon.awssdk.services.cloudwatch.model.Dimension;
|
||||||
import software.amazon.awssdk.services.cloudwatch.model.MetricDatum;
|
import software.amazon.awssdk.services.cloudwatch.model.MetricDatum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
/*
|
|
||||||
* A representation of a key of a MetricDatum. This class is useful when wanting to compare
|
* A representation of a key of a MetricDatum. This class is useful when wanting to compare
|
||||||
* whether 2 keys have the same MetricDatum. This feature will be used in MetricAccumulatingQueue
|
* whether 2 keys have the same MetricDatum. This feature will be used in MetricAccumulatingQueue
|
||||||
* where we aggregate metrics across multiple MetricScopes.
|
* where we aggregate metrics across multiple MetricScopes.
|
||||||
|
|
@ -48,12 +46,15 @@ public class CloudWatchMetricKey {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
if (obj == null)
|
}
|
||||||
|
if (obj == null) {
|
||||||
return false;
|
return false;
|
||||||
if (getClass() != obj.getClass())
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
CloudWatchMetricKey other = (CloudWatchMetricKey) obj;
|
CloudWatchMetricKey other = (CloudWatchMetricKey) obj;
|
||||||
return Objects.equals(other.dimensions, dimensions) && Objects.equals(other.metricName, metricName);
|
return Objects.equals(other.dimensions, dimensions) && Objects.equals(other.metricName, metricName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ import java.util.Objects;
|
||||||
*
|
*
|
||||||
* MetricDatumWithKey<SampleMetricKey> sampleDatumWithKey = new MetricDatumWithKey<SampleMetricKey>(new
|
* MetricDatumWithKey<SampleMetricKey> sampleDatumWithKey = new MetricDatumWithKey<SampleMetricKey>(new
|
||||||
* SampleMetricKey(System.currentTimeMillis()), datum)
|
* SampleMetricKey(System.currentTimeMillis()), datum)
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Setter
|
@Setter
|
||||||
|
|
@ -59,12 +58,15 @@ public class MetricDatumWithKey<KeyType> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
if (obj == null)
|
}
|
||||||
|
if (obj == null) {
|
||||||
return false;
|
return false;
|
||||||
if (getClass() != obj.getClass())
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
MetricDatumWithKey<?> other = (MetricDatumWithKey<?>) obj;
|
MetricDatumWithKey<?> other = (MetricDatumWithKey<?>) obj;
|
||||||
return Objects.equals(other.key, key) && Objects.equals(other.datum, datum);
|
return Objects.equals(other.key, key) && Objects.equals(other.datum, datum);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,8 @@ public class FanOutRecordsPublisher implements RecordsPublisher {
|
||||||
if (flow != null && recordsDeliveryAck.batchUniqueIdentifier().getFlowIdentifier()
|
if (flow != null && recordsDeliveryAck.batchUniqueIdentifier().getFlowIdentifier()
|
||||||
.equals(flow.getSubscribeToShardId())) {
|
.equals(flow.getSubscribeToShardId())) {
|
||||||
log.error(
|
log.error(
|
||||||
"{}: Received unexpected ack for the active subscription {}. Throwing. ", streamAndShardId, recordsDeliveryAck.batchUniqueIdentifier().getFlowIdentifier());
|
"{}: Received unexpected ack for the active subscription {}. Throwing.",
|
||||||
|
streamAndShardId, recordsDeliveryAck.batchUniqueIdentifier().getFlowIdentifier());
|
||||||
throw new IllegalStateException("Unexpected ack for the active subscription");
|
throw new IllegalStateException("Unexpected ack for the active subscription");
|
||||||
}
|
}
|
||||||
// Otherwise publisher received a stale ack.
|
// Otherwise publisher received a stale ack.
|
||||||
|
|
@ -335,7 +336,8 @@ public class FanOutRecordsPublisher implements RecordsPublisher {
|
||||||
if (flow != null) {
|
if (flow != null) {
|
||||||
String logMessage = String.format(
|
String logMessage = String.format(
|
||||||
"%s: [SubscriptionLifetime] - (FanOutRecordsPublisher#errorOccurred) @ %s id: %s -- %s." +
|
"%s: [SubscriptionLifetime] - (FanOutRecordsPublisher#errorOccurred) @ %s id: %s -- %s." +
|
||||||
" Last successful request details -- %s", streamAndShardId, flow.connectionStartedAt, flow.subscribeToShardId, category.throwableTypeString, lastSuccessfulRequestDetails);
|
" Last successful request details -- %s", streamAndShardId, flow.connectionStartedAt,
|
||||||
|
flow.subscribeToShardId, category.throwableTypeString, lastSuccessfulRequestDetails);
|
||||||
switch (category.throwableType) {
|
switch (category.throwableType) {
|
||||||
case READ_TIMEOUT:
|
case READ_TIMEOUT:
|
||||||
log.debug(logMessage, propagationThrowable);
|
log.debug(logMessage, propagationThrowable);
|
||||||
|
|
@ -778,7 +780,11 @@ public class FanOutRecordsPublisher implements RecordsPublisher {
|
||||||
executeExceptionOccurred(throwable);
|
executeExceptionOccurred(throwable);
|
||||||
} else {
|
} else {
|
||||||
final SubscriptionShutdownEvent subscriptionShutdownEvent = new SubscriptionShutdownEvent(
|
final SubscriptionShutdownEvent subscriptionShutdownEvent = new SubscriptionShutdownEvent(
|
||||||
() -> {parent.recordsDeliveryQueue.poll(); executeExceptionOccurred(throwable);}, "onError", throwable);
|
() -> {
|
||||||
|
parent.recordsDeliveryQueue.poll();
|
||||||
|
executeExceptionOccurred(throwable);
|
||||||
|
},
|
||||||
|
"onError", throwable);
|
||||||
tryEnqueueSubscriptionShutdownEvent(subscriptionShutdownEvent);
|
tryEnqueueSubscriptionShutdownEvent(subscriptionShutdownEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -786,7 +792,6 @@ public class FanOutRecordsPublisher implements RecordsPublisher {
|
||||||
|
|
||||||
private void executeExceptionOccurred(Throwable throwable) {
|
private void executeExceptionOccurred(Throwable throwable) {
|
||||||
synchronized (parent.lockObject) {
|
synchronized (parent.lockObject) {
|
||||||
|
|
||||||
log.debug("{}: [SubscriptionLifetime]: (RecordFlow#exceptionOccurred) @ {} id: {} -- {}: {}",
|
log.debug("{}: [SubscriptionLifetime]: (RecordFlow#exceptionOccurred) @ {} id: {} -- {}: {}",
|
||||||
parent.streamAndShardId, connectionStartedAt, subscribeToShardId, throwable.getClass().getName(),
|
parent.streamAndShardId, connectionStartedAt, subscribeToShardId, throwable.getClass().getName(),
|
||||||
throwable.getMessage());
|
throwable.getMessage());
|
||||||
|
|
@ -817,7 +822,11 @@ public class FanOutRecordsPublisher implements RecordsPublisher {
|
||||||
executeComplete();
|
executeComplete();
|
||||||
} else {
|
} else {
|
||||||
final SubscriptionShutdownEvent subscriptionShutdownEvent = new SubscriptionShutdownEvent(
|
final SubscriptionShutdownEvent subscriptionShutdownEvent = new SubscriptionShutdownEvent(
|
||||||
() -> {parent.recordsDeliveryQueue.poll(); executeComplete();}, "onComplete");
|
() -> {
|
||||||
|
parent.recordsDeliveryQueue.poll();
|
||||||
|
executeComplete();
|
||||||
|
},
|
||||||
|
"onComplete");
|
||||||
tryEnqueueSubscriptionShutdownEvent(subscriptionShutdownEvent);
|
tryEnqueueSubscriptionShutdownEvent(subscriptionShutdownEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue