smengcl commented on code in PR #4438:
URL: https://github.com/apache/ozone/pull/4438#discussion_r1145579929


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffManager.java:
##########
@@ -342,19 +369,26 @@ private synchronized SnapshotDiffResponse 
submitSnapDiffJob(
     }
   }
 
+

Review Comment:
   nit
   
   ```suggestion
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffManager.java:
##########
@@ -797,14 +831,14 @@ private int addToReport(String jobId, int index,
   private synchronized void updateJobStatus(String jobKey,
                                             JobStatus oldStatus,
                                             JobStatus newStatus) {
-    SnapshotDiffJob report = snapDiffJobTable.get(jobKey);
-    if (report.getStatus() != oldStatus) {
+    SnapshotDiffJob snapshotDiffJob = snapDiffJobTable.get(jobKey);
+    if (snapshotDiffJob.getStatus() != oldStatus) {
       throw new IllegalStateException("Invalid job status. Current job " +
-          "status is '" + report.getStatus() + "', while '" + oldStatus +
-          "' is expected.");
+          "status is '" + snapshotDiffJob.getStatus() + "', while '" +
+          oldStatus + "' is expected.");
     }
-    snapDiffJobTable.put(jobKey,
-        new SnapshotDiffJob(report.getJobId(), newStatus));
+    snapshotDiffJob.setStatus(newStatus);
+    snapDiffJobTable.put(jobKey, snapshotDiffJob);
   }

Review Comment:
   gotta make sure this write goes through Ratis later. Otherwise follower OMs 
won't have this entry at all (thus no "resume" when former leader is 
permanantly down).



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffManager.java:
##########
@@ -160,6 +167,8 @@ public SnapshotDiffManager(ManagedRocksDB db,
         new ArrayBlockingQueue<>(DEFAULT_THREAD_POOL_SIZE),
         new ThreadPoolExecutor.CallerRunsPolicy()
     );
+
+    this.loadJobsOnStartUp();

Review Comment:
   Could it be worth it to add a delay before actually resuming SnapDiff?
   Or even better, we could make it event-triggered (e.g. when OM is "ready", 
rather than a fixed-time wait).
   If so, we can do this in a new jira.



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotUtils.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.snapshot;
+
+import java.io.IOException;
+import org.apache.hadoop.ozone.om.OzoneManager;
+import org.apache.hadoop.ozone.om.exceptions.OMException;
+import org.apache.hadoop.ozone.om.helpers.SnapshotInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static 
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.KEY_NOT_FOUND;
+
+/**
+ * Util class for snapshot diff APIs.
+ */
+public final class SnapshotUtils {
+  private static final Logger LOG =
+      LoggerFactory.getLogger(SnapshotUtils.class);
+
+  private SnapshotUtils() {
+    throw new IllegalStateException("SnapshotUtils should not be 
initialized.");
+  }
+
+  public static SnapshotInfo getSnapshotInfo(final OzoneManager ozoneManager,
+                                             final String volumeName,
+                                             final String bucketName,
+                                             final String snapshotName)
+      throws IOException {
+    return getSnapshotInfo(ozoneManager,
+        SnapshotInfo.getTableKey(volumeName, bucketName, snapshotName));
+  }
+
+  public static SnapshotInfo getSnapshotInfo(final OzoneManager ozoneManager,
+                                             final String key)
+      throws IOException {
+    SnapshotInfo snapshotInfo;
+    try {
+      snapshotInfo = ozoneManager.getMetadataManager()
+          .getSnapshotInfoTable()
+          .get(key);
+    } catch (IOException e) {
+      LOG.error("Snapshot {}: not found: {}", key, e);
+      throw e;
+    }

Review Comment:
   Do we need to check cache here as well?



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