swamirishi commented on code in PR #4315:
URL: https://github.com/apache/ozone/pull/4315#discussion_r1132819325


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/managed/ManagedSSTDumpIterator.java:
##########
@@ -0,0 +1,203 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.hdds.utils.db.managed;
+
+import com.google.common.collect.Lists;
+import org.apache.hadoop.hdds.utils.HddsServerUtil;
+import org.eclipse.jetty.io.RuntimeIOException;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Iterator to Parse output of RocksDBSSTDumpTool.
+ */
+public class ManagedSSTDumpIterator implements
+        Iterator<ManagedSSTDumpIterator.KeyValue>, AutoCloseable {
+  private Process process;
+  private static final String SST_DUMP_TOOL_CLASS =
+          "org.apache.hadoop.hdds.utils.db.managed.ManagedSSTDumpTool";
+  private static final String PATTERN_REGEX =
+          "'([^=>]+)' seq:([0-9]+), type:([0-9]+) =>";
+
+  public static final int PATTERN_KEY_GROUP_NUMBER = 1;
+  public static final int PATTERN_SEQ_GROUP_NUMBER = 2;
+  public static final int PATTERN_TYPE_GROUP_NUMBER = 3;
+  private static final Pattern PATTERN_MATCHER =
+          Pattern.compile(PATTERN_REGEX);
+  private BufferedReader processOutput;
+  private StringBuilder stdoutString;
+
+  private Matcher currentMatcher;
+  private int prevMatchEndIndex;
+  private KeyValue currentKey;
+  private char[] charBuffer;
+  private KeyValue nextKey;
+
+  private long pollIntervalMillis;
+  private Lock lock;
+
+
+  public ManagedSSTDumpIterator(String sstDumptoolJarPath,
+                                String sstFilePath,
+                                long pollIntervalMillis) throws IOException {
+    File sstFile = new File(sstFilePath);
+    if (!sstFile.exists() || !sstFile.isFile()) {
+      throw new IOException(String.format("Invalid SST File Path : %s",
+              sstFile.getAbsolutePath()));
+    }

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]

Reply via email to