This is an automated email from the ASF dual-hosted git repository.
tejaskriya pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new b0960dfe20d HDDS-13518. Move ozone debug ratislogparser to ozone debug
ratis parse (#8902)
b0960dfe20d is described below
commit b0960dfe20dca515198f9f06062852804c9215c1
Author: Sarveksha Yeshavantha Raju
<[email protected]>
AuthorDate: Thu Sep 4 19:14:00 2025 +0530
HDDS-13518. Move ozone debug ratislogparser to ozone debug ratis parse
(#8902)
---
.../docs/content/tools/debug/RatisLogParser.md | 24 +++++------
hadoop-hdds/docs/content/tools/debug/_index.md | 4 +-
.../ozone/dn/ratis/TestDnRatisLogParser.java | 8 ++--
.../ozone/parser/TestOzoneHARatisLogParser.java | 7 ++-
.../RatisLogParser.java => ratis/RatisDebug.java} | 22 ++++------
.../package-info.java} | 25 +----------
.../parse}/BaseLogParser.java | 6 +--
.../parse/RatisLogParser.java} | 50 +++++++++++++++-------
.../parse}/package-info.java | 2 +-
.../debug/segmentparser/OMRatisLogParser.java | 43 -------------------
.../debug/segmentparser/SCMRatisLogParser.java | 42 ------------------
11 files changed, 69 insertions(+), 164 deletions(-)
diff --git a/hadoop-hdds/docs/content/tools/debug/RatisLogParser.md
b/hadoop-hdds/docs/content/tools/debug/RatisLogParser.md
index 88437130406..17064bbb327 100644
--- a/hadoop-hdds/docs/content/tools/debug/RatisLogParser.md
+++ b/hadoop-hdds/docs/content/tools/debug/RatisLogParser.md
@@ -22,18 +22,16 @@ weight: 5
limitations under the License.
-->
-The Ratis log parser tool takes a segment file as input, and give the output
in a human-readable format.
-It has the following subcommands, which can be used to parse the Ratis logs of
different components:
-
+The Ratis log parser tool takes a segment file as input and gives a
human-readable output.
+It can be used to parse Ratis logs from different components by specifying the
corresponding role.
```bash
-Usage: ozone debug ratislogparser [-hV] [--verbose] [COMMAND]
-Shell of printing Ratis Log in understandable text
- -h, --help Show this help message and exit.
- -V, --version Print version information and exit.
- --verbose More verbose output. Show the stack trace of the errors.
-Commands:
- datanode dump datanode segment file
- generic dump generic ratis segment file
- om dump om ratis segment file
- scm dump scm ratis segment file
+Usage: ozone debug ratis parse [-hV] [--verbose] [--role=<role>]
-s=<segmentFile>
+Shell for printing Ratis Log in understandable text
+ -h, --help Show this help message and exit.
+ --role=<role> Component role for parsing. Values: om, scm, datanode
+ Default: generic
+ -s, --segmentPath, --segment-path=<segmentFile>
+ Path of the segment file
+ -V, --version Print version information and exit.
+ --verbose More verbose output. Show the stack trace of the errors.
```
diff --git a/hadoop-hdds/docs/content/tools/debug/_index.md
b/hadoop-hdds/docs/content/tools/debug/_index.md
index 01c6dd2e9e1..20adf899213 100644
--- a/hadoop-hdds/docs/content/tools/debug/_index.md
+++ b/hadoop-hdds/docs/content/tools/debug/_index.md
@@ -30,10 +30,10 @@ It includes the following tools:
* **om** - Debug commands related to OM.
* **datanode** - Debug commands related to Datanode.
* **replicas** - Debug commands for key replica related issues.
- * **ratislogparser** - Shell of printing Ratis Log in understandable text
+ * **ratis** - Debug commands related to Ratis.
* **auditparser** - A tool to parse and query Ozone audit logs.
* **log** - A tool to parse and provide insights on logs, currently
supports only the datanode's container logs.
* **checknative** - Checks if native libraries are loaded
* **version** - Show internal version of Ozone components
-For more information see the following subpages:
\ No newline at end of file
+For more information see the following subpages:
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/dn/ratis/TestDnRatisLogParser.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/dn/ratis/TestDnRatisLogParser.java
index 4de55ce6485..d57c03f92fc 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/dn/ratis/TestDnRatisLogParser.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/dn/ratis/TestDnRatisLogParser.java
@@ -29,7 +29,7 @@
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.ozone.OzoneConfigKeys;
-import org.apache.hadoop.ozone.debug.segmentparser.DatanodeRatisLogParser;
+import org.apache.hadoop.ozone.debug.ratis.parse.RatisLogParser;
import org.apache.ozone.test.GenericTestUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@@ -78,11 +78,11 @@ public void testRatisLogParsing() throws Exception {
GenericTestUtils.waitFor(logFile::exists, 100, 15000);
assertThat(logFile).isFile();
- DatanodeRatisLogParser datanodeRatisLogParser =
- new DatanodeRatisLogParser();
+ RatisLogParser datanodeRatisLogParser =
+ new RatisLogParser();
datanodeRatisLogParser.setSegmentFile(logFile);
datanodeRatisLogParser.parseRatisLogs(
- DatanodeRatisLogParser::smToContainerLogString);
+ RatisLogParser::smToContainerLogString);
assertThat(out.toString(StandardCharsets.UTF_8.name()))
.contains("Num Total Entries:");
}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/parser/TestOzoneHARatisLogParser.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/parser/TestOzoneHARatisLogParser.java
index 35891353b1e..cd85abe9021 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/parser/TestOzoneHARatisLogParser.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/parser/TestOzoneHARatisLogParser.java
@@ -38,8 +38,7 @@
import org.apache.hadoop.ozone.client.ObjectStore;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientFactory;
-import org.apache.hadoop.ozone.debug.segmentparser.OMRatisLogParser;
-import org.apache.hadoop.ozone.debug.segmentparser.SCMRatisLogParser;
+import org.apache.hadoop.ozone.debug.ratis.parse.RatisLogParser;
import org.apache.hadoop.ozone.om.helpers.OMRatisHelper;
import org.apache.ozone.test.GenericTestUtils;
import org.apache.ozone.test.tag.Flaky;
@@ -123,7 +122,7 @@ void testRatisLogParsing() throws Exception {
GenericTestUtils.waitFor(logFile::exists, 100, 15000);
assertThat(logFile).isFile();
- OMRatisLogParser omRatisLogParser = new OMRatisLogParser();
+ RatisLogParser omRatisLogParser = new RatisLogParser();
omRatisLogParser.setSegmentFile(logFile);
omRatisLogParser.parseRatisLogs(OMRatisHelper::smProtoToString);
@@ -151,7 +150,7 @@ void testRatisLogParsing() throws Exception {
GenericTestUtils.waitFor(logFile::exists, 100, 15000);
assertThat(logFile).isFile();
- SCMRatisLogParser scmRatisLogParser = new SCMRatisLogParser();
+ RatisLogParser scmRatisLogParser = new RatisLogParser();
scmRatisLogParser.setSegmentFile(logFile);
scmRatisLogParser.parseRatisLogs(SCMRatisRequest::smProtoToString);
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/RatisLogParser.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ratis/RatisDebug.java
similarity index 65%
rename from
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/RatisLogParser.java
rename to
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ratis/RatisDebug.java
index d809abec1f0..a888a1d6216 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/RatisLogParser.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ratis/RatisDebug.java
@@ -15,27 +15,23 @@
* limitations under the License.
*/
-package org.apache.hadoop.ozone.debug.segmentparser;
+package org.apache.hadoop.ozone.debug.ratis;
import org.apache.hadoop.hdds.cli.DebugSubcommand;
-import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.ozone.debug.ratis.parse.RatisLogParser;
import org.kohsuke.MetaInfServices;
import picocli.CommandLine;
/**
- * Parse Ratis Log CLI implementation.
+ * Ratis debug related commands.
*/
@CommandLine.Command(
- name = "ratislogparser",
- description = "Shell of printing Ratis Log in understandable text",
+ name = "ratis",
+ description = "Debug commands related to Ratis.",
subcommands = {
- DatanodeRatisLogParser.class,
- GenericRatisLogParser.class,
- OMRatisLogParser.class,
- SCMRatisLogParser.class
- },
- versionProvider = HddsVersionProvider.class,
- mixinStandardHelpOptions = true)
+ RatisLogParser.class
+ }
+)
@MetaInfServices(DebugSubcommand.class)
-public class RatisLogParser implements DebugSubcommand {
+public class RatisDebug implements DebugSubcommand {
}
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/GenericRatisLogParser.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ratis/package-info.java
similarity index 54%
rename from
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/GenericRatisLogParser.java
rename to
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ratis/package-info.java
index a4544c299f1..c042312404c 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/GenericRatisLogParser.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ratis/package-info.java
@@ -15,28 +15,7 @@
* limitations under the License.
*/
-package org.apache.hadoop.ozone.debug.segmentparser;
-
-import java.util.concurrent.Callable;
-import org.apache.hadoop.hdds.cli.HddsVersionProvider;
-import picocli.CommandLine;
-
/**
- * Command line utility to parse and dump any generic ratis segment file.
+ * Ratis debug related commands.
*/
[email protected](
- name = "generic",
- description = "dump generic ratis segment file",
- mixinStandardHelpOptions = true,
- versionProvider = HddsVersionProvider.class)
-public class GenericRatisLogParser extends BaseLogParser
- implements Callable<Void> {
- @CommandLine.ParentCommand
- private RatisLogParser logParser;
-
- @Override
- public Void call() throws Exception {
- parseRatisLogs(null);
- return null;
- }
-}
+package org.apache.hadoop.ozone.debug.ratis;
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/BaseLogParser.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ratis/parse/BaseLogParser.java
similarity index 91%
rename from
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/BaseLogParser.java
rename to
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ratis/parse/BaseLogParser.java
index b1565d84695..667936fe4e3 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/BaseLogParser.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ratis/parse/BaseLogParser.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.hadoop.ozone.debug.segmentparser;
+package org.apache.hadoop.ozone.debug.ratis.parse;
import com.google.common.annotations.VisibleForTesting;
import java.io.File;
@@ -43,8 +43,8 @@ public void parseRatisLogs(
ParseRatisLog prl = builder.build();
prl.dumpSegmentFile();
} catch (Exception e) {
- System.out.println(DatanodeRatisLogParser.class.getSimpleName()
- + "failed with exception " + e.toString());
+ System.out.println(RatisLogParser.class.getSimpleName()
+ + "failed with exception " + e);
}
}
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/DatanodeRatisLogParser.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ratis/parse/RatisLogParser.java
similarity index 51%
rename from
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/DatanodeRatisLogParser.java
rename to
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ratis/parse/RatisLogParser.java
index f6fc76177c0..3cdbc0d381f 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/DatanodeRatisLogParser.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ratis/parse/RatisLogParser.java
@@ -15,44 +15,62 @@
* limitations under the License.
*/
-package org.apache.hadoop.ozone.debug.segmentparser;
+package org.apache.hadoop.ozone.debug.ratis.parse;
import java.util.concurrent.Callable;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.scm.ha.SCMRatisRequest;
import
org.apache.hadoop.ozone.container.common.transport.server.ratis.ContainerStateMachine;
+import org.apache.hadoop.ozone.om.helpers.OMRatisHelper;
import org.apache.ratis.proto.RaftProtos.StateMachineLogEntryProto;
import org.apache.ratis.protocol.RaftGroupId;
import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
import picocli.CommandLine;
/**
- * Command line utility to parse and dump a datanode ratis segment file.
+ * Parse Ratis Log CLI implementation.
*/
@CommandLine.Command(
- name = "datanode",
- description = "dump datanode segment file",
- mixinStandardHelpOptions = true,
- versionProvider = HddsVersionProvider.class)
-public class DatanodeRatisLogParser extends BaseLogParser
- implements Callable<Void> {
- @CommandLine.ParentCommand
- private RatisLogParser logParser;
+ name = "parse",
+ description = "Shell for printing Ratis Log in understandable text",
+ versionProvider = HddsVersionProvider.class,
+ mixinStandardHelpOptions = true)
+public class RatisLogParser extends BaseLogParser implements Callable<Void> {
+ @CommandLine.Option(names = {"--role"},
+ defaultValue = "generic",
+ showDefaultValue = CommandLine.Help.Visibility.ALWAYS,
+ description = "Component role for parsing. Values: om, scm, datanode")
+ private String role;
private static final RaftGroupId DUMMY_PIPELINE_ID =
RaftGroupId.valueOf(ByteString.copyFromUtf8("ADummyRatisGroup"));
public static String smToContainerLogString(
StateMachineLogEntryProto logEntryProto) {
- return ContainerStateMachine.
- smProtoToString(DUMMY_PIPELINE_ID, null, logEntryProto);
+ return ContainerStateMachine.smProtoToString(DUMMY_PIPELINE_ID, null,
logEntryProto);
}
@Override
public Void call() throws Exception {
- System.out.println("Dumping Datanode Ratis Log");
- System.out.println("Using Dummy PipelineID:" + DUMMY_PIPELINE_ID + "\n\n");
-
- parseRatisLogs(DatanodeRatisLogParser::smToContainerLogString);
+ switch (role.toLowerCase()) {
+ case "om":
+ System.out.println("Dumping OM Ratis Log");
+ parseRatisLogs(OMRatisHelper::smProtoToString);
+ break;
+ case "scm":
+ System.out.println("Dumping SCM Ratis Log");
+ parseRatisLogs(SCMRatisRequest::smProtoToString);
+ break;
+ case "datanode":
+ System.out.println("Dumping Datanode Ratis Log");
+ System.out.println("Using Dummy PipelineID:" + DUMMY_PIPELINE_ID +
"\n\n");
+ parseRatisLogs(RatisLogParser::smToContainerLogString);
+ break;
+ default:
+ System.out.println("Dumping Generic Ratis Log");
+ parseRatisLogs(null);
+ break;
+ }
return null;
}
}
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/package-info.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ratis/parse/package-info.java
similarity index 94%
rename from
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/package-info.java
rename to
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ratis/parse/package-info.java
index 37c388e3e81..56e3c703662 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/package-info.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ratis/parse/package-info.java
@@ -18,4 +18,4 @@
/**
* Command line utility for dump ratis log files.
*/
-package org.apache.hadoop.ozone.debug.segmentparser;
+package org.apache.hadoop.ozone.debug.ratis.parse;
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/OMRatisLogParser.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/OMRatisLogParser.java
deleted file mode 100644
index 2c080d70633..00000000000
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/OMRatisLogParser.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.segmentparser;
-
-import java.util.concurrent.Callable;
-import org.apache.hadoop.hdds.cli.HddsVersionProvider;
-import org.apache.hadoop.ozone.om.helpers.OMRatisHelper;
-import picocli.CommandLine;
-
-/**
- * Command line utility to parse and dump a OM ratis segment file.
- */
[email protected](
- name = "om",
- description = "dump om ratis segment file",
- mixinStandardHelpOptions = true,
- versionProvider = HddsVersionProvider.class)
-public class OMRatisLogParser extends BaseLogParser implements Callable<Void> {
-
- @Override
- public Void call() throws Exception {
- System.out.println("Dumping OM Ratis Log");
-
- parseRatisLogs(OMRatisHelper::smProtoToString);
- return null;
- }
-}
-
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/SCMRatisLogParser.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/SCMRatisLogParser.java
deleted file mode 100644
index e4232ddba18..00000000000
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/SCMRatisLogParser.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.segmentparser;
-
-import java.util.concurrent.Callable;
-import org.apache.hadoop.hdds.cli.HddsVersionProvider;
-import org.apache.hadoop.hdds.scm.ha.SCMRatisRequest;
-import picocli.CommandLine;
-
-/**
- * Command line utility to parse and dump a SCM ratis segment file.
- */
[email protected](
- name = "scm",
- description = "dump scm ratis segment file",
- mixinStandardHelpOptions = true,
- versionProvider = HddsVersionProvider.class)
-public class SCMRatisLogParser extends BaseLogParser implements Callable<Void>
{
-
- @Override
- public Void call() throws Exception {
- System.out.println("Dumping SCM Ratis Log");
-
- parseRatisLogs(SCMRatisRequest::smProtoToString);
- return null;
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]