ChenSammi commented on code in PR #3292:
URL: https://github.com/apache/ozone/pull/3292#discussion_r853961191
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/utils/HddsVolumeUtil.java:
##########
@@ -71,167 +61,65 @@ public static String getHddsRoot(String volumeRoot) {
}
/**
- * Returns storageID if it is valid. Throws an exception otherwise.
- */
- @VisibleForTesting
- public static String getStorageID(Properties props, File versionFile)
- throws InconsistentStorageStateException {
- return getProperty(props, OzoneConsts.STORAGE_ID, versionFile);
- }
-
- /**
- * Returns clusterID if it is valid. It should match the clusterID from the
- * Datanode. Throws an exception otherwise.
- */
- @VisibleForTesting
- public static String getClusterID(Properties props, File versionFile,
- String clusterID) throws InconsistentStorageStateException {
- String cid = getProperty(props, OzoneConsts.CLUSTER_ID, versionFile);
-
- if (clusterID == null) {
- return cid;
- }
- if (!clusterID.equals(cid)) {
- throw new InconsistentStorageStateException("Mismatched " +
- "ClusterIDs. Version File : " + versionFile + " has clusterID: " +
- cid + " and Datanode has clusterID: " + clusterID);
- }
- return cid;
- }
-
- /**
- * Returns datanodeUuid if it is valid. It should match the UUID of the
- * Datanode. Throws an exception otherwise.
- */
- @VisibleForTesting
- public static String getDatanodeUUID(Properties props, File versionFile,
- String datanodeUuid)
- throws InconsistentStorageStateException {
- String datanodeID = getProperty(props, OzoneConsts.DATANODE_UUID,
- versionFile);
-
- if (datanodeUuid != null && !datanodeUuid.equals(datanodeID)) {
- throw new InconsistentStorageStateException("Mismatched " +
- "DatanodeUUIDs. Version File : " + versionFile + " has datanodeUuid:
"
- + datanodeID + " and Datanode has datanodeUuid: " + datanodeUuid);
- }
- return datanodeID;
- }
-
- /**
- * Returns creationTime if it is valid. Throws an exception otherwise.
+ * Initialize db instance, rocksdb will load the existing instance
+ * if present and format a new one if not.
+ * @param containerDBPath
+ * @param conf
+ * @throws IOException
*/
- @VisibleForTesting
- public static long getCreationTime(Properties props, File versionFile)
- throws InconsistentStorageStateException {
- String cTimeStr = getProperty(props, OzoneConsts.CTIME, versionFile);
-
- long cTime = Long.parseLong(cTimeStr);
- long currentTime = Time.now();
- if (cTime > currentTime || cTime < 0) {
- throw new InconsistentStorageStateException("Invalid Creation time in " +
- "Version File : " + versionFile + " - " + cTime + ". Current system"
+
- " time is " + currentTime);
- }
- return cTime;
+ public static void initPerDiskDBStore(String containerDBPath,
+ ConfigurationSource conf) throws IOException {
+ DatanodeStore store = BlockUtils.getUncachedDatanodeStore(containerDBPath,
+ OzoneConsts.SCHEMA_V3, conf, false);
+ BlockUtils.addDB(store, containerDBPath, conf, OzoneConsts.SCHEMA_V3);
}
/**
- * Returns layOutVersion if it is valid. Throws an exception otherwise.
+ * Load already formatted db instances for all HddsVolumes.
+ * @param hddsVolumeSet
+ * @param dbVolumeSet
+ * @param logger
*/
- @VisibleForTesting
- public static int getLayOutVersion(Properties props, File versionFile) throws
- InconsistentStorageStateException {
- String lvStr = getProperty(props, OzoneConsts.LAYOUTVERSION, versionFile);
-
- int lv = Integer.parseInt(lvStr);
- if (HDDSVolumeLayoutVersion.getLatestVersion().getVersion() != lv) {
- throw new InconsistentStorageStateException("Invalid layOutVersion. " +
- "Version file has layOutVersion as " + lv + " and latest Datanode " +
- "layOutVersion is " +
- HDDSVolumeLayoutVersion.getLatestVersion().getVersion());
- }
- return lv;
- }
-
- public static String getProperty(
- Properties props, String propName, File
- versionFile
- )
- throws InconsistentStorageStateException {
- String value = props.getProperty(propName);
- if (StringUtils.isBlank(value)) {
- throw new InconsistentStorageStateException("Invalid " + propName +
- ". Version File : " + versionFile + " has null or empty " +
propName);
+ public static void loadAllHddsVolumeDbStore(MutableVolumeSet hddsVolumeSet,
+ MutableVolumeSet dbVolumeSet, Logger logger) {
+ // Scan subdirs under the db volumes and build a one-to-one map
+ // between each HddsVolume -> DbVolume.
+ mapDbVolumesToDataVolumesIfNeeded(hddsVolumeSet, dbVolumeSet);
+
+ for (HddsVolume volume : StorageVolumeUtil.getHddsVolumesList(
+ hddsVolumeSet.getVolumesList())) {
+ try {
+ volume.loadDbStore();
+ } catch (IOException e) {
+ onFailure(volume);
Review Comment:
Shall we just fail the volume, like
"hddsVolumeSet.failVolume(volume.getStorageDir().getPath());"?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]