public abstract class Engine extends Object implements Closeable
Modifier and Type | Class and Description |
---|---|
static class |
Engine.Create |
static class |
Engine.Delete |
static class |
Engine.DeleteByQuery |
static interface |
Engine.FailedEngineListener |
static class |
Engine.Get |
static class |
Engine.GetResult |
static class |
Engine.Index |
static class |
Engine.IndexingOperation |
protected static class |
Engine.IndexThrottle
A throttling class that can be activated, causing the
acquireThrottle method to block on a lock when throttling
is enabled |
protected static class |
Engine.NoOpLock
A Lock implementation that always allows the lock to be acquired
|
static interface |
Engine.Operation |
static interface |
Engine.RecoveryHandler
Recovery allow to start the recovery process.
|
static class |
Engine.Searcher |
Modifier and Type | Field and Description |
---|---|
protected SnapshotDeletionPolicy |
deletionPolicy |
protected EngineConfig |
engineConfig |
protected Throwable |
failedEngine |
protected Engine.FailedEngineListener |
failedEngineListener |
protected ReentrantLock |
failEngineLock |
protected AtomicBoolean |
isClosed |
protected ESLogger |
logger |
protected ReleasableLock |
readLock |
protected ReentrantReadWriteLock |
rwl |
protected ShardId |
shardId |
protected Store |
store |
protected ReleasableLock |
writeLock |
Modifier | Constructor and Description |
---|---|
protected |
Engine(EngineConfig engineConfig) |
Modifier and Type | Method and Description |
---|---|
Engine.Searcher |
acquireSearcher(String source)
Returns a new searcher instance.
|
void |
close() |
protected abstract void |
closeNoLock(String reason)
Method to close the engine while the write lock is held.
|
EngineConfig |
config() |
abstract void |
create(Engine.Create create) |
abstract void |
delete(Engine.Delete delete) |
abstract void |
delete(Engine.DeleteByQuery delete) |
protected void |
ensureOpen() |
void |
failEngine(String reason,
Throwable failure)
fail engine due to some error.
|
abstract void |
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.
|
abstract void |
flush(boolean force,
boolean waitIfOngoing)
Flushes the state of the engine including the transaction log, clearing memory.
|
void |
flushAndClose()
Flush the engine (committing segments to disk and truncating the
translog) and close it.
|
void |
forceMerge(boolean flush)
Optimizes to 1 segment
|
abstract void |
forceMerge(boolean flush,
int maxNumSegments,
boolean onlyExpungeDeletes,
boolean upgrade)
Triggers a forced merge on this engine
|
abstract Engine.GetResult |
get(Engine.Get get) |
protected Engine.GetResult |
getFromSearcher(Engine.Get get) |
protected abstract org.apache.lucene.search.SearcherManager |
getSearcherManager() |
protected Segment[] |
getSegmentInfo(org.apache.lucene.index.SegmentInfos lastCommittedSegmentInfos) |
protected static long |
guardedRamBytesUsed(org.apache.lucene.util.Accountable a)
Returns 0 in the case where accountable is null, otherwise returns
ramBytesUsed() |
abstract boolean |
hasUncommittedChanges()
Returns
true the internal writer has any uncommitted changes. |
abstract void |
index(Engine.Index index) |
static boolean |
isMergedSegment(org.apache.lucene.index.AtomicReader reader)
Returns whether a leaf reader comes from a merge (versus flush or addIndexes).
|
protected boolean |
maybeFailEngine(String source,
Throwable t)
Check whether the engine should be failed
|
abstract void |
maybeMerge() |
protected Engine.Searcher |
newSearcher(String source,
org.apache.lucene.search.IndexSearcher searcher,
org.apache.lucene.search.SearcherManager manager) |
abstract boolean |
possibleMergeNeeded()
Returns true if a possible merge is really needed.
|
abstract void |
recover(Engine.RecoveryHandler recoveryHandler) |
abstract void |
refresh(String source)
Refreshes the engine for new search operations to reflect the latest
changes.
|
boolean |
refreshNeeded() |
abstract List<Segment> |
segments()
The list of segments in the engine.
|
SegmentsStats |
segmentsStats()
Global stats on segments.
|
abstract SnapshotIndexCommit |
snapshotIndex()
Snapshots the index and returns a handle to it.
|
protected Throwable |
wrapIfClosed(Throwable t)
Wrap a Throwable in an
EngineClosedException if the engine is already closed |
protected void |
writerSegmentStats(SegmentsStats stats) |
protected final ShardId shardId
protected final ESLogger logger
protected final EngineConfig engineConfig
protected final Store store
protected final AtomicBoolean isClosed
protected final Engine.FailedEngineListener failedEngineListener
protected final SnapshotDeletionPolicy deletionPolicy
protected final ReentrantLock failEngineLock
protected final ReentrantReadWriteLock rwl
protected final ReleasableLock readLock
protected final ReleasableLock writeLock
protected volatile Throwable failedEngine
protected Engine(EngineConfig engineConfig)
protected static long guardedRamBytesUsed(org.apache.lucene.util.Accountable a)
ramBytesUsed()
public static boolean isMergedSegment(org.apache.lucene.index.AtomicReader reader)
protected Engine.Searcher newSearcher(String source, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.SearcherManager manager)
public final EngineConfig config()
public abstract void create(Engine.Create create) throws EngineException
EngineException
public abstract void index(Engine.Index index) throws EngineException
EngineException
public abstract void delete(Engine.Delete delete) throws EngineException
EngineException
public abstract void delete(Engine.DeleteByQuery delete) throws EngineException
EngineException
protected final Engine.GetResult getFromSearcher(Engine.Get get) throws EngineException
EngineException
public abstract Engine.GetResult get(Engine.Get get) throws EngineException
EngineException
public final Engine.Searcher acquireSearcher(String source) throws EngineException
EngineException
Engine.Searcher.close()
protected void ensureOpen()
public final SegmentsStats segmentsStats()
protected void writerSegmentStats(SegmentsStats stats)
protected Segment[] getSegmentInfo(org.apache.lucene.index.SegmentInfos lastCommittedSegmentInfos)
public final boolean refreshNeeded()
public abstract boolean possibleMergeNeeded()
public abstract void maybeMerge() throws EngineException
EngineException
public abstract void refresh(String source) throws EngineException
EngineException
public abstract void flush(boolean force, boolean waitIfOngoing) throws EngineException
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 abstract void flush() throws EngineException
EngineException
public void forceMerge(boolean flush)
public abstract void forceMerge(boolean flush, int maxNumSegments, boolean onlyExpungeDeletes, boolean upgrade) throws EngineException
EngineException
public abstract SnapshotIndexCommit snapshotIndex() throws EngineException
EngineException
public abstract void recover(Engine.RecoveryHandler recoveryHandler) throws EngineException
EngineException
public void failEngine(String reason, Throwable failure)
protected boolean maybeFailEngine(String source, Throwable t)
protected Throwable wrapIfClosed(Throwable t)
EngineClosedException
if the engine is already closedprotected abstract org.apache.lucene.search.SearcherManager getSearcherManager()
protected abstract void closeNoLock(String reason) throws ElasticsearchException
ElasticsearchException
public void flushAndClose() throws IOException
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public abstract boolean hasUncommittedChanges()
true
the internal writer has any uncommitted changes. Otherwise false
Copyright © 2009–2015. All rights reserved.