Source:
public DruidCoordinatorRuntimeParams run(DruidCoordinatorRuntimeParams params) { LOG.info("Run coordinator segment compactor"); final CoordinatorDynamicConfig dynamicConfig = params.getCoordinatorDynamicConfig(); final CoordinatorStats stats = new CoordinatorStats(); if (dynamicConfig.getMaxCompactionTaskSlots() > 0) { Map<String, VersionedIntervalTimeline<String, DataSegment>> dataSources = params.getDataSources(); List<CoordinatorCompactionConfig> compactionConfigList = dynamicConfig.getCompactionConfigs(); if (compactionConfigList != null && !compactionConfigList.isEmpty()) { Map<String, CoordinatorCompactionConfig> compactionConfigs = compactionConfigList .stream() .collect(Collectors.toMap(CoordinatorCompactionConfig::getDataSource, Function.identity())); final List<TaskStatusPlus> runningCompactTasks = indexingServiceClient .getRunningTasks() .stream() .filter(status -> status.getType().equals("compact")) .collect(Collectors.toList()); final CompactionSegmentIterator iterator = policy.reset(compactionConfigs, dataSources); final int compactionTaskCapacity = (int) Math.min( indexingServiceClient.getTotalWorkerCapacity() * dynamicConfig.getCompactionTaskSlotRatio(), dynamicConfig.getMaxCompactionTaskSlots() ); final int numAvailableCompactionTaskSlots = runningCompactTasks.size() > 0 ? compactionTaskCapacity - runningCompactTasks.size() : Math.max(1, compactionTaskCapacity - runningCompactTasks.size()); LOG.info("Running tasks [%d/%d]", runningCompactTasks.size(), compactionTaskCapacity); if (numAvailableCompactionTaskSlots > 0) { stats.accumulate(doRun(compactionConfigs, numAvailableCompactionTaskSlots, iterator)); } else { stats.accumulate(makeStats(0, iterator)); } } else { LOG.info("compactionConfig is empty. Skip."); } } else { LOG.info("maxCompactionTaskSlots was set to 0. Skip compaction"); } return params.buildFromExisting() .withCoordinatorStats(stats) .build(); }

Target:
public DruidCoordinatorRuntimeParams run(DruidCoordinatorRuntimeParams params) { LOG.info("Run coordinator segment compactor"); final CoordinatorDynamicConfig dynamicConfig = params.getCoordinatorDynamicConfig(); final CoordinatorStats stats = new CoordinatorStats(); if (dynamicConfig.getMaxCompactionTaskSlots() > 0) { Map<String, VersionedIntervalTimeline<String, DataSegment>> dataSources = params.getDataSources(); List<CoordinatorCompactionConfig> compactionConfigList = dynamicConfig.getCompactionConfigs(); if (compactionConfigList != null && !compactionConfigList.isEmpty()) { Map<String, CoordinatorCompactionConfig> compactionConfigs = compactionConfigList .stream() .collect(Collectors.toMap(CoordinatorCompactionConfig::getDataSource, Function.identity())); final int numRunningCompactTasks = indexingServiceClient .getRunningTasks() .stream() .filter(status -> status.getType().equals(COMPACT_TASK_TYPE)) .collect(Collectors.toList()) .size(); final CompactionSegmentIterator iterator = policy.reset(compactionConfigs, dataSources); final int compactionTaskCapacity = (int) Math.min( indexingServiceClient.getTotalWorkerCapacity() * dynamicConfig.getCompactionTaskSlotRatio(), dynamicConfig.getMaxCompactionTaskSlots() ); final int numAvailableCompactionTaskSlots = numRunningCompactTasks > 0 ? compactionTaskCapacity - numRunningCompactTasks : Math.max(1, compactionTaskCapacity); LOG.info("Running tasks [%d/%d]", numRunningCompactTasks, compactionTaskCapacity); if (numAvailableCompactionTaskSlots > 0) { stats.accumulate(doRun(compactionConfigs, numAvailableCompactionTaskSlots, iterator)); } else { stats.accumulate(makeStats(0, iterator)); } } else { LOG.info("compactionConfig is empty. Skip."); } } else { LOG.info("maxCompactionTaskSlots was set to 0. Skip compaction"); } return params.buildFromExisting() .withCoordinatorStats(stats) .build(); }