smengcl commented on code in PR #3786:
URL: https://github.com/apache/ozone/pull/3786#discussion_r992943484


##########
hadoop-hdds/rocksdb-checkpoint-differ/src/main/java/org/apache/ozone/rocksdiff/RocksDBCheckpointDiffer.java:
##########
@@ -262,57 +336,34 @@ public void onCompactionCompleted(
                   e.printStackTrace();
                 }
               }
+              sb.append('\n');
+
               LOG.warn("List of output files:");
               for (String file : compactionJobInfo.outputFiles()) {
+                final String fn = file.substring(filenameBegin + 1);
+                sb.append(fn).append('\t');
                 LOG.warn(file + ",");
               }
-              // Let us also build the graph
-              for (String outFilePath : compactionJobInfo.outputFiles()) {
-                String outfile =
-                    Paths.get(outFilePath).getFileName().toString();
-                CompactionNode outfileNode = compactionNodeTable.get(outfile);
-                if (outfileNode == null) {
-                  long numKeys = 0;
-                  try {
-                    numKeys = getSSTFileSummary(outfile);
-                  } catch (Exception e) {
-                    LOG.warn(e.getMessage());
-                  }
-                  outfileNode = new CompactionNode(outfile,
-                      lastSnapshotPrefix, numKeys,
-                      currentCompactionGen);
-                  compactionDAGFwd.addNode(outfileNode);
-                  compactionDAGReverse.addNode(outfileNode);
-                  compactionNodeTable.put(outfile, outfileNode);
-                }
-                for (String inFilePath : compactionJobInfo.inputFiles()) {
-                  String infile =
-                      Paths.get(inFilePath).getFileName().toString();
-                  CompactionNode infileNode = compactionNodeTable.get(infile);
-                  if (infileNode == null) {
-                    long numKeys = 0;
-                    try {
-                      numKeys = getSSTFileSummary(infile);
-                    } catch (Exception e) {
-                      LOG.warn(e.getMessage());
-                    }
-                    infileNode = new CompactionNode(infile,
-                        lastSnapshotPrefix,
-                        numKeys, UNKNOWN_COMPACTION_GEN);
-                    compactionDAGFwd.addNode(infileNode);
-                    compactionDAGReverse.addNode(infileNode);
-                    compactionNodeTable.put(infile, infileNode);
-                  }
-                  if (outfileNode.fileName.compareToIgnoreCase(
-                      infileNode.fileName) != 0) {
-                    compactionDAGFwd.putEdge(outfileNode, infileNode);
-                    compactionDAGReverse.putEdge(infileNode, outfileNode);
-                  }
-                }
-              }
-              if (debugEnabled(DEBUG_DAG_BUILD_UP)) {
-                printMutableGraph(null, null, compactionDAGFwd);
+              sb.append('\n');
+
+              // Persist infile/outfile to file
+              try (BufferedWriter bw = Files.newBufferedWriter(
+                  Paths.get(CURRENT_COMPACTION_LOG_FILENAME),
+                  StandardOpenOption.CREATE, StandardOpenOption.APPEND)) {
+                bw.write(sb.toString());
+                bw.flush();
+              } catch (IOException e) {
+                throw new RuntimeException(
+                    "Failed to append to log for DB compaction tracking", e);
               }
+
+              // Let us also build the graph
+//              populateCompactionDAG(compactionJobInfo.inputFiles(),

Review Comment:
   I have restored the commented out lines in 
https://github.com/apache/ozone/pull/3824 . This was commented out to test the 
DAG reconstruction (read from compaction log) in the UT.



-- 
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