Package org.opensearch.indices
Class IndicesService
java.lang.Object
org.opensearch.common.lifecycle.AbstractLifecycleComponent
org.opensearch.indices.IndicesService
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<IndexService>
,org.opensearch.common.lease.Releasable
,org.opensearch.common.lifecycle.LifecycleComponent
,IndexService.ShardStoreDeleter
,IndicesClusterStateService.AllocatedIndices<IndexShard,
IndexService>
@PublicApi(since="1.0.0")
public class IndicesService
extends org.opensearch.common.lifecycle.AbstractLifecycleComponent
implements IndicesClusterStateService.AllocatedIndices<IndexShard,IndexService>, IndexService.ShardStoreDeleter
Main OpenSearch indices service
- Opensearch.api:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An item in the index shard cachestatic enum
result type returned bysignaling different reasons why a shard can / cannot be deleted
Nested classes/interfaces inherited from interface org.opensearch.indices.cluster.IndicesClusterStateService.AllocatedIndices
IndicesClusterStateService.AllocatedIndices.IndexRemovalReason
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Setting
<org.opensearch.common.unit.TimeValue> This setting is used to set the refresh interval when theindex.refresh_interval
index setting is not provided during index creation or when the existingindex.refresh_interval
index setting is set as null.If enabled, this setting enforces that indexes will be created with a replication type matching the cluster setting defined in cluster.indices.replication.strategy by rejecting any request that specifies a replication type that does not match the cluster setting.static final Setting
<org.opensearch.common.unit.TimeValue> This setting is used to set the minimum refresh interval applicable for all indexes in a cluster.This setting is used to restrict creation or updation of index where the `index.translog.durability` index setting is set as ASYNC if enabled.static final Setting
<ReplicationType> static final String
Used to specify SEGMENT replication type as the default replication strategy for all indices in a cluster.static final Setting
<org.opensearch.common.unit.TimeValue> static final String
static final String
Fields inherited from class org.opensearch.common.lifecycle.AbstractLifecycleComponent
lifecycle
-
Constructor Summary
ConstructorDescriptionIndicesService
(Settings settings, PluginsService pluginsService, NodeEnvironment nodeEnv, org.opensearch.core.xcontent.NamedXContentRegistry xContentRegistry, AnalysisRegistry analysisRegistry, IndexNameExpressionResolver indexNameExpressionResolver, MapperRegistry mapperRegistry, org.opensearch.core.common.io.stream.NamedWriteableRegistry namedWriteableRegistry, ThreadPool threadPool, IndexScopedSettings indexScopedSettings, org.opensearch.core.indices.breaker.CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ScriptService scriptService, ClusterService clusterService, Client client, MetaStateService metaStateService, Collection<Function<IndexSettings, Optional<EngineFactory>>> engineFactoryProviders, Map<String, IndexStorePlugin.DirectoryFactory> directoryFactories, ValuesSourceRegistry valuesSourceRegistry, Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories, IndexStorePlugin.DirectoryFactory remoteDirectoryFactory, Supplier<RepositoriesService> repositoriesServiceSupplier, SearchRequestStats searchRequestStats, RemoteStoreStatsTrackerFactory remoteStoreStatsTrackerFactory, RecoverySettings recoverySettings, CacheService cacheService, RemoteStoreSettings remoteStoreSettings) IndicesService
(Settings settings, PluginsService pluginsService, NodeEnvironment nodeEnv, org.opensearch.core.xcontent.NamedXContentRegistry xContentRegistry, AnalysisRegistry analysisRegistry, IndexNameExpressionResolver indexNameExpressionResolver, MapperRegistry mapperRegistry, org.opensearch.core.common.io.stream.NamedWriteableRegistry namedWriteableRegistry, ThreadPool threadPool, IndexScopedSettings indexScopedSettings, org.opensearch.core.indices.breaker.CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ScriptService scriptService, ClusterService clusterService, Client client, MetaStateService metaStateService, Collection<Function<IndexSettings, Optional<EngineFactory>>> engineFactoryProviders, Map<String, IndexStorePlugin.DirectoryFactory> directoryFactories, ValuesSourceRegistry valuesSourceRegistry, Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories, IndexStorePlugin.DirectoryFactory remoteDirectoryFactory, Supplier<RepositoriesService> repositoriesServiceSupplier, SearchRequestStats searchRequestStats, RemoteStoreStatsTrackerFactory remoteStoreStatsTrackerFactory, RecoverySettings recoverySettings, CacheService cacheService, RemoteStoreSettings remoteStoreSettings, FileCache fileCache) IndicesService
(Settings settings, PluginsService pluginsService, NodeEnvironment nodeEnv, org.opensearch.core.xcontent.NamedXContentRegistry xContentRegistry, AnalysisRegistry analysisRegistry, IndexNameExpressionResolver indexNameExpressionResolver, MapperRegistry mapperRegistry, org.opensearch.core.common.io.stream.NamedWriteableRegistry namedWriteableRegistry, ThreadPool threadPool, IndexScopedSettings indexScopedSettings, org.opensearch.core.indices.breaker.CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ScriptService scriptService, ClusterService clusterService, Client client, MetaStateService metaStateService, Collection<Function<IndexSettings, Optional<EngineFactory>>> engineFactoryProviders, Map<String, IndexStorePlugin.DirectoryFactory> directoryFactories, ValuesSourceRegistry valuesSourceRegistry, Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories, IndexStorePlugin.DirectoryFactory remoteDirectoryFactory, Supplier<RepositoriesService> repositoriesServiceSupplier, SearchRequestStats searchRequestStats, RemoteStoreStatsTrackerFactory remoteStoreStatsTrackerFactory, RecoverySettings recoverySettings, CacheService cacheService, RemoteStoreSettings remoteStoreSettings, FileCache fileCache, CompositeIndexSettings compositeIndexSettings, Consumer<IndexShard> replicator) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Accumulate stats from the passed Objectvoid
addPendingDelete
(org.opensearch.core.index.Index index, IndexSettings settings) Adds a pending delete for the given index.void
addPendingDelete
(org.opensearch.core.index.shard.ShardId shardId, IndexSettings settings) Adds a pending delete for the given index shard.boolean
boolean
awaitClose
(long timeout, TimeUnit timeUnit) Wait for thisIndicesService
to be effectively closed.buildAliasFilter
(ClusterState state, String index, Set<String> resolvedExpressions) boolean
canCache
(ShardSearchRequest request, SearchContext context) Can the shard request be cached at all?boolean
canDeleteIndexContents
(org.opensearch.core.index.Index index, IndexSettings indexSettings) This method returns true if the current node is allowed to delete the given index.canDeleteShardContent
(org.opensearch.core.index.shard.ShardId shardId, IndexSettings indexSettings) ReturnsShardDeletionCheckResult
signaling whether the shards content for the given shard can be deleted.void
clearIndexShardCache
(org.opensearch.core.index.shard.ShardId shardId, boolean queryCache, boolean fieldDataCache, boolean requestCache, String... fields) Clears the caches for the given shard id if the shard is still allocated on this nodecreateIndex
(IndexMetadata indexMetadata, List<IndexEventListener> builtInListeners, boolean writeDanglingIndices) Creates a newIndexService
for the given metadata.createIndexMapperService
(IndexMetadata indexMetadata) creates a new mapper service for the given index, in order to do administrative work like mapping updates.createShard
(ShardRouting shardRouting, SegmentReplicationCheckpointPublisher checkpointPublisher, PeerRecoveryTargetService recoveryTargetService, RecoveryListener recoveryListener, RepositoriesService repositoriesService, Consumer<IndexShard.ShardFailure> onShardFailure, Consumer<org.opensearch.core.index.shard.ShardId> globalCheckpointSyncer, RetentionLeaseSyncer retentionLeaseSyncer, DiscoveryNode targetNode, DiscoveryNode sourceNode, RemoteStoreStatsTrackerFactory remoteStoreStatsTrackerFactory, DiscoveryNodes discoveryNodes) Creates a shard for the specified shard routing and starts recovery.void
deleteShardStore
(String reason, org.opensearch.core.index.shard.ShardId shardId, ClusterState clusterState) This method deletes the shard contents on disk for the given shard ID.void
deleteShardStore
(String reason, ShardLock lock, IndexSettings indexSettings) Deletes the shard with an already acquired shard lock.void
deleteUnassignedIndex
(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()
org.opensearch.core.indices.breaker.CircuitBreakerService
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.getRewriteContext
(LongSupplier nowInMillis) Returns a newQueryRewriteContext
with the givennow
providerorg.opensearch.core.common.unit.ByteSizeValue
getValidationRewriteContext
(LongSupplier nowInMillis) Returns a newQueryRewriteContext
for query validation with the givennow
providerboolean
hasIndex
(org.opensearch.core.index.Index index) boolean
Checks if all pending deletes have completed.indexService
(org.opensearch.core.index.Index index) Returns an IndexService for the specified index if exists otherwise returnsnull
.indexServiceSafe
(org.opensearch.core.index.Index index) Returns an IndexService for the specified index if exists otherwise aIndexNotFoundException
is thrown.boolean
boolean
isMetadataField
(org.opensearch.Version indexCreatedVersion, String field) Returns true if the provided field is a registered metadata field (including ones registered via plugins), false otherwise.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 thecontext's query result
.void
processPendingDeletes
(org.opensearch.core.index.Index index, IndexSettings indexSettings, org.opensearch.common.unit.TimeValue timeout) Processes all pending deletes for the given index.void
removeIndex
(org.opensearch.core.index.Index index, IndicesClusterStateService.AllocatedIndices.IndexRemovalReason reason, String extraInfo) Removes the given index from this service and releases all associated resources.stats
(CommonStatsFlags flags) verifyIndexIsDeleted
(org.opensearch.core.index.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 givenmetadata
holds sane values to create anIndexService
.<T,
E extends Exception>
TwithTempIndexService
(IndexMetadata indexMetadata, org.opensearch.common.CheckedFunction<IndexService, T, E> indexServiceConsumer) Methods inherited from class org.opensearch.common.lifecycle.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opensearch.indices.cluster.IndicesClusterStateService.AllocatedIndices
getShardOrNull
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
INDICES_CACHE_CLEANUP_INTERVAL_SETTING_KEY
- See Also:
-
INDICES_SHARDS_CLOSED_TIMEOUT
- See Also:
-
INDICES_CACHE_CLEAN_INTERVAL_SETTING
public static final Setting<org.opensearch.common.unit.TimeValue> INDICES_CACHE_CLEAN_INTERVAL_SETTING -
INDICES_ID_FIELD_DATA_ENABLED_SETTING
-
WRITE_DANGLING_INDICES_INFO_SETTING
-
CLUSTER_SETTING_REPLICATION_TYPE
Used to specify SEGMENT replication type as the default replication strategy for all indices in a cluster. By default, this is false.- See Also:
-
CLUSTER_REPLICATION_TYPE_SETTING
-
CLUSTER_DEFAULT_INDEX_REFRESH_INTERVAL_SETTING
public static final Setting<org.opensearch.common.unit.TimeValue> CLUSTER_DEFAULT_INDEX_REFRESH_INTERVAL_SETTINGThis setting is used to set the refresh interval when theindex.refresh_interval
index setting is not provided during index creation or when the existingindex.refresh_interval
index setting is set as null. This comes handy when the user wants to set a default refresh interval across all indexes created in a cluster which is different from 1s and also at the same time have searchIdle feature supported. The setting can only be as low as thecluster.minimum.index.refresh_interval
. -
CLUSTER_MINIMUM_INDEX_REFRESH_INTERVAL_SETTING
public static final Setting<org.opensearch.common.unit.TimeValue> CLUSTER_MINIMUM_INDEX_REFRESH_INTERVAL_SETTINGThis setting is used to set the minimum refresh interval applicable for all indexes in a cluster. Thecluster.default.index.refresh_interval
setting value needs to be higher than this setting's value. Index creation will fail if the index settingindex.refresh_interval
is supplied with a value lower than the cluster minimum refresh interval. -
CLUSTER_REMOTE_INDEX_RESTRICT_ASYNC_DURABILITY_SETTING
This setting is used to restrict creation or updation of index where the `index.translog.durability` index setting is set as ASYNC if enabled. If disabled, any of the durability mode can be used and switched at any later time from one to another. -
CLUSTER_INDEX_RESTRICT_REPLICATION_TYPE_SETTING
If enabled, this setting enforces that indexes will be created with a replication type matching the cluster setting defined in cluster.indices.replication.strategy by rejecting any request that specifies a replication type that does not match the cluster setting. If disabled, a user can choose a replication type on a per-index basis using the index.replication.type setting.
-
-
Constructor Details
-
IndicesService
public IndicesService(Settings settings, PluginsService pluginsService, NodeEnvironment nodeEnv, org.opensearch.core.xcontent.NamedXContentRegistry xContentRegistry, AnalysisRegistry analysisRegistry, IndexNameExpressionResolver indexNameExpressionResolver, MapperRegistry mapperRegistry, org.opensearch.core.common.io.stream.NamedWriteableRegistry namedWriteableRegistry, ThreadPool threadPool, IndexScopedSettings indexScopedSettings, org.opensearch.core.indices.breaker.CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ScriptService scriptService, ClusterService clusterService, Client client, MetaStateService metaStateService, Collection<Function<IndexSettings, Optional<EngineFactory>>> engineFactoryProviders, Map<String, IndexStorePlugin.DirectoryFactory> directoryFactories, ValuesSourceRegistry valuesSourceRegistry, Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories, IndexStorePlugin.DirectoryFactory remoteDirectoryFactory, Supplier<RepositoriesService> repositoriesServiceSupplier, SearchRequestStats searchRequestStats, @Nullable RemoteStoreStatsTrackerFactory remoteStoreStatsTrackerFactory, RecoverySettings recoverySettings, CacheService cacheService, RemoteStoreSettings remoteStoreSettings, FileCache fileCache, CompositeIndexSettings compositeIndexSettings, Consumer<IndexShard> replicator) -
IndicesService
public IndicesService(Settings settings, PluginsService pluginsService, NodeEnvironment nodeEnv, org.opensearch.core.xcontent.NamedXContentRegistry xContentRegistry, AnalysisRegistry analysisRegistry, IndexNameExpressionResolver indexNameExpressionResolver, MapperRegistry mapperRegistry, org.opensearch.core.common.io.stream.NamedWriteableRegistry namedWriteableRegistry, ThreadPool threadPool, IndexScopedSettings indexScopedSettings, org.opensearch.core.indices.breaker.CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ScriptService scriptService, ClusterService clusterService, Client client, MetaStateService metaStateService, Collection<Function<IndexSettings, Optional<EngineFactory>>> engineFactoryProviders, Map<String, IndexStorePlugin.DirectoryFactory> directoryFactories, ValuesSourceRegistry valuesSourceRegistry, Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories, IndexStorePlugin.DirectoryFactory remoteDirectoryFactory, Supplier<RepositoriesService> repositoriesServiceSupplier, SearchRequestStats searchRequestStats, @Nullable RemoteStoreStatsTrackerFactory remoteStoreStatsTrackerFactory, RecoverySettings recoverySettings, CacheService cacheService, RemoteStoreSettings remoteStoreSettings, FileCache fileCache) -
IndicesService
public IndicesService(Settings settings, PluginsService pluginsService, NodeEnvironment nodeEnv, org.opensearch.core.xcontent.NamedXContentRegistry xContentRegistry, AnalysisRegistry analysisRegistry, IndexNameExpressionResolver indexNameExpressionResolver, MapperRegistry mapperRegistry, org.opensearch.core.common.io.stream.NamedWriteableRegistry namedWriteableRegistry, ThreadPool threadPool, IndexScopedSettings indexScopedSettings, org.opensearch.core.indices.breaker.CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ScriptService scriptService, ClusterService clusterService, Client client, MetaStateService metaStateService, Collection<Function<IndexSettings, Optional<EngineFactory>>> engineFactoryProviders, Map<String, IndexStorePlugin.DirectoryFactory> directoryFactories, ValuesSourceRegistry valuesSourceRegistry, Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories, IndexStorePlugin.DirectoryFactory remoteDirectoryFactory, Supplier<RepositoriesService> repositoriesServiceSupplier, SearchRequestStats searchRequestStats, @Nullable RemoteStoreStatsTrackerFactory remoteStoreStatsTrackerFactory, RecoverySettings recoverySettings, CacheService cacheService, RemoteStoreSettings remoteStoreSettings)
-
-
Method Details
-
doStart
protected void doStart()- Specified by:
doStart
in classorg.opensearch.common.lifecycle.AbstractLifecycleComponent
-
clusterService
-
doStop
protected void doStop()- Specified by:
doStop
in classorg.opensearch.common.lifecycle.AbstractLifecycleComponent
-
doClose
- Specified by:
doClose
in classorg.opensearch.common.lifecycle.AbstractLifecycleComponent
- Throws:
IOException
-
awaitClose
Wait for thisIndicesService
to be effectively closed. When this returnstrue
, all shards and shard stores are closed and all shardclosed listeners
have run. However someshard closed listeners
might not have run.- Returns:
- true if all shards closed within the given timeout, false otherwise
- Throws:
InterruptedException
- if the current thread got interrupted while waiting for shards to close
-
stats
-
iterator
- Specified by:
iterator
in interfaceIterable<IndexService>
-
hasIndex
public boolean hasIndex(org.opensearch.core.index.Index index) -
indexService
Returns an IndexService for the specified index if exists otherwise returnsnull
.- Specified by:
indexService
in interfaceIndicesClusterStateService.AllocatedIndices<IndexShard,
IndexService>
-
indexServiceSafe
Returns an IndexService for the specified index if exists otherwise aIndexNotFoundException
is thrown. -
createIndex
public IndexService createIndex(IndexMetadata indexMetadata, List<IndexEventListener> builtInListeners, boolean writeDanglingIndices) throws IOException Creates a newIndexService
for the given metadata.- Specified by:
createIndex
in interfaceIndicesClusterStateService.AllocatedIndices<IndexShard,
IndexService> - Parameters:
indexMetadata
- the index metadata to create the index forbuiltInListeners
- a list of built-in lifecycleIndexEventListener
that should should be used along side with the per-index listenerswriteDanglingIndices
- whether dangling indices information should be written- Throws:
ResourceAlreadyExistsException
- if the index already exists.IOException
-
withTempIndexService
public <T,E extends Exception> T withTempIndexService(IndexMetadata indexMetadata, org.opensearch.common.CheckedFunction<IndexService, T, throws IOException, EE> indexServiceConsumer) - Throws:
IOException
E
-
createIndexMapperService
creates a new mapper service for the given index, in order to do administrative work like mapping updates. This *should not* be used for document parsing. Doing so will result in an exception.Note: the returned
MapperService
should be closed when unneeded.- Throws:
IOException
-
verifyIndexMetadata
public void verifyIndexMetadata(IndexMetadata metadata, IndexMetadata metadataUpdate) throws IOException This method verifies that the givenmetadata
holds sane values to create anIndexService
. This method tries to update the meta data of the createdIndexService
if the givenmetadataUpdate
is different from the givenmetadata
. This method will throw an exception if the creation or the update fails. The createdIndexService
will not be registered and will be closed immediately.- Throws:
IOException
-
createShard
public IndexShard createShard(ShardRouting shardRouting, SegmentReplicationCheckpointPublisher checkpointPublisher, PeerRecoveryTargetService recoveryTargetService, RecoveryListener recoveryListener, RepositoriesService repositoriesService, Consumer<IndexShard.ShardFailure> onShardFailure, Consumer<org.opensearch.core.index.shard.ShardId> globalCheckpointSyncer, RetentionLeaseSyncer retentionLeaseSyncer, DiscoveryNode targetNode, DiscoveryNode sourceNode, RemoteStoreStatsTrackerFactory remoteStoreStatsTrackerFactory, DiscoveryNodes discoveryNodes) throws IOException Description copied from interface:IndicesClusterStateService.AllocatedIndices
Creates a shard for the specified shard routing and starts recovery.- Specified by:
createShard
in interfaceIndicesClusterStateService.AllocatedIndices<IndexShard,
IndexService> - Parameters:
shardRouting
- the shard routingrecoveryTargetService
- recovery service for the targetrecoveryListener
- a callback when recovery changes state (finishes or fails)repositoriesService
- service responsible for snapshot/restoreonShardFailure
- a callback when this shard failsglobalCheckpointSyncer
- a callback when this shard syncs the global checkpointretentionLeaseSyncer
- a callback when this shard syncs retention leasestargetNode
- the node where this shard will be recoveredsourceNode
- the source node to recover this shard from (it might be null)remoteStoreStatsTrackerFactory
- factory for remote store stats trackers- Returns:
- a new shard
- Throws:
IOException
- if an I/O exception occurs when creating the shard
-
removeIndex
public void removeIndex(org.opensearch.core.index.Index index, IndicesClusterStateService.AllocatedIndices.IndexRemovalReason reason, String extraInfo) Description copied from interface:IndicesClusterStateService.AllocatedIndices
Removes the given index from this service and releases all associated resources. Persistent parts of the index like the shards files, state and transaction logs are kept around in the case of a disaster recovery.- Specified by:
removeIndex
in interfaceIndicesClusterStateService.AllocatedIndices<IndexShard,
IndexService> - Parameters:
index
- the index to removereason
- the reason to remove the indexextraInfo
- extra information that will be used for logging and reporting
-
getIndicesFieldDataCache
-
getCircuitBreakerService
public org.opensearch.core.indices.breaker.CircuitBreakerService getCircuitBreakerService() -
getIndicesQueryCache
-
addDocStatusStats
Accumulate stats from the passed Object- Parameters:
stats
- Instance storingIndexingStats.Stats.DocStatusStats
-
deleteUnassignedIndex
Deletes an index that is not assigned to this node. This method cleans up all disk folders relating to the index but does not deal with in-memory structures. For those callremoveIndex(Index, IndexRemovalReason, String)
- Specified by:
deleteUnassignedIndex
in interfaceIndicesClusterStateService.AllocatedIndices<IndexShard,
IndexService>
-
deleteShardStore
public void deleteShardStore(String reason, ShardLock lock, IndexSettings indexSettings) throws IOException Deletes the shard with an already acquired shard lock.- Specified by:
deleteShardStore
in interfaceIndexService.ShardStoreDeleter
- Parameters:
reason
- the reason for the shard deletionlock
- the lock of the shard to deleteindexSettings
- the shards index settings.- Throws:
IOException
- if an IOException occurs
-
deleteShardStore
public void deleteShardStore(String reason, org.opensearch.core.index.shard.ShardId shardId, ClusterState clusterState) throws IOException, ShardLockObtainFailedException This method deletes the shard contents on disk for the given shard ID. This method will fail if the shard deleting is prevented bycanDeleteShardContent(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.
- Parameters:
reason
- the reason for the shard deletionshardId
- the shards ID to deleteclusterState
- . This is required to access the indexes settings etc.- Throws:
IOException
- if an IOException occursShardLockObtainFailedException
-
canDeleteIndexContents
public boolean canDeleteIndexContents(org.opensearch.core.index.Index index, IndexSettings indexSettings) This method returns true if the current node is allowed to delete the given index. This is the case if the index is deleted in the metadata or there is no allocation on the local node and the index isn't on a shared file system.- Parameters:
index
-Index
to check whether deletion is allowedindexSettings
-IndexSettings
for the given index- Returns:
- true if the index can be deleted on this node
-
verifyIndexIsDeleted
@Nullable public IndexMetadata verifyIndexIsDeleted(org.opensearch.core.index.Index index, ClusterState clusterState) Verify that the contents on disk for the given index is deleted; if not, delete the contents. This method assumes that an index is already deleted in the cluster state and/or explicitly through index tombstones.- Specified by:
verifyIndexIsDeleted
in interfaceIndicesClusterStateService.AllocatedIndices<IndexShard,
IndexService> - Parameters:
index
-Index
to make sure its deleted from diskclusterState
-ClusterState
to ensure the index is not part of it- Returns:
- IndexMetadata for the index loaded from disk
-
canDeleteShardContent
public IndicesService.ShardDeletionCheckResult canDeleteShardContent(org.opensearch.core.index.shard.ShardId shardId, IndexSettings indexSettings) ReturnsShardDeletionCheckResult
signaling whether the shards content for the given shard can be deleted.- Parameters:
shardId
- the shard to delete.indexSettings
- the shards's relevantIndexSettings
. This is required to access the indexes settings etc.
-
addPendingDelete
public void addPendingDelete(org.opensearch.core.index.shard.ShardId shardId, IndexSettings settings) Adds a pending delete for the given index shard.- Specified by:
addPendingDelete
in interfaceIndexService.ShardStoreDeleter
-
addPendingDelete
Adds a pending delete for the given index. -
processPendingDeletes
public void processPendingDeletes(org.opensearch.core.index.Index index, IndexSettings indexSettings, org.opensearch.common.unit.TimeValue timeout) throws IOException, InterruptedException, ShardLockObtainFailedException Processes all pending deletes for the given index. This method will acquire all locks for the given index and will process all pending deletes for this index. Pending deletes might occur if the OS doesn't allow deletion of files because they are used by a different process ie. on Windows where files might still be open by a virus scanner. On a shared filesystem a replica might not have been closed when the primary is deleted causing problems on delete calls so we schedule there deletes later.- Specified by:
processPendingDeletes
in interfaceIndicesClusterStateService.AllocatedIndices<IndexShard,
IndexService> - Parameters:
index
- the index to process the pending deletes fortimeout
- the timeout used for processing pending deletes- Throws:
IOException
InterruptedException
ShardLockObtainFailedException
-
hasUncompletedPendingDeletes
public boolean hasUncompletedPendingDeletes()Checks if all pending deletes have completed. Used by tests to ensure we don't check directory contents while deletion still ongoing. * The reason is that, on Windows, browsing the directory contents can interfere with the deletion process and delay it unnecessarily. -
getAnalysis
-
canCache
Can the shard request be cached at all? -
loadIntoContext
public void loadIntoContext(ShardSearchRequest request, SearchContext context, QueryPhase queryPhase) throws Exception Loads the cache result, computing it if needed by executing the query phase and otherwise deserializing the cached value into thecontext'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.- Throws:
Exception
-
getTotalIndexingBufferBytes
public org.opensearch.core.common.unit.ByteSizeValue getTotalIndexingBufferBytes() -
buildAliasFilter
public AliasFilter buildAliasFilter(ClusterState state, String index, Set<String> resolvedExpressions) -
getRewriteContext
Returns a newQueryRewriteContext
with the givennow
provider -
getValidationRewriteContext
Returns a newQueryRewriteContext
for query validation with the givennow
provider -
clearIndexShardCache
public void clearIndexShardCache(org.opensearch.core.index.shard.ShardId shardId, boolean queryCache, boolean fieldDataCache, boolean requestCache, String... fields) Clears the caches for the given shard id if the shard is still allocated on this node -
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. Useful to filter the fields that such API return. The predicate receives the field name as input argument. In case multiple plugins register a field filter throughMapperPlugin.getFieldFilter()
, only fields that match all the registered filters will be returned by get mappings, get index, get field mappings and field capabilities API. -
isMetadataField
Returns true if the provided field is a registered metadata field (including ones registered via plugins), false otherwise. -
isIdFieldDataEnabled
public boolean isIdFieldDataEnabled() -
allPendingDanglingIndicesWritten
public boolean allPendingDanglingIndicesWritten() -
getRemoteStoreSettings
-
getCompositeIndexSettings
-