szetszwo commented on code in PR #3656:
URL: https://github.com/apache/ozone/pull/3656#discussion_r938357519


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/AbstractDatanodeStore.java:
##########
@@ -116,7 +117,7 @@ public void start(ConfigurationSource config)
               OZONE_METADATA_STORE_ROCKSDB_STATISTICS_DEFAULT);
 
       if (!rocksDbStat.equals(OZONE_METADATA_STORE_ROCKSDB_STATISTICS_OFF)) {
-        Statistics statistics = new Statistics();
+        Statistics statistics = new ManagedStatistics();

Review Comment:
   Use ManagedStatistics and remove the Statistics import.
   ```
           final ManagedStatistics statistics = new ManagedStatistics();
   ```
   



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBConfigFromFile.java:
##########
@@ -20,6 +20,7 @@
 package org.apache.hadoop.hdds.utils.db;
 
 import com.google.common.base.Preconditions;
+import org.apache.hadoop.hdds.utils.db.managed.ManagedDBOptions;
 import org.eclipse.jetty.util.StringUtil;
 import org.rocksdb.ColumnFamilyDescriptor;
 import org.rocksdb.DBOptions;

Review Comment:
   Use ManagedDBOptions and remove the import.



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBProfile.java:
##########
@@ -64,7 +66,7 @@ public DBOptions getDBOptions() {
       final long bytesPerSync = toLong(StorageUnit.MB.toBytes(1.00));
       final boolean createIfMissing = true;
       final boolean createMissingColumnFamilies = true;
-      return new DBOptions()
+      return new ManagedDBOptions()

Review Comment:
   Similar as before
   ```
         final ManagedDBOptions options = new ManagedDBOptions();
         
options.setIncreaseParallelism(Runtime.getRuntime().availableProcessors())
             .setMaxBackgroundCompactions(maxBackgroundCompactions)
             .setMaxBackgroundFlushes(maxBackgroundFlushes)
             .setBytesPerSync(bytesPerSync)
             .setCreateIfMissing(createIfMissing)
             .setCreateMissingColumnFamilies(createMissingColumnFamilies);
         return options;
   ```



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/utils/db/DatanodeDBProfile.java:
##########
@@ -21,10 +21,10 @@
 import org.apache.hadoop.hdds.conf.ConfigurationSource;
 import org.apache.hadoop.hdds.conf.StorageUnit;
 import org.apache.hadoop.hdds.utils.db.DBProfile;
+import org.apache.hadoop.hdds.utils.db.managed.ManagedLRUCache;
 import org.rocksdb.BlockBasedTableConfig;
 import org.rocksdb.DBOptions;
 import org.rocksdb.ColumnFamilyOptions;

Review Comment:
   Why not replace them with ManagedDBOptions and ManagedColumnFamilyOptions?



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/managed/ManagedRocksIterator.java:
##########
@@ -0,0 +1,130 @@
+/*
+ * 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.hdds.utils.db.managed;
+
+import org.rocksdb.RocksDB;
+import org.rocksdb.RocksDBException;
+import org.rocksdb.RocksIterator;
+
+import java.nio.ByteBuffer;
+
+/**
+ * Managed RocksIterator.
+ */
+public class ManagedRocksIterator extends RocksIterator {
+  private final RocksIterator original;
+
+  public ManagedRocksIterator(RocksDB parent, RocksIterator original) {
+    // This object just act as a proxy to the real iterator.
+    super(parent, original.getNativeHandle());

Review Comment:
   There are two RocksIterator objects which may cause problems in the future.  
E.g. RocksDB may add a new method to RocksIterator but it is not overridden in 
ManagedRocksIterator.  I suggest to have a get() method as below.
   ```
   public class ManagedRocksIterator {
     private final RocksIterator original;
   
     public ManagedRocksIterator(RocksIterator original) {
       this.original = original;
     }
   
     public RocksIterator get() {
       return original;
     }
   
     @Override
     protected void finalize() throws Throwable {
       ManagedRocksObjectUtils.assertClosed(original);
       super.finalize();
     }
   }
   ```



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBProfile.java:
##########
@@ -51,7 +53,7 @@ public ColumnFamilyOptions getColumnFamilyOptions() {
       // Write Buffer Size -- set to 128 MB
       final long writeBufferSize = toLong(StorageUnit.MB.toBytes(128));
 
-      return new ColumnFamilyOptions()
+      return new ManagedColumnFamilyOptions()

Review Comment:
   Change the return type to ManagedColumnFamilyOptions and remove the 
ColumnFamilyOptions import.
   ```
         final ManagedColumnFamilyOptions options = new 
ManagedColumnFamilyOptions();
         options.setLevelCompactionDynamicLevelBytes(true)
             .setWriteBufferSize(writeBufferSize)
             .setTableFormatConfig(getBlockBasedTableConfig());
         return options;
   ```
   We may consider to override all the setXxx methods in 
ManagedColumnFamilyOptions for returning ManagedColumnFamilyOptions.  But it 
seems not worth doing so.



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