Skip to content

Commit

Permalink
Renaming replication listener classes
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
kartg committed Mar 14, 2022
1 parent 97d02fd commit 7f20128
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -3082,15 +3082,15 @@ public void startRecovery(
new ActionListener<TrackShardResponse>() {
@Override
public void onResponse(TrackShardResponse unused) {
replicationListener.onReplicationDone(replicationState);
segRepListener.onReplicationDone(replicationState);
recoveryState.getIndex().setFileDetailsComplete();
finalizeRecovery();
postRecovery("Shard setup complete.");
}

@Override
public void onFailure(Exception e) {
replicationListener.onReplicationFailure(
segRepListener.onReplicationFailure(
replicationState,
new ReplicationFailedException(indexShard, e),
true
Expand Down Expand Up @@ -3748,7 +3748,7 @@ public synchronized void onNewCheckpoint(
checkpoint,
this,
source,
new SegmentReplicationReplicaService.ReplicationListener() {
new SegmentReplicationReplicaService.SegmentReplicationListener() {
@Override
public void onReplicationDone(ReplicationState state) {
markReplicationComplete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -859,7 +859,7 @@ public IndexShard createShard(
indexShard.startRecovery(
recoveryState,
segmentReplicationReplicaService,
replicationListener,
segRepListener,
replicationSource,
recoveryTargetService,
recoveryListener,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -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
Expand All @@ -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;
}
Expand Down Expand Up @@ -1028,7 +1028,7 @@ U createIndex(IndexMetadata indexMetadata, List<IndexEventListener> builtInIndex
T createShard(
ShardRouting shardRouting,
SegmentReplicationReplicaService replicaService,
SegmentReplicationReplicaService.ReplicationListener replicationListener,
SegmentReplicationReplicaService.SegmentReplicationListener segRepListener,
PrimaryShardReplicationSource replicationSource,
PeerRecoveryTargetService recoveryTargetService,
PeerRecoveryTargetService.RecoveryListener recoveryListener,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import org.opensearch.OpenSearchException;

public interface RListener {
public interface ReplicationListener {

void onDone(RState state);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7f20128

Please sign in to comment.