From 9feff9809bb4279ed638c88b83edaca3ec2fd2d7 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Sat, 9 Jun 2018 20:04:45 -0400 Subject: [PATCH] CCR side of #31213 Relates #31213 --- .../org/elasticsearch/index/engine/InternalEngineTests.java | 4 ++-- .../index/engine/LuceneChangesSnapshotTests.java | 6 +++--- .../java/org/elasticsearch/index/engine/EngineTestCase.java | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index 94c6066080a..647c6c5f7a3 100644 --- a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -1361,7 +1361,7 @@ public class InternalEngineTests extends EngineTestCase { liveDocs.add(doc.id()); } } - long localCheckpoint = engine.getLocalCheckpointTracker().getCheckpoint(); + long localCheckpoint = engine.getLocalCheckpoint(); globalCheckpoint.set(randomLongBetween(0, localCheckpoint)); engine.getTranslog().sync(); engine.forceMerge(true, 1, false, false, false); @@ -1427,7 +1427,7 @@ public class InternalEngineTests extends EngineTestCase { liveDocs.add(doc.id()); } } - long localCheckpoint = engine.getLocalCheckpointTracker().getCheckpoint(); + long localCheckpoint = engine.getLocalCheckpoint(); globalCheckpoint.set(randomLongBetween(0, localCheckpoint)); engine.getTranslog().sync(); long keptIndex = globalCheckpoint.get() + 1 - retainedExtraOps; diff --git a/server/src/test/java/org/elasticsearch/index/engine/LuceneChangesSnapshotTests.java b/server/src/test/java/org/elasticsearch/index/engine/LuceneChangesSnapshotTests.java index ba1d5fb81d0..2e91c473ffe 100644 --- a/server/src/test/java/org/elasticsearch/index/engine/LuceneChangesSnapshotTests.java +++ b/server/src/test/java/org/elasticsearch/index/engine/LuceneChangesSnapshotTests.java @@ -236,8 +236,8 @@ public class LuceneChangesSnapshotTests extends EngineTestCase { } void pullOperations(Engine follower) throws IOException { - long leaderCheckpoint = leader.getLocalCheckpointTracker().getCheckpoint(); - long followerCheckpoint = follower.getLocalCheckpointTracker().getCheckpoint(); + long leaderCheckpoint = leader.getLocalCheckpoint(); + long followerCheckpoint = follower.getLocalCheckpoint(); if (followerCheckpoint < leaderCheckpoint) { long fromSeqNo = followerCheckpoint + 1; long batchSize = randomLongBetween(0, 100); @@ -255,7 +255,7 @@ public class LuceneChangesSnapshotTests extends EngineTestCase { readLatch.countDown(); readLatch.await(); while (isDone.get() == false || - follower.getLocalCheckpointTracker().getCheckpoint() < leader.getLocalCheckpointTracker().getCheckpoint()) { + follower.getLocalCheckpointTracker().getCheckpoint() < leader.getLocalCheckpoint()) { pullOperations(follower); } assertConsistentHistoryBetweenTranslogAndLuceneIndex(follower, mapperService); diff --git a/test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java index 74200149f18..2513b4b1e53 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java @@ -802,7 +802,7 @@ public abstract class EngineTestCase extends ESTestCase { */ public static List readAllOperationsInLucene(Engine engine, MapperService mapper) throws IOException { final List operations = new ArrayList<>(); - long maxSeqNo = Math.max(0, engine.getLocalCheckpointTracker().getMaxSeqNo()); + long maxSeqNo = Math.max(0, ((InternalEngine)engine).getLocalCheckpointTracker().getMaxSeqNo()); try (Translog.Snapshot snapshot = engine.newLuceneChangesSnapshot("test", mapper, 0, maxSeqNo, false)) { Translog.Operation op; while ((op = snapshot.next()) != null){ @@ -838,7 +838,7 @@ public abstract class EngineTestCase extends ESTestCase { .collect(Collectors.toMap(Translog.Operation::seqNo, Function.identity())); final long globalCheckpoint = engine.getTranslog().getLastSyncedGlobalCheckpoint(); final long retainedOps = engine.config().getIndexSettings().getSoftDeleteRetentionOperations(); - final long maxSeqNo = engine.getLocalCheckpointTracker().getMaxSeqNo(); + long maxSeqNo = Math.max(0, ((InternalEngine)engine).getLocalCheckpointTracker().getMaxSeqNo()); for (Translog.Operation translogOp : translogOps.values()) { final Translog.Operation luceneOp = luceneOps.get(translogOp.seqNo()); if (luceneOp == null) {