Class DataStorage


@Private public class DataStorage extends Storage
Data storage information file.

See Also:
  • Field Details

  • Constructor Details

    • DataStorage

      public DataStorage(StorageInfo storageInfo)
  • Method Details

    • getBPStorage

      public BlockPoolSliceStorage getBPStorage(String bpid)
    • getDatanodeUuid

      public String getDatanodeUuid()
    • setDatanodeUuid

      public void setDatanodeUuid(String newDatanodeUuid)
    • createStorageID

      public static boolean createStorageID(Storage.StorageDirectory sd, boolean regenerateStorageIds, org.apache.hadoop.conf.Configuration conf)
      Create an ID for this storage.
      Returns:
      true if a new storage ID was generated.
    • enableTrash

      public void enableTrash(String bpid)
      Enable trash for the specified block pool storage. Even if trash is enabled by the caller, it is superseded by the 'previous' directory if a layout upgrade is in progress.
    • clearTrash

      public void clearTrash(String bpid)
    • trashEnabled

      public boolean trashEnabled(String bpid)
    • setRollingUpgradeMarker

      public void setRollingUpgradeMarker(String bpid) throws IOException
      Throws:
      IOException
    • clearRollingUpgradeMarker

      public void clearRollingUpgradeMarker(String bpid) throws IOException
      Throws:
      IOException
    • getTrashDirectoryForReplica

      public String getTrashDirectoryForReplica(String bpid, ReplicaInfo info)
      If rolling upgrades are in progress then do not delete block files immediately. Instead we move the block files to an intermediate 'trash' directory. If there is a subsequent rollback, then the block files will be restored from trash.
      Returns:
      trash directory if rolling upgrade is in progress, null otherwise.
    • prepareVolume

      public DataStorage.VolumeBuilder prepareVolume(DataNode datanode, StorageLocation location, List<NamespaceInfo> nsInfos) throws IOException
      Prepare a storage directory. It creates a builder which can be used to add to the volume. If the volume cannot be added, it is OK to discard the builder later.
      Parameters:
      datanode - DataNode object.
      location - the StorageLocation for the storage directory.
      nsInfos - an array of namespace infos.
      Returns:
      a VolumeBuilder that holds the metadata of this storage directory and can be added to DataStorage later.
      Throws:
      IOException - if encounters I/O errors. Note that if there is IOException, the state of DataStorage is not modified.
    • setPropertiesFromFields

      protected void setPropertiesFromFields(Properties props, Storage.StorageDirectory sd) throws IOException
      Description copied from class: Storage
      Set common storage fields into the given properties object. Should be overloaded if additional fields need to be set.
      Overrides:
      setPropertiesFromFields in class Storage
      Parameters:
      props - the Properties object to write into
      Throws:
      IOException
    • setFieldsFromProperties

      protected void setFieldsFromProperties(Properties props, Storage.StorageDirectory sd) throws IOException
      Description copied from class: StorageInfo
      Get common storage fields. Should be overloaded if additional fields need to be get.
      Overrides:
      setFieldsFromProperties in class StorageInfo
      Parameters:
      props - properties
      Throws:
      IOException - on error
    • isPreUpgradableLayout

      public boolean isPreUpgradableLayout(Storage.StorageDirectory sd) throws IOException
      Description copied from class: Storage
      Return true if the layout of the given storage directory is from a version of Hadoop prior to the introduction of the "current" and "previous" directories which allow upgrade and rollback.
      Specified by:
      isPreUpgradableLayout in class Storage
      Throws:
      IOException
    • fullyDelete

      @Deprecated public static boolean fullyDelete(File dir)
      Deprecated.
      Prefer FileIoProvider#fullydelete.
      Parameters:
      dir -
      Returns: