public class NodeEnvironment extends AbstractComponent implements Closeable
Modifier and Type | Field and Description |
---|---|
static String |
ADD_NODE_ID_TO_CUSTOM_PATH |
static String |
INDICES_FOLDER |
static String |
NODE_LOCK_FILENAME |
static String |
NODES_FOLDER |
static String |
SETTING_CUSTOM_DATA_PATH_ENABLED |
componentSettings, logger, settings
Constructor and Description |
---|
NodeEnvironment(Settings settings,
Environment environment) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
deleteIndexDirectorySafe(Index index,
long lockTimeoutMS,
Settings indexSettings)
Deletes an indexes data directory recursively iff all of the indexes
shards locks were successfully acquired.
|
void |
deleteIndexDirectoryUnderLock(Index index,
Settings indexSettings)
Deletes an indexes data directory recursively.
|
void |
deleteShardDirectorySafe(ShardId shardId,
Settings indexSettings)
Deletes a shard data directory iff the shards locks were successfully acquired.
|
void |
deleteShardDirectoryUnderLock(ShardLock lock,
Settings indexSettings)
Deletes a shard data directory.
|
void |
ensureAtomicMoveSupported()
This method tries to write an empty file and moves it using an atomic move operation.
|
Set<String> |
findAllIndices() |
Set<ShardId> |
findAllShardIds()
Tries to find all allocated shards for all indices iff the given index on the current node.
|
Set<ShardId> |
findAllShardIds(Index index)
Tries to find all allocated shards for the given index or for all indices iff the given index is
null
on the current node. |
static boolean |
hasCustomDataPath(Settings indexSettings) |
boolean |
hasNodeFile() |
File[] |
indexLocations(Index index)
Deprecated.
use
indexPaths(org.elasticsearch.index.Index) instead |
Path[] |
indexPaths(Index index)
Returns all data paths excluding custom index paths.
|
boolean |
isCustomPathsEnabled()
return true if custom paths are allowed for indices
|
int |
localNodeId() |
List<ShardLock> |
lockAllForIndex(Index index,
Settings settings,
long lockTimeoutMS)
Tries to lock all local shards for the given index.
|
Set<ShardId> |
lockedShards()
Returns all currently lock shards
|
File[] |
nodeDataLocations()
Deprecated.
use
nodeDataPaths() instead |
Path[] |
nodeDataPaths()
Returns an array of all of the nodes data locations.
|
Path |
resolveCustomLocation(Settings indexSettings,
ShardId shardId)
Resolve the custom path for a index's shard.
|
File[] |
shardDataLocations(ShardId shardId,
Settings settings)
Deprecated.
use
shardDataPaths instead |
Path[] |
shardDataPaths(ShardId shardId,
Settings indexSettings)
Returns all paths where lucene data will be stored, if a index.data_path
setting is present, will return the custom data path to be used
|
File[] |
shardLocations(ShardId shardId)
Deprecated.
|
ShardLock |
shardLock(ShardId id)
Tries to lock the given shards ID.
|
ShardLock |
shardLock(ShardId id,
long lockTimeoutMS)
Tries to lock the given shards ID.
|
Path[] |
shardPaths(ShardId shardId)
Returns all shard paths excluding custom shard path
|
nodeName
public static final String ADD_NODE_ID_TO_CUSTOM_PATH
public static final String SETTING_CUSTOM_DATA_PATH_ENABLED
public static final String NODES_FOLDER
public static final String INDICES_FOLDER
public static final String NODE_LOCK_FILENAME
@Inject public NodeEnvironment(Settings settings, Environment environment) throws IOException
IOException
public void deleteShardDirectorySafe(ShardId shardId, @IndexSettings Settings indexSettings) throws IOException
shardId
- the id of the shard to delete to deleteIOException
- if an IOException occurspublic void deleteShardDirectoryUnderLock(ShardLock lock, @IndexSettings Settings indexSettings) throws IOException
lock
- the shards lockIOException
- if an IOException occurspublic void deleteIndexDirectorySafe(Index index, long lockTimeoutMS, @IndexSettings Settings indexSettings) throws IOException
index
- the index to deletelockTimeoutMS
- how long to wait for acquiring the indices shard locksindexSettings
- settings for the index being deletedException
- if any of the shards data directories can't be locked or deletedIOException
public void deleteIndexDirectoryUnderLock(Index index, @IndexSettings Settings indexSettings) throws IOException
index
- the index to deleteindexSettings
- settings for the index being deletedIOException
public List<ShardLock> lockAllForIndex(Index index, @IndexSettings Settings settings, long lockTimeoutMS) throws IOException
LockObtainFailedException
is thrown and all previously acquired locks are released.index
- the index to lock shards forlockTimeoutMS
- how long to wait for acquiring the indices shard locksShardLock
instances for this index.IOException
- if an IOException occurs.public ShardLock shardLock(ShardId id) throws IOException
LockObtainFailedException
is thrown.
Note: this method will return immediately if the lock can't be acquired.id
- the shard ID to lockShardLock.close()
to release the lockIOException
- if an IOException occurs.public ShardLock shardLock(ShardId id, long lockTimeoutMS) throws IOException
LockObtainFailedException
is thrownid
- the shard ID to locklockTimeoutMS
- the lock timeout in millisecondsShardLock.close()
to release the lockIOException
- if an IOException occurs.public int localNodeId()
public boolean hasNodeFile()
public Path[] nodeDataPaths()
ElasticsearchIllegalStateException
- if the node is not configured to store local locations@Deprecated public File[] nodeDataLocations()
nodeDataPaths()
instead@Deprecated public File[] indexLocations(Index index)
indexPaths(org.elasticsearch.index.Index)
instead@Deprecated public File[] shardLocations(ShardId shardId)
shardPaths(org.elasticsearch.index.shard.ShardId)
instead@Deprecated public File[] shardDataLocations(ShardId shardId, @IndexSettings Settings settings)
shardDataPaths
insteadpublic Path[] indexPaths(Index index)
public Path[] shardDataPaths(ShardId shardId, @IndexSettings Settings indexSettings)
public Path[] shardPaths(ShardId shardId)
public Set<ShardId> findAllShardIds(Index index) throws IOException
null
on the current node. NOTE: This methods is prone to race-conditions on the filesystem layer since it might not
see directories created concurrently or while it's traversing.index
- the index to filter shards for or null
if all shards for all indices should be listedIOException
- if an IOException occurspublic Set<ShardId> findAllShardIds() throws IOException
IOException
- if an IOException occurspublic void close()
close
in interface Closeable
close
in interface AutoCloseable
public void ensureAtomicMoveSupported() throws IOException
ElasticsearchIllegalStateException
if this operation is
not supported by the filesystem. This test is executed on each of the data directories.
This method cleans up all files even in the case of an error.IOException
public boolean isCustomPathsEnabled()
public static boolean hasCustomDataPath(@IndexSettings Settings indexSettings)
indexSettings
- settings for an indexpublic Path resolveCustomLocation(@IndexSettings Settings indexSettings, ShardId shardId)
IndexMetaData.SETTING_DATA_PATH
setting to determine
the root path for the index.indexSettings
- settings for the indexshardId
- shard to resolve the path toCopyright © 2009–2015. All rights reserved.