Source:
public List<JobTaskMoveAssignment> getAssignmentsToBalanceHost(HostState host, List<HostState> hosts) { String hostID = host.getHostUuid(); List<JobTaskMoveAssignment> rv = new ArrayList<>(); if ((hosts == null) || hosts.isEmpty()) { log.warn("[spawn.balancer] reallocation failed: host list empty", hostID); return rv; } List<HostState> sortedHosts = sortHostsByDiskSpace(hosts); int numAlleviateHosts = (int) Math.ceil(sortedHosts.size() * config.getAlleviateHostPercentage()); HostFailWorker.FailState failState = spawn.getHostFailWorker().getFailureState(hostID); if ((failState == HostFailWorker.FailState.FAILING_FS_OKAY) || isExtremeHost(hostID, true, true) || (host.getAvailDiskBytes() < config.getMinFreeDiskSpaceToRecieveNewTasks())) { log.info("[spawn.balancer] categorized as overloaded host; looking for tasks to push off of it", hostID); List<HostState> lightHosts = sortedHosts.subList(0, numAlleviateHosts); rv.addAll(pushTasksOffHost(host, lightHosts, true, 1, config.getTasksMovedFullRebalance(),true)); } else if (isExtremeHost(hostID, true, false)) { log.info("[spawn.balancer] categorized as underloaded host; looking for tasks to pull onto it", hostID); List<HostState> heavyHosts = Lists.reverse(sortedHosts.subList(sortedHosts.size() - numAlleviateHosts, sortedHosts.size())); rv.addAll(pushTasksOntoHost(host, heavyHosts)); } else if (isExtremeHost(hostID, false, true)) { log.info("[spawn.balance] categorized as overworked host; looking for tasks to push off it", hostID); rv.addAll(balanceActiveJobsOnHost(host, hosts)); } if (rv.isEmpty()) { rv.addAll(balanceActiveJobsOnHost(host, hosts)); } return pruneTaskReassignments(rv); }

Target:
public List<JobTaskMoveAssignment> getAssignmentsToBalanceHost(HostState host, List<HostState> hosts) { String hostID = host.getHostUuid(); List<JobTaskMoveAssignment> rv = new ArrayList<>(); if ((hosts == null) || hosts.isEmpty()) { log.warn("[spawn.balancer] reallocation failed: host list empty", hostID); return rv; } List<HostState> sortedHosts = sortHostsByDiskSpace(hosts); int numAlleviateHosts = (int) Math.ceil(sortedHosts.size() * config.getAlleviateHostPercentage()); HostFailWorker.FailState failState = spawn.getHostFailWorker().getFailureState(hostID); if ((failState == HostFailWorker.FailState.FAILING_FS_OKAY) || isExtremeHost(hostID, true, true) || (host.getAvailDiskBytes() < config.getMinFreeDiskSpaceToRecieveNewTasks())) { log.info("[spawn.balancer] categorized as overloaded host; looking for tasks to push off of it", hostID); List<HostState> lightHosts = sortedHosts.subList(0, numAlleviateHosts); List<JobTaskMoveAssignment> moveAssignments = pushTasksOffHost(host, lightHosts, true, config.getTasksMovedFullRebalance(), true); rv.addAll(moveAssignments); } else if (isExtremeHost(hostID, true, false)) { log.info("[spawn.balancer] categorized as underloaded host; looking for tasks to pull onto it", hostID); List<HostState> heavyHosts = Lists.reverse(sortedHosts.subList(sortedHosts.size() - numAlleviateHosts, sortedHosts.size())); List<JobTaskMoveAssignment> moveAssignments = pushTasksOntoHost(host, heavyHosts); rv.addAll(moveAssignments); } else if (isExtremeHost(hostID, false, true)) { log.info("[spawn.balance] categorized as overworked host; looking for tasks to push off it", hostID); rv.addAll(balanceActiveJobsOnHost(host, hosts)); } if (rv.isEmpty()) { rv.addAll(balanceActiveJobsOnHost(host, hosts)); } return pruneTaskReassignments(rv); }