sarvekshayr commented on code in PR #9469:
URL: https://github.com/apache/ozone/pull/9469#discussion_r2665549511


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/om/ContainerToKeyMapping.java:
##########
@@ -0,0 +1,357 @@
+/*
+ * 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.OM_KEY_PREFIX;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.stream.Collectors;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.hadoop.hdds.cli.AbstractSubcommand;
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition;
+import org.apache.hadoop.hdds.utils.db.DBStore;
+import org.apache.hadoop.hdds.utils.db.DBStoreBuilder;
+import org.apache.hadoop.hdds.utils.db.LongCodec;
+import org.apache.hadoop.hdds.utils.db.StringCodec;
+import org.apache.hadoop.hdds.utils.db.Table;
+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.om.codec.OMDBDefinition;
+import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
+import org.apache.hadoop.ozone.om.helpers.OmDirectoryInfo;
+import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
+import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
+import org.rocksdb.ColumnFamilyDescriptor;
+import org.rocksdb.ColumnFamilyHandle;
+import org.rocksdb.RocksDBException;
+import picocli.CommandLine;
+
+/**
+ * Tool to map full key paths that use the specified containers.
+ * Note: Currently only processes FSO layout buckets.
+ */
[email protected](
+    name = "container-key-mapping",
+    aliases = "ckm",
+    description = "Maps full key paths that use the specified containers. " +
+        "Note: A container can have both FSO and OBS keys. Currently this tool 
processes only FSO keys")
+public class ContainerToKeyMapping extends AbstractSubcommand implements 
Callable<Void> {
+  private static final String DIRTREE_DB_NAME = "omdirtree.db";
+  private static final String DIRTREE_TABLE_NAME = "dirTreeTable";
+  private static final DBColumnFamilyDefinition<Long, String> 
DIRTREE_TABLE_DEFINITION =
+      new DBColumnFamilyDefinition<>(DIRTREE_TABLE_NAME,
+          LongCodec.get(),
+          StringCodec.get());
+
+  @CommandLine.ParentCommand
+  private OMDebug parent;
+
+  @CommandLine.Option(names = {"--containers"},
+      required = true,
+      description = "Comma separated Container IDs")
+  private String containers;
+
+  private ManagedRocksDB rocksDB;
+  private ColumnFamilyHandle volumeCFHandle;
+  private ColumnFamilyHandle bucketCFHandle;
+  private ColumnFamilyHandle directoryCFHandle;
+  private ColumnFamilyHandle fileCFHandle;
+  private DBStore dirTreeDbStore;
+  private Table<Long, String> dirTreeTable;
+  // Cache volume IDs to avoid repeated lookups
+  private final Map<String, Long> volumeCache = new HashMap<>();
+
+  // TODO: Add support to OBS keys (HDDS-14118)
+  @Override
+  public Void call() throws Exception {
+    err().println("Note: A container can have both FSO and OBS keys. Currently 
this tool processes only FSO keys");

Review Comment:
   This will be removed once the tool supports OBS keys. 
   Added it as err() so it is visible on console without impacting jq parsing. 



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