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


##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/defrag/TestSnapshotDefragService.java:
##########
@@ -224,6 +236,71 @@ private String getFromCodecBuffer(CodecBuffer buffer) {
     return StringCodec.get().fromCodecBuffer(buffer);
   }
 
+  private void putString(Table<String, CodecBuffer> table, String key,
+      String value) throws RocksDatabaseException, CodecException {
+    table.put(key, StringCodec.get().toDirectCodecBuffer(value));
+  }
+
+  private DBStore createDBStore(String name, String tableName)
+      throws RocksDatabaseException {
+    return DBStoreBuilder.newBuilder(configuration)
+        .setName(name)
+        .setPath(tempDir)
+        .addTable(tableName)
+        .build();
+  }
+
+  private Path createLiveSstDelta(DBStore sourceStore, String tableName,
+      String key, LiveSstType liveSstType) throws Exception {
+    Table<String, CodecBuffer> sourceTable = sourceStore.getTable(
+        tableName, StringCodec.get(), CodecBufferCodec.get(true));
+    putString(sourceTable, key, "source-value");
+    sourceStore.flushDB();
+
+    if (liveSstType == LiveSstType.PREVIOUSLY_INGESTED) {
+      File externalFile = tempDir.resolve("external-" + UUID.randomUUID()
+          + ".sst").toFile();
+      try (RDBSstFileWriter writer = new RDBSstFileWriter(externalFile);
+           CodecBuffer keyBuffer = StringCodec.get().toDirectCodecBuffer(key);
+           CodecBuffer valueBuffer = StringCodec.get()
+               .toDirectCodecBuffer("ingested-value")) {
+        writer.put(keyBuffer, valueBuffer);
+      }
+      sourceTable.loadFromFile(externalFile);
+    }
+
+    LiveFileMetaData liveFile = ((RDBStore) sourceStore).getDb()
+        .getLiveFilesMetaData().stream()
+        .max(Comparator.comparingLong(LiveFileMetaData::largestSeqno))
+        .orElseThrow(() -> new IllegalStateException("No live SST file"));
+    Path sourceFile = Paths.get(liveFile.path(), liveFile.fileName());
+    Path deltaFile = tempDir.resolve("delta-" + UUID.randomUUID() + ".sst");
+    Files.createLink(deltaFile, sourceFile);
+    return deltaFile;
+  }

Review Comment:
   Addressed in ca72a52dc86. The helper now records the target column family 
live filenames before ingestion, filters post-ingestion metadata to that column 
family, selects the newly added file, and requires exactly one match. This 
deterministically selects the ingested SST.



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