You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "hemantk-12 (via GitHub)" <gi...@apache.org> on 2023/03/24 20:04:23 UTC

[GitHub] [ozone] hemantk-12 commented on a diff in pull request #4438: HDDS-7952. [Snapshot] Server side changes to add job status and wait time to mimic the async behaviour for snapshot diff API.

hemantk-12 commented on code in PR #4438:
URL: https://github.com/apache/ozone/pull/4438#discussion_r1148006773


##########
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:
   As of now, all the snapDiff related tables are in separate DB: [db.snapdiff](https://github.com/apache/ozone/blob/5756fd876f0997629205238195edfee0c7472b01/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneConsts.java#L567).  



##########
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:
   Added a TODO.



##########
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:
   Not sure. It is just moved form OmSnapshotManager to here.
   
   I believe it won't be needed because by the time we get snapDiff request, double would have flushed the create snapshot entries. 



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org