Class BlockUtils
java.lang.Object
org.apache.hadoop.ozone.container.keyvalue.helpers.BlockUtils
Utils functions to help block functions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddDB(DatanodeStore store, String containerDBPath, org.apache.hadoop.hdds.conf.ConfigurationSource conf, String schemaVersion) Add a DB handler into cache.static voiddeleteAllDumpFiles(File dumpDir) static voiddumpKVContainerDataToFiles(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource conf) Dump container KV metadata to external files.static org.apache.hadoop.ozone.container.common.helpers.BlockDatagetBlockData(byte[] bytes) Parses theBlockDatafrom a bytes array.static DBHandlegetDB(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource conf) Get a DB handler for a given container.static DatanodeStoregetUncachedDatanodeStore(String containerDBPath, String schemaVersion, org.apache.hadoop.hdds.conf.ConfigurationSource conf, boolean readOnly) Obtain a DB handler for a given container or the underlying volume.static DatanodeStoregetUncachedDatanodeStore(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource conf, boolean readOnly) Obtain a DB handler for a given container.static voidloadKVContainerDataFromFiles(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource conf) Load container KV metadata from external files.static voidremoveContainerFromDB(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource conf) Remove container KV metadata from per-disk db store.static voidremoveDB(KeyValueContainerData container, org.apache.hadoop.hdds.conf.ConfigurationSource conf) Remove a DB handler from cache.static voidshutdownCache(org.apache.hadoop.hdds.conf.ConfigurationSource config) Shutdown all DB Handles.static voidverifyBCSId(Container container, org.apache.hadoop.hdds.client.BlockID blockID) Verify if request block BCSID is supported.static voidverifyReplicaIdx(Container container, org.apache.hadoop.hdds.client.BlockID blockID) Verify if request's replicaIndex matches with containerData.
-
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 folderschemaVersion- The Container Schema versionconf- ConfigurationreadOnly- 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 dataconf- 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 theBlockDatafrom 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.StorageContainerExceptionIOException
-
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.StorageContainerExceptionIOException
-
deleteAllDumpFiles
- Throws:
IOException
-