public class IndicesService extends AbstractLifecycleComponent<IndicesService> implements Iterable<IndexService>
Modifier and Type | Field and Description |
---|---|
static String |
INDICES_SHARDS_CLOSED_TIMEOUT |
lifecycle
deprecationLogger, logger, settings
Constructor and Description |
---|
IndicesService(Settings settings,
IndicesLifecycle indicesLifecycle,
IndicesAnalysisService indicesAnalysisService,
Injector injector,
NodeEnvironment nodeEnv) |
Modifier and Type | Method and Description |
---|---|
void |
addPendingDelete(Index index,
Settings settings)
Adds a pending delete for the given index.
|
void |
addPendingDelete(ShardId shardId,
Settings settings)
Adds a pending delete for the given index shard.
|
boolean |
canDeleteIndexContents(Index index,
Settings indexSettings,
boolean closed)
This method returns true if the current node is allowed to delete the
given index.
|
boolean |
canDeleteShardContent(ShardId shardId,
IndexMetaData metaData)
Returns
true iff the shards content for the given shard can be deleted. |
boolean |
changesAllowed()
Returns true if changes (adding / removing) indices, shards and so on are allowed.
|
IndexService |
createIndex(String sIndexName,
Settings settings,
String localNodeId) |
void |
deleteClosedIndex(String reason,
IndexMetaData metaData,
ClusterState clusterState) |
void |
deleteIndex(String index,
String reason)
Deletes the given index.
|
void |
deleteIndexStore(String reason,
IndexMetaData metaData,
ClusterState clusterState,
boolean closed)
Deletes the index store trying to acquire all shards locks for this index.
|
void |
deleteShardStore(String reason,
ShardId shardId,
ClusterState clusterState)
This method deletes the shard contents on disk for the given shard ID.
|
void |
deleteShardStore(String reason,
ShardLock lock,
Settings indexSettings)
Deletes the shard with an already acquired shard lock.
|
protected void |
doClose() |
protected void |
doStart() |
protected void |
doStop() |
boolean |
hasIndex(String index) |
IndexService |
indexService(String index)
Returns an IndexService for the specified index if exists otherwise returns
null . |
IndexService |
indexServiceSafe(String index)
Returns an IndexService for the specified index if exists otherwise a
IndexNotFoundException is thrown. |
IndicesLifecycle |
indicesLifecycle() |
Iterator<IndexService> |
iterator() |
void |
processPendingDeletes(Index index,
Settings indexSettings,
TimeValue timeout)
Processes all pending deletes for the given index.
|
void |
removeIndex(String index,
String reason)
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) |
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
logDeprecatedSetting, logRemovedSetting, nodeName
public static final String INDICES_SHARDS_CLOSED_TIMEOUT
@Inject public IndicesService(Settings settings, IndicesLifecycle indicesLifecycle, IndicesAnalysisService indicesAnalysisService, Injector injector, NodeEnvironment nodeEnv)
protected void doStart()
doStart
in class AbstractLifecycleComponent<IndicesService>
protected void doStop()
doStop
in class AbstractLifecycleComponent<IndicesService>
protected void doClose()
doClose
in class AbstractLifecycleComponent<IndicesService>
public IndicesLifecycle indicesLifecycle()
public NodeIndicesStats stats(boolean includePrevious)
public NodeIndicesStats stats(boolean includePrevious, CommonStatsFlags flags)
public boolean changesAllowed()
public Iterator<IndexService> iterator()
iterator
in interface Iterable<IndexService>
public boolean hasIndex(String index)
@Nullable public IndexService indexService(String index)
null
.public IndexService indexServiceSafe(String index)
IndexNotFoundException
is thrown.public IndexService createIndex(String sIndexName, Settings settings, String localNodeId)
public void removeIndex(String index, String reason)
index
- the index to removereason
- the high level reason causing this removalpublic void deleteIndex(String index, String reason) throws IOException
removeIndex(String, String)
but fires
different lifecycle events to ensure pending resources of this index are immediately removed.index
- the index to deletereason
- the high level reason causing this deleteIOException
public void deleteClosedIndex(String reason, IndexMetaData metaData, ClusterState clusterState)
public void deleteIndexStore(String reason, IndexMetaData metaData, ClusterState clusterState, boolean closed) throws IOException
IOException
public void deleteShardStore(String reason, ShardLock lock, Settings indexSettings) throws IOException
reason
- the reason for the shard deletionlock
- the lock of the shard to deleteindexSettings
- the shards index settings.IOException
- if an IOException occurspublic void deleteShardStore(String reason, ShardId shardId, ClusterState clusterState) throws IOException
canDeleteShardContent(org.elasticsearch.index.shard.ShardId, org.elasticsearch.cluster.metadata.IndexMetaData)
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.IOException
- if an IOException occurspublic boolean canDeleteIndexContents(Index index, Settings indexSettings, boolean closed)
index
- Index
to check whether deletion is allowedindexSettings
- Settings
for the given indexpublic boolean canDeleteShardContent(ShardId shardId, IndexMetaData metaData)
true
iff the shards content for the given shard can be deleted.
This method will return false
if:
shardId
- the shard to delete.metaData
- the shards index metadata. This is required to access the indexes settings etc.public void addPendingDelete(ShardId shardId, Settings settings)
public void addPendingDelete(Index index, Settings settings)
public void processPendingDeletes(Index index, Settings indexSettings, TimeValue timeout) throws IOException, InterruptedException
index
- the index to process the pending deletes fortimeout
- the timeout used for processing pending deletesIOException
InterruptedException
Copyright © 2009–2017. All rights reserved.