Class CompactionTaskManager

  • All Implemented Interfaces:
    org.apache.iotdb.commons.service.IService

    public class CompactionTaskManager
    extends java.lang.Object
    implements org.apache.iotdb.commons.service.IService
    CompactionMergeTaskPoolManager provides a ThreadPool tPro queue and run all compaction tasks.
    • Field Detail

      • currentTaskNum

        public static volatile java.util.concurrent.atomic.AtomicInteger currentTaskNum
    • Constructor Detail

      • CompactionTaskManager

        public CompactionTaskManager()
    • Method Detail

      • start

        public void start()
        Specified by:
        start in interface org.apache.iotdb.commons.service.IService
      • stop

        public void stop()
        Specified by:
        stop in interface org.apache.iotdb.commons.service.IService
      • waitAndStop

        public void waitAndStop​(long milliseconds)
        Specified by:
        waitAndStop in interface org.apache.iotdb.commons.service.IService
      • waitAllCompactionFinish

        public void waitAllCompactionFinish()
      • getID

        public org.apache.iotdb.commons.service.ServiceType getID()
        Specified by:
        getID in interface org.apache.iotdb.commons.service.IService
      • addTaskToWaitingQueue

        public boolean addTaskToWaitingQueue​(AbstractCompactionTask compactionTask)
                                      throws java.lang.InterruptedException
        This method submit the compaction task to the PriorityQueue in CompactionTaskManager. Notice! The task will not be submitted immediately. If the queue size is larger than max size, the task with last priority will be removed from the task.
        Throws:
        java.lang.InterruptedException
      • getMergeWriteRateLimiter

        public com.google.common.util.concurrent.RateLimiter getMergeWriteRateLimiter()
      • mergeRateLimiterAcquire

        public static void mergeRateLimiterAcquire​(com.google.common.util.concurrent.RateLimiter limiter,
                                                   long bytesLength)
        wait by throughoutMbPerSec limit to avoid continuous Write Or Read
      • submitSubTask

        public java.util.concurrent.Future<java.lang.Void> submitSubTask​(java.util.concurrent.Callable<java.lang.Void> subCompactionTask)
      • abortCompaction

        public java.util.List<AbstractCompactionTask> abortCompaction​(java.lang.String storageGroupName)
        Abort all compactions of a storage group. The running compaction tasks will be returned as a list, the compaction threads for the storage group are not terminated util all the tasks in the list is finish. The outer caller can use function isAnyTaskInListStillRunning to determine this.
      • isAnyTaskInListStillRunning

        public boolean isAnyTaskInListStillRunning​(java.util.List<AbstractCompactionTask> compactionTasks)
      • getExecutingTaskCount

        public int getExecutingTaskCount()
      • getTotalTaskCount

        public int getTotalTaskCount()
      • getFinishedTaskNum

        public long getFinishedTaskNum()
      • getSGWithRegionId

        public static java.lang.String getSGWithRegionId​(java.lang.String storageGroupName,
                                                         java.lang.String dataRegionId)
      • restart

        public void restart()
                     throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • clearCandidateQueue

        public void clearCandidateQueue()
      • getCompactionTaskFutureMayBlock

        public java.util.concurrent.Future<CompactionTaskSummary> getCompactionTaskFutureMayBlock​(AbstractCompactionTask task)
                                                                                           throws java.lang.InterruptedException,
                                                                                                  java.util.concurrent.TimeoutException
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException