public class IndicesService extends AbstractLifecycleComponent implements IndicesClusterStateService.AllocatedIndices<IndexShard,IndexService>, IndexService.ShardStoreDeleter
Modifier and Type | Class and Description |
---|---|
static class |
IndicesService.ShardDeletionCheckResult
result type returned by
signaling different reasons why a shard can / cannot be deleted |
IndicesClusterStateService.AllocatedIndices.IndexRemovalReason
Modifier and Type | Field and Description |
---|---|
static Setting<TimeValue> |
INDICES_CACHE_CLEAN_INTERVAL_SETTING |
static java.lang.String |
INDICES_SHARDS_CLOSED_TIMEOUT |
lifecycle
deprecationLogger, logger, settings
Constructor and Description |
---|
IndicesService(Settings settings,
PluginsService pluginsService,
NodeEnvironment nodeEnv,
NamedXContentRegistry xContentRegistry,
ClusterSettings clusterSettings,
AnalysisRegistry analysisRegistry,
IndexNameExpressionResolver indexNameExpressionResolver,
MapperRegistry mapperRegistry,
NamedWriteableRegistry namedWriteableRegistry,
ThreadPool threadPool,
IndexScopedSettings indexScopedSettings,
CircuitBreakerService circuitBreakerService,
BigArrays bigArrays,
ScriptService scriptService,
ClusterService clusterService,
Client client,
MetaStateService metaStateService) |
Modifier and Type | Method and Description |
---|---|
void |
addPendingDelete(Index index,
IndexSettings settings)
Adds a pending delete for the given index.
|
void |
addPendingDelete(ShardId shardId,
IndexSettings settings)
Adds a pending delete for the given index shard.
|
AliasFilter |
buildAliasFilter(ClusterState state,
java.lang.String index,
java.lang.String... expressions) |
boolean |
canCache(ShardSearchRequest request,
SearchContext context)
Can the shard request be cached at all?
|
boolean |
canDeleteIndexContents(Index index,
IndexSettings indexSettings)
This method returns true if the current node is allowed to delete the given index.
|
IndicesService.ShardDeletionCheckResult |
canDeleteShardContent(ShardId shardId,
IndexSettings indexSettings)
Returns
ShardDeletionCheckResult signaling whether the shards content for the given shard can be deleted. |
void |
clearRequestCache(IndexShard shard) |
IndexService |
createIndex(IndexMetaData indexMetaData,
java.util.List<IndexEventListener> builtInListeners)
Creates a new
IndexService for the given metadata. |
MapperService |
createIndexMapperService(IndexMetaData indexMetaData)
creates a new mapper service for the given index, in order to do administrative work like mapping updates.
|
IndexShard |
createShard(ShardRouting shardRouting,
RecoveryState recoveryState,
PeerRecoveryTargetService recoveryTargetService,
PeerRecoveryTargetService.RecoveryListener recoveryListener,
RepositoriesService repositoriesService,
java.util.function.Consumer<IndexShard.ShardFailure> onShardFailure)
Creates shard for the specified shard routing and starts recovery,
|
void |
deleteShardStore(java.lang.String reason,
ShardId shardId,
ClusterState clusterState)
This method deletes the shard contents on disk for the given shard ID.
|
void |
deleteShardStore(java.lang.String reason,
ShardLock lock,
IndexSettings indexSettings)
Deletes the shard with an already acquired shard lock.
|
void |
deleteUnassignedIndex(java.lang.String reason,
IndexMetaData metaData,
ClusterState clusterState)
Deletes an index that is not assigned to this node.
|
protected void |
doClose() |
protected void |
doStart() |
protected void |
doStop() |
AnalysisRegistry |
getAnalysis() |
CircuitBreakerService |
getCircuitBreakerService() |
FieldStats<?> |
getFieldStats(IndexShard shard,
Engine.Searcher searcher,
java.lang.String field,
boolean useCache)
Fetch FieldStats for a field.
|
IndicesFieldDataCache |
getIndicesFieldDataCache() |
IndicesQueryCache |
getIndicesQueryCache() |
ByteSizeValue |
getTotalIndexingBufferBytes() |
boolean |
hasIndex(Index index) |
boolean |
hasUncompletedPendingDeletes()
Checks if all pending deletes have completed.
|
IndexService |
indexService(Index index)
Returns an IndexService for the specified index if exists otherwise returns
null . |
IndexService |
indexServiceSafe(Index index)
Returns an IndexService for the specified index if exists otherwise a
IndexNotFoundException is thrown. |
java.util.Iterator<IndexService> |
iterator() |
void |
loadIntoContext(ShardSearchRequest request,
SearchContext context,
QueryPhase queryPhase)
Loads the cache result, computing it if needed by executing the query phase and otherwise deserializing the cached
value into the
context's query result . |
void |
processPendingDeletes(Index index,
IndexSettings indexSettings,
TimeValue timeout)
Processes all pending deletes for the given index.
|
void |
removeIndex(Index index,
IndicesClusterStateService.AllocatedIndices.IndexRemovalReason reason,
java.lang.String extraInfo)
Removes the given index from this service and releases all associated resources.
|
NodeIndicesStats |
stats(boolean includePrevious)
Returns the node stats indices stats.
|
NodeIndicesStats |
stats(boolean includePrevious,
CommonStatsFlags flags) |
IndexMetaData |
verifyIndexIsDeleted(Index index,
ClusterState clusterState)
Verify that the contents on disk for the given index is deleted; if not, delete the contents.
|
void |
verifyIndexMetadata(IndexMetaData metaData,
IndexMetaData metaDataUpdate)
This method verifies that the given
metaData holds sane values to create an IndexService . |
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
logDeprecatedSetting, logRemovedSetting, nodeName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getShardOrNull
public static final java.lang.String INDICES_SHARDS_CLOSED_TIMEOUT
public IndicesService(Settings settings, PluginsService pluginsService, NodeEnvironment nodeEnv, NamedXContentRegistry xContentRegistry, ClusterSettings clusterSettings, AnalysisRegistry analysisRegistry, IndexNameExpressionResolver indexNameExpressionResolver, MapperRegistry mapperRegistry, NamedWriteableRegistry namedWriteableRegistry, ThreadPool threadPool, IndexScopedSettings indexScopedSettings, CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ScriptService scriptService, ClusterService clusterService, Client client, MetaStateService metaStateService)
protected void doStart()
doStart
in class AbstractLifecycleComponent
protected void doStop()
doStop
in class AbstractLifecycleComponent
protected void doClose()
doClose
in class AbstractLifecycleComponent
public NodeIndicesStats stats(boolean includePrevious)
public NodeIndicesStats stats(boolean includePrevious, CommonStatsFlags flags)
public java.util.Iterator<IndexService> iterator()
iterator
in interface java.lang.Iterable<IndexService>
public boolean hasIndex(Index index)
@Nullable public IndexService indexService(Index index)
null
.indexService
in interface IndicesClusterStateService.AllocatedIndices<IndexShard,IndexService>
public IndexService indexServiceSafe(Index index)
IndexNotFoundException
is thrown.public IndexService createIndex(IndexMetaData indexMetaData, java.util.List<IndexEventListener> builtInListeners) throws java.io.IOException
IndexService
for the given metadata.createIndex
in interface IndicesClusterStateService.AllocatedIndices<IndexShard,IndexService>
indexMetaData
- the index metadata to create the index forbuiltInListeners
- a list of built-in lifecycle IndexEventListener
that should should be used along side with the per-index listenersResourceAlreadyExistsException
- if the index already exists.java.io.IOException
public MapperService createIndexMapperService(IndexMetaData indexMetaData) throws java.io.IOException
MapperService
should be closed when unneeded.java.io.IOException
public void verifyIndexMetadata(IndexMetaData metaData, IndexMetaData metaDataUpdate) throws java.io.IOException
metaData
holds sane values to create an IndexService
.
This method tries to update the meta data of the created IndexService
if the given metaDataUpdate
is different from the given metaData
.
This method will throw an exception if the creation or the update fails.
The created IndexService
will not be registered and will be closed immediately.java.io.IOException
public IndexShard createShard(ShardRouting shardRouting, RecoveryState recoveryState, PeerRecoveryTargetService recoveryTargetService, PeerRecoveryTargetService.RecoveryListener recoveryListener, RepositoriesService repositoriesService, java.util.function.Consumer<IndexShard.ShardFailure> onShardFailure) throws java.io.IOException
IndicesClusterStateService.AllocatedIndices
createShard
in interface IndicesClusterStateService.AllocatedIndices<IndexShard,IndexService>
java.io.IOException
public void removeIndex(Index index, IndicesClusterStateService.AllocatedIndices.IndexRemovalReason reason, java.lang.String extraInfo)
IndicesClusterStateService.AllocatedIndices
removeIndex
in interface IndicesClusterStateService.AllocatedIndices<IndexShard,IndexService>
index
- the index to removereason
- the reason to remove the indexextraInfo
- extra information that will be used for logging and reportingpublic IndicesFieldDataCache getIndicesFieldDataCache()
public CircuitBreakerService getCircuitBreakerService()
public IndicesQueryCache getIndicesQueryCache()
public void deleteUnassignedIndex(java.lang.String reason, IndexMetaData metaData, ClusterState clusterState)
IndicesClusterStateService.AllocatedIndices.removeIndex(Index, IndexRemovalReason, String)
deleteUnassignedIndex
in interface IndicesClusterStateService.AllocatedIndices<IndexShard,IndexService>
public void deleteShardStore(java.lang.String reason, ShardLock lock, IndexSettings indexSettings) throws java.io.IOException
deleteShardStore
in interface IndexService.ShardStoreDeleter
reason
- the reason for the shard deletionlock
- the lock of the shard to deleteindexSettings
- the shards index settings.java.io.IOException
- if an IOException occurspublic void deleteShardStore(java.lang.String reason, ShardId shardId, ClusterState clusterState) throws java.io.IOException, ShardLockObtainFailedException
canDeleteShardContent(ShardId, IndexSettings)
of if the shards lock can not be acquired.
On data nodes, if the deleted shard is the last shard folder in its index, the method will attempt to remove the index folder as well.reason
- the reason for the shard deletionshardId
- the shards ID to deleteclusterState
- . This is required to access the indexes settings etc.java.io.IOException
- if an IOException occursShardLockObtainFailedException
public boolean canDeleteIndexContents(Index index, IndexSettings indexSettings)
index
- Index
to check whether deletion is allowedindexSettings
- IndexSettings
for the given index@Nullable public IndexMetaData verifyIndexIsDeleted(Index index, ClusterState clusterState)
verifyIndexIsDeleted
in interface IndicesClusterStateService.AllocatedIndices<IndexShard,IndexService>
index
- Index
to make sure its deleted from diskclusterState
- ClusterState
to ensure the index is not part of itpublic IndicesService.ShardDeletionCheckResult canDeleteShardContent(ShardId shardId, IndexSettings indexSettings)
ShardDeletionCheckResult
signaling whether the shards content for the given shard can be deleted.shardId
- the shard to delete.indexSettings
- the shards's relevant IndexSettings
. This is required to access the indexes settings etc.public void addPendingDelete(ShardId shardId, IndexSettings settings)
addPendingDelete
in interface IndexService.ShardStoreDeleter
public void addPendingDelete(Index index, IndexSettings settings)
public void processPendingDeletes(Index index, IndexSettings indexSettings, TimeValue timeout) throws java.io.IOException, java.lang.InterruptedException, ShardLockObtainFailedException
processPendingDeletes
in interface IndicesClusterStateService.AllocatedIndices<IndexShard,IndexService>
index
- the index to process the pending deletes fortimeout
- the timeout used for processing pending deletesjava.io.IOException
java.lang.InterruptedException
ShardLockObtainFailedException
public boolean hasUncompletedPendingDeletes()
public AnalysisRegistry getAnalysis()
public boolean canCache(ShardSearchRequest request, SearchContext context)
public void clearRequestCache(IndexShard shard)
public void loadIntoContext(ShardSearchRequest request, SearchContext context, QueryPhase queryPhase) throws java.lang.Exception
context's query result
. The combination of load + compute allows
to have a single load operation that will cause other requests with the same key to wait till its loaded an reuse
the same cache.java.lang.Exception
public FieldStats<?> getFieldStats(IndexShard shard, Engine.Searcher searcher, java.lang.String field, boolean useCache) throws java.lang.Exception
shard
- the shard to use with the cache keysearcher
- searcher to use to lookup the field statsfield
- the actual fielduseCache
- should this request use the cache?java.lang.Exception
public ByteSizeValue getTotalIndexingBufferBytes()
public AliasFilter buildAliasFilter(ClusterState state, java.lang.String index, java.lang.String... expressions)