private synchronized void updateCompletedDriverGroups(TaskStatus taskStatus) { // Sets.difference returns a view. // Once we add the difference into `completedDriverGroups`, the view will be empty. // `completedLifespansChangeListeners.invoke` happens asynchronously. // As a result, calling the listeners before updating `completedDriverGroups` doesn't make a difference. // That's why a copy must be made here. Set<Lifespan> newlyCompletedDriverGroups = ImmutableSet.copyOf(Sets.difference(taskStatus.getCompletedDriverGroups(), this.completedDriverGroups)); if (newlyCompletedDriverGroups.isEmpty()) { return; } completedLifespansChangeListeners.invoke(newlyCompletedDriverGroups, executor); // newlyCompletedDriverGroups is a view. // Making changes to completedDriverGroups will change newlyCompletedDriverGroups. completedDriverGroups.addAll(newlyCompletedDriverGroups); } }
public static TaskStatus failWith(TaskStatus taskStatus, TaskState state, List<ExecutionFailureInfo> exceptions) { return new TaskStatus( taskStatus.getTaskId(), taskStatus.getTaskInstanceId(), MAX_VERSION, state, taskStatus.getSelf(), taskStatus.getNodeId(), taskStatus.getCompletedDriverGroups(), exceptions, taskStatus.getQueuedPartitionedDrivers(), taskStatus.getRunningPartitionedDrivers(), taskStatus.isOutputBufferOverutilized(), taskStatus.getPhysicalWrittenDataSize(), taskStatus.getMemoryReservation(), taskStatus.getSystemMemoryReservation(), taskStatus.getFullGcCount(), taskStatus.getFullGcTime()); } }