Package org.elasticsearch.index.engine
Class InternalEngine
- java.lang.Object
-
- org.elasticsearch.index.engine.Engine
-
- org.elasticsearch.index.engine.InternalEngine
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class InternalEngine extends Engine
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
InternalEngine.DeletionStrategy
protected static class
InternalEngine.IndexingStrategy
-
Nested classes/interfaces inherited from class org.elasticsearch.index.engine.Engine
Engine.CommitId, Engine.Delete, Engine.DeleteResult, Engine.EventListener, Engine.Get, Engine.GetResult, Engine.Index, Engine.IndexCommitRef, Engine.IndexResult, Engine.IndexThrottle, Engine.NoOp, Engine.NoOpLock, Engine.NoOpResult, Engine.Operation, Engine.Result, Engine.Searcher, Engine.SearcherScope, Engine.SyncedFlushResult, Engine.TranslogRecoveryRunner, Engine.Warmer
-
-
Field Summary
-
Fields inherited from class org.elasticsearch.index.engine.Engine
allocationId, engineConfig, eventListener, failedEngine, failEngineLock, HISTORY_UUID_KEY, isClosed, lastWriteNanos, logger, MAX_UNSAFE_AUTO_ID_TIMESTAMP_COMMIT_ID, MIN_RETAINED_SEQNO, readLock, rwl, shardId, store, SYNC_COMMIT_ID, writeLock
-
-
Constructor Summary
Constructors Constructor Description InternalEngine(EngineConfig engineConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Engine.IndexCommitRef
acquireLastIndexCommit(boolean flushFirst)
Snapshots the most recent index and returns a handle to it.java.io.Closeable
acquireRetentionLockForPeerRecovery()
Acquires a lock on the translog files and Lucene soft-deleted documents to prevent them from being trimmedEngine.IndexCommitRef
acquireSafeIndexCommit()
Snapshots the most recent safe index commit from the engine.void
activateThrottling()
Request that this engine throttle incoming indexing requests to one thread.protected boolean
assertNonPrimaryOrigin(Engine.Operation operation)
protected boolean
assertPrimaryCanOptimizeAddDocument(Engine.Index index)
protected boolean
assertPrimaryIncomingSequenceNumber(Engine.Operation.Origin origin, long seqNo)
protected void
closeNoLock(java.lang.String reason, java.util.concurrent.CountDownLatch closedLatch)
Closes the engine without acquiring the write lock.protected void
commitIndexWriter(org.apache.lucene.index.IndexWriter writer, Translog translog, java.lang.String syncId)
Commits the specified index writer.void
deactivateThrottling()
Reverses a previousEngine.activateThrottling()
call.Engine.DeleteResult
delete(Engine.Delete delete)
Perform document delete operation on the engineprotected InternalEngine.DeletionStrategy
deletionStrategyForOperation(Engine.Delete delete)
boolean
ensureTranslogSynced(java.util.stream.Stream<Translog.Location> locations)
Ensures that all locations in the given stream have been written to the underlying storage.int
estimateNumberOfHistoryOperations(java.lang.String source, MapperService mapperService, long startingSeqNo)
Returns the estimated number of history operations whose seq# at least the provided seq# in this engine.int
fillSeqNoGaps(long primaryTerm)
Fills up the local checkpoints history with no-ops until the local checkpoint and the max seen sequence ID are identical.Engine.CommitId
flush(boolean force, boolean waitIfOngoing)
Flushes the state of the engine including the transaction log, clearing memory.void
forceMerge(boolean flush, int maxNumSegments, boolean onlyExpungeDeletes, boolean upgrade, boolean upgradeOnlyAncientSegments)
Triggers a forced merge on this engineEngine.GetResult
get(Engine.Get get, java.util.function.BiFunction<java.lang.String,Engine.SearcherScope,Engine.Searcher> searcherFactory)
java.lang.String
getHistoryUUID()
returns the history uuid for the enginelong
getIndexBufferRAMBytesUsed()
How much heap is used that would be freed by a refresh.long
getIndexThrottleTimeInMillis()
Returns the number of milliseconds this engine was under index throttling.protected org.apache.lucene.index.SegmentInfos
getLastCommittedSegmentInfos()
long
getLastSyncedGlobalCheckpoint()
Returns the latest global checkpoint value that has been persisted in the underlying storage (i.e.long
getLocalCheckpoint()
long
getMaxSeenAutoIdTimestamp()
Returns the maximum auto_id_timestamp of all append-only index requests have been processed by this engine or the auto_id_timestamp received from its primary shard viaEngine.updateMaxUnsafeAutoIdTimestamp(long)
.MergeStats
getMergeStats()
protected org.apache.lucene.search.ReferenceManager<org.apache.lucene.search.IndexSearcher>
getReferenceManager(Engine.SearcherScope scope)
SeqNoStats
getSeqNoStats(long globalCheckpoint)
Translog.Location
getTranslogLastWriteLocation()
Returns the last location that the translog of this engine has written into.TranslogStats
getTranslogStats()
long
getWritingBytes()
Returns how many bytes we are currently moving from indexing buffer to segments on diskprotected boolean
hasBeenProcessedBefore(Engine.Operation op)
Checks if the given operation has been processed in this engine or not.boolean
hasCompleteOperationHistory(java.lang.String source, MapperService mapperService, long startingSeqNo)
Checks if this engine has every operations sincestartingSeqNo
(inclusive) in its history (either Lucene or translog)Engine.IndexResult
index(Engine.Index index)
Perform document index operation on the engineprotected InternalEngine.IndexingStrategy
indexingStrategyForOperation(Engine.Index index)
void
initializeMaxSeqNoOfUpdatesOrDeletes()
A primary shard calls this method once to initialize the max_seq_no_of_updates marker using the max_seq_no from Lucene index and translog before replaying the local translog in its local recovery.boolean
isRecovering()
Returnstrue
iff this engine is currently recovering from translog.boolean
isThrottled()
Returns thetrue
iff this engine is currently under index throttling.boolean
isTranslogSyncNeeded()
Checks if the underlying storage sync is required.protected boolean
maybeFailEngine(java.lang.String source, java.lang.Exception e)
Check whether the engine should be failedvoid
maybePruneDeletes()
Tries to prune buffered deletes from the version map.Translog.Snapshot
newChangesSnapshot(java.lang.String source, MapperService mapperService, long fromSeqNo, long toSeqNo, boolean requiredFullRange)
Creates a new history snapshot from Lucene for reading operations whose seqno in the requesting seqno range (both inclusive)Engine.NoOpResult
noOp(Engine.NoOp noOp)
void
onSettingsChanged()
protected InternalEngine.DeletionStrategy
planDeletionAsNonPrimary(Engine.Delete delete)
protected InternalEngine.DeletionStrategy
planDeletionAsPrimary(Engine.Delete delete)
protected InternalEngine.IndexingStrategy
planIndexingAsNonPrimary(Engine.Index index)
protected InternalEngine.IndexingStrategy
planIndexingAsPrimary(Engine.Index index)
protected java.util.Optional<java.lang.Exception>
preFlightCheckForNoOp(Engine.NoOp noOp)
Executes a pre-flight check for a given NoOp.Translog.Snapshot
readHistoryOperations(java.lang.String source, MapperService mapperService, long startingSeqNo)
Creates a new history snapshot for reading operations since the provided seqno.InternalEngine
recoverFromTranslog(Engine.TranslogRecoveryRunner translogRecoveryRunner, long recoverUpToSeqNo)
Performs recovery from the transaction log up torecoverUpToSeqNo
(inclusive).void
refresh(java.lang.String source)
Synchronously refreshes the engine for new search operations to reflect the latest changes.protected void
refreshIfNeeded(java.lang.String source, long requestingSeqNo)
Refresh this engine **internally** iff the requesting seq_no is greater than the last refreshed checkpoint.int
restoreLocalHistoryFromTranslog(Engine.TranslogRecoveryRunner translogRecoveryRunner)
This method replays translog to restore the Lucene index which might be reverted previously.void
rollTranslogGeneration()
Rolls the translog generation and cleans unneeded.java.util.List<Segment>
segments(boolean verbose)
The list of segments in the engine.boolean
shouldPeriodicallyFlush()
Checks if this engine should be flushed periodically.boolean
shouldRollTranslogGeneration()
Tests whether or not the translog generation should be rolled to a new generation.void
skipTranslogRecovery()
Do not replay translog operations, but make the engine be ready.Engine.SyncedFlushResult
syncFlush(java.lang.String syncId, Engine.CommitId expectedCommitId)
Attempts to do a special commit where the given syncID is put into the commit data.void
syncTranslog()
void
trimOperationsFromTranslog(long belowTerm, long aboveSeqNo)
Trims translog for terms belowbelowTerm
and seq# aboveaboveSeqNo
void
trimUnreferencedTranslogFiles()
checks and removes translog files that no longer need to be retained.void
updateMaxUnsafeAutoIdTimestamp(long newTimestamp)
Forces this engine to advance its max_unsafe_auto_id_timestamp marker to at least the given timestamp.void
waitForOpsToComplete(long seqNo)
Waits for all operations up to the provided sequence number to complete.void
writeIndexingBuffer()
Called when our engine is using too much heap and should move buffered indexed/deleted documents to disk.protected void
writerSegmentStats(SegmentsStats stats)
-
Methods inherited from class org.elasticsearch.index.engine.Engine
acquireSearcher, acquireSearcher, advanceMaxSeqNoOfUpdatesOrDeletes, close, commitStats, completionStats, config, docsStats, docStats, ensureOpen, ensureOpen, failEngine, flush, flushAndClose, forceMerge, getFromSearcher, getLastWriteNanos, getMaxSeqNoOfUpdatesOrDeletes, getSegmentInfo, guardedRamBytesUsed, isMergedSegment, refreshNeeded, segmentsStats
-
-
-
-
Constructor Detail
-
InternalEngine
public InternalEngine(EngineConfig engineConfig)
-
-
Method Detail
-
restoreLocalHistoryFromTranslog
public int restoreLocalHistoryFromTranslog(Engine.TranslogRecoveryRunner translogRecoveryRunner) throws java.io.IOException
Description copied from class:Engine
This method replays translog to restore the Lucene index which might be reverted previously. This ensures that all acknowledged writes are restored correctly when this engine is promoted.- Specified by:
restoreLocalHistoryFromTranslog
in classEngine
- Returns:
- the number of translog operations have been recovered
- Throws:
java.io.IOException
-
fillSeqNoGaps
public int fillSeqNoGaps(long primaryTerm) throws java.io.IOException
Description copied from class:Engine
Fills up the local checkpoints history with no-ops until the local checkpoint and the max seen sequence ID are identical.- Specified by:
fillSeqNoGaps
in classEngine
- Parameters:
primaryTerm
- the shards primary term this engine was created for- Returns:
- the number of no-ops added
- Throws:
java.io.IOException
-
recoverFromTranslog
public InternalEngine recoverFromTranslog(Engine.TranslogRecoveryRunner translogRecoveryRunner, long recoverUpToSeqNo) throws java.io.IOException
Description copied from class:Engine
Performs recovery from the transaction log up torecoverUpToSeqNo
(inclusive). This operation will close the engine if the recovery fails.- Specified by:
recoverFromTranslog
in classEngine
- Parameters:
translogRecoveryRunner
- the translog recovery runnerrecoverUpToSeqNo
- the upper bound, inclusive, of sequence number to be recovered- Throws:
java.io.IOException
-
skipTranslogRecovery
public void skipTranslogRecovery()
Description copied from class:Engine
Do not replay translog operations, but make the engine be ready.- Specified by:
skipTranslogRecovery
in classEngine
-
isTranslogSyncNeeded
public boolean isTranslogSyncNeeded()
Description copied from class:Engine
Checks if the underlying storage sync is required.- Specified by:
isTranslogSyncNeeded
in classEngine
-
ensureTranslogSynced
public boolean ensureTranslogSynced(java.util.stream.Stream<Translog.Location> locations) throws java.io.IOException
Description copied from class:Engine
Ensures that all locations in the given stream have been written to the underlying storage.- Specified by:
ensureTranslogSynced
in classEngine
- Throws:
java.io.IOException
-
syncTranslog
public void syncTranslog() throws java.io.IOException
- Specified by:
syncTranslog
in classEngine
- Throws:
java.io.IOException
-
readHistoryOperations
public Translog.Snapshot readHistoryOperations(java.lang.String source, MapperService mapperService, long startingSeqNo) throws java.io.IOException
Creates a new history snapshot for reading operations since the provided seqno. The returned snapshot can be retrieved from either Lucene index or translog files.- Specified by:
readHistoryOperations
in classEngine
- Throws:
java.io.IOException
-
estimateNumberOfHistoryOperations
public int estimateNumberOfHistoryOperations(java.lang.String source, MapperService mapperService, long startingSeqNo) throws java.io.IOException
Returns the estimated number of history operations whose seq# at least the provided seq# in this engine.- Specified by:
estimateNumberOfHistoryOperations
in classEngine
- Throws:
java.io.IOException
-
getTranslogStats
public TranslogStats getTranslogStats()
- Specified by:
getTranslogStats
in classEngine
-
getTranslogLastWriteLocation
public Translog.Location getTranslogLastWriteLocation()
Description copied from class:Engine
Returns the last location that the translog of this engine has written into.- Specified by:
getTranslogLastWriteLocation
in classEngine
-
getHistoryUUID
public java.lang.String getHistoryUUID()
Description copied from class:Engine
returns the history uuid for the engine- Specified by:
getHistoryUUID
in classEngine
-
getWritingBytes
public long getWritingBytes()
Returns how many bytes we are currently moving from indexing buffer to segments on disk- Specified by:
getWritingBytes
in classEngine
-
get
public Engine.GetResult get(Engine.Get get, java.util.function.BiFunction<java.lang.String,Engine.SearcherScope,Engine.Searcher> searcherFactory) throws EngineException
- Specified by:
get
in classEngine
- Throws:
EngineException
-
assertPrimaryCanOptimizeAddDocument
protected boolean assertPrimaryCanOptimizeAddDocument(Engine.Index index)
-
assertPrimaryIncomingSequenceNumber
protected boolean assertPrimaryIncomingSequenceNumber(Engine.Operation.Origin origin, long seqNo)
-
index
public Engine.IndexResult index(Engine.Index index) throws java.io.IOException
Description copied from class:Engine
Perform document index operation on the engine- Specified by:
index
in classEngine
- Parameters:
index
- operation to perform- Returns:
Engine.IndexResult
containing updated translog location, version and document specific failures Note: engine level failures (i.e. persistent engine failures) are thrown- Throws:
java.io.IOException
-
planIndexingAsNonPrimary
protected final InternalEngine.IndexingStrategy planIndexingAsNonPrimary(Engine.Index index) throws java.io.IOException
- Throws:
java.io.IOException
-
indexingStrategyForOperation
protected InternalEngine.IndexingStrategy indexingStrategyForOperation(Engine.Index index) throws java.io.IOException
- Throws:
java.io.IOException
-
planIndexingAsPrimary
protected final InternalEngine.IndexingStrategy planIndexingAsPrimary(Engine.Index index) throws java.io.IOException
- Throws:
java.io.IOException
-
delete
public Engine.DeleteResult delete(Engine.Delete delete) throws java.io.IOException
Description copied from class:Engine
Perform document delete operation on the engine- Specified by:
delete
in classEngine
- Parameters:
delete
- operation to perform- Returns:
Engine.DeleteResult
containing updated translog location, version and document specific failures Note: engine level failures (i.e. persistent engine failures) are thrown- Throws:
java.io.IOException
-
deletionStrategyForOperation
protected InternalEngine.DeletionStrategy deletionStrategyForOperation(Engine.Delete delete) throws java.io.IOException
- Throws:
java.io.IOException
-
planDeletionAsNonPrimary
protected final InternalEngine.DeletionStrategy planDeletionAsNonPrimary(Engine.Delete delete) throws java.io.IOException
- Throws:
java.io.IOException
-
assertNonPrimaryOrigin
protected boolean assertNonPrimaryOrigin(Engine.Operation operation)
-
planDeletionAsPrimary
protected final InternalEngine.DeletionStrategy planDeletionAsPrimary(Engine.Delete delete) throws java.io.IOException
- Throws:
java.io.IOException
-
maybePruneDeletes
public void maybePruneDeletes()
Description copied from class:Engine
Tries to prune buffered deletes from the version map.- Specified by:
maybePruneDeletes
in classEngine
-
noOp
public Engine.NoOpResult noOp(Engine.NoOp noOp)
-
preFlightCheckForNoOp
protected java.util.Optional<java.lang.Exception> preFlightCheckForNoOp(Engine.NoOp noOp) throws java.io.IOException
Executes a pre-flight check for a given NoOp. If this method returns a non-empty result, the engine won't process this NoOp and returns a failure.- Throws:
java.io.IOException
-
refresh
public void refresh(java.lang.String source) throws EngineException
Description copied from class:Engine
Synchronously refreshes the engine for new search operations to reflect the latest changes.- Specified by:
refresh
in classEngine
- Throws:
EngineException
-
writeIndexingBuffer
public void writeIndexingBuffer() throws EngineException
Description copied from class:Engine
Called when our engine is using too much heap and should move buffered indexed/deleted documents to disk.- Specified by:
writeIndexingBuffer
in classEngine
- Throws:
EngineException
-
syncFlush
public Engine.SyncedFlushResult syncFlush(java.lang.String syncId, Engine.CommitId expectedCommitId) throws EngineException
Description copied from class:Engine
Attempts to do a special commit where the given syncID is put into the commit data. The attempt succeeds if there are not pending writes in lucene and the current point is equal to the expected one.- Specified by:
syncFlush
in classEngine
- Parameters:
syncId
- id of this syncexpectedCommitId
- the expected value of- Returns:
- true if the sync commit was made, false o.w.
- Throws:
EngineException
-
shouldPeriodicallyFlush
public boolean shouldPeriodicallyFlush()
Description copied from class:Engine
Checks if this engine should be flushed periodically. This check is mainly based on the uncommitted translog size and the translog flush threshold setting.- Specified by:
shouldPeriodicallyFlush
in classEngine
-
flush
public Engine.CommitId flush(boolean force, boolean waitIfOngoing) throws EngineException
Description copied from class:Engine
Flushes the state of the engine including the transaction log, clearing memory.- Specified by:
flush
in classEngine
- Parameters:
force
- iftrue
a lucene commit is executed even if no changes need to be committed.waitIfOngoing
- iftrue
this call will block until all currently running flushes have finished. Otherwise this call will return without blocking.- Returns:
- the commit Id for the resulting commit
- Throws:
EngineException
-
rollTranslogGeneration
public void rollTranslogGeneration() throws EngineException
Description copied from class:Engine
Rolls the translog generation and cleans unneeded.- Specified by:
rollTranslogGeneration
in classEngine
- Throws:
EngineException
-
trimUnreferencedTranslogFiles
public void trimUnreferencedTranslogFiles() throws EngineException
Description copied from class:Engine
checks and removes translog files that no longer need to be retained. SeeTranslogDeletionPolicy
for details- Specified by:
trimUnreferencedTranslogFiles
in classEngine
- Throws:
EngineException
-
shouldRollTranslogGeneration
public boolean shouldRollTranslogGeneration()
Description copied from class:Engine
Tests whether or not the translog generation should be rolled to a new generation. This test is based on the size of the current generation compared to the configured generation threshold size.- Specified by:
shouldRollTranslogGeneration
in classEngine
- Returns:
true
if the current generation should be rolled to a new generation
-
trimOperationsFromTranslog
public void trimOperationsFromTranslog(long belowTerm, long aboveSeqNo) throws EngineException
Description copied from class:Engine
Trims translog for terms belowbelowTerm
and seq# aboveaboveSeqNo
- Specified by:
trimOperationsFromTranslog
in classEngine
- Throws:
EngineException
- See Also:
Translog.trimOperations(long, long)
-
forceMerge
public void forceMerge(boolean flush, int maxNumSegments, boolean onlyExpungeDeletes, boolean upgrade, boolean upgradeOnlyAncientSegments) throws EngineException, java.io.IOException
Description copied from class:Engine
Triggers a forced merge on this engine- Specified by:
forceMerge
in classEngine
- Throws:
EngineException
java.io.IOException
-
acquireLastIndexCommit
public Engine.IndexCommitRef acquireLastIndexCommit(boolean flushFirst) throws EngineException
Description copied from class:Engine
Snapshots the most recent index and returns a handle to it. If needed will try and "commit" the lucene index to make sure we have a "fresh" copy of the files to snapshot.- Specified by:
acquireLastIndexCommit
in classEngine
- Parameters:
flushFirst
- indicates whether the engine should flush before returning the snapshot- Throws:
EngineException
-
acquireSafeIndexCommit
public Engine.IndexCommitRef acquireSafeIndexCommit() throws EngineException
Description copied from class:Engine
Snapshots the most recent safe index commit from the engine.- Specified by:
acquireSafeIndexCommit
in classEngine
- Throws:
EngineException
-
maybeFailEngine
protected boolean maybeFailEngine(java.lang.String source, java.lang.Exception e)
Description copied from class:Engine
Check whether the engine should be failed- Overrides:
maybeFailEngine
in classEngine
-
getLastCommittedSegmentInfos
protected org.apache.lucene.index.SegmentInfos getLastCommittedSegmentInfos()
- Specified by:
getLastCommittedSegmentInfos
in classEngine
-
writerSegmentStats
protected final void writerSegmentStats(SegmentsStats stats)
- Overrides:
writerSegmentStats
in classEngine
-
getIndexBufferRAMBytesUsed
public long getIndexBufferRAMBytesUsed()
Description copied from class:Engine
How much heap is used that would be freed by a refresh. Note that this may throwAlreadyClosedException
.- Specified by:
getIndexBufferRAMBytesUsed
in classEngine
-
segments
public java.util.List<Segment> segments(boolean verbose)
Description copied from class:Engine
The list of segments in the engine.
-
closeNoLock
protected final void closeNoLock(java.lang.String reason, java.util.concurrent.CountDownLatch closedLatch)
Closes the engine without acquiring the write lock. This should only be called while the write lock is hold or in a disaster condition ie. if the engine is failed.- Specified by:
closeNoLock
in classEngine
-
getReferenceManager
protected final org.apache.lucene.search.ReferenceManager<org.apache.lucene.search.IndexSearcher> getReferenceManager(Engine.SearcherScope scope)
- Specified by:
getReferenceManager
in classEngine
-
activateThrottling
public void activateThrottling()
Description copied from class:Engine
Request that this engine throttle incoming indexing requests to one thread. Must be matched by a later call toEngine.deactivateThrottling()
.- Specified by:
activateThrottling
in classEngine
-
deactivateThrottling
public void deactivateThrottling()
Description copied from class:Engine
Reverses a previousEngine.activateThrottling()
call.- Specified by:
deactivateThrottling
in classEngine
-
isThrottled
public boolean isThrottled()
Description copied from class:Engine
Returns thetrue
iff this engine is currently under index throttling.- Specified by:
isThrottled
in classEngine
- See Also:
Engine.getIndexThrottleTimeInMillis()
-
getIndexThrottleTimeInMillis
public long getIndexThrottleTimeInMillis()
Description copied from class:Engine
Returns the number of milliseconds this engine was under index throttling.- Specified by:
getIndexThrottleTimeInMillis
in classEngine
-
commitIndexWriter
protected void commitIndexWriter(org.apache.lucene.index.IndexWriter writer, Translog translog, @Nullable java.lang.String syncId) throws java.io.IOException
Commits the specified index writer.- Parameters:
writer
- the index writer to committranslog
- the translogsyncId
- the sync flush ID (null
if not committing a synced flush)- Throws:
java.io.IOException
- if an I/O exception occurs committing the specfied writer
-
onSettingsChanged
public void onSettingsChanged()
- Overrides:
onSettingsChanged
in classEngine
-
getMergeStats
public MergeStats getMergeStats()
- Overrides:
getMergeStats
in classEngine
-
getLastSyncedGlobalCheckpoint
public long getLastSyncedGlobalCheckpoint()
Description copied from class:Engine
Returns the latest global checkpoint value that has been persisted in the underlying storage (i.e. translog's checkpoint)- Specified by:
getLastSyncedGlobalCheckpoint
in classEngine
-
getLocalCheckpoint
public long getLocalCheckpoint()
- Specified by:
getLocalCheckpoint
in classEngine
- Returns:
- the local checkpoint for this Engine
-
waitForOpsToComplete
public void waitForOpsToComplete(long seqNo) throws java.lang.InterruptedException
Description copied from class:Engine
Waits for all operations up to the provided sequence number to complete.- Specified by:
waitForOpsToComplete
in classEngine
- Parameters:
seqNo
- the sequence number that the checkpoint must advance to before this method returns- Throws:
java.lang.InterruptedException
- if the thread was interrupted while blocking on the condition
-
hasBeenProcessedBefore
protected final boolean hasBeenProcessedBefore(Engine.Operation op)
Checks if the given operation has been processed in this engine or not.- Returns:
- true if the given operation was processed; otherwise false.
-
getSeqNoStats
public SeqNoStats getSeqNoStats(long globalCheckpoint)
- Specified by:
getSeqNoStats
in classEngine
- Returns:
- a
SeqNoStats
object, using local state and the supplied global checkpoint
-
newChangesSnapshot
public Translog.Snapshot newChangesSnapshot(java.lang.String source, MapperService mapperService, long fromSeqNo, long toSeqNo, boolean requiredFullRange) throws java.io.IOException
Description copied from class:Engine
Creates a new history snapshot from Lucene for reading operations whose seqno in the requesting seqno range (both inclusive)- Specified by:
newChangesSnapshot
in classEngine
- Throws:
java.io.IOException
-
hasCompleteOperationHistory
public boolean hasCompleteOperationHistory(java.lang.String source, MapperService mapperService, long startingSeqNo) throws java.io.IOException
Description copied from class:Engine
Checks if this engine has every operations sincestartingSeqNo
(inclusive) in its history (either Lucene or translog)- Specified by:
hasCompleteOperationHistory
in classEngine
- Throws:
java.io.IOException
-
acquireRetentionLockForPeerRecovery
public java.io.Closeable acquireRetentionLockForPeerRecovery()
Description copied from class:Engine
Acquires a lock on the translog files and Lucene soft-deleted documents to prevent them from being trimmed- Specified by:
acquireRetentionLockForPeerRecovery
in classEngine
-
isRecovering
public boolean isRecovering()
Description copied from class:Engine
Returnstrue
iff this engine is currently recovering from translog.- Overrides:
isRecovering
in classEngine
-
refreshIfNeeded
protected final void refreshIfNeeded(java.lang.String source, long requestingSeqNo)
Refresh this engine **internally** iff the requesting seq_no is greater than the last refreshed checkpoint.
-
getMaxSeenAutoIdTimestamp
public final long getMaxSeenAutoIdTimestamp()
Description copied from class:Engine
Returns the maximum auto_id_timestamp of all append-only index requests have been processed by this engine or the auto_id_timestamp received from its primary shard viaEngine.updateMaxUnsafeAutoIdTimestamp(long)
. Notes this method returns the auto_id_timestamp of all append-only requests, not max_unsafe_auto_id_timestamp.- Overrides:
getMaxSeenAutoIdTimestamp
in classEngine
-
updateMaxUnsafeAutoIdTimestamp
public final void updateMaxUnsafeAutoIdTimestamp(long newTimestamp)
Description copied from class:Engine
Forces this engine to advance its max_unsafe_auto_id_timestamp marker to at least the given timestamp. The engine will disable optimization for all append-only whose timestamp at mostnewTimestamp
.- Specified by:
updateMaxUnsafeAutoIdTimestamp
in classEngine
-
initializeMaxSeqNoOfUpdatesOrDeletes
public void initializeMaxSeqNoOfUpdatesOrDeletes()
Description copied from class:Engine
A primary shard calls this method once to initialize the max_seq_no_of_updates marker using the max_seq_no from Lucene index and translog before replaying the local translog in its local recovery.- Specified by:
initializeMaxSeqNoOfUpdatesOrDeletes
in classEngine
-
-