protected Result tryIncreaseLoadByAction(ActionType actionType,
                                                   ClusterModelSnapshot cluster,
                                                   BrokerUpdater.Broker srcBroker,
                                                   List<BrokerUpdater.Broker> candidateBrokers,
                                                   Collection<Goal> goalsByPriority,
                                                   Collection<Goal> optimizedGoals,
                                                   Map<String, Set<String>> goalsByGroup) {
        List<Action> actionList = new ArrayList<>();
        candidateBrokers.sort(highLoadComparator()); // higher load first
        double loadChange = 0.0;
        for (BrokerUpdater.Broker candidateBroker : candidateBrokers) {
            List<TopicPartitionReplicaUpdater.TopicPartitionReplica> candidateReplicas = cluster
                    .replicasFor(candidateBroker.getBrokerId())
                    .stream()
                    .sorted(partitionComparator) // higher load first
                    .collect(Collectors.toList());
            for (TopicPartitionReplicaUpdater.TopicPartitionReplica tp : candidateReplicas) {
                Optional<Action> optionalAction;
                ActionParameters parameters = new ActionParameters(cluster, tp, candidateBroker, List.of(srcBroker), goalsByPriority, optimizedGoals, goalsByGroup);
                if (actionType == ActionType.MOVE) {
                    optionalAction = tryMovePartitionOut(parameters);
                } else {
                    optionalAction = trySwapPartitionOut(parameters, Comparator.comparingDouble(p -> p.loadValue(resource())),
                            (src, candidate) -> src.loadValue(resource()) > candidate.loadValue(resource()));
                }

                if (optionalAction.isPresent()) {
                    Action action = optionalAction.get();
                    cluster.applyAction(action);
                    actionList.add(action);
                    loadChange += tp.loadValue(resource());
                    if (action.getType() == ActionType.SWAP) {
                        loadChange -= cluster.replica(action.getDestBrokerId(), action.getDestTopicPartition()).loadValue(resource());
                    }
                }
                if (isBrokerAcceptable(srcBroker)) {
                    // broker is acceptable after action, skip iterating reset partitions
                    return new Result(actionList, loadChange);
                }
            }
        }
        return new Result(actionList, loadChange);
    }
Try to increase resource load by move or swap replicas in.

@param actionType       type of action
@param cluster          cluster model
@param srcBroker        broker to increase load
@param candidateBrokers candidate brokers to move replicas from, or swap replicas with
@param goalsByPriority  all configured goals sorted by priority
@return a list of actions able to increase load of srcBroker along with load change
core/src/main/java/kafka/autobalancer/goals/AbstractResourceGoal.java