Skip to content

Commit

Permalink
Remove redundant code
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <kalsac@amazon.com>
  • Loading branch information
Sachin Kale committed Feb 21, 2023
1 parent 3f3bfc6 commit 9b3a4f0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1093,12 +1093,8 @@ public long getAsLong() {
* @param reason the reason the global checkpoint was updated
*/
public synchronized void updateGlobalCheckpointOnReplica(final long newGlobalCheckpoint, final String reason) {
assert primaryMode == false;
updateGlobalCheckpoint(newGlobalCheckpoint, reason);
}

public synchronized void updateGlobalCheckpoint(final long newGlobalCheckpoint, final String reason) {
assert invariant();
assert primaryMode == false;
/*
* The global checkpoint here is a local knowledge which is updated under the mandate of the primary. It can happen that the primary
* information is lagging compared to a replica (e.g., if a replica is promoted to primary but has stale info relative to other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ public RemoteFsTranslog(
try {
download(translogTransferManager, location);
Checkpoint checkpoint = readCheckpoint(location);
assert globalCheckpointSupplier instanceof ReplicationTracker
: "globalCheckpointSupplier is not instance of ReplicationTracker";
((ReplicationTracker) globalCheckpointSupplier).updateGlobalCheckpoint(checkpoint.globalCheckpoint, "RemoteFsTranslog init");
this.readers.addAll(recoverFromFiles(checkpoint));
if (readers.isEmpty()) {
throw new IllegalStateException("at least one reader must be recovered");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@
import org.opensearch.env.TestEnvironment;
import org.opensearch.index.IndexSettings;
import org.opensearch.index.engine.MissingHistoryOperationsException;
import org.opensearch.index.engine.SafeCommitInfo;
import org.opensearch.index.seqno.LocalCheckpointTracker;
import org.opensearch.index.seqno.LocalCheckpointTrackerTests;
import org.opensearch.index.seqno.ReplicationTracker;
import org.opensearch.index.seqno.SequenceNumbers;
import org.opensearch.index.shard.ShardId;
import org.opensearch.index.translog.transfer.BlobStoreTransferService;
Expand Down Expand Up @@ -95,7 +93,6 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.opensearch.common.util.BigArrays.NON_RECYCLING_INSTANCE;
import static org.opensearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO;
import static org.opensearch.index.translog.SnapshotMatchers.containsOperationsInAnyOrder;
import static org.opensearch.index.translog.TranslogDeletionPolicies.createTranslogDeletionPolicy;

Expand All @@ -106,7 +103,7 @@ public class RemoteFSTranslogTests extends OpenSearchTestCase {
protected final ShardId shardId = new ShardId("index", "_na_", 1);

protected RemoteFsTranslog translog;
private ReplicationTracker replicationTracker;
private AtomicLong globalCheckpoint;
protected Path translogDir;
// A default primary term is used by translog instances created in this test.
private final AtomicLong primaryTerm = new AtomicLong();
Expand Down Expand Up @@ -158,17 +155,7 @@ private RemoteFsTranslog create(Path path) throws IOException {

private RemoteFsTranslog create(Path path, BlobStoreRepository repository, String translogUUID) throws IOException {
this.repository = repository;
replicationTracker = new ReplicationTracker(
shardId,
translogUUID,
IndexSettingsModule.newIndexSettings("index", Settings.EMPTY),
primaryTerm.get(),
UNASSIGNED_SEQ_NO,
value -> {},
System::currentTimeMillis,
(leases, listener) -> {},
() -> SafeCommitInfo.EMPTY
);
globalCheckpoint = new AtomicLong(SequenceNumbers.NO_OPS_PERFORMED);
final TranslogConfig translogConfig = getTranslogConfig(path);
final TranslogDeletionPolicy deletionPolicy = createTranslogDeletionPolicy(translogConfig.getIndexSettings());
threadPool = new TestThreadPool(getClass().getName());
Expand All @@ -177,7 +164,7 @@ private RemoteFsTranslog create(Path path, BlobStoreRepository repository, Strin
translogConfig,
translogUUID,
deletionPolicy,
replicationTracker,
() -> globalCheckpoint.get(),
primaryTerm::get,
getPersistedSeqNoConsumer(),
repository,
Expand Down Expand Up @@ -1272,7 +1259,7 @@ public int write(ByteBuffer src) throws IOException {
config,
translogUUID,
new DefaultTranslogDeletionPolicy(-1, -1, 0),
replicationTracker,
() -> SequenceNumbers.NO_OPS_PERFORMED,
primaryTerm::get,
persistedSeqNos::add,
repository,
Expand Down

0 comments on commit 9b3a4f0

Please sign in to comment.