public abstract class Engine extends Object implements Closeable
Modifier and Type | Class and Description |
---|---|
static class |
Engine.CommitId |
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 class |
Engine.Searcher |
static class |
Engine.SyncedFlushResult |
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 |
static String |
SYNC_COMMIT_ID |
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.
|
protected Engine.Searcher |
acquireSearcher(String source,
boolean maybeWrap) |
void |
close() |
protected abstract void |
closeNoLock(String reason)
Method to close the engine while the write lock is held.
|
CommitStats |
commitStats()
get commits stats for the last commit
|
EngineConfig |
config() |
abstract void |
create(Engine.Create create) |
abstract void |
delete(Engine.Delete delete) |
abstract void |
delete(Engine.DeleteByQuery delete)
Deprecated.
This was removed, but we keep this API so translog can replay any DBQs on upgrade.
|
protected void |
ensureOpen() |
void |
failEngine(String reason,
Throwable failure)
fail engine due to some error.
|
abstract 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.
|
abstract Engine.CommitId |
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,
boolean upgradeOnlyAncientSegments)
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.index.SegmentInfos |
getLastCommittedSegmentInfos() |
MergeStats |
getMergeStats() |
protected abstract org.apache.lucene.search.SearcherManager |
getSearcherManager() |
protected Segment[] |
getSegmentInfo(org.apache.lucene.index.SegmentInfos lastCommittedSegmentInfos,
boolean verbose) |
abstract Translog |
getTranslog()
returns the translog for this engine
|
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 boolean |
index(Engine.Index index) |
abstract long |
indexWriterRAMBytesUsed()
How much heap Lucene's IndexWriter is using
|
protected static boolean |
isMergedSegment(org.apache.lucene.index.LeafReader 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
|
protected Engine.Searcher |
newSearcher(String source,
org.apache.lucene.search.IndexSearcher searcher,
org.apache.lucene.search.SearcherManager manager) |
void |
onSettingsChanged() |
protected static org.apache.lucene.index.SegmentInfos |
readLastCommittedSegmentInfos(org.apache.lucene.search.SearcherManager sm,
Store store)
Read the last segments info from the commit pointed to by the searcher manager
|
abstract void |
refresh(String source)
Refreshes the engine for new search operations to reflect the latest
changes.
|
boolean |
refreshNeeded() |
protected static org.apache.lucene.index.SegmentReader |
segmentReader(org.apache.lucene.index.LeafReader reader)
Tries to extract a segment reader from the given index reader.
|
abstract List<Segment> |
segments(boolean verbose)
The list of segments in the engine.
|
SegmentsStats |
segmentsStats()
Global stats on segments.
|
abstract SnapshotIndexCommit |
snapshotIndex(boolean flushFirst)
Snapshots the index and returns a handle to it.
|
abstract Engine.SyncedFlushResult |
syncFlush(String syncId,
Engine.CommitId expectedCommitId)
Attempts to do a special commit where the given syncID is put into the commit data.
|
protected Throwable |
wrapIfClosed(Throwable t)
Wrap a Throwable in an
EngineClosedException if the engine is already closed |
protected void |
writerSegmentStats(SegmentsStats stats) |
public static final String SYNC_COMMIT_ID
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()
protected static org.apache.lucene.index.SegmentReader segmentReader(org.apache.lucene.index.LeafReader reader)
IllegalStateException
is thrown.protected static boolean isMergedSegment(org.apache.lucene.index.LeafReader reader)
protected Engine.Searcher newSearcher(String source, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.SearcherManager manager)
public final EngineConfig config()
protected abstract org.apache.lucene.index.SegmentInfos getLastCommittedSegmentInfos()
public MergeStats getMergeStats()
public abstract void create(Engine.Create create) throws EngineException
EngineException
public abstract boolean index(Engine.Index index) throws EngineException
EngineException
public abstract void delete(Engine.Delete delete) throws EngineException
EngineException
@Deprecated public abstract void delete(Engine.DeleteByQuery delete) throws EngineException
EngineException
public abstract Engine.SyncedFlushResult syncFlush(String syncId, Engine.CommitId expectedCommitId) throws EngineException
syncId
- id of this syncexpectedCommitId
- the expected value ofEngineException
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 final Engine.Searcher acquireSearcher(String source, boolean maybeWrap) throws EngineException
EngineException
public abstract Translog getTranslog()
protected void ensureOpen()
public CommitStats commitStats()
protected static org.apache.lucene.index.SegmentInfos readLastCommittedSegmentInfos(org.apache.lucene.search.SearcherManager sm, Store store) throws IOException
IOException
public final SegmentsStats segmentsStats()
protected void writerSegmentStats(SegmentsStats stats)
public abstract long indexWriterRAMBytesUsed()
protected Segment[] getSegmentInfo(org.apache.lucene.index.SegmentInfos lastCommittedSegmentInfos, boolean verbose)
public abstract List<Segment> segments(boolean verbose)
public final boolean refreshNeeded()
public abstract void refresh(String source) throws EngineException
EngineException
public abstract Engine.CommitId 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 Engine.CommitId flush() throws EngineException
EngineException
public void forceMerge(boolean flush) throws IOException
IOException
public abstract void forceMerge(boolean flush, int maxNumSegments, boolean onlyExpungeDeletes, boolean upgrade, boolean upgradeOnlyAncientSegments) throws EngineException, IOException
EngineException
IOException
public abstract SnapshotIndexCommit snapshotIndex(boolean flushFirst) throws EngineException
flushFirst
- indicates whether the engine should flush before returning the snapshotEngineException
public void failEngine(String reason, @Nullable 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)
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
public void onSettingsChanged()
Copyright © 2009–2016. All rights reserved.