java.lang.Object
org.apache.hadoop.ozone.container.keyvalue.helpers.BlockUtils

public final class BlockUtils extends Object
Utils functions to help block functions.
  • Method Details

    • getUncachedDatanodeStore

      public static DatanodeStore getUncachedDatanodeStore(String containerDBPath, String schemaVersion, org.apache.hadoop.hdds.conf.ConfigurationSource conf, boolean readOnly) throws IOException
      Obtain a DB handler for a given container or the underlying volume. This handler is not cached and the caller must close it after using it. If another thread attempts to open the same container when it is already opened by this thread, the other thread will get a RocksDB exception.
      Parameters:
      containerDBPath - The absolute path to the container database folder
      schemaVersion - The Container Schema version
      conf - Configuration
      readOnly - open DB in read-only mode or not
      Returns:
      Handler to the given container.
      Throws:
      IOException
    • getUncachedDatanodeStore

      public static DatanodeStore getUncachedDatanodeStore(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource conf, boolean readOnly) throws IOException
      Obtain a DB handler for a given container. This handler is not cached and the caller must close it after using it. If another thread attempts to open the same container when it is already opened by this thread, the other thread will get a RocksDB exception.
      Parameters:
      containerData - The container data
      conf - Configuration
      Throws:
      IOException
    • getDB

      public static DBHandle getDB(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource conf) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
      Get a DB handler for a given container. If the handler doesn't exist in cache yet, first create one and add into cache. This function is called with containerManager ReadLock held.
      Parameters:
      containerData - containerData.
      conf - configuration.
      Returns:
      DB handle.
      Throws:
      org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
    • removeDB

      public static void removeDB(KeyValueContainerData container, org.apache.hadoop.hdds.conf.ConfigurationSource conf)
      Remove a DB handler from cache.
      Parameters:
      container - - Container data.
      conf - - Configuration.
    • shutdownCache

      public static void shutdownCache(org.apache.hadoop.hdds.conf.ConfigurationSource config)
      Shutdown all DB Handles.
      Parameters:
      config -
    • addDB

      public static void addDB(DatanodeStore store, String containerDBPath, org.apache.hadoop.hdds.conf.ConfigurationSource conf, String schemaVersion)
      Add a DB handler into cache.
      Parameters:
      store - - low-level DatanodeStore for DB.
      containerDBPath - - DB path of the container.
      conf - configuration.
      schemaVersion - schemaVersion.
    • getBlockData

      public static org.apache.hadoop.ozone.container.common.helpers.BlockData getBlockData(byte[] bytes) throws IOException
      Parses the BlockData from a bytes array.
      Parameters:
      bytes - Block data in bytes.
      Returns:
      Block data.
      Throws:
      IOException - if the bytes array is malformed or invalid.
    • verifyBCSId

      public static void verifyBCSId(Container container, org.apache.hadoop.hdds.client.BlockID blockID) throws IOException
      Verify if request block BCSID is supported.
      Parameters:
      container - container object.
      blockID - requested block info
      Throws:
      IOException - if cannot support block's blockCommitSequenceId
    • verifyReplicaIdx

      public static void verifyReplicaIdx(Container container, org.apache.hadoop.hdds.client.BlockID blockID) throws IOException
      Verify if request's replicaIndex matches with containerData.
      Parameters:
      container - container object.
      blockID - requested block info
      Throws:
      IOException - if replicaIndex mismatches.
    • removeContainerFromDB

      public static void removeContainerFromDB(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource conf) throws IOException
      Remove container KV metadata from per-disk db store.
      Parameters:
      containerData -
      conf -
      Throws:
      IOException
    • dumpKVContainerDataToFiles

      public static void dumpKVContainerDataToFiles(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource conf) throws IOException
      Dump container KV metadata to external files.
      Parameters:
      containerData -
      conf -
      Throws:
      org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
      IOException
    • loadKVContainerDataFromFiles

      public static void loadKVContainerDataFromFiles(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource conf) throws IOException
      Load container KV metadata from external files.
      Parameters:
      containerData -
      conf -
      Throws:
      org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
      IOException
    • deleteAllDumpFiles

      public static void deleteAllDumpFiles(File dumpDir) throws IOException
      Throws:
      IOException