Class StorageLocation

java.lang.Object
org.apache.hadoop.hdfs.server.datanode.StorageLocation
All Implemented Interfaces:
Comparable<StorageLocation>, Checkable<StorageLocation.CheckContext,VolumeCheckResult>

@Private public class StorageLocation extends Object implements Checkable<StorageLocation.CheckContext,VolumeCheckResult>, Comparable<StorageLocation>
Encapsulates the URI and storage medium that together describe a storage directory. The default storage medium is assumed to be DISK, if none is specified.
  • Method Details

    • normalizeFileURI

      public static URI normalizeFileURI(URI uri)
    • getStorageType

      public org.apache.hadoop.fs.StorageType getStorageType()
    • getUri

      public URI getUri()
    • getNormalizedUri

      public URI getNormalizedUri()
    • matchesStorageDirectory

      public boolean matchesStorageDirectory(Storage.StorageDirectory sd) throws IOException
      Throws:
      IOException
    • matchesStorageDirectory

      public boolean matchesStorageDirectory(Storage.StorageDirectory sd, String bpid) throws IOException
      Throws:
      IOException
    • parse

      public static StorageLocation parse(String rawLocation) throws IOException, SecurityException
      Attempt to parse a storage uri with storage class and URI. The storage class component of the uri is case-insensitive.
      Parameters:
      rawLocation - Location string of the format [type]uri, where [type] is optional.
      Returns:
      A StorageLocation object if successfully parsed, null otherwise. Does not throw any exceptions.
      Throws:
      IOException
      SecurityException
    • parseCapacityRatio

      public static Map<URI,Double> parseCapacityRatio(String capacityRatioConf) throws SecurityException
      Attempt to parse the storage capacity ratio and related volume directory out of the capacity ratio config string.
      Parameters:
      capacityRatioConf - Config string of the capacity ratio
      Returns:
      Map of URI of the volume and capacity ratio.
      Throws:
      SecurityException - when format is incorrect or ratio is not between 0 - 1.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(StorageLocation obj)
      Specified by:
      compareTo in interface Comparable<StorageLocation>
    • getBpURI

      public URI getBpURI(String bpid, String currentStorageDir)
    • makeBlockPoolDir

      public void makeBlockPoolDir(String blockPoolID, org.apache.hadoop.conf.Configuration conf) throws IOException
      Create physical directory for block pools on the data node.
      Parameters:
      blockPoolID - the block pool id
      conf - Configuration instance to use.
      Throws:
      IOException - on errors
    • check

      Description copied from interface: Checkable
      Query the health of this object. This method may hang indefinitely depending on the status of the target resource.
      Specified by:
      check in interface Checkable<StorageLocation.CheckContext,VolumeCheckResult>
      Parameters:
      context - for the probe operation. May be null depending on the implementation.
      Returns:
      result of the check operation.
      Throws:
      IOException