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 |
acquireIndexCommit(boolean safeCommit,
boolean flushFirst) |
Snapshots the index and returns a handle to it.
|
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.
|
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() |
|
protected org.apache.lucene.search.ReferenceManager<org.apache.lucene.search.IndexSearcher> |
getSearcherManager(java.lang.String source,
Engine.SearcherScope scope) |
|
Translog |
getTranslog() |
returns the translog for this engine
|
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
|
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 |
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, acquireSearcher, close, commitStats, config, ensureOpen, failEngine, flushAndClose, forceMerge, getFromSearcher, getLastWriteNanos, getSegmentInfo, guardedRamBytesUsed, isMergedSegment, newSearcher, refreshNeeded, segmentsStatspublic static final java.lang.String MAX_UNSAFE_AUTO_ID_TIMESTAMP_COMMIT_ID
public InternalEngine(EngineConfig engineConfig)
public void restoreLocalCheckpointFromTranslog()
throws java.io.IOException
EnginerestoreLocalCheckpointFromTranslog in class Enginejava.io.IOException - if an I/O exception occurred reading the translogpublic int fillSeqNoGaps(long primaryTerm)
throws java.io.IOException
EnginefillSeqNoGaps in class EngineprimaryTerm - the shards primary term this engine was created forjava.io.IOExceptionpublic InternalEngine recoverFromTranslog() throws java.io.IOException
EnginerecoverFromTranslog in class Enginejava.io.IOExceptionpublic void skipTranslogRecovery()
EngineskipTranslogRecovery in class Enginepublic Translog getTranslog()
EnginegetTranslog in class Enginepublic java.lang.String getHistoryUUID()
EnginegetHistoryUUID in class Enginepublic long getWritingBytes()
getWritingBytes in class Enginepublic Engine.GetResult get(Engine.Get get, java.util.function.BiFunction<java.lang.String,Engine.SearcherScope,Engine.Searcher> searcherFactory) throws EngineException
get in class EngineEngineExceptionprotected boolean assertOriginPrimarySequenceNumber(long seqNo)
protected long doGenerateSeqNoForOperation(Engine.Operation operation)
operation - the operationpublic Engine.IndexResult index(Engine.Index index) throws java.io.IOException
Engineindex in class Engineindex - 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.IOExceptionpublic Engine.DeleteResult delete(Engine.Delete delete) throws java.io.IOException
Enginedelete in class Enginedelete - 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.IOExceptionpublic Engine.NoOpResult noOp(Engine.NoOp noOp)
public void refresh(java.lang.String source)
throws EngineException
Enginerefresh in class EngineEngineExceptionpublic void writeIndexingBuffer()
throws EngineException
EnginewriteIndexingBuffer in class EngineEngineExceptionpublic Engine.SyncedFlushResult syncFlush(java.lang.String syncId, Engine.CommitId expectedCommitId) throws EngineException
EnginesyncFlush in class EnginesyncId - id of this syncexpectedCommitId - the expected value ofEngineExceptionpublic boolean shouldPeriodicallyFlush()
EngineshouldPeriodicallyFlush in class Enginepublic Engine.CommitId flush() throws EngineException
Engineflush in class EngineEngineExceptionpublic Engine.CommitId flush(boolean force, boolean waitIfOngoing) throws EngineException
Engineflush in class Engineforce - 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.EngineExceptionpublic void rollTranslogGeneration()
throws EngineException
EnginerollTranslogGeneration in class EngineEngineExceptionpublic void trimTranslog()
throws EngineException
EngineTranslogDeletionPolicy for detailstrimTranslog in class EngineEngineExceptionpublic void forceMerge(boolean flush,
int maxNumSegments,
boolean onlyExpungeDeletes,
boolean upgrade,
boolean upgradeOnlyAncientSegments)
throws EngineException,
java.io.IOException
EngineforceMerge in class EngineEngineExceptionjava.io.IOExceptionpublic Engine.IndexCommitRef acquireIndexCommit(boolean safeCommit, boolean flushFirst) throws EngineException
EngineacquireIndexCommit in class EnginesafeCommit - indicates whether the engine should acquire the most recent safe commit, or the most recent commit.flushFirst - indicates whether the engine should flush before returning the snapshotEngineExceptionprotected boolean maybeFailEngine(java.lang.String source,
java.lang.Exception e)
EnginemaybeFailEngine in class Engineprotected org.apache.lucene.index.SegmentInfos getLastCommittedSegmentInfos()
getLastCommittedSegmentInfos in class Engineprotected final void writerSegmentStats(SegmentsStats stats)
writerSegmentStats in class Enginepublic long getIndexBufferRAMBytesUsed()
EngineAlreadyClosedException.getIndexBufferRAMBytesUsed in class Enginepublic java.util.List<Segment> segments(boolean verbose)
Engineprotected final void closeNoLock(java.lang.String reason,
java.util.concurrent.CountDownLatch closedLatch)
closeNoLock in class Engineprotected org.apache.lucene.search.ReferenceManager<org.apache.lucene.search.IndexSearcher> getSearcherManager(java.lang.String source,
Engine.SearcherScope scope)
getSearcherManager in class Enginepublic void activateThrottling()
EngineEngine.deactivateThrottling().activateThrottling in class Enginepublic void deactivateThrottling()
EngineEngine.activateThrottling() call.deactivateThrottling in class Enginepublic boolean isThrottled()
Enginetrue iff this engine is currently under index throttling.isThrottled in class EngineEngine.getIndexThrottleTimeInMillis()public long getIndexThrottleTimeInMillis()
EnginegetIndexThrottleTimeInMillis in class Engineprotected 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 Enginepublic MergeStats getMergeStats()
getMergeStats in class Enginepublic final LocalCheckpointTracker getLocalCheckpointTracker()
EnginegetLocalCheckpointTracker in class Enginepublic boolean isRecovering()
Enginetrue iff this engine is currently recovering from translog.isRecovering in class Engine