Source:
public CoordinatorStats run(DruidCoordinator coordinator, DruidCoordinatorRuntimeParams params, DataSegment segment) { final CoordinatorStats stats = new CoordinatorStats(); final Set<DataSegment> availableSegments = params.getAvailableSegments(); final Map<String, Integer> loadStatus = Maps.newHashMap(); int totalReplicantsInCluster = params.getSegmentReplicantLookup().getTotalReplicants(segment.getIdentifier()); for (Map.Entry<String, Integer> entry : getTieredReplicants().entrySet()) { final String tier = entry.getKey(); final int expectedReplicantsInTier = entry.getValue(); final int totalReplicantsInTier = params.getSegmentReplicantLookup() .getTotalReplicants(segment.getIdentifier(), tier); final int loadedReplicantsInTier = params.getSegmentReplicantLookup() .getLoadedReplicants(segment.getIdentifier(), tier); final MinMaxPriorityQueue<ServerHolder> serverQueue = params.getDruidCluster().getHistoricalsByTier(tier); final int maxSegmentsInQueue = params.getCoordinatorDynamicConfig().getMaxSegmentsInQueue(); if (serverQueue == null) { log.makeAlert("Tier[%s] has no servers! Check your cluster configuration!", tier).emit(); continue; } final List<ServerHolder> serverHolderList = serverQueue.stream() .filter(s -> s.getNumberOfSegmentsInQueue() < maxSegmentsInQueue) .collect(Collectors.toList()); final BalancerStrategy strategy = params.getBalancerStrategy(); if (availableSegments.contains(segment)) { CoordinatorStats assignStats = assign( params.getReplicationManager(), tier, totalReplicantsInCluster, expectedReplicantsInTier, totalReplicantsInTier, strategy, serverHolderList, segment ); stats.accumulate(assignStats); totalReplicantsInCluster += assignStats.getTieredStat(ASSIGNED_COUNT, tier); } loadStatus.put(tier, expectedReplicantsInTier - loadedReplicantsInTier); } stats.accumulate(drop(loadStatus, segment, params)); return stats; }

Target:
public CoordinatorStats run(DruidCoordinator coordinator, DruidCoordinatorRuntimeParams params, DataSegment segment) { final CoordinatorStats stats = new CoordinatorStats(); final Set<DataSegment> availableSegments = params.getAvailableSegments(); final Map<String, Integer> loadStatus = Maps.newHashMap(); int totalReplicantsInCluster = params.getSegmentReplicantLookup().getTotalReplicants(segment.getIdentifier()); for (Map.Entry<String, Integer> entry : getTieredReplicants().entrySet()) { final String tier = entry.getKey(); final int expectedReplicantsInTier = entry.getValue(); final int totalReplicantsInTier = params.getSegmentReplicantLookup() .getTotalReplicants(segment.getIdentifier(), tier); final int loadedReplicantsInTier = params.getSegmentReplicantLookup() .getLoadedReplicants(segment.getIdentifier(), tier); final MinMaxPriorityQueue<ServerHolder> serverQueue = params.getDruidCluster().getHistoricalsByTier(tier); if (serverQueue == null) { log.makeAlert("Tier[%s] has no servers! Check your cluster configuration!", tier).emit(); continue; } final int maxSegmentsInNodeLoadingQueue = params.getCoordinatorDynamicConfig() .getMaxSegmentsInNodeLoadingQueue(); Predicate<ServerHolder> serverHolderPredicate; if (maxSegmentsInNodeLoadingQueue > 0) { serverHolderPredicate = s -> (s != null && s.getNumberOfSegmentsInQueue() < maxSegmentsInNodeLoadingQueue); } else { serverHolderPredicate = Objects::nonNull; } final List<ServerHolder> serverHolderList = serverQueue.stream() .filter(serverHolderPredicate) .collect(Collectors.toList()); final BalancerStrategy strategy = params.getBalancerStrategy(); if (availableSegments.contains(segment)) { CoordinatorStats assignStats = assign( params.getReplicationManager(), tier, totalReplicantsInCluster, expectedReplicantsInTier, totalReplicantsInTier, strategy, serverHolderList, segment ); stats.accumulate(assignStats); totalReplicantsInCluster += assignStats.getTieredStat(ASSIGNED_COUNT, tier); } loadStatus.put(tier, expectedReplicantsInTier - loadedReplicantsInTier); } stats.accumulate(drop(loadStatus, segment, params)); return stats; }