Skip to content

Commit

Permalink
Refactored code and simplified remote txlog check
Browse files Browse the repository at this point in the history
Signed-off-by: Ashish Singh <ssashish@amazon.com>
  • Loading branch information
ashking94 committed Aug 29, 2022
1 parent 9d5ec82 commit efad86c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3302,6 +3302,13 @@ private boolean isRemoteStoreEnabled() {
return (remoteStore != null && shardRouting.primary());
}

public boolean isRemoteTxlogEnabledOnPrimary() {
return indexSettings != null
&& indexSettings.isSegRepEnabled()
&& indexSettings.isRemoteStoreEnabled()
&& indexSettings.isRemoteTranslogStoreEnabled();
}

/**
* Acquire a primary operation permit whenever the shard is ready for indexing. If a permit is directly available, the provided
* ActionListener will be called on the calling thread. During relocation hand-off, permit acquisition can be delayed. The provided
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.opensearch.OpenSearchTimeoutException;
import org.opensearch.action.ActionListener;
import org.opensearch.action.ActionRunnable;
import org.opensearch.action.support.replication.TransportWriteAction;
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.ClusterStateObserver;
import org.opensearch.cluster.metadata.IndexMetadata;
Expand Down Expand Up @@ -240,7 +239,7 @@ private void doRecovery(final long recoveryId, final StartRecoveryRequest preExi
logger.trace("{} preparing shard for peer recovery", recoveryTarget.shardId());
indexShard.prepareForIndexRecovery();
boolean isRecoveringReplicaWithRemoteTxLogEnabledIndex = recoveryTarget.state().getPrimary() == false
&& TransportWriteAction.IS_REMOTE_TXLOG_ENABLED.apply(indexShard);
&& indexShard.isRemoteTxlogEnabledOnPrimary();
final long startingSeqNo = isRecoveringReplicaWithRemoteTxLogEnabledIndex
? indexShard.fetchStartSeqNoFromLastCommit()
: indexShard.recoverLocallyUpToGlobalCheckpoint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.opensearch.action.support.PlainActionFuture;
import org.opensearch.action.support.ThreadedActionListener;
import org.opensearch.action.support.replication.ReplicationResponse;
import org.opensearch.action.support.replication.TransportWriteAction;
import org.opensearch.cluster.routing.IndexShardRoutingTable;
import org.opensearch.cluster.routing.ShardRouting;
import org.opensearch.common.CheckedRunnable;
Expand Down Expand Up @@ -318,7 +317,7 @@ && isTargetSameHistory()
assert startingSeqNo >= 0 : "startingSeqNo must be non negative. got: " + startingSeqNo;

boolean isRecoveringReplicaWithRemoteTxLogEnabledIndex = request.isPrimaryRelocation() == false
&& TransportWriteAction.IS_REMOTE_TXLOG_ENABLED.apply(shard);
&& shard.isRemoteTxlogEnabledOnPrimary();

if (isRecoveringReplicaWithRemoteTxLogEnabledIndex) {
sendFileStep.whenComplete(r -> {
Expand Down

0 comments on commit efad86c

Please sign in to comment.