public class NodeEnvironment extends AbstractComponent implements Closeable
Modifier and Type | Class and Description |
---|---|
static class |
NodeEnvironment.NodePath |
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_ENABLE_LUCENE_SEGMENT_INFOS_TRACE |
deprecationLogger, logger, settings
Constructor and Description |
---|
NodeEnvironment(Settings settings,
Environment environment) |
Modifier and Type | Method and Description |
---|---|
static void |
acquireFSLockForPaths(Settings indexSettings,
Path... shardPaths)
Acquires, then releases, all
write.lock files in the given
shard paths. |
Path[] |
availableShardPaths(ShardId shardId)
Returns all shard paths excluding custom shard path.
|
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(Index index)
Tries to find all allocated shards for the given index
on the current node.
|
static boolean |
hasCustomDataPath(Settings indexSettings) |
boolean |
hasNodeFile() |
Path[] |
indexPaths(Index index)
Returns all index paths.
|
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
|
Path[] |
nodeDataPaths()
Returns an array of all of the nodes data locations.
|
NodeEnvironment.NodePath[] |
nodePaths()
Returns an array of all of the
NodeEnvironment.NodePath s. |
Path |
resolveCustomLocation(Settings indexSettings,
ShardId shardId)
Resolve the custom path for a index's shard.
|
ShardLock |
shardLock(ShardId id)
Tries to lock the given shards ID.
|
ShardLock |
shardLock(ShardId id,
long lockTimeoutMS)
Tries to lock the given shards ID.
|
static Path |
shardStatePathToDataPath(Path shardPath)
Returns the
NodePath.path for this shard. |
logDeprecatedSetting, logRemovedSetting, nodeName
public static final String ADD_NODE_ID_TO_CUSTOM_PATH
public static final String SETTING_ENABLE_LUCENE_SEGMENT_INFOS_TRACE
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, Settings indexSettings) throws IOException
shardId
- the id of the shard to delete to deleteIOException
- if an IOException occurspublic static void acquireFSLockForPaths(Settings indexSettings, Path... shardPaths) throws IOException
write.lock
files in the given
shard paths. The "write.lock" file is assumed to be under the shard
path's "index" directory as used by Elasticsearch.org.apache.lucene.store.LockObtainFailedException
- if any of the locks could not be acquiredIOException
public void deleteShardDirectoryUnderLock(ShardLock lock, Settings indexSettings) throws IOException
lock
- the shards lockIOException
- if an IOException occursElasticsearchException
- if the write.lock is not acquirablepublic void deleteIndexDirectorySafe(Index index, long lockTimeoutMS, Settings indexSettings) throws IOException
index
- the index to deletelockTimeoutMS
- how long to wait for acquiring the indices shard locksindexSettings
- settings for the index being deletedIOException
- if any of the shards data directories can't be locked or deletedpublic void deleteIndexDirectoryUnderLock(Index index, Settings indexSettings) throws IOException
index
- the index to deleteindexSettings
- settings for the index being deletedIOException
public List<ShardLock> lockAllForIndex(Index index, 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()
IllegalStateException
- if the node is not configured to store local locationspublic NodeEnvironment.NodePath[] nodePaths()
NodeEnvironment.NodePath
s.public Path[] availableShardPaths(ShardId shardId)
public Set<String> findAllIndices() throws IOException
IOException
public Set<ShardId> findAllShardIds(Index index) throws IOException
index
- the index to filter shardsIOException
- if an IOException occurspublic void close()
close
in interface Closeable
close
in interface AutoCloseable
public void ensureAtomicMoveSupported() throws IOException
IllegalStateException
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 static boolean hasCustomDataPath(Settings indexSettings)
indexSettings
- settings for an indexpublic Path resolveCustomLocation(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–2016. All rights reserved.