qiaojialin commented on a change in pull request #258: [IOTDB-143]Development 
of merge
URL: https://github.com/apache/incubator-iotdb/pull/258#discussion_r314202063
 
 

 ##########
 File path: 
server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
 ##########
 @@ -185,53 +204,95 @@ public StorageGroupProcessor(String systemInfoDir, 
String storageGroupName)
   private void recover() throws ProcessorException {
     logger.info("recover Storage Group  {}", storageGroupName);
 
-    // collect TsFiles from sequential data directory
-    List<File> tsFiles = 
getAllFiles(DirectoryManager.getInstance().getAllSequenceFileFolders());
-    recoverSeqFiles(tsFiles);
-
-    // collect TsFiles from unsequential data directory
-    tsFiles = 
getAllFiles(DirectoryManager.getInstance().getAllUnSequenceFileFolders());
-    recoverUnseqFiles(tsFiles);
+    try {
+      // collect TsFiles from sequential and unsequential data directory
+      List<TsFileResource> seqTsFiles = 
getAllFiles(DirectoryManager.getInstance().getAllSequenceFileFolders());
+      List<TsFileResource> unseqTsFiles =
+          
getAllFiles(DirectoryManager.getInstance().getAllUnSequenceFileFolders());
+
+      recoverSeqFiles(seqTsFiles);
+      recoverUnseqFiles(unseqTsFiles);
+
+      String taskName = storageGroupName + "-" + System.currentTimeMillis();
+      File mergingMods = new File(storageGroupSysDir, 
MERGING_MODIFICAITON_FILE_NAME);
+      if (mergingMods.exists()) {
+        mergingModification = new ModificationFile(storageGroupSysDir + 
File.separator + MERGING_MODIFICAITON_FILE_NAME);
+      }
+      RecoverMergeTask recoverMergeTask = new RecoverMergeTask(seqTsFiles, 
unseqTsFiles,
+          storageGroupSysDir.getPath(), this::mergeEndAction, taskName,
+          IoTDBDescriptor.getInstance().getConfig().isForceFullMerge());
+      logger.info("{} a RecoverMergeTask {} starts...", storageGroupName, 
taskName);
+      
recoverMergeTask.recoverMerge(IoTDBDescriptor.getInstance().getConfig().isContinueMergeAfterReboot());
+      if 
(!IoTDBDescriptor.getInstance().getConfig().isContinueMergeAfterReboot()) {
+        mergingMods.delete();
+      }
+    } catch (IOException e) {
+      throw new ProcessorException(e);
+    }
 
     for (TsFileResource resource : sequenceFileList) {
       latestTimeForEachDevice.putAll(resource.getEndTimeMap());
       latestFlushedTimeForEachDevice.putAll(resource.getEndTimeMap());
     }
   }
 
-  private List<File> getAllFiles(List<String> folders) {
+  private List<TsFileResource> getAllFiles(List<String> folders) throws 
IOException {
     List<File> tsFiles = new ArrayList<>();
     for (String baseDir : folders) {
       File fileFolder = new File(baseDir, storageGroupName);
       if (!fileFolder.exists()) {
         continue;
       }
+      // some TsFileResource may be persisting when the system crashed, try 
recovering such
 
 Review comment:
   ```suggestion
         // some TsFileResource may be being persisted when the system crashed, 
try recovering such
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to