swamirishi commented on code in PR #8214:
URL: https://github.com/apache/ozone/pull/8214#discussion_r2023896222
##########
hadoop-hdds/rocksdb-checkpoint-differ/src/main/java/org/apache/ozone/rocksdiff/RocksDBCheckpointDiffer.java:
##########
@@ -1382,6 +1393,62 @@ public void pruneSstFiles() {
}
}
+ /**
+ * Defines the task that removes OMKeyInfo from SST files from backup
directory to
+ * save disk space.
+ */
+ public void pruneSstFileValues() {
+ if (!shouldRun()) {
+ return;
+ }
+ Path sstBackupDirPath = Paths.get(sstBackupDir);
+ String kVSeparator = ",";
+
+ try (Stream<Path> files = Files.list(sstBackupDirPath)
+ .filter(file -> file.endsWith(ROCKSDB_SST_SUFFIX)) ) {
+
+ for (Path file : files.collect(Collectors.toList())) {
+ // Write the file.sst => file.sst.tmp
+ File sstFile = file.toFile();
+ File prunedSSTFile = Files.createFile(sstBackupDirPath
+ .resolve( sstFile.getName() + ".tmp")).toFile();
+
+ ManagedEnvOptions envOptions = new ManagedEnvOptions();
+ ManagedOptions managedOptions = new ManagedOptions();
+ ManagedSstFileWriter sstFileWriter = new
ManagedSstFileWriter(envOptions, managedOptions))
+ sstFileWriter.open(prunedSSTFile.getAbsolutePath());
+
+ ManagedRawSSTFileReader sstFileReader = new ManagedRawSSTFileReader<>(
+ managedOptions, sstFile.getAbsolutePath(), 2 * 1024 * 1024);
+ ManagedRawSSTFileIterator<String> itr = sstFileReader.newIterator(
+ keyValue -> StringUtils.bytes2String(keyValue.getKey()) +
kVSeparator
+ + StringUtils.bytes2String(keyValue.getValue()), null, null);
+
+ while(itr.hasNext()) {
+ String[] keyValue = itr.next().split(kVSeparator);
+ if (keyValue[1].isEmpty()) {
+ sstFileWriter.delete(keyValue[0].getBytes(UTF_8));
+ } else {
+ sstFileWriter.put(keyValue[0].getBytes(UTF_8),
"\0".getBytes(UTF_8));
+ }
+ }
+ sstFileWriter.finish();
+
+ // Acquire a mutex
+ try (BootstrapStateHandler.Lock lock = getBootstrapStateLock().lock())
{
Review Comment:
You need to take an ozone manager lock. Create an SST_FILE_LOCK resource in
OzoneManagerLock just on the sst file not entire lock
https://github.com/apache/ozone/blob/c4e78d9ad42c438d1cd840696cc279da1e2442f4/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/lock/OzoneManagerLock.java#L460
--
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]