smengcl commented on code in PR #4420:
URL: https://github.com/apache/ozone/pull/4420#discussion_r1145957603
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestLDBCli.java:
##########
@@ -36,295 +38,281 @@
import org.apache.hadoop.ozone.debug.RDBParser;
import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
import org.apache.hadoop.ozone.om.request.OMRequestTestUtils;
-import org.apache.ozone.test.GenericTestUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.rules.TemporaryFolder;
+import org.jetbrains.annotations.NotNull;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Named;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import picocli.CommandLine;
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.time.LocalDateTime;
-import java.util.List;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.TreeMap;
+import java.util.stream.Stream;
import static java.nio.charset.StandardCharsets.UTF_8;
-
/**
- * This class tests the Debug LDB CLI that reads from rocks db file.
+ * This class tests `ozone debug ldb` CLI that reads from a RocksDB directory.
*/
public class TestLDBCli {
+ private static final String KEY_TABLE = "keyTable";
+ private static final String BLOCK_DATA = "block_data";
+ private static final ObjectMapper MAPPER = new ObjectMapper();
private OzoneConfiguration conf;
+ private DBStore dbStore;
+ @TempDir
+ private File tempDir;
+ private StringWriter stdout, stderr;
+ private CommandLine cmd;
+ private NavigableMap<String, Map<String, ?>> dbMap;
+
+ @BeforeEach
+ public void setup() throws IOException {
+ conf = new OzoneConfiguration();
+ stdout = new StringWriter();
+ stderr = new StringWriter();
Review Comment:
Done
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/DBScanner.java:
##########
@@ -67,62 +66,81 @@
@MetaInfServices(SubcommandWithParent.class)
public class DBScanner implements Callable<Void>, SubcommandWithParent {
- public static final Logger LOG =
- LoggerFactory.getLogger(DBScanner.class);
+ public static final Logger LOG = LoggerFactory.getLogger(DBScanner.class);
+ private static final String SCHEMA_V3 = "V3";
+
+ @CommandLine.Spec
+ private CommandLine.Model.CommandSpec spec;
+
+ @CommandLine.ParentCommand
+ private RDBParser parent;
- @CommandLine.Option(names = {"--column_family", "--column-family"},
+ @CommandLine.Option(names = {"--column_family", "--column-family", "--cf"},
required = true,
description = "Table name")
private String tableName;
@CommandLine.Option(names = {"--with-keys"},
- description = "List Key -> Value instead of just Value.",
- defaultValue = "false",
- showDefaultValue = CommandLine.Help.Visibility.ALWAYS)
- private static boolean withKey;
+ description = "Print a JSON object of key->value pairs (default)"
+ + " instead of a JSON array of only values.",
+ defaultValue = "true")
+ private boolean withKey;
- @CommandLine.Option(names = {"--length", "-l"},
- description = "Maximum number of items to list.")
- private static int limit = -1;
+ @CommandLine.Option(names = {"--length", "--limit", "-l"},
+ description = "Maximum number of items to list.",
+ defaultValue = "-1")
+ private long limit;
@CommandLine.Option(names = {"--out", "-o"},
description = "File to dump table scan data")
- private static String fileName;
+ private String fileName;
- @CommandLine.Option(names = {"--startkey", "-sk"},
+ @CommandLine.Option(names = {"--startkey", "--sk", "-s"},
description = "Key from which to iterate the DB")
- private static String startKey;
+ private String startKey;
- @CommandLine.Option(names = {"--dnSchema", "-d", "--dn-schema"},
- description = "Datanode DB Schema Version : V1/V2/V3",
+ @CommandLine.Option(names = {"--dnSchema", "--dn-schema", "-d"},
+ description = "Datanode DB Schema Version: V1/V2/V3",
defaultValue = "V2")
- private static String dnDBSchemaVersion;
+ private String dnDBSchemaVersion;
- @CommandLine.Option(names = {"--container-id", "-cid"},
- description = "Container ID when datanode DB Schema is V3",
+ @CommandLine.Option(names = {"--container-id", "--cid"},
+ description = "Container ID. Applicable if datanode DB Schema is V3",
defaultValue = "-1")
- private static long containerId;
+ private long containerId;
- @CommandLine.Option(names = { "--show-count",
- "-count" }, description = "Get estimated key count for a"
- + " given column family in the db",
+ @CommandLine.Option(names = { "--show-count", "--count" },
+ description = "Get estimated key count for the given DB column family",
defaultValue = "false",
showDefaultValue = CommandLine.Help.Visibility.ALWAYS)
- private static boolean showCount;
+ private boolean showCount;
+ @Override
+ public Void call() throws Exception {
+ List<ColumnFamilyDescriptor> cfs =
+ RocksDBUtils.getColumnFamilyDescriptors(parent.getDbPath());
- @CommandLine.ParentCommand
- private RDBParser parent;
+ final List<ColumnFamilyHandle> columnFamilyHandleList = new ArrayList<>();
+ ManagedRocksDB rocksDB = ManagedRocksDB.openReadOnly(parent.getDbPath(),
Review Comment:
Done
--
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]