Class GarbageCollectorThread

  • All Implemented Interfaces:
    java.lang.Runnable

    public class GarbageCollectorThread
    extends java.lang.Object
    implements java.lang.Runnable
    This is the garbage collector thread that runs in the background to remove any entry log files that no longer contains any active ledger.
    • Field Detail

      • scheduledFuture

        java.util.concurrent.Future<?> scheduledFuture
      • gcWaitTime

        final long gcWaitTime
      • isForceMinorCompactionAllow

        boolean isForceMinorCompactionAllow
      • enableMinorCompaction

        boolean enableMinorCompaction
      • minorCompactionThreshold

        final double minorCompactionThreshold
      • minorCompactionInterval

        final long minorCompactionInterval
      • minorCompactionMaxTimeMillis

        final long minorCompactionMaxTimeMillis
      • lastMinorCompactionTime

        long lastMinorCompactionTime
      • isForceMajorCompactionAllow

        boolean isForceMajorCompactionAllow
      • enableMajorCompaction

        boolean enableMajorCompaction
      • majorCompactionThreshold

        final double majorCompactionThreshold
      • majorCompactionInterval

        final long majorCompactionInterval
      • majorCompactionMaxTimeMillis

        long majorCompactionMaxTimeMillis
      • lastMajorCompactionTime

        long lastMajorCompactionTime
      • isForceGCAllowWhenNoSpace

        final boolean isForceGCAllowWhenNoSpace
      • compacting

        final java.util.concurrent.atomic.AtomicBoolean compacting
      • minorCompacting

        final java.util.concurrent.atomic.AtomicBoolean minorCompacting
      • majorCompacting

        final java.util.concurrent.atomic.AtomicBoolean majorCompacting
      • running

        volatile boolean running
      • forceGarbageCollection

        final java.util.concurrent.atomic.AtomicBoolean forceGarbageCollection
      • suspendMajorCompaction

        final java.util.concurrent.atomic.AtomicBoolean suspendMajorCompaction
      • suspendMinorCompaction

        final java.util.concurrent.atomic.AtomicBoolean suspendMinorCompaction
    • Method Detail

      • newExecutor

        static java.util.concurrent.ScheduledExecutorService newExecutor()
      • enableForceGC

        public void enableForceGC()
      • enableForceGC

        public void enableForceGC​(boolean forceMajor,
                                  boolean forceMinor)
      • disableForceGC

        public void disableForceGC()
      • triggerGC

        java.util.concurrent.Future<?> triggerGC​(boolean force,
                                                 boolean suspendMajor,
                                                 boolean suspendMinor)
      • triggerGC

        java.util.concurrent.Future<?> triggerGC()
      • isInForceGC

        public boolean isInForceGC()
      • isMajorGcSuspend

        public boolean isMajorGcSuspend()
      • isMinorGcSuspend

        public boolean isMinorGcSuspend()
      • suspendMajorGC

        public void suspendMajorGC()
      • resumeMajorGC

        public void resumeMajorGC()
      • suspendMinorGC

        public void suspendMinorGC()
      • resumeMinorGC

        public void resumeMinorGC()
      • start

        public void start()
      • getModInitialDelay

        public long getModInitialDelay()
        when number of ledger's Dir are more than 1,the same of GarbageCollectorThread will do the same thing, Especially 1) deleting ledger, then SyncThread will be timed to do rocksDB compact 2) compact: entry, cost cpu. then get Mod initial Delay time to simply avoid GarbageCollectorThread working at the same time
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • runWithFlags

        public void runWithFlags​(boolean force,
                                 boolean suspendMajor,
                                 boolean suspendMinor)
      • calculateUsageIndex

        int calculateUsageIndex​(int numBuckets,
                                double usage)
        Calculate the index for the batch based on the usage between 0 and 1.
        Parameters:
        numBuckets - Number of reporting buckets.
        usage - 0.0 - 1.0 value representing the usage of the entry log.
        Returns:
        index based on the number of buckets The last bucket will have the 1.0 if added.
      • shutdown

        public void shutdown()
                      throws java.lang.InterruptedException
        Shutdown the garbage collector thread.
        Throws:
        java.lang.InterruptedException - if there is an exception stopping gc thread.
      • compactEntryLog

        protected void compactEntryLog​(EntryLogMetadata entryLogMeta)
        Compact an entry log.
        Parameters:
        entryLogMeta -
      • isForceGCAllowWhenNoSpace

        public boolean isForceGCAllowWhenNoSpace()