Source:
<code>public DynamicLifespanScheduler( BucketNodeMap bucketNodeMap, List<InternalNode> nodeByTaskId, List<ConnectorPartitionHandle> partitionHandles, OptionalInt concurrentLifespansPerTask) { this.bucketNodeMap = requireNonNull(bucketNodeMap, "bucketNodeMap is null"); <START> if (bucketNodeMap.isDynamic() && bucketNodeMap.getBucketToNode().size() != 0) { <END> this.nodeByTaskId = bucketNodeMap.getBucketToNode(); } else { this.nodeByTaskId = requireNonNull(nodeByTaskId, "nodeByTaskId is null"); } this.partitionHandles = unmodifiableList(new ArrayList<>( requireNonNull(partitionHandles, "partitionHandles is null"))); this.concurrentLifespansPerTask = requireNonNull(concurrentLifespansPerTask, "concurrentLifespansPerTask is null"); concurrentLifespansPerTask.ifPresent(lifespansPerTask -> checkArgument(lifespansPerTask >= 1, "concurrentLifespansPerTask must be great or equal to 1 if present")); int bucketCount = partitionHandles.size(); verify(bucketCount > 0); this.runningDriverGroupIdsByTask = new IntSet[nodeByTaskId.size()]; for (int i = 0; i < nodeByTaskId.size(); i++) { runningDriverGroupIdsByTask[i] = new IntOpenHashSet(); } this.taskByDriverGroup = new int[bucketCount]; this.driverGroupQueue = new IntArrayFIFOQueue(bucketCount); for (int i = 0; i < bucketCount; i++) { taskByDriverGroup[i] = NOT_ASSIGNED; driverGroupQueue.enqueue(i); } this.failedTasks = new IntOpenHashSet(); }</code><technical_language>I this is correct nodeByTaskId is mapped task id, bucketToNode is mapped buckets. In cases task handle multiple buckets sequentially, in facebook's setup. expected changes happen in scheduleInitial schedule. Basically try assign a driverGroup (i.e. worker concept of hive bucket), try check bucketNodeMap find a preferred node. If task node failed, select a random node</technical_language>

Target:
public DynamicLifespanScheduler( BucketNodeMap bucketNodeMap, List<InternalNode> nodeByTaskId, List<ConnectorPartitionHandle> partitionHandles, OptionalInt concurrentLifespansPerTask) { this.bucketNodeMap = requireNonNull(bucketNodeMap, "bucketNodeMap is null"); this.nodeByTaskId = requireNonNull(nodeByTaskId, "nodeByTaskId is null"); this.partitionHandles = unmodifiableList(new ArrayList<>( requireNonNull(partitionHandles, "partitionHandles is null"))); this.concurrentLifespansPerTask = requireNonNull(concurrentLifespansPerTask, "concurrentLifespansPerTask is null"); concurrentLifespansPerTask.ifPresent(lifespansPerTask -> checkArgument(lifespansPerTask >= 1, "concurrentLifespansPerTask must be great or equal to 1 if present")); int bucketCount = partitionHandles.size(); verify(bucketCount > 0); this.runningDriverGroupIdsByTask = new IntSet[nodeByTaskId.size()]; for (int i = 0; i < nodeByTaskId.size(); i++) { runningDriverGroupIdsByTask[i] = new IntOpenHashSet(); } this.taskByDriverGroup = new int[bucketCount]; this.noPreferenceDriverGroups = new IntArrayFIFOQueue(); this.nodeToPreferredDriverGroups = new HashMap<>(); Set<InternalNode> nodeSet = ImmutableSet.copyOf(nodeByTaskId); for (int i = 0; i < bucketCount; i++) { taskByDriverGroup[i] = NOT_ASSIGNED; if (bucketNodeMap.getAssignedNode(i).isPresent() && nodeSet.contains(bucketNodeMap.getAssignedNode(i).get())) { InternalNode preferredNode = bucketNodeMap.getAssignedNode(i).get(); nodeToPreferredDriverGroups.computeIfAbsent(preferredNode, k -> new IntArrayFIFOQueue()); nodeToPreferredDriverGroups.get(preferredNode).enqueue(i); } else { noPreferenceDriverGroups.enqueue(i); } } this.failedTasks = new IntOpenHashSet(); }