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


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/om/OMRatisLogRepair.java:
##########
@@ -0,0 +1,237 @@
+/*
+ * 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.repair.om;
+
+import static 
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type.EchoRPC;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.nio.ByteBuffer;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.ozone.om.helpers.OMRatisHelper;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
+import org.apache.hadoop.ozone.repair.RepairTool;
+import org.apache.ratis.proto.RaftProtos;
+import org.apache.ratis.server.metrics.SegmentedRaftLogMetrics;
+import org.apache.ratis.server.raftlog.segmented.LogSegmentPath;
+import org.apache.ratis.server.raftlog.segmented.LogSegmentStartEnd;
+import org.apache.ratis.server.raftlog.segmented.SegmentedRaftLogInputStream;
+import org.apache.ratis.server.raftlog.segmented.SegmentedRaftLogOutputStream;
+import org.apache.ratis.util.Preconditions;
+import org.apache.ratis.util.SizeInBytes;
+import picocli.CommandLine;
+
+
+/**
+ * Tool to omit a raft log in a ratis segment file.
+ */
+@CommandLine.Command(
+    name = "skip-ratis-transaction",
+    aliases = "srt",
+    description = "CLI to omit a raft log in a ratis segment file. The raft 
log at the index specified " +
+        "is replaced with an EchoOM command (which is a dummy command). It is 
an offline command " +
+        "i.e., doesn't require OM to be running. " +
+        "The command should be run for the same transaction on all 3 OMs only 
when they all OMs are crashing " +
+        "while applying the same transaction. If there is only one OM that is 
crashing, " +
+        "then the DB should manually copied from one of the good OMs to the 
crashing OM instead.",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class
+)
+public class OMRatisLogRepair extends RepairTool {
+
+  @CommandLine.Option(names = {"-s", "--segment-path", "--segmentPath"},
+      required = true,
+      description = "Path of the input segment file")
+  private File segmentFile;
+  @CommandLine.Option(names = {"-b", "--backup"},
+      required = true,
+      description = "Path to put the backup of the original repaired segment 
file")
+  private File backupPath;
+
+  @CommandLine.Option(names = {"--index"},
+      required = true,
+      description = "Index of the failing transaction that should be removed")
+  private long index;
+
+  @Override
+  public void execute() throws Exception {
+
+    info("Taking back up of Raft Log file: " + 
this.segmentFile.getAbsolutePath() + " to location: " + backupPath);
+    if (!segmentFile.exists()) {
+      error("Error: Source segment file \"" + segmentFile + "\" does not 
exist.");
+      return;
+    }
+    if (backupPath.exists()) {
+      error("Error: Backup file for segment file  \"" + backupPath + "\" 
already exists.");
+      return;
+    }
+    try {
+      if (!isDryRun()) {
+        Files.copy(segmentFile.toPath(), backupPath.toPath());

Review Comment:
   Thanks for the suggestion, I have made the changes according to it



-- 
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: issues-unsubscr...@ozone.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org
For additional commands, e-mail: issues-h...@ozone.apache.org

Reply via email to