Class ShardPath

java.lang.Object
org.elasticsearch.index.shard.ShardPath

public final class ShardPath
extends java.lang.Object
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static java.lang.String INDEX_FOLDER_NAME  
    static java.lang.String TRANSLOG_FOLDER_NAME  
  • Constructor Summary

    Constructors 
    Constructor Description
    ShardPath​(boolean isCustomDataPath, java.nio.file.Path dataPath, java.nio.file.Path shardStatePath, ShardId shardId)  
  • Method Summary

    Modifier and Type Method Description
    static void deleteLeftoverShardDirectory​(org.apache.logging.log4j.Logger logger, NodeEnvironment env, ShardLock lock, IndexSettings indexSettings)
    This method tries to delete left-over shards where the index name has been reused but the UUID is different to allow the new shard to be allocated.
    boolean equals​(java.lang.Object o)  
    boolean exists()  
    java.nio.file.Path getDataPath()  
    java.nio.file.Path getRootDataPath()
    Returns the data-path root for this shard.
    java.nio.file.Path getRootStatePath()
    Returns the state-path root for this shard.
    ShardId getShardId()  
    java.nio.file.Path getShardStatePath()  
    int hashCode()  
    boolean isCustomDataPath()
    Returns true iff the data location is a custom data location and therefore outside of the nodes configured data paths.
    static ShardPath loadShardPath​(org.apache.logging.log4j.Logger logger, NodeEnvironment env, ShardId shardId, java.lang.String customDataPath)
    This method walks through the nodes shard paths to find the data and state path for the given shard.
    static ShardPath loadShardPath​(org.apache.logging.log4j.Logger logger, ShardId shardId, java.lang.String customDataPath, java.nio.file.Path[] availableShardPaths, int nodeLockId, java.nio.file.Path sharedDataPath)
    This method walks through the nodes shard paths to find the data and state path for the given shard.
    java.nio.file.Path resolveIndex()  
    java.nio.file.Path resolveTranslog()  
    static ShardPath selectNewPathForShard​(NodeEnvironment env, ShardId shardId, IndexSettings indexSettings, long avgShardSizeInBytes, java.util.Map<java.nio.file.Path,​java.lang.Integer> dataPathToShardCount)  
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • ShardPath

      public ShardPath​(boolean isCustomDataPath, java.nio.file.Path dataPath, java.nio.file.Path shardStatePath, ShardId shardId)
  • Method Details

    • resolveTranslog

      public java.nio.file.Path resolveTranslog()
    • resolveIndex

      public java.nio.file.Path resolveIndex()
    • getDataPath

      public java.nio.file.Path getDataPath()
    • exists

      public boolean exists()
    • getShardId

      public ShardId getShardId()
    • getShardStatePath

      public java.nio.file.Path getShardStatePath()
    • getRootDataPath

      public java.nio.file.Path getRootDataPath()
      Returns the data-path root for this shard. The root is a parent of getDataPath() without the index name and the shard ID.
    • getRootStatePath

      public java.nio.file.Path getRootStatePath()
      Returns the state-path root for this shard. The root is a parent of getRootStatePath() ()} without the index name and the shard ID.
    • isCustomDataPath

      public boolean isCustomDataPath()
      Returns true iff the data location is a custom data location and therefore outside of the nodes configured data paths.
    • loadShardPath

      public static ShardPath loadShardPath​(org.apache.logging.log4j.Logger logger, NodeEnvironment env, ShardId shardId, java.lang.String customDataPath) throws java.io.IOException
      This method walks through the nodes shard paths to find the data and state path for the given shard. If multiple directories with a valid shard state exist the one with the highest version will be used. Note: this method resolves custom data locations for the shard if such a custom data path is provided.
      Throws:
      java.io.IOException
    • loadShardPath

      public static ShardPath loadShardPath​(org.apache.logging.log4j.Logger logger, ShardId shardId, java.lang.String customDataPath, java.nio.file.Path[] availableShardPaths, int nodeLockId, java.nio.file.Path sharedDataPath) throws java.io.IOException
      This method walks through the nodes shard paths to find the data and state path for the given shard. If multiple directories with a valid shard state exist the one with the highest version will be used. Note: this method resolves custom data locations for the shard.
      Throws:
      java.io.IOException
    • deleteLeftoverShardDirectory

      public static void deleteLeftoverShardDirectory​(org.apache.logging.log4j.Logger logger, NodeEnvironment env, ShardLock lock, IndexSettings indexSettings) throws java.io.IOException
      This method tries to delete left-over shards where the index name has been reused but the UUID is different to allow the new shard to be allocated.
      Throws:
      java.io.IOException
    • selectNewPathForShard

      public static ShardPath selectNewPathForShard​(NodeEnvironment env, ShardId shardId, IndexSettings indexSettings, long avgShardSizeInBytes, java.util.Map<java.nio.file.Path,​java.lang.Integer> dataPathToShardCount) throws java.io.IOException
      Throws:
      java.io.IOException
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object