Skip to content

Commit

Permalink
Pass global checkpoint supplier on open translog
Browse files Browse the repository at this point in the history
This commit modifies the signature of InternalEngine#openTranslog to
feed through the global checkpoint supplier down to the opening of the
translog.
  • Loading branch information
jasontedor committed Nov 7, 2016
1 parent 86ec4d0 commit 6cbed98
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Function;
import java.util.function.LongSupplier;

public class InternalEngine extends Engine {

Expand Down Expand Up @@ -169,7 +170,7 @@ public InternalEngine(EngineConfig engineConfig) throws EngineException {
seqNoStats.getLocalCheckpoint(),
seqNoStats.getGlobalCheckpoint());
indexWriter = writer;
translog = openTranslog(engineConfig, writer);
translog = openTranslog(engineConfig, writer, seqNoService::getGlobalCheckpoint);
assert translog.getGeneration() != null;
} catch (IOException | TranslogCorruptedException e) {
throw new EngineCreationFailureException(shardId, "failed to create engine", e);
Expand Down Expand Up @@ -257,9 +258,8 @@ private void recoverFromTranslog(TranslogRecoveryPerformer handler) throws IOExc
}
}

private Translog openTranslog(EngineConfig engineConfig, IndexWriter writer) throws IOException {
private Translog openTranslog(EngineConfig engineConfig, IndexWriter writer, LongSupplier globalCheckpointSupplier) throws IOException {
assert openMode != null;
assert seqNoService != null;
final TranslogConfig translogConfig = engineConfig.getTranslogConfig();
Translog.TranslogGeneration generation = null;
if (openMode == EngineConfig.OpenMode.OPEN_INDEX_AND_TRANSLOG) {
Expand All @@ -272,7 +272,7 @@ private Translog openTranslog(EngineConfig engineConfig, IndexWriter writer) thr
throw new IndexFormatTooOldException("trasnlog", "translog has no generation nor a UUID - this might be an index from a previous version consider upgrading to N-1 first");
}
}
final Translog translog = new Translog(translogConfig, generation, seqNoService::getGlobalCheckpoint);
final Translog translog = new Translog(translogConfig, generation, globalCheckpointSupplier);
if (generation == null || generation.translogUUID == null) {
assert openMode != EngineConfig.OpenMode.OPEN_INDEX_AND_TRANSLOG : "OpenMode must not be "
+ EngineConfig.OpenMode.OPEN_INDEX_AND_TRANSLOG;
Expand Down

0 comments on commit 6cbed98

Please sign in to comment.