java.io.Closeable
, java.lang.AutoCloseable
public class InternalEngine extends 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.Warmer
Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
MAX_UNSAFE_AUTO_ID_TIMESTAMP_COMMIT_ID |
allocationId, engineConfig, eventListener, failedEngine, failEngineLock, HISTORY_UUID_KEY, isClosed, lastWriteNanos, logger, readLock, rwl, shardId, store, SYNC_COMMIT_ID, writeLock
Constructor | Description |
---|---|
InternalEngine(EngineConfig engineConfig) |
Modifier and Type | Method | Description |
---|---|---|
Engine.IndexCommitRef |
acquireLastIndexCommit(boolean flushFirst) |
Snapshots the most recent index and returns a handle to it.
|
Engine.IndexCommitRef |
acquireSafeIndexCommit() |
Snapshots the most recent safe index commit from the engine.
|
Engine.Searcher |
acquireSearcher(java.lang.String source,
Engine.SearcherScope scope) |
Returns a new searcher instance.
|
void |
activateThrottling() |
Request that this engine throttle incoming indexing requests to one thread.
|
protected boolean |
assertOriginPrimarySequenceNumber(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 previous
Engine.activateThrottling() call. |
Engine.DeleteResult |
delete(Engine.Delete delete) |
Perform document delete operation on the engine
|
protected long |
doGenerateSeqNoForOperation(Engine.Operation operation) |
Generate the sequence number for the specified operation.
|
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 |
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() |
Flushes the state of the engine including the transaction log, clearing memory and persisting
documents in the lucene index to disk including a potentially heavy and durable fsync operation.
|
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 engine
|
Engine.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 engine
|
long |
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() |
|
LocalCheckpointTracker |
getLocalCheckpointTracker() |
The sequence number service for this engine.
|
MergeStats |
getMergeStats() |
|
long |
getWritingBytes() |
Returns how many bytes we are currently moving from indexing buffer to segments on disk
|
Engine.IndexResult |
index(Engine.Index index) |
Perform document index operation on the engine
|
boolean |
isRecovering() |
Returns
true iff this engine is currently recovering from translog. |
boolean |
isThrottled() |
Returns the
true iff this engine is currently under index throttling. |
protected boolean |
maybeFailEngine(java.lang.String source,
java.lang.Exception e) |
Check whether the engine should be failed
|
void |
maybePruneDeletes() |
Tries to prune buffered deletes from the version map.
|
Engine.NoOpResult |
noOp(Engine.NoOp noOp) |
|
void |
onSettingsChanged() |
|
InternalEngine |
recoverFromTranslog() |
Performs recovery from the transaction log.
|
void |
refresh(java.lang.String source) |
Synchronously refreshes the engine for new search operations to reflect the latest
changes.
|
void |
restoreLocalCheckpointFromTranslog() |
Marks operations in the translog as completed.
|
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.
|
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 |
trimTranslog() |
checks and removes translog files that no longer need to be retained.
|
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) |
acquireSearcher, acquireTranslogRetentionLock, close, commitStats, config, ensureOpen, ensureOpen, estimateTranslogOperationsFromMinSeq, failEngine, flushAndClose, forceMerge, getFromSearcher, getLastSyncedGlobalCheckpoint, getLastWriteNanos, getSegmentInfo, getTranslogLastWriteLocation, getTranslogStats, guardedRamBytesUsed, isMergedSegment, isTranslogSyncNeeded, newTranslogSnapshotFromMinSeqNo, refreshNeeded, segmentsStats, shouldRollTranslogGeneration
public static final java.lang.String MAX_UNSAFE_AUTO_ID_TIMESTAMP_COMMIT_ID
public InternalEngine(EngineConfig engineConfig)
public void restoreLocalCheckpointFromTranslog() throws java.io.IOException
Engine
restoreLocalCheckpointFromTranslog
in class Engine
java.io.IOException
- if an I/O exception occurred reading the translogpublic int fillSeqNoGaps(long primaryTerm) throws java.io.IOException
Engine
fillSeqNoGaps
in class Engine
primaryTerm
- the shards primary term this engine was created forjava.io.IOException
public InternalEngine recoverFromTranslog() throws java.io.IOException
Engine
recoverFromTranslog
in class Engine
java.io.IOException
public void skipTranslogRecovery()
Engine
skipTranslogRecovery
in class Engine
public boolean ensureTranslogSynced(java.util.stream.Stream<Translog.Location> locations) throws java.io.IOException
Engine
ensureTranslogSynced
in class Engine
java.io.IOException
public void syncTranslog() throws java.io.IOException
syncTranslog
in class Engine
java.io.IOException
public java.lang.String getHistoryUUID()
Engine
getHistoryUUID
in class Engine
public long getWritingBytes()
getWritingBytes
in class Engine
public Engine.GetResult get(Engine.Get get, java.util.function.BiFunction<java.lang.String,Engine.SearcherScope,Engine.Searcher> searcherFactory) throws EngineException
get
in class Engine
EngineException
protected boolean assertOriginPrimarySequenceNumber(long seqNo)
protected long doGenerateSeqNoForOperation(Engine.Operation operation)
operation
- the operationpublic Engine.IndexResult index(Engine.Index index) throws java.io.IOException
Engine
index
in class Engine
index
- operation to performEngine.IndexResult
containing updated translog location, version and
document specific failures
Note: engine level failures (i.e. persistent engine failures) are thrownjava.io.IOException
public Engine.DeleteResult delete(Engine.Delete delete) throws java.io.IOException
Engine
delete
in class Engine
delete
- operation to performEngine.DeleteResult
containing updated translog location, version and
document specific failures
Note: engine level failures (i.e. persistent engine failures) are thrownjava.io.IOException
public void maybePruneDeletes()
Engine
maybePruneDeletes
in class Engine
public Engine.NoOpResult noOp(Engine.NoOp noOp)
public void refresh(java.lang.String source) throws EngineException
Engine
refresh
in class Engine
EngineException
public void writeIndexingBuffer() throws EngineException
Engine
writeIndexingBuffer
in class Engine
EngineException
public Engine.SyncedFlushResult syncFlush(java.lang.String syncId, Engine.CommitId expectedCommitId) throws EngineException
Engine
syncFlush
in class Engine
syncId
- id of this syncexpectedCommitId
- the expected value ofEngineException
public boolean shouldPeriodicallyFlush()
Engine
shouldPeriodicallyFlush
in class Engine
public Engine.CommitId flush() throws EngineException
Engine
flush
in class Engine
EngineException
public Engine.CommitId flush(boolean force, boolean waitIfOngoing) throws EngineException
Engine
flush
in class Engine
force
- if true
a lucene commit is executed even if no changes need to be committed.waitIfOngoing
- if true
this call will block until all currently running flushes have finished.
Otherwise this call will return without blocking.EngineException
public void rollTranslogGeneration() throws EngineException
Engine
rollTranslogGeneration
in class Engine
EngineException
public void trimTranslog() throws EngineException
Engine
TranslogDeletionPolicy
for detailstrimTranslog
in class Engine
EngineException
public void forceMerge(boolean flush, int maxNumSegments, boolean onlyExpungeDeletes, boolean upgrade, boolean upgradeOnlyAncientSegments) throws EngineException, java.io.IOException
Engine
forceMerge
in class Engine
EngineException
java.io.IOException
public Engine.IndexCommitRef acquireLastIndexCommit(boolean flushFirst) throws EngineException
Engine
acquireLastIndexCommit
in class Engine
flushFirst
- indicates whether the engine should flush before returning the snapshotEngineException
public Engine.IndexCommitRef acquireSafeIndexCommit() throws EngineException
Engine
acquireSafeIndexCommit
in class Engine
EngineException
protected boolean maybeFailEngine(java.lang.String source, java.lang.Exception e)
Engine
maybeFailEngine
in class Engine
protected org.apache.lucene.index.SegmentInfos getLastCommittedSegmentInfos()
getLastCommittedSegmentInfos
in class Engine
protected final void writerSegmentStats(SegmentsStats stats)
writerSegmentStats
in class Engine
public long getIndexBufferRAMBytesUsed()
Engine
AlreadyClosedException
.getIndexBufferRAMBytesUsed
in class Engine
public java.util.List<Segment> segments(boolean verbose)
Engine
protected final void closeNoLock(java.lang.String reason, java.util.concurrent.CountDownLatch closedLatch)
closeNoLock
in class Engine
public Engine.Searcher acquireSearcher(java.lang.String source, Engine.SearcherScope scope)
Engine
acquireSearcher
in class Engine
source
- the source API or routing that triggers this searcher acquirescope
- the scope of this searcher ie. if the searcher will be used for get or search purposesEngine.Searcher.close()
public void activateThrottling()
Engine
Engine.deactivateThrottling()
.activateThrottling
in class Engine
public void deactivateThrottling()
Engine
Engine.activateThrottling()
call.deactivateThrottling
in class Engine
public boolean isThrottled()
Engine
true
iff this engine is currently under index throttling.isThrottled
in class Engine
Engine.getIndexThrottleTimeInMillis()
public long getIndexThrottleTimeInMillis()
Engine
getIndexThrottleTimeInMillis
in class Engine
protected void commitIndexWriter(org.apache.lucene.index.IndexWriter writer, Translog translog, @Nullable java.lang.String syncId) throws java.io.IOException
writer
- the index writer to committranslog
- the translogsyncId
- the sync flush ID (null
if not committing a synced flush)java.io.IOException
- if an I/O exception occurs committing the specfied writerpublic void onSettingsChanged()
onSettingsChanged
in class Engine
public MergeStats getMergeStats()
getMergeStats
in class Engine
public final LocalCheckpointTracker getLocalCheckpointTracker()
Engine
getLocalCheckpointTracker
in class Engine
public boolean isRecovering()
Engine
true
iff this engine is currently recovering from translog.isRecovering
in class Engine