public class ShadowEngine extends Engine
IndexReader is opened instead of
an IndexWriter. All methods that would usually perform write
operations are no-ops, this means:
- No operations are written to or read from the translog
- Create, Index, and Delete do nothing
- Flush does not fsync any files, or make any on-disk changes
In order for new segments to become visible, the ShadowEngine may perform
stage1 of the traditional recovery process (copying segment files) from a
regular primary (which uses InternalEngine)
Notice that since this Engine does not deal with the translog, any
Engine.get(Get, Function) request goes directly to the searcher,
meaning it is non-realtime.Engine.CommitId, Engine.Delete, Engine.DeleteResult, Engine.EventListener, Engine.Get, Engine.GetResult, Engine.Index, Engine.IndexResult, Engine.IndexThrottle, Engine.NoOpLock, Engine.Operation, Engine.Result, Engine.Searcher, Engine.SyncedFlushResult, Engine.Warmer| Modifier and Type | Field and Description |
|---|---|
static TimeValue |
DEFAULT_NONEXISTENT_INDEX_RETRY_WAIT |
static java.lang.String |
NONEXISTENT_INDEX_RETRY_WAIT
how long to wait for an index to exist
|
deletionPolicy, engineConfig, eventListener, failedEngine, failEngineLock, isClosed, lastWriteNanos, logger, readLock, rwl, shardId, store, SYNC_COMMIT_ID, writeLock| Constructor and Description |
|---|
ShadowEngine(EngineConfig engineConfig) |
| Modifier and Type | Method and Description |
|---|---|
org.apache.lucene.index.IndexCommit |
acquireIndexCommit(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 void |
closeNoLock(java.lang.String reason,
java.util.concurrent.CountDownLatch closedLatch)
Method to close the engine while the write lock is held.
|
void |
deactivateThrottling()
Reverses a previous
Engine.activateThrottling() call. |
Engine.DeleteResult |
delete(Engine.Delete delete)
Perform document delete operation on the engine
|
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.Function<java.lang.String,Engine.Searcher> searcherFacotry) |
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() |
protected org.apache.lucene.search.SearcherManager |
getSearcherManager() |
Translog |
getTranslog()
returns the translog for this engine
|
Engine.IndexResult |
index(Engine.Index index)
Perform document index operation on the engine
|
boolean |
isThrottled()
Returns the
true iff this engine is currently under index throttling. |
Engine |
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.
|
java.util.List<Segment> |
segments(boolean verbose)
The list of segments in the engine.
|
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 |
writeIndexingBuffer()
Called when our engine is using too much heap and should move buffered indexed/deleted documents to disk.
|
acquireSearcher, close, commitStats, config, ensureOpen, failEngine, flushAndClose, forceMerge, getFromSearcher, getLastWriteNanos, getMergeStats, getSegmentInfo, guardedRamBytesUsed, isMergedSegment, isRecovering, maybeFailEngine, newSearcher, onSettingsChanged, readLastCommittedSegmentInfos, refreshNeeded, segmentReader, segmentsStats, writerSegmentStatspublic static final java.lang.String NONEXISTENT_INDEX_RETRY_WAIT
public static final TimeValue DEFAULT_NONEXISTENT_INDEX_RETRY_WAIT
public ShadowEngine(EngineConfig engineConfig)
public Engine.IndexResult index(Engine.Index index)
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 thrownpublic Engine.DeleteResult delete(Engine.Delete delete)
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 thrownpublic Engine.SyncedFlushResult syncFlush(java.lang.String syncId, Engine.CommitId expectedCommitId)
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 forceMerge(boolean flush,
int maxNumSegments,
boolean onlyExpungeDeletes,
boolean upgrade,
boolean upgradeOnlyAncientSegments)
throws EngineException
EngineforceMerge in class EngineEngineExceptionpublic Engine.GetResult get(Engine.Get get, java.util.function.Function<java.lang.String,Engine.Searcher> searcherFacotry) throws EngineException
get in class EngineEngineExceptionpublic Translog getTranslog()
EnginegetTranslog in class Enginepublic java.util.List<Segment> segments(boolean verbose)
Enginepublic void refresh(java.lang.String source)
throws EngineException
Enginerefresh in class EngineEngineExceptionpublic org.apache.lucene.index.IndexCommit acquireIndexCommit(boolean flushFirst)
throws EngineException
EngineacquireIndexCommit in class EngineflushFirst - indicates whether the engine should flush before returning the snapshotEngineExceptionprotected org.apache.lucene.search.SearcherManager getSearcherManager()
getSearcherManager in class Engineprotected void closeNoLock(java.lang.String reason,
java.util.concurrent.CountDownLatch closedLatch)
EnginecloseNoLock in class Engineprotected org.apache.lucene.index.SegmentInfos getLastCommittedSegmentInfos()
getLastCommittedSegmentInfos in class Enginepublic long getIndexBufferRAMBytesUsed()
EngineAlreadyClosedException.getIndexBufferRAMBytesUsed in class Enginepublic void writeIndexingBuffer()
EnginewriteIndexingBuffer 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 Enginepublic Engine recoverFromTranslog() throws java.io.IOException
EnginerecoverFromTranslog in class Enginejava.io.IOException