Package org.elasticsearch.index
Class IndexService
java.lang.Object
org.elasticsearch.index.AbstractIndexComponent
org.elasticsearch.index.IndexService
- All Implemented Interfaces:
java.lang.Iterable<IndexShard>
,IndexComponent
,IndicesClusterStateService.AllocatedIndex<IndexShard>
public class IndexService extends AbstractIndexComponent implements IndicesClusterStateService.AllocatedIndex<IndexShard>
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IndexService.IndexCreationContext
static interface
IndexService.ShardStoreDeleter
-
Field Summary
Fields Modifier and Type Field Description static Setting<org.elasticsearch.common.unit.TimeValue>
GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING
static Setting<org.elasticsearch.common.unit.TimeValue>
RETENTION_LEASE_SYNC_INTERVAL_SETTING
Fields inherited from class org.elasticsearch.index.AbstractIndexComponent
deprecationLogger, logger
-
Constructor Summary
Constructors Constructor Description IndexService(IndexSettings indexSettings, IndexService.IndexCreationContext indexCreationContext, NodeEnvironment nodeEnv, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, SimilarityService similarityService, IndexService.ShardStoreDeleter shardStoreDeleter, IndexAnalyzers indexAnalyzers, EngineFactory engineFactory, CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ThreadPool threadPool, ScriptService scriptService, ClusterService clusterService, Client client, QueryCache queryCache, IndexStorePlugin.DirectoryFactory directoryFactory, IndexEventListener eventListener, java.util.function.Function<IndexService,org.elasticsearch.common.CheckedFunction<org.apache.lucene.index.DirectoryReader,org.apache.lucene.index.DirectoryReader,java.io.IOException>> wrapperFactory, MapperRegistry mapperRegistry, IndicesFieldDataCache indicesFieldDataCache, java.util.List<SearchOperationListener> searchOperationListeners, java.util.List<IndexingOperationListener> indexingOperationListeners, NamedWriteableRegistry namedWriteableRegistry, java.util.function.BooleanSupplier idFieldDataEnabled, java.util.function.BooleanSupplier allowExpensiveQueries, IndexNameExpressionResolver expressionResolver, ValuesSourceRegistry valuesSourceRegistry, IndexStorePlugin.RecoveryStateFactory recoveryStateFactory)
-
Method Summary
Modifier and Type Method Description void
addMetadataListener(java.util.function.Consumer<IndexMetadata> listener)
IndexCache
cache()
boolean
clearCaches(boolean queryCache, boolean fieldDataCache, java.lang.String... fields)
Clears the caches for the given shard id if the shard is still allocated on this nodevoid
close(java.lang.String reason, boolean delete)
RecoveryState
createRecoveryState(ShardRouting shardRouting, DiscoveryNode targetNode, DiscoveryNode sourceNode)
IndexShard
createShard(ShardRouting routing, java.util.function.Consumer<ShardId> globalCheckpointSyncer, RetentionLeaseSyncer retentionLeaseSyncer)
void
deleteDanglingIndicesInfo()
BigArrays
getBigArrays()
TheBigArrays
to use for this index.EngineFactory
getEngineFactory()
IndexAnalyzers
getIndexAnalyzers()
IndexEventListener
getIndexEventListener()
IndexSettings
getIndexSettings()
Returns the index settings of this index.java.util.function.Supplier<org.apache.lucene.search.Sort>
getIndexSortSupplier()
IndexMetadata
getMetadata()
ScriptService
getScriptService()
TheScriptService
to use for this index.IndexShard
getShard(int shardId)
Return the shard with the provided id, or throw an exception if it doesn't exist.IndexShard
getShardOrNull(int shardId)
Return the shard with the provided id, or null if there is no such shard.ThreadPool
getThreadPool()
TheThreadPool
to use for this index.boolean
hasShard(int shardId)
java.lang.String
indexUUID()
java.util.Iterator<IndexShard>
iterator()
MapperService
mapperService()
QueryShardContext
newQueryShardContext(int shardId, org.apache.lucene.search.IndexSearcher searcher, java.util.function.LongSupplier nowInMillis, java.lang.String clusterAlias)
Creates a new QueryShardContext.int
numberOfShards()
void
removeShard(int shardId, java.lang.String reason)
Removes shard with given id.java.util.Set<java.lang.Integer>
shardIds()
SimilarityService
similarityService()
boolean
updateMapping(IndexMetadata currentIndexMetadata, IndexMetadata newIndexMetadata)
Checks if index requires refresh from master.void
updateMetadata(IndexMetadata currentIndexMetadata, IndexMetadata newIndexMetadata)
Updates the metadata of this index.void
writeDanglingIndicesInfo()
org.elasticsearch.common.xcontent.NamedXContentRegistry
xContentRegistry()
-
Field Details
-
GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING
public static final Setting<org.elasticsearch.common.unit.TimeValue> GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING -
RETENTION_LEASE_SYNC_INTERVAL_SETTING
public static final Setting<org.elasticsearch.common.unit.TimeValue> RETENTION_LEASE_SYNC_INTERVAL_SETTING
-
-
Constructor Details
-
IndexService
public IndexService(IndexSettings indexSettings, IndexService.IndexCreationContext indexCreationContext, NodeEnvironment nodeEnv, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, SimilarityService similarityService, IndexService.ShardStoreDeleter shardStoreDeleter, IndexAnalyzers indexAnalyzers, EngineFactory engineFactory, CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ThreadPool threadPool, ScriptService scriptService, ClusterService clusterService, Client client, QueryCache queryCache, IndexStorePlugin.DirectoryFactory directoryFactory, IndexEventListener eventListener, java.util.function.Function<IndexService,org.elasticsearch.common.CheckedFunction<org.apache.lucene.index.DirectoryReader,org.apache.lucene.index.DirectoryReader,java.io.IOException>> wrapperFactory, MapperRegistry mapperRegistry, IndicesFieldDataCache indicesFieldDataCache, java.util.List<SearchOperationListener> searchOperationListeners, java.util.List<IndexingOperationListener> indexingOperationListeners, NamedWriteableRegistry namedWriteableRegistry, java.util.function.BooleanSupplier idFieldDataEnabled, java.util.function.BooleanSupplier allowExpensiveQueries, IndexNameExpressionResolver expressionResolver, ValuesSourceRegistry valuesSourceRegistry, IndexStorePlugin.RecoveryStateFactory recoveryStateFactory)
-
-
Method Details
-
numberOfShards
public int numberOfShards() -
getIndexEventListener
-
iterator
- Specified by:
iterator
in interfacejava.lang.Iterable<IndexShard>
-
hasShard
public boolean hasShard(int shardId) -
getShardOrNull
Return the shard with the provided id, or null if there is no such shard.- Specified by:
getShardOrNull
in interfaceIndicesClusterStateService.AllocatedIndex<IndexShard>
-
getShard
Return the shard with the provided id, or throw an exception if it doesn't exist. -
shardIds
public java.util.Set<java.lang.Integer> shardIds() -
cache
-
getIndexAnalyzers
-
mapperService
-
xContentRegistry
public org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry() -
similarityService
-
getIndexSortSupplier
public java.util.function.Supplier<org.apache.lucene.search.Sort> getIndexSortSupplier() -
close
public void close(java.lang.String reason, boolean delete) throws java.io.IOException- Throws:
java.io.IOException
-
writeDanglingIndicesInfo
public void writeDanglingIndicesInfo() -
deleteDanglingIndicesInfo
public void deleteDanglingIndicesInfo() -
indexUUID
public java.lang.String indexUUID() -
createShard
public IndexShard createShard(ShardRouting routing, java.util.function.Consumer<ShardId> globalCheckpointSyncer, RetentionLeaseSyncer retentionLeaseSyncer) throws java.io.IOException- Throws:
java.io.IOException
-
removeShard
public void removeShard(int shardId, java.lang.String reason)Description copied from interface:IndicesClusterStateService.AllocatedIndex
Removes shard with given id.- Specified by:
removeShard
in interfaceIndicesClusterStateService.AllocatedIndex<IndexShard>
-
createRecoveryState
public RecoveryState createRecoveryState(ShardRouting shardRouting, DiscoveryNode targetNode, DiscoveryNode sourceNode) -
getIndexSettings
Description copied from interface:IndicesClusterStateService.AllocatedIndex
Returns the index settings of this index.- Specified by:
getIndexSettings
in interfaceIndicesClusterStateService.AllocatedIndex<IndexShard>
- Overrides:
getIndexSettings
in classAbstractIndexComponent
-
newQueryShardContext
public QueryShardContext newQueryShardContext(int shardId, org.apache.lucene.search.IndexSearcher searcher, java.util.function.LongSupplier nowInMillis, java.lang.String clusterAlias)Creates a new QueryShardContext. The context has not types set yet, if types are required set them viaQueryShardContext.setTypes(String...)
. Passing anull
IndexSearcher
will return a valid context, however it won't be able to makeIndexReader
-specific optimizations, such as rewriting containing range queries. -
getThreadPool
TheThreadPool
to use for this index. -
getBigArrays
TheBigArrays
to use for this index. -
getScriptService
TheScriptService
to use for this index. -
updateMapping
public boolean updateMapping(IndexMetadata currentIndexMetadata, IndexMetadata newIndexMetadata) throws java.io.IOExceptionDescription copied from interface:IndicesClusterStateService.AllocatedIndex
Checks if index requires refresh from master.- Specified by:
updateMapping
in interfaceIndicesClusterStateService.AllocatedIndex<IndexShard>
- Throws:
java.io.IOException
-
getMetadata
-
addMetadataListener
-
updateMetadata
Description copied from interface:IndicesClusterStateService.AllocatedIndex
Updates the metadata of this index. Changes become visible throughIndicesClusterStateService.AllocatedIndex.getIndexSettings()
.- Specified by:
updateMetadata
in interfaceIndicesClusterStateService.AllocatedIndex<IndexShard>
- Parameters:
currentIndexMetadata
- the current index metadatanewIndexMetadata
- the new index metadata
-
getEngineFactory
-
clearCaches
public boolean clearCaches(boolean queryCache, boolean fieldDataCache, java.lang.String... fields)Clears the caches for the given shard id if the shard is still allocated on this node
-