java.io.Closeable, java.lang.AutoCloseable, java.lang.Iterable<IndexShard>, LifecycleComponent, Releasable, IndexService.ShardStoreDeleter, IndicesClusterStateService.AllocatedIndices<IndexShard,IndexService>public class IndicesService extends AbstractLifecycleComponent implements IndicesClusterStateService.AllocatedIndices<IndexShard,IndexService>, IndexService.ShardStoreDeleter
| Modifier and Type | Class | 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 | Description |
|---|---|---|
static Setting<TimeValue> |
INDICES_CACHE_CLEAN_INTERVAL_SETTING |
|
static java.lang.String |
INDICES_SHARDS_CLOSED_TIMEOUT |
deprecationLogger, logger, settingslifecycle| Constructor | Description |
|---|---|
IndicesService(Settings settings,
PluginsService pluginsService,
NodeEnvironment nodeEnv,
NamedXContentRegistry xContentRegistry,
AnalysisRegistry analysisRegistry,
IndexNameExpressionResolver indexNameExpressionResolver,
MapperRegistry mapperRegistry,
NamedWriteableRegistry namedWriteableRegistry,
ThreadPool threadPool,
IndexScopedSettings indexScopedSettings,
CircuitBreakerService circuitBreakerService,
BigArrays bigArrays,
ScriptService scriptService,
Client client,
MetaStateService metaStateService) |
| Modifier and Type | Method | 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 |
clearIndexShardCache(ShardId shardId,
boolean queryCache,
boolean fieldDataCache,
boolean requestCache,
java.lang.String... fields) |
Clears the caches for the given shard id if the shard is still allocated on this node
|
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,
java.util.function.Consumer<ShardId> globalCheckpointSyncer) |
Creates shard for the specified shard routing and starts recovery,
|
void |
deleteShardStore(java.lang.String reason,
ShardLock lock,
IndexSettings indexSettings) |
Deletes the shard with an already acquired shard lock.
|
void |
deleteShardStore(java.lang.String reason,
ShardId shardId,
ClusterState clusterState) |
This method deletes the shard contents on disk for the given shard ID.
|
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() |
|
java.util.function.Function<java.lang.String,java.util.function.Predicate<java.lang.String>> |
getFieldFilter() |
Returns a function which given an index name, returns a predicate which fields must match in order to be returned by get mappings,
get index, get field mappings and field capabilities API.
|
IndicesFieldDataCache |
getIndicesFieldDataCache() |
|
IndicesQueryCache |
getIndicesQueryCache() |
|
QueryRewriteContext |
getRewriteContext(java.util.function.LongSupplier nowInMillis) |
Returns a new
QueryRewriteContext with the given now provider |
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. |
boolean |
isMetaDataField(java.lang.String field) |
Returns true if the provided field is a registered metadata field (including ones registered via plugins), false otherwise.
|
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. |
logDeprecatedSetting, logRemovedSetting, nodeNameaddLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stopgetShardOrNullpublic static final java.lang.String INDICES_SHARDS_CLOSED_TIMEOUT
public IndicesService(Settings settings, PluginsService pluginsService, NodeEnvironment nodeEnv, NamedXContentRegistry xContentRegistry, AnalysisRegistry analysisRegistry, IndexNameExpressionResolver indexNameExpressionResolver, MapperRegistry mapperRegistry, NamedWriteableRegistry namedWriteableRegistry, ThreadPool threadPool, IndexScopedSettings indexScopedSettings, CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ScriptService scriptService, Client client, MetaStateService metaStateService)
protected void doStart()
doStart in class AbstractLifecycleComponentprotected void doStop()
doStop in class AbstractLifecycleComponentprotected void doClose()
doClose in class AbstractLifecycleComponentpublic NodeIndicesStats stats(boolean includePrevious)
public NodeIndicesStats stats(boolean includePrevious, CommonStatsFlags flags)
public java.util.Iterator<IndexService> iterator()
iterator in interface java.lang.Iterable<IndexShard>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.IOExceptionpublic MapperService createIndexMapperService(IndexMetaData indexMetaData) throws java.io.IOException
MapperService should be closed when unneeded.java.io.IOExceptionpublic 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.IOExceptionpublic IndexShard createShard(ShardRouting shardRouting, RecoveryState recoveryState, PeerRecoveryTargetService recoveryTargetService, PeerRecoveryTargetService.RecoveryListener recoveryListener, RepositoriesService repositoriesService, java.util.function.Consumer<IndexShard.ShardFailure> onShardFailure, java.util.function.Consumer<ShardId> globalCheckpointSyncer) throws java.io.IOException
IndicesClusterStateService.AllocatedIndicescreateShard in interface IndicesClusterStateService.AllocatedIndices<IndexShard,IndexService>java.io.IOExceptionpublic void removeIndex(Index index, IndicesClusterStateService.AllocatedIndices.IndexRemovalReason reason, java.lang.String extraInfo)
IndicesClusterStateService.AllocatedIndicesremoveIndex 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)
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.ShardStoreDeleterreason - 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 occursShardLockObtainFailedExceptionpublic 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.ShardStoreDeleterpublic 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.IOExceptionjava.lang.InterruptedExceptionShardLockObtainFailedExceptionpublic boolean hasUncompletedPendingDeletes()
public AnalysisRegistry getAnalysis()
public boolean canCache(ShardSearchRequest request, SearchContext context)
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.Exceptionpublic ByteSizeValue getTotalIndexingBufferBytes()
public AliasFilter buildAliasFilter(ClusterState state, java.lang.String index, java.lang.String... expressions)
public QueryRewriteContext getRewriteContext(java.util.function.LongSupplier nowInMillis)
QueryRewriteContext with the given now providerpublic void clearIndexShardCache(ShardId shardId, boolean queryCache, boolean fieldDataCache, boolean requestCache, java.lang.String... fields)
public java.util.function.Function<java.lang.String,java.util.function.Predicate<java.lang.String>> getFieldFilter()
MapperPlugin.getFieldFilter(), only fields that match all the registered filters will be
returned by get mappings, get index, get field mappings and field capabilities API.public boolean isMetaDataField(java.lang.String field)