xBis7 commented on code in PR #4134:
URL: https://github.com/apache/ozone/pull/4134#discussion_r1095569625


##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java:
##########
@@ -1123,6 +1169,75 @@ private static FileStatusAdapter 
getFileStatusAdapterForBucket(
                     HddsProtos.ReplicationType.EC);
   }
 
+  /**
+   * Generate a FileStatusAdapter for a snapshot under a bucket.
+   * @param ozoneBucket OzoneBucket object.
+   * @param ozoneSnapshot OzoneSnapshot object.
+   * @param uri Full URI to OFS root.
+   * @param owner Owner of the parent volume of the bucket.
+   * @param group Group of the parent volume of the bucket.
+   * @return FileStatusAdapter for a snapshot.
+   */
+  private static FileStatusAdapter getFileStatusAdapterForBucketSnapshot(
+      OzoneBucket ozoneBucket, OzoneSnapshot ozoneSnapshot,
+      URI uri, String owner, String group) {
+    String pathStr = uri.toString() +
+        OZONE_URI_DELIMITER + ozoneSnapshot.getVolumeName() +
+        OZONE_URI_DELIMITER + ozoneSnapshot.getBucketName() +
+        OZONE_URI_DELIMITER + OM_SNAPSHOT_INDICATOR +
+        OZONE_URI_DELIMITER + ozoneSnapshot.getName();
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("getFileStatusAdapterForBucketSnapshot: " +
+              "ozoneSnapshot={}, pathStr={}",
+          ozoneSnapshot.getName(), pathStr);
+    }
+    Path path = new Path(pathStr);
+    return new FileStatusAdapter(0L, 0L, path, true, (short)0, 0L,
+        ozoneSnapshot.getCreationTime(), 0L,
+        FsPermission.getDirDefault().toShort(),
+        owner, group, null, new BlockLocation[0],
+        !StringUtils.isEmpty(ozoneBucket.getEncryptionKeyName()),
+        ozoneBucket.getReplicationConfig() != null &&
+            ozoneBucket.getReplicationConfig().getReplicationType() ==
+                HddsProtos.ReplicationType.EC);
+  }
+
+  /**
+   * Generate a FileStatusAdapter for a bucket
+   * followed by a snapshot indicator.
+   * @param ozoneVolume OzoneVolume object.
+   * @param ozoneBucket OzoneBucket object.
+   * @param uri Full URI to OFS root.
+   * @return FileStatusAdapter for a snapshot indicator.
+   */
+  private static FileStatusAdapter getFileStatusAdapterWithSnapshotIndicator(

Review Comment:
   Let's say that we have `vol1`, `bucket1` and `snap1`. 
   
   If we are on path `/vol1/bucket1/.snapshot/snap1` and we need to get the 
`FileStatusAdapter` for `snap1`, we will call 
`getFileStatusAdapterForBucketSnapshot`. 
   
   If we are on path `/vol1/bucket1/.snapshot`, then we need to get the 
`FileStatusAdapter` for the snapshot indicator (`.snapshot`) and we will call 
`getFileStatusAdapterWithSnapshotIndicator`. The snapshot indicator isn't a 
directory or an entity like a bucket or a snapshot or a key but just a prefix 
for OM to know that we are referring to a snapshot and it should look it up in 
the snapshot table. `/vol1/bucket1/.snapshot` isn't an actual path and we can't 
have a `FileStatusAdapter` for the indicator. Therefore, we create a 
`FileStatusAdapter` for the bucket and append the snapshot indicator to the 
path and that's the difference with the `FileStatusAdapter` for a bucket.
   
   



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