GeorgeJahad commented on code in PR #3652:
URL: https://github.com/apache/ozone/pull/3652#discussion_r940683251


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/SnapshotInfo.java:
##########
@@ -365,4 +391,144 @@ public static SnapshotInfo getFromProtobuf(
 
     return osib.build();
   }
+
+  /**
+   * Get volume from snapshot path.
+   */
+  private static String getVolumeNameFromPath(String path) {
+    String volumeName = null;
+    String[] names = path.split(OM_KEY_PREFIX);
+    if (names.length > 0) {
+      volumeName = names[0];
+    }
+    return volumeName;
+  }
+
+  /**
+   * Get bucket from snapshot path.
+   */
+  private static String getBucketNameFromPath(String path) {
+    String bucketName = null;
+    String[] names = path.split(OM_KEY_PREFIX);
+    if (names.length > 1) {
+      bucketName = names[1];
+    }
+    return bucketName;
+  }
+
+  /**
+   * Get directory from snapshot path.
+   * Note that snapshot on directories is not supported yet;
+   *  this is only used to confirm that snapshotPath doesn't
+   *  contain a directory
+   */
+  public String getDirName() {
+    String dirName = null;
+    String[] names = snapshotPath.split(OM_KEY_PREFIX);
+    if (names.length > 2) {
+      dirName = String.join(OM_KEY_PREFIX,
+          Arrays.copyOfRange(names, 2, names.length));
+    }
+    return dirName;
+  }
+
+  /**
+   * Get the name of the lock resource for this snapshot.
+   */
+  public String getSnapshotLockResourceName() {
+    return getBucketName() + OM_KEY_PREFIX + SNAPSHOT_FLAG;
+  }
+
+  @Override
+  public Map<String, String> toAuditMap() {
+    Map<String, String> auditMap = new LinkedHashMap<>();
+    auditMap.put(OzoneConsts.VOLUME, getVolumeName());
+    auditMap.put(OzoneConsts.BUCKET, getBucketName());
+    auditMap.put(OzoneConsts.OM_SNAPSHOT_NAME, this.name);
+    return auditMap;
+  }
+
+  /**
+   * Get the name of the checkpoint directory.
+   */
+  public static String getCheckpointDirName(String name, String snapshotPath) {
+    return SEPARATOR + getTableKey(name, snapshotPath);
+  }
+  /**
+   * Get the name of the checkpoint directory, (non-static).
+   */
+  public String getCheckpointDirName() {
+    return getCheckpointDirName(name, snapshotPath);
+  }

Review Comment:
   Good point, I'll fix.



-- 
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]

Reply via email to