You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/09/27 08:25:21 UTC

[GitHub] [ozone] sadanand48 commented on a diff in pull request #3729: HDDS-6855. [SNAPSHOTS] Path Based Access for Ozone Snapshots.

sadanand48 commented on code in PR #3729:
URL: https://github.com/apache/ozone/pull/3729#discussion_r980923601


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -0,0 +1,186 @@
+/*
+ * 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;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import org.apache.hadoop.hdds.utils.db.DBCheckpoint;
+import org.apache.hadoop.hdds.utils.db.RDBStore;
+import org.apache.hadoop.ozone.OzoneConfigKeys;
+import org.apache.hadoop.ozone.om.exceptions.OMException;
+import org.apache.hadoop.ozone.om.helpers.SnapshotInfo;
+
+import java.io.IOException;
+
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nonnull;
+import java.util.concurrent.ExecutionException;
+
+import static org.apache.hadoop.ozone.OzoneConsts.OM_KEY_PREFIX;
+import static org.apache.hadoop.ozone.OzoneConsts.OM_SNAPSHOT_INDICATOR;
+import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.INVALID_KEY_NAME;
+import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.KEY_NOT_FOUND;
+
+
+/**
+ * This class is used to manage/create OM snapshots.
+ */
+public final class OmSnapshotManager {
+  private final OzoneManager ozoneManager;
+  private final LoadingCache<String, OmSnapshot> snapshotCache;
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(OmSnapshotManager.class);
+
+  OmSnapshotManager(OzoneManager ozoneManager) {
+    this.ozoneManager = ozoneManager;
+
+    // size of lru cache
+    int cacheSize = ozoneManager.getConfiguration().getInt(
+        OzoneConfigKeys.OZONE_OM_SNAPSHOT_CACHE_MAX_SIZE,
+        OzoneConfigKeys.OZONE_OM_SNAPSHOT_CACHE_MAX_SIZE_DEFAULT);
+
+    CacheLoader<String, OmSnapshot> loader;
+    loader = new CacheLoader<String, OmSnapshot>() {
+      @Override
+
+      // load the snapshot into the cache if not already there
+      @Nonnull
+      public OmSnapshot load(@Nonnull String snapshotTableKey)
+          throws IOException {
+        SnapshotInfo snapshotInfo;
+        // see if the snapshot exists
+        snapshotInfo = getSnapshotInfo(snapshotTableKey);
+
+        // read in the snapshot
+        OzoneConfiguration conf = ozoneManager.getConfiguration();
+        OMMetadataManager snapshotMetadataManager;
+
+        // Create the snapshot metadata manager by finding the corresponding
+        // RocksDB instance, creating an OmMetadataManagerImpl instance based on
+        // that
+        try {
+          snapshotMetadataManager = OmMetadataManagerImpl
+              .createSnapshotMetadataManager(

Review Comment:
   We should also close the open RocksDB instances during cache eviction.



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