Source:
public DruidCoordinatorRuntimeParams run(DruidCoordinatorRuntimeParams params) { LOG.info("Run coordinator segment compactor"); final CoordinatorCompactionConfig dynamicConfig = params.getCoordinatorCompactionConfig(); final CoordinatorStats stats = new CoordinatorStats(); if (dynamicConfig.getMaxCompactionTaskSlots() > 0) { Map<String, VersionedIntervalTimeline<String, DataSegment>> dataSources = params.getDataSources(); List<DataSourceCompactionConfig> compactionConfigList = dynamicConfig.getCompactionConfigs(); if (compactionConfigList != null && !compactionConfigList.isEmpty()) { Map<String, DataSourceCompactionConfig> compactionConfigs = compactionConfigList .stream() .collect(Collectors.toMap(DataSourceCompactionConfig::getDataSource, Function.identity())); final int numNonCompleteCompactionTasks = findNumNonCompleteCompactTasks( indexingServiceClient.getRunningTasks(), indexingServiceClient.getPendingTasks(), indexingServiceClient.getWaitingTasks() ); final CompactionSegmentIterator iterator = policy.reset(compactionConfigs, dataSources); final int compactionTaskCapacity = (int) Math.min( indexingServiceClient.getTotalWorkerCapacity() * dynamicConfig.getCompactionTaskSlotRatio(), dynamicConfig.getMaxCompactionTaskSlots() ); final int numAvailableCompactionTaskSlots = numNonCompleteCompactionTasks > 0 ? compactionTaskCapacity - numNonCompleteCompactionTasks : Math.max(1, compactionTaskCapacity); LOG.info("Running tasks [%d/%d]", numNonCompleteCompactionTasks, 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 CoordinatorCompactionConfig dynamicConfig = params.getCoordinatorCompactionConfig(); final CoordinatorStats stats = new CoordinatorStats(); if (dynamicConfig.getMaxCompactionTaskSlots() > 0) { Map<String, VersionedIntervalTimeline<String, DataSegment>> dataSources = params.getDataSources(); List<DataSourceCompactionConfig> compactionConfigList = dynamicConfig.getCompactionConfigs(); if (compactionConfigList != null && !compactionConfigList.isEmpty()) { Map<String, DataSourceCompactionConfig> compactionConfigs = compactionConfigList .stream() .collect(Collectors.toMap(DataSourceCompactionConfig::getDataSource, Function.identity())); final int numNonCompleteCompactionTasks = findNumNonCompleteCompactTasks( indexingServiceClient.getRunningTasks(), indexingServiceClient.getPendingTasks(), indexingServiceClient.getWaitingTasks() ); final CompactionSegmentIterator iterator = policy.reset(compactionConfigs, dataSources); final int compactionTaskCapacity = (int) Math.min( indexingServiceClient.getTotalWorkerCapacity() * dynamicConfig.getCompactionTaskSlotRatio(), dynamicConfig.getMaxCompactionTaskSlots() ); final int numAvailableCompactionTaskSlots = numNonCompleteCompactionTasks > 0 ? compactionTaskCapacity - numNonCompleteCompactionTasks : Math.max(1, compactionTaskCapacity); LOG.info( "Found [%d] available task slots for compaction out of [%d] max compaction task capacity", numAvailableCompactionTaskSlots, 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(); }