Class KeyValueContainerUtil
java.lang.Object
org.apache.hadoop.ozone.container.keyvalue.helpers.KeyValueContainerUtil
Class which defines utility methods for KeyValueContainer.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateContainerMetaData(File containerMetaDataPath, File chunksPath, File dbFile, String schemaVersion, org.apache.hadoop.hdds.conf.ConfigurationSource conf) creates metadata path, chunks path and metadata DB for the specified container.static longgetBlockLength(org.apache.hadoop.ozone.container.common.helpers.BlockData block) static longgetBlockLengthTryCatch(org.apache.hadoop.ozone.container.common.helpers.BlockData block) static PathgetTmpDirectoryPath(KeyValueContainerData keyValueContainerData, HddsVolume hddsVolume) static booleanisSameSchemaVersion(String schema, String other) static voidmoveToDeletedContainerDir(KeyValueContainerData keyValueContainerData, HddsVolume hddsVolume) Moves container directory to a new location under "volume/hdds/cluster-id/tmp/deleted-containers" and updates metadata and chunks path.static booleannoBlocksInContainer(DatanodeStore store, KeyValueContainerData containerData, boolean bCheckChunksFilePath) Returns if there are no blocks in the container.static voidparseKVContainerData(KeyValueContainerData kvContainerData, org.apache.hadoop.hdds.conf.ConfigurationSource config) Parse KeyValueContainerData and verify checksum.static voidparseKVContainerData(KeyValueContainerData kvContainerData, org.apache.hadoop.hdds.conf.ConfigurationSource config, boolean skipVerifyChecksum) static voidremoveContainer(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource conf) remove Container 1. remove db, 2. move to tmp directory.static voidremoveContainerDB(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource conf) remove Container db, the Level DB file.
-
Method Details
-
createContainerMetaData
public static void createContainerMetaData(File containerMetaDataPath, File chunksPath, File dbFile, String schemaVersion, org.apache.hadoop.hdds.conf.ConfigurationSource conf) throws IOException creates metadata path, chunks path and metadata DB for the specified container.- Parameters:
containerMetaDataPath- Path to the container's metadata directory.chunksPath- Path were chunks for this container should be stored.dbFile- Path to the container's .db file.schemaVersion- The schema version of the container. If this method has not been updated after a schema version addition and does not recognize the latest SchemaVersion, anIllegalArgumentExceptionis thrown.conf- The configuration to use for this container.- Throws:
IOException
-
removeContainer
public static void removeContainer(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource conf) throws IOException remove Container 1. remove db, 2. move to tmp directory.- Parameters:
containerData- - Data of the container to remove.- Throws:
IOException
-
removeContainerDB
public static void removeContainerDB(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource conf) throws IOException remove Container db, the Level DB file.- Parameters:
containerData- - Data of the container to remove.conf- - configuration of the cluster.- Throws:
IOException
-
noBlocksInContainer
public static boolean noBlocksInContainer(DatanodeStore store, KeyValueContainerData containerData, boolean bCheckChunksFilePath) throws IOException Returns if there are no blocks in the container.- Parameters:
store- DBStorecontainerData- Container to checkbCheckChunksFilePath- Whether to check chunksfilepath has any blocks- Returns:
- true if the directory containing blocks is empty
- Throws:
IOException
-
parseKVContainerData
public static void parseKVContainerData(KeyValueContainerData kvContainerData, org.apache.hadoop.hdds.conf.ConfigurationSource config) throws IOException Parse KeyValueContainerData and verify checksum. Set block related metadata like block commit sequence id, block count, bytes used and pending delete block count and delete transaction id. This method will verify checksum by default.- Parameters:
kvContainerData-config-- Throws:
IOException
-
parseKVContainerData
public static void parseKVContainerData(KeyValueContainerData kvContainerData, org.apache.hadoop.hdds.conf.ConfigurationSource config, boolean skipVerifyChecksum) throws IOException - Parameters:
kvContainerData-config-skipVerifyChecksum- checksum verification should be skipped if the state has changed to RECOVERING during container import, false otherwise- Throws:
IOException
-
getBlockLengthTryCatch
public static long getBlockLengthTryCatch(org.apache.hadoop.ozone.container.common.helpers.BlockData block) -
getBlockLength
public static long getBlockLength(org.apache.hadoop.ozone.container.common.helpers.BlockData block) -
isSameSchemaVersion
-
moveToDeletedContainerDir
public static void moveToDeletedContainerDir(KeyValueContainerData keyValueContainerData, HddsVolume hddsVolume) throws IOException Moves container directory to a new location under "volume/hdds/cluster-id/tmp/deleted-containers" and updates metadata and chunks path. Containers will be moved under it before getting deleted to avoid, in case of failure, having artifact leftovers on the default container path on the disk. Delete operation for Schema < V3 1. Container is marked DELETED 2. Container is removed from memory container set 3. Container DB handler from cache is removed and closed 4. Container directory renamed to tmp directory. 5. Container is deleted from tmp directory. Delete operation for Schema V3 1. Container is marked DELETED 2. Container is removed from memory container set 3. Container from DB is removed 4. Container directory renamed to tmp directory. 5. Container is deleted from tmp directory.- Parameters:
keyValueContainerData-- Throws:
IOException
-
getTmpDirectoryPath
public static Path getTmpDirectoryPath(KeyValueContainerData keyValueContainerData, HddsVolume hddsVolume)
-