Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
Signed-off-by: Poojita Raj <[email protected]>
  • Loading branch information
Poojita-Raj committed May 17, 2022
1 parent d7fc756 commit b84c184
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import org.opensearch.indices.recovery.PeerRecoveryTargetService;
import org.opensearch.indices.recovery.RecoveryListener;
import org.opensearch.indices.recovery.RecoveryState;
import org.opensearch.indices.replication.common.ReplicationState;
import org.opensearch.repositories.RepositoriesService;
import org.opensearch.search.SearchService;
import org.opensearch.snapshots.SnapshotShardsService;
Expand Down Expand Up @@ -204,18 +205,6 @@ public IndicesClusterStateService(
this.sendRefreshMapping = settings.getAsBoolean("indices.cluster.send_refresh_mapping", true);
}

public ShardStateAction getShardStateAction() {
return shardStateAction;
}

public ClusterService getClusterService() {
return clusterService;
}

public ActionListener<Void> getShardStateActionListener() {
return SHARD_STATE_ACTION_LISTENER;
}

@Override
protected void doStart() {
// Doesn't make sense to manage shards on non-master and non-data nodes
Expand Down Expand Up @@ -756,6 +745,11 @@ public synchronized void handleRecoveryFailure(ShardRouting shardRouting, boolea
failAndRemoveShard(shardRouting, sendShardFailure, "failed recovery", failure, clusterService.state());
}

public void handleRecoveryDone(ReplicationState state, ShardRouting shardRouting, long primaryTerm) {
RecoveryState RecState = (RecoveryState) state;
shardStateAction.shardStarted(shardRouting, primaryTerm, "after " + RecState.getRecoverySource(), SHARD_STATE_ACTION_LISTENER);
}

private void failAndRemoveShard(
ShardRouting shardRouting,
boolean sendShardFailure,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public long startRecovery(IndexShard indexShard, DiscoveryNode sourceNode, Repli

private void startRecoveryInternal(RecoveryTarget recoveryTarget, TimeValue activityTimeout) {
RecoveryTarget existingTarget = onGoingRecoveries.putIfAbsent(recoveryTarget.getId(), recoveryTarget);
assert existingTarget == null : "found two RecoveryStatus instances with the same id";
assert existingTarget == null : "found two RecoveryTarget instances with the same id";
logger.trace(
"{} started recovery from {}, id [{}]",
recoveryTarget.indexShard().shardId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,7 @@ public RecoveryListener(

@Override
public void onDone(ReplicationState state) {
RecoveryState RecState = (RecoveryState) state;
indicesClusterStateService.getShardStateAction()
.shardStarted(
shardRouting,
primaryTerm,
"after " + RecState.getRecoverySource(),
indicesClusterStateService.getShardStateActionListener()
);
indicesClusterStateService.handleRecoveryDone(state, shardRouting, primaryTerm);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ public void fail(OpenSearchException e, boolean sendShardFailure) {

protected void ensureRefCount() {
if (refCount() <= 0) {
throw new OpenSearchException("RecoveryStatus is used but it's refcount is 0. Probably a mismatch between incRef/decRef calls");
throw new OpenSearchException(
"ReplicationTarget is used but it's refcount is 0. Probably a mismatch between incRef/decRef calls"
);
}
}

Expand Down

0 comments on commit b84c184

Please sign in to comment.