duongkame commented on code in PR #4190:
URL: https://github.com/apache/ozone/pull/4190#discussion_r1091303192
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -268,4 +280,29 @@ private void verifySnapshotInfoForSnapDiff(final
SnapshotInfo fromSnapshot,
" should be older than to toSnapshot:" + toSnapshot.getName());
}
}
+
+ private RocksDB createRocksDbForSnapshotDiff(OzoneConfiguration config) {
+ final Options options = new Options().setCreateIfMissing(true);
+
+ final File dbDirPath =
+ ServerUtils.getDBPath(config, OZONE_OM_SNAPSHOT_DIFF_DB_DIR);
+
+ String dbPath = Paths.get(dbDirPath.toString(), OM_SNAPSHOT_DIFF_DB_NAME)
+ .toFile()
+ .getAbsolutePath();
+
+ try {
+ return RocksDB.open(options, dbPath);
Review Comment:
Please add this `open ` overload to ManagedRocksDB and used it. It'll help
you assert if RocksDb objects are not closed properly
##########
hadoop-ozone/ozone-manager/pom.xml:
##########
@@ -271,6 +271,44 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
<excludeFilterFile>${basedir}/dev-support/findbugsExcludeFile.xml</excludeFilterFile>
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>depcheck</id>
+ <phase></phase>
+ </execution>
+ <execution>
+ <id>banned-rocksdb-imports</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <RestrictImports>
+ <includeTestCode>false</includeTestCode>
+ <reason>Use managed RocksObjects under
org.apache.hadoop.hdds.utils.db.managed instead.</reason>
+ <!-- By default, ban all the classes in org.rocksdb -->
+ <bannedImport>org.rocksdb.**</bannedImport>
+ <allowedImports>
+ <!-- Allow these imports for snapshot diff. We can't use
managed DB for Snapshot diff because
Review Comment:
Actually, the `managed` package can always be extended to adapt to new
needs. And it's important for this feature to use managed RocksObject to assert
memory leak.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/RocksDbPersistentList.java:
##########
@@ -0,0 +1,139 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 java.util.Iterator;
+import org.apache.hadoop.hdds.utils.db.CodecRegistry;
+import org.rocksdb.ColumnFamilyHandle;
+import org.rocksdb.RocksDB;
Review Comment:
Please use `managed` objects.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -35,6 +38,8 @@
import org.apache.hadoop.ozone.om.snapshot.SnapshotDiffManager;
import org.apache.hadoop.ozone.snapshot.SnapshotDiffReport;
import org.apache.ozone.rocksdiff.RocksDBCheckpointDiffer;
+import org.rocksdb.Options;
Review Comment:
As mentioned below, please extend the Managed objects and use them instead
of using RocksObject directly.
--
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]