public class IndexShard extends AbstractIndexShardComponent
Modifier and Type | Field and Description |
---|---|
protected AtomicReference<Engine> |
currentEngineReference |
protected EngineFactory |
engineFactory |
static String |
INDEX_FLUSH_ON_CLOSE
Index setting to control if a flush is executed before engine is closed
This setting is realtime updateable.
|
static String |
INDEX_REFRESH_INTERVAL |
protected ShardRouting |
shardRouting |
protected IndexShardState |
state |
deprecationLogger, indexSettings, logger, shardId
Constructor and Description |
---|
IndexShard(ShardId shardId,
IndexSettingsService indexSettingsService,
IndicesLifecycle indicesLifecycle,
Store store,
StoreRecoveryService storeRecoveryService,
ThreadPool threadPool,
MapperService mapperService,
IndexQueryParserService queryParserService,
IndexCache indexCache,
IndexAliasesService indexAliasesService,
IndicesQueryCache indicesQueryCache,
ShardPercolateService shardPercolateService,
CodecService codecService,
ShardTermVectorsService termVectorsService,
IndexFieldDataService indexFieldDataService,
IndexService indexService,
IndicesWarmer warmer,
SnapshotDeletionPolicy deletionPolicy,
SimilarityService similarityService,
EngineFactory factory,
ClusterService clusterService,
ShardPath path,
BigArrays bigArrays,
IndexSearcherWrappingService wrappingService,
IndexingMemoryController indexingMemoryController) |
Modifier and Type | Method and Description |
---|---|
Engine.Searcher |
acquireSearcher(String source) |
void |
addFailedEngineListener(Engine.FailedEngineListener failedEngineListener) |
boolean |
allowsPrimaryPromotion()
Returns
true iff this shard allows primary promotion, otherwise false |
boolean |
canIndex()
returns true if this shard supports indexing (i.e., write) operations.
|
boolean |
checkIdle(long inactiveTimeNS)
Called by
IndexingMemoryController to check whether more than inactiveTimeNS has passed since the last
indexing operation, and become inactive (reducing indexing and translog buffers to tiny values) if so. |
void |
close(String reason,
boolean flushEngine) |
CommitStats |
commitStats() |
CompletionStats |
completionStats(String... fields) |
void |
create(Engine.Create create) |
void |
decrementOperationCounter() |
void |
delete(Engine.Delete delete) |
void |
deleteShardState()
Deletes the shards metadata state.
|
DocsStats |
docStats() |
Engine |
engine() |
protected Engine |
engineUnsafe()
NOTE: returns null if engine is not yet started (e.g.
|
void |
failShard(String reason,
Throwable e)
Fails the shard and marks the shard store as corrupted if
e is caused by index corruption |
ShardFieldData |
fieldData() |
FieldDataStats |
fieldDataStats(String... fields) |
void |
finalizeRecovery()
perform the last stages of recovery once all translog operations are done.
|
Engine.CommitId |
flush(FlushRequest request) |
FlushStats |
flushStats() |
void |
forceMerge(ForceMergeRequest forceMerge) |
Engine.GetResult |
get(Engine.Get get) |
boolean |
getActive()
Returns
true if this shard is active (has seen indexing ops in the last IndexingMemoryController.SHARD_INACTIVE_TIME_SETTING (default 5 minutes), else false . |
ByteSizeValue |
getIndexingBufferSize() |
int |
getOperationsCount() |
org.apache.lucene.search.QueryCachingPolicy |
getQueryCachingPolicy() |
ShardGetService |
getService() |
GetStats |
getStats() |
ShardSuggestMetric |
getSuggestMetric() |
Translog.Durabilty |
getTranslogDurability()
Returns the current translog durability mode
|
boolean |
ignoreRecoveryAttempt()
Returns true if this shard can ignore a recovery attempt made to it (since the already doing/done it)
|
void |
incrementOperationCounter() |
boolean |
index(Engine.Index index)
Index a document and return whether it was created, as opposed to just
updated.
|
IndexFieldDataService |
indexFieldDataService() |
ShardIndexingService |
indexingService() |
IndexingStats |
indexingStats(String... types) |
IndexService |
indexService() |
boolean |
isFlushOnClose() |
MapperService |
mapperService() |
MergeStats |
mergeStats() |
org.apache.lucene.util.Version |
minimumCompatibleVersion() |
protected Engine |
newEngine(boolean skipTranslogRecovery,
EngineConfig config) |
PercolatorQueriesRegistry |
percolateRegistry() |
int |
performBatchRecovery(Iterable<Translog.Operation> operations)
Applies all operations in the iterable to the current engine and returns the number of operations applied.
|
void |
performRecoveryRestart()
called if recovery has to be restarted after network error / delay **
|
Map<String,Mapping> |
performTranslogRecovery(boolean indexExists)
After the store has been recovered, we need to start the engine in order to apply operations
|
IndexShard |
postRecovery(String reason) |
Engine.Create |
prepareCreateOnPrimary(SourceToParse source,
long version,
VersionType versionType,
boolean canHaveDuplicates,
boolean autoGeneratedId) |
Engine.Create |
prepareCreateOnReplica(SourceToParse source,
long version,
VersionType versionType,
boolean canHaveDuplicates,
boolean autoGeneratedId) |
Engine.Delete |
prepareDeleteOnPrimary(String type,
String id,
long version,
VersionType versionType) |
Engine.Delete |
prepareDeleteOnReplica(String type,
String id,
long version,
VersionType versionType) |
void |
prepareForIndexRecovery()
called before starting to copy index files over
|
Engine.Index |
prepareIndexOnPrimary(SourceToParse source,
long version,
VersionType versionType,
boolean canHaveDuplicates) |
Engine.Index |
prepareIndexOnReplica(SourceToParse source,
long version,
VersionType versionType,
boolean canHaveDuplicates) |
QueryCacheStats |
queryCacheStats() |
void |
readAllowed() |
void |
recoverFromStore(ShardRouting shard,
StoreRecoveryService.RecoveryListener recoveryListener) |
IndexShardState |
recovering(String reason,
RecoveryState.Type type,
DiscoveryNode sourceNode)
Marks the shard as recovering based on a remote or local node, fails with exception is recovering is not allowed to be set.
|
IndexShardState |
recovering(String reason,
RecoveryState.Type type,
RestoreSource restoreSource)
Marks the shard as recovering based on a restore, fails with exception is recovering is not allowed to be set.
|
RecoveryState |
recoveryState()
Returns the current
RecoveryState if this shard is recovering or has been recovering. |
RecoveryStats |
recoveryStats()
returns stats about ongoing recoveries, both source and target
|
void |
refresh(String source) |
RefreshStats |
refreshStats() |
IndexShard |
relocated(String reason) |
ShardRequestCache |
requestCache() |
ShardRouting |
routingEntry()
Returns the latest cluster routing entry received with this shard.
|
ShardSearchStats |
searchService() |
SearchStats |
searchStats(String... groups) |
SegmentsStats |
segmentStats() |
ShardBitsetFilterCache |
shardBitsetFilterCache() |
ShardPath |
shardPath() |
ShardPercolateService |
shardPercolateService() |
void |
skipTranslogRecovery()
After the store has been recovered, we need to start the engine.
|
SnapshotIndexCommit |
snapshotIndex(boolean flushFirst) |
IndexShardState |
state() |
Store |
store() |
StoreStats |
storeStats() |
SuggestStats |
suggestStats() |
void |
sync(Translog.Location location)
Syncs the given location with the underlying storage unless already synced.
|
Engine.SyncedFlushResult |
syncFlush(String syncId,
Engine.CommitId expectedCommitId) |
ShardTermVectorsService |
termVectorsService() |
TranslogStats |
translogStats() |
void |
updateBufferSize(ByteSizeValue shardIndexingBufferSize,
ByteSizeValue shardTranslogBufferSize)
Change the indexing and translog buffer sizes.
|
void |
updateRoutingEntry(ShardRouting newRouting,
boolean persistState)
Updates the shards routing entry.
|
org.apache.lucene.util.Version |
upgrade(UpgradeRequest upgrade)
Upgrades the shard to the current version of Lucene and returns the minimum segment version
|
protected void |
verifyStarted() |
protected void |
verifyStartedOrRecovering() |
ShardIndexWarmerService |
warmerService() |
WarmerStats |
warmerStats() |
indexSettings, nodeName, shardId
protected volatile ShardRouting shardRouting
protected volatile IndexShardState state
protected final AtomicReference<Engine> currentEngineReference
protected final EngineFactory engineFactory
public static final String INDEX_FLUSH_ON_CLOSE
public static final String INDEX_REFRESH_INTERVAL
@Inject public IndexShard(ShardId shardId, IndexSettingsService indexSettingsService, IndicesLifecycle indicesLifecycle, Store store, StoreRecoveryService storeRecoveryService, ThreadPool threadPool, MapperService mapperService, IndexQueryParserService queryParserService, IndexCache indexCache, IndexAliasesService indexAliasesService, IndicesQueryCache indicesQueryCache, ShardPercolateService shardPercolateService, CodecService codecService, ShardTermVectorsService termVectorsService, IndexFieldDataService indexFieldDataService, IndexService indexService, @Nullable IndicesWarmer warmer, SnapshotDeletionPolicy deletionPolicy, SimilarityService similarityService, EngineFactory factory, ClusterService clusterService, ShardPath path, BigArrays bigArrays, IndexSearcherWrappingService wrappingService, IndexingMemoryController indexingMemoryController)
public Store store()
public boolean canIndex()
public ShardIndexingService indexingService()
public ShardGetService getService()
public ShardTermVectorsService termVectorsService()
public ShardSuggestMetric getSuggestMetric()
public ShardBitsetFilterCache shardBitsetFilterCache()
public IndexFieldDataService indexFieldDataService()
public MapperService mapperService()
public IndexService indexService()
public ShardSearchStats searchService()
public ShardIndexWarmerService warmerService()
public ShardRequestCache requestCache()
public ShardFieldData fieldData()
public ShardRouting routingEntry()
public org.apache.lucene.search.QueryCachingPolicy getQueryCachingPolicy()
public void updateRoutingEntry(ShardRouting newRouting, boolean persistState)
public IndexShardState recovering(String reason, RecoveryState.Type type, DiscoveryNode sourceNode) throws IndexShardStartedException, IndexShardRelocatedException, IndexShardRecoveringException, IndexShardClosedException
public IndexShardState recovering(String reason, RecoveryState.Type type, RestoreSource restoreSource) throws IndexShardStartedException
IndexShardStartedException
public IndexShard relocated(String reason) throws IndexShardNotStartedException
IndexShardNotStartedException
public IndexShardState state()
public Engine.Create prepareCreateOnPrimary(SourceToParse source, long version, VersionType versionType, boolean canHaveDuplicates, boolean autoGeneratedId)
public Engine.Create prepareCreateOnReplica(SourceToParse source, long version, VersionType versionType, boolean canHaveDuplicates, boolean autoGeneratedId)
public void create(Engine.Create create)
public Engine.Index prepareIndexOnPrimary(SourceToParse source, long version, VersionType versionType, boolean canHaveDuplicates)
public Engine.Index prepareIndexOnReplica(SourceToParse source, long version, VersionType versionType, boolean canHaveDuplicates)
public boolean index(Engine.Index index)
public Engine.Delete prepareDeleteOnPrimary(String type, String id, long version, VersionType versionType)
public Engine.Delete prepareDeleteOnReplica(String type, String id, long version, VersionType versionType)
public void delete(Engine.Delete delete)
public Engine.GetResult get(Engine.Get get)
public void refresh(String source)
public RefreshStats refreshStats()
public FlushStats flushStats()
public DocsStats docStats()
@Nullable public CommitStats commitStats()
CommitStats
if engine is open, otherwise nullpublic IndexingStats indexingStats(String... types)
public SearchStats searchStats(String... groups)
public GetStats getStats()
public StoreStats storeStats()
public MergeStats mergeStats()
public SegmentsStats segmentStats()
public WarmerStats warmerStats()
public QueryCacheStats queryCacheStats()
public FieldDataStats fieldDataStats(String... fields)
public PercolatorQueriesRegistry percolateRegistry()
public ShardPercolateService shardPercolateService()
public TranslogStats translogStats()
public SuggestStats suggestStats()
public CompletionStats completionStats(String... fields)
public Engine.SyncedFlushResult syncFlush(String syncId, Engine.CommitId expectedCommitId)
public Engine.CommitId flush(FlushRequest request) throws ElasticsearchException
ElasticsearchException
public void forceMerge(ForceMergeRequest forceMerge) throws IOException
IOException
public org.apache.lucene.util.Version upgrade(UpgradeRequest upgrade) throws IOException
IOException
public org.apache.lucene.util.Version minimumCompatibleVersion()
public SnapshotIndexCommit snapshotIndex(boolean flushFirst) throws EngineException
EngineException
public void failShard(String reason, @Nullable Throwable e)
e
is caused by index corruptionpublic Engine.Searcher acquireSearcher(String source)
public void close(String reason, boolean flushEngine) throws IOException
IOException
public IndexShard postRecovery(String reason) throws IndexShardStartedException, IndexShardRelocatedException, IndexShardClosedException
public void prepareForIndexRecovery()
public int performBatchRecovery(Iterable<Translog.Operation> operations)
public ByteSizeValue getIndexingBufferSize()
public Map<String,Mapping> performTranslogRecovery(boolean indexExists)
public void skipTranslogRecovery() throws IOException
IOException
public void performRecoveryRestart() throws IOException
IOException
public RecoveryStats recoveryStats()
public RecoveryState recoveryState()
RecoveryState
if this shard is recovering or has been recovering.
Returns null if the recovery has not yet started or shard was not recovered (created via an API).public void finalizeRecovery()
postRecovery(String)
.public boolean ignoreRecoveryAttempt()
public void readAllowed() throws IllegalIndexShardStateException
IllegalIndexShardStateException
protected final void verifyStartedOrRecovering() throws IllegalIndexShardStateException
IllegalIndexShardStateException
protected final void verifyStarted() throws IllegalIndexShardStateException
IllegalIndexShardStateException
public void addFailedEngineListener(Engine.FailedEngineListener failedEngineListener)
public void updateBufferSize(ByteSizeValue shardIndexingBufferSize, ByteSizeValue shardTranslogBufferSize)
IndexWriter
is currently using more than
the new buffering indexing size then we do a refresh to free up the heap.public boolean checkIdle(long inactiveTimeNS)
IndexingMemoryController
to check whether more than inactiveTimeNS
has passed since the last
indexing operation, and become inactive (reducing indexing and translog buffers to tiny values) if so. This returns true
if the shard is inactive.public boolean getActive()
true
if this shard is active (has seen indexing ops in the last IndexingMemoryController.SHARD_INACTIVE_TIME_SETTING
(default 5 minutes), else false
.public final boolean isFlushOnClose()
public void deleteShardState() throws IOException
IOException
- if the delete failspublic ShardPath shardPath()
public void recoverFromStore(ShardRouting shard, StoreRecoveryService.RecoveryListener recoveryListener)
public Engine engine()
protected Engine engineUnsafe()
protected Engine newEngine(boolean skipTranslogRecovery, EngineConfig config)
public boolean allowsPrimaryPromotion()
true
iff this shard allows primary promotion, otherwise false
public void incrementOperationCounter()
public void decrementOperationCounter()
public int getOperationsCount()
public void sync(Translog.Location location)
public Translog.Durabilty getTranslogDurability()
Copyright © 2009–2016. All rights reserved.