sashapolo commented on code in PR #7880:
URL: https://github.com/apache/ignite-3/pull/7880#discussion_r3026929590


##########
modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogGarbageCollector.java:
##########
@@ -286,6 +370,69 @@ private static boolean isLogIndexInRange(long index, 
IndexFileMeta indexFileMeta
         return index >= indexFileMeta.firstLogIndexInclusive() && index < 
indexFileMeta.lastLogIndexExclusive();
     }
 
+    private void initLogSizeFromDisk() throws IOException {
+        Path indexFilesDir = indexFileManager.indexFilesDir();
+
+        try (Stream<Path> files = Stream.concat(Files.list(segmentFilesDir), 
Files.list(indexFilesDir))) {
+            long logSizeOnDisk = files
+                    .mapToLong(path -> {
+                        try {
+                            return Files.size(path);
+                        } catch (IOException e) {
+                            throw new UncheckedIOException(e);
+                        }
+                    })
+                    .sum();
+
+            logSizeBytes.addAndGet(logSizeOnDisk);
+        }
+    }
+
+    private class GcTask implements Runnable {
+        @Override
+        public void run() {
+            while (!Thread.currentThread().isInterrupted()) {
+                try {
+                    runGcCycle();
+                } catch (ClosedByInterruptException e) {
+                    return;
+                } catch (IOException e) {
+                    failureProcessor.process(new 
FailureContext(CRITICAL_ERROR, e));
+                }
+
+                LockSupport.park();
+            }
+        }
+
+        private void runGcCycle() throws IOException {
+            if (logSizeBytes.get() < softLimitBytes) {
+                return;
+            }
+
+            LOG.info("Starting Log Storage GC cycle.");

Review Comment:
   https://issues.apache.org/jira/browse/IGNITE-28432



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

Reply via email to