Tejaskriya commented on code in PR #8016:
URL: https://github.com/apache/ozone/pull/8016#discussion_r2068006370


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/om/CompactionLogDagPrinter.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.debug.om;
+
+import static org.apache.hadoop.ozone.OzoneConsts.COMPACTION_LOG_TABLE;
+
+import com.google.protobuf.InvalidProtocolBufferException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.Callable;
+import org.apache.hadoop.hdds.cli.AbstractSubcommand;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.hdds.utils.db.managed.ManagedRocksDB;
+import org.apache.hadoop.hdds.utils.db.managed.ManagedRocksIterator;
+import org.apache.hadoop.ozone.debug.RocksDBUtils;
+import org.apache.hadoop.ozone.graph.PrintableGraph;
+import org.apache.ozone.compaction.log.CompactionLogEntry;
+import org.apache.ozone.rocksdiff.CompactionDag;
+import org.rocksdb.ColumnFamilyDescriptor;
+import org.rocksdb.ColumnFamilyHandle;
+import org.rocksdb.RocksDBException;
+import picocli.CommandLine;
+
+/**
+ * Handler to generate image for current compaction DAG.
+ * ozone debug om print-compaction-dag.
+ */
[email protected](
+    name = "print-compaction-dag",
+    aliases = "pcd",
+    description = "Create an image of the current compaction log DAG. " +
+        "This command is an offline command. i.e., it can run on any instance 
of om.db " +
+        "and does not require OM to be up.")
+public class CompactionLogDagPrinter extends AbstractSubcommand implements 
Callable<Void> {
+
+  @CommandLine.Option(names = {"-o", "--output-file"},
+      required = true,
+      description = "Path to location at which image will be downloaded. " +
+          "Should include the image file name with \".png\" extension.")
+  private String imageLocation;
+
+  @CommandLine.Option(names = {"--db"},
+      required = true,
+      scope = CommandLine.ScopeType.INHERIT,
+      description = "Path to OM RocksDB")
+  private String dbPath;
+
+  @Override
+  public Void call() throws Exception {
+    try {
+      final List<ColumnFamilyHandle> cfHandleList = new ArrayList<>();
+      List<ColumnFamilyDescriptor> cfDescList = 
RocksDBUtils.getColumnFamilyDescriptors(dbPath);
+      ManagedRocksDB activeRocksDB = ManagedRocksDB.openReadOnly(dbPath, 
cfDescList, cfHandleList);
+      ColumnFamilyHandle compactionLogTableCFHandle =
+          RocksDBUtils.getColumnFamilyHandle(COMPACTION_LOG_TABLE, 
cfHandleList);
+
+      CompactionDag compactionDag = new CompactionDag();
+      loadCompactionDagFromDB(activeRocksDB, compactionLogTableCFHandle, 
compactionDag);
+
+      pngPrintMutableGraph(compactionDag, imageLocation);
+      out().println("Graph was generated at '" + imageLocation + "'.");
+    } catch (RocksDBException ex) {
+      err().println("Failed to open RocksDB: " + ex);
+      throw new IOException(ex);

Review Comment:
   Right, we don't need to. Changing it to simply throw ex 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]

Reply via email to