You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/05/19 14:06:31 UTC

[GitHub] [iotdb] dongxuwang commented on a diff in pull request #5948: [IOTDB-3225] TsFile Repair Tool

dongxuwang commented on code in PR #5948:
URL: https://github.com/apache/iotdb/pull/5948#discussion_r877091624


##########
server/src/main/java/org/apache/iotdb/db/utils/repair/TsFileRepairTool.java:
##########
@@ -0,0 +1,211 @@
+/*
+ * 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.iotdb.db.utils.repair;
+
+import org.apache.iotdb.commons.conf.IoTDBConstant;
+import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
+import org.apache.iotdb.tsfile.exception.write.WriteProcessException;
+import org.apache.iotdb.tsfile.fileSystem.FSFactoryProducer;
+import org.apache.iotdb.tsfile.fileSystem.fsFactory.FSFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+import static org.apache.iotdb.tsfile.common.constant.TsFileConstant.TSFILE_SUFFIX;
+
+/**
+ * Repair corrupted seq file which has overlap data with previous files. This tool will move the
+ * corrupted seq files to the corresponding unseq data dir. For example: There are seq files 1 2 3,
+ * in which there is a device in file 2 and file 3 that overlap with file 1, then file 2 and file 3
+ * will be thrown into the corresponding unseq directory.
+ */
+public class TsFileRepairTool {
+  // move bad seq files or not
+  private static boolean moveFile = false;
+  private static boolean printBadDevice = false;
+
+  private static final Logger logger = LoggerFactory.getLogger(TsFileRepairTool.class);
+  private static final FSFactory fsFactory = FSFactoryProducer.getFSFactory();
+  private static String baseDataDirPath;
+
+  /**
+   * Num of param should be three, which is [path of base data dir] [move file or not] [print device
+   * or not]. Eg: xxx/iotdb/data false true
+   */
+  public static void main(String[] args) throws WriteProcessException, IOException {
+    if (!checkArgs(args)) {
+      System.exit(1);
+    }
+    String msg = moveFile ? "with moving bad files" : "without moving bad files";
+    System.out.println("Start repairing " + msg + " ...");
+    // get seq data dirs
+    List<String> seqDataDirs =
+        new ArrayList<>(

Review Comment:
   This is a redundant new



-- 
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: reviews-unsubscribe@iotdb.apache.org

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