From 7f2012871caa81a8a821855adde3e0aea6a02354 Mon Sep 17 00:00:00 2001 From: Kartik Ganesh Date: Mon, 14 Mar 2022 10:25:53 -0700 Subject: [PATCH] Renaming replication listener classes The ReplicationListener class has been renamed to SegmentReplicationListener, and the parent class now takes the more-generic ReplicationListener name. The inner classes in IndicesClusterStateService have also been renamed to ShardRouting* to reflect their purpose. Signed-off-by: Kartik Ganesh --- .../org/opensearch/index/shard/IndexShard.java | 8 ++++---- .../org/opensearch/indices/IndicesService.java | 4 ++-- .../cluster/IndicesClusterStateService.java | 14 +++++++------- .../recovery/PeerRecoveryTargetService.java | 4 ++-- .../SegmentReplicationReplicaService.java | 6 +++--- .../{RListener.java => ReplicationListener.java} | 2 +- .../replication/common/ReplicationTarget.java | 4 ++-- .../replication/copy/ReplicationCollection.java | 2 +- .../replication/copy/SegmentReplicationTarget.java | 2 +- ...AbstractIndicesClusterStateServiceTestCase.java | 2 +- 10 files changed, 24 insertions(+), 24 deletions(-) rename server/src/main/java/org/opensearch/indices/replication/common/{RListener.java => ReplicationListener.java} (91%) diff --git a/server/src/main/java/org/opensearch/index/shard/IndexShard.java b/server/src/main/java/org/opensearch/index/shard/IndexShard.java index 7720103085669..ed2558dee2fef 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShard.java @@ -3040,7 +3040,7 @@ protected Engine getEngineOrNull() { public void startRecovery( RecoveryState recoveryState, SegmentReplicationReplicaService segmentReplicationReplicaService, - SegmentReplicationReplicaService.ReplicationListener replicationListener, + SegmentReplicationReplicaService.SegmentReplicationListener segRepListener, PrimaryShardReplicationSource replicationSource, PeerRecoveryTargetService peerRecoveryTargetService, PeerRecoveryTargetService.RecoveryListener recoveryListener, @@ -3082,7 +3082,7 @@ public void startRecovery( new ActionListener() { @Override public void onResponse(TrackShardResponse unused) { - replicationListener.onReplicationDone(replicationState); + segRepListener.onReplicationDone(replicationState); recoveryState.getIndex().setFileDetailsComplete(); finalizeRecovery(); postRecovery("Shard setup complete."); @@ -3090,7 +3090,7 @@ public void onResponse(TrackShardResponse unused) { @Override public void onFailure(Exception e) { - replicationListener.onReplicationFailure( + segRepListener.onReplicationFailure( replicationState, new ReplicationFailedException(indexShard, e), true @@ -3748,7 +3748,7 @@ public synchronized void onNewCheckpoint( checkpoint, this, source, - new SegmentReplicationReplicaService.ReplicationListener() { + new SegmentReplicationReplicaService.SegmentReplicationListener() { @Override public void onReplicationDone(ReplicationState state) { markReplicationComplete(); diff --git a/server/src/main/java/org/opensearch/indices/IndicesService.java b/server/src/main/java/org/opensearch/indices/IndicesService.java index 2fb399b84153a..6f05de5aa3609 100644 --- a/server/src/main/java/org/opensearch/indices/IndicesService.java +++ b/server/src/main/java/org/opensearch/indices/IndicesService.java @@ -838,7 +838,7 @@ public synchronized void verifyIndexMetadata(IndexMetadata metadata, IndexMetada public IndexShard createShard( final ShardRouting shardRouting, final SegmentReplicationReplicaService segmentReplicationReplicaService, - final SegmentReplicationReplicaService.ReplicationListener replicationListener, + final SegmentReplicationReplicaService.SegmentReplicationListener segRepListener, final PrimaryShardReplicationSource replicationSource, final PeerRecoveryTargetService recoveryTargetService, final PeerRecoveryTargetService.RecoveryListener recoveryListener, @@ -859,7 +859,7 @@ public IndexShard createShard( indexShard.startRecovery( recoveryState, segmentReplicationReplicaService, - replicationListener, + segRepListener, replicationSource, recoveryTargetService, recoveryListener, diff --git a/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java b/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java index b28488b9f554d..88c60010ddfdb 100644 --- a/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java +++ b/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java @@ -630,10 +630,10 @@ private void createShard(DiscoveryNodes nodes, RoutingTable routingTable, ShardR indicesService.createShard( shardRouting, segmentReplicationReplicaService, - new ReplicationListener(shardRouting, primaryTerm), + new ShardRoutingReplicationListener(shardRouting, primaryTerm), replicationSource, recoveryTargetService, - new RecoveryListener(shardRouting, primaryTerm), + new ShardRoutingRecoveryListener(shardRouting, primaryTerm), repositoriesService, failedShardHandler, globalCheckpointSyncer, @@ -748,7 +748,7 @@ private static DiscoveryNode findSourceNodeForPeerRecovery( return sourceNode; } - private class ReplicationListener implements SegmentReplicationReplicaService.ReplicationListener { + private class ShardRoutingReplicationListener implements SegmentReplicationReplicaService.SegmentReplicationListener { /** * ShardRouting with which the shard was created @@ -760,7 +760,7 @@ private class ReplicationListener implements SegmentReplicationReplicaService.Re */ private final long primaryTerm; - private ReplicationListener(final ShardRouting shardRouting, final long primaryTerm) { + private ShardRoutingReplicationListener(final ShardRouting shardRouting, final long primaryTerm) { this.shardRouting = shardRouting; this.primaryTerm = primaryTerm; } @@ -778,7 +778,7 @@ public void onReplicationFailure(ReplicationState state, ReplicationFailedExcept } } - private class RecoveryListener implements PeerRecoveryTargetService.RecoveryListener { + private class ShardRoutingRecoveryListener implements PeerRecoveryTargetService.RecoveryListener { /** * ShardRouting with which the shard was created @@ -790,7 +790,7 @@ private class RecoveryListener implements PeerRecoveryTargetService.RecoveryList */ private final long primaryTerm; - private RecoveryListener(final ShardRouting shardRouting, final long primaryTerm) { + private ShardRoutingRecoveryListener(final ShardRouting shardRouting, final long primaryTerm) { this.shardRouting = shardRouting; this.primaryTerm = primaryTerm; } @@ -1028,7 +1028,7 @@ U createIndex(IndexMetadata indexMetadata, List builtInIndex T createShard( ShardRouting shardRouting, SegmentReplicationReplicaService replicaService, - SegmentReplicationReplicaService.ReplicationListener replicationListener, + SegmentReplicationReplicaService.SegmentReplicationListener segRepListener, PrimaryShardReplicationSource replicationSource, PeerRecoveryTargetService recoveryTargetService, PeerRecoveryTargetService.RecoveryListener recoveryListener, diff --git a/server/src/main/java/org/opensearch/indices/recovery/PeerRecoveryTargetService.java b/server/src/main/java/org/opensearch/indices/recovery/PeerRecoveryTargetService.java index d19069634218d..59246d03beda5 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/PeerRecoveryTargetService.java +++ b/server/src/main/java/org/opensearch/indices/recovery/PeerRecoveryTargetService.java @@ -70,7 +70,7 @@ import org.opensearch.index.translog.Translog; import org.opensearch.index.translog.TranslogCorruptedException; import org.opensearch.indices.recovery.RecoveriesCollection.RecoveryRef; -import org.opensearch.indices.replication.common.RListener; +import org.opensearch.indices.replication.common.ReplicationListener; import org.opensearch.indices.replication.common.RState; import org.opensearch.tasks.Task; import org.opensearch.threadpool.ThreadPool; @@ -351,7 +351,7 @@ public static StartRecoveryRequest getStartRecoveryRequest( return request; } - public interface RecoveryListener extends RListener { + public interface RecoveryListener extends ReplicationListener { @Override default void onDone(RState state) { diff --git a/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationReplicaService.java b/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationReplicaService.java index 7483f07165bb0..aa8df620f1412 100644 --- a/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationReplicaService.java +++ b/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationReplicaService.java @@ -36,7 +36,7 @@ import org.opensearch.indices.recovery.DelayRecoveryException; import org.opensearch.indices.recovery.RecoverySettings; import org.opensearch.indices.recovery.Timer; -import org.opensearch.indices.replication.common.RListener; +import org.opensearch.indices.replication.common.ReplicationListener; import org.opensearch.indices.replication.common.RState; import org.opensearch.indices.replication.copy.PrimaryShardReplicationSource; import org.opensearch.indices.replication.copy.ReplicationCheckpoint; @@ -161,7 +161,7 @@ public void startReplication( final ReplicationCheckpoint checkpoint, final IndexShard indexShard, PrimaryShardReplicationSource source, - final ReplicationListener listener + final SegmentReplicationListener listener ) { final long replicationId = onGoingReplications.startReplication( checkpoint, @@ -288,7 +288,7 @@ public void onFailure(Exception e) { } } - public interface ReplicationListener extends RListener { + public interface SegmentReplicationListener extends ReplicationListener { @Override default void onDone(RState state) { diff --git a/server/src/main/java/org/opensearch/indices/replication/common/RListener.java b/server/src/main/java/org/opensearch/indices/replication/common/ReplicationListener.java similarity index 91% rename from server/src/main/java/org/opensearch/indices/replication/common/RListener.java rename to server/src/main/java/org/opensearch/indices/replication/common/ReplicationListener.java index 44d813d952bfb..4c5d20580d113 100644 --- a/server/src/main/java/org/opensearch/indices/replication/common/RListener.java +++ b/server/src/main/java/org/opensearch/indices/replication/common/ReplicationListener.java @@ -10,7 +10,7 @@ import org.opensearch.OpenSearchException; -public interface RListener { +public interface ReplicationListener { void onDone(RState state); diff --git a/server/src/main/java/org/opensearch/indices/replication/common/ReplicationTarget.java b/server/src/main/java/org/opensearch/indices/replication/common/ReplicationTarget.java index 3e18239ea0aaf..9a4b26300d16c 100644 --- a/server/src/main/java/org/opensearch/indices/replication/common/ReplicationTarget.java +++ b/server/src/main/java/org/opensearch/indices/replication/common/ReplicationTarget.java @@ -38,7 +38,7 @@ public abstract class ReplicationTarget extends AbstractRefCounted { protected final AtomicBoolean finished = new AtomicBoolean(); protected final IndexShard indexShard; protected final Store store; - protected final RListener listener; + protected final ReplicationListener listener; protected final MultiFileWriter multiFileWriter; protected final Logger logger; protected final RecoveryState.Index recoveryStateIndex; @@ -53,7 +53,7 @@ public abstract class ReplicationTarget extends AbstractRefCounted { public abstract RState state(); - public ReplicationTarget(String name, IndexShard indexShard, RecoveryState.Index recoveryStateIndex, RListener listener) { + public ReplicationTarget(String name, IndexShard indexShard, RecoveryState.Index recoveryStateIndex, ReplicationListener listener) { super(name); this.logger = Loggers.getLogger(getClass(), indexShard.shardId()); this.listener = listener; diff --git a/server/src/main/java/org/opensearch/indices/replication/copy/ReplicationCollection.java b/server/src/main/java/org/opensearch/indices/replication/copy/ReplicationCollection.java index d24d077843f6b..76094cd1672af 100644 --- a/server/src/main/java/org/opensearch/indices/replication/copy/ReplicationCollection.java +++ b/server/src/main/java/org/opensearch/indices/replication/copy/ReplicationCollection.java @@ -75,7 +75,7 @@ public long startReplication( ReplicationCheckpoint checkpoint, IndexShard indexShard, PrimaryShardReplicationSource source, - SegmentReplicationReplicaService.ReplicationListener listener, + SegmentReplicationReplicaService.SegmentReplicationListener listener, TimeValue activityTimeout ) { SegmentReplicationTarget replicationTarget = new SegmentReplicationTarget(checkpoint, indexShard, source, listener); diff --git a/server/src/main/java/org/opensearch/indices/replication/copy/SegmentReplicationTarget.java b/server/src/main/java/org/opensearch/indices/replication/copy/SegmentReplicationTarget.java index 5fbc8fd8f82bd..613125b3aee1a 100644 --- a/server/src/main/java/org/opensearch/indices/replication/copy/SegmentReplicationTarget.java +++ b/server/src/main/java/org/opensearch/indices/replication/copy/SegmentReplicationTarget.java @@ -77,7 +77,7 @@ public SegmentReplicationTarget( ReplicationCheckpoint checkpoint, IndexShard indexShard, PrimaryShardReplicationSource source, - SegmentReplicationReplicaService.ReplicationListener listener + SegmentReplicationReplicaService.SegmentReplicationListener listener ) { super("replication_status", indexShard, new RecoveryState.Index(), listener); this.checkpoint = checkpoint; diff --git a/server/src/test/java/org/opensearch/indices/cluster/AbstractIndicesClusterStateServiceTestCase.java b/server/src/test/java/org/opensearch/indices/cluster/AbstractIndicesClusterStateServiceTestCase.java index 2c88b99e4ecea..278c8c3408adc 100644 --- a/server/src/test/java/org/opensearch/indices/cluster/AbstractIndicesClusterStateServiceTestCase.java +++ b/server/src/test/java/org/opensearch/indices/cluster/AbstractIndicesClusterStateServiceTestCase.java @@ -255,7 +255,7 @@ public MockIndexService indexService(Index index) { public MockIndexShard createShard( final ShardRouting shardRouting, final SegmentReplicationReplicaService replicaService, - final SegmentReplicationReplicaService.ReplicationListener replicationListener, + final SegmentReplicationReplicaService.SegmentReplicationListener segRepListener, final PrimaryShardReplicationSource replicationSource, final PeerRecoveryTargetService recoveryTargetService, final PeerRecoveryTargetService.RecoveryListener recoveryListener,