Class TaskExecutor
- java.lang.Object
-
- org.apache.flink.runtime.rpc.RpcEndpoint
-
- org.apache.flink.runtime.taskexecutor.TaskExecutor
-
- All Implemented Interfaces:
AutoCloseable,org.apache.flink.runtime.rpc.RpcGateway,TaskExecutorGateway,TaskExecutorOperatorEventGateway,TaskExecutorThreadInfoGateway,org.apache.flink.util.AutoCloseableAsync
public class TaskExecutor extends org.apache.flink.runtime.rpc.RpcEndpoint implements TaskExecutorGateway
TaskExecutor implementation. The task executor is responsible for the execution of multipleTask.
-
-
Field Summary
Fields Modifier and Type Field Description static StringTASK_MANAGER_NAME
-
Constructor Summary
Constructors Constructor Description TaskExecutor(org.apache.flink.runtime.rpc.RpcService rpcService, TaskManagerConfiguration taskManagerConfiguration, HighAvailabilityServices haServices, TaskManagerServices taskExecutorServices, ExternalResourceInfoProvider externalResourceInfoProvider, HeartbeatServices heartbeatServices, TaskManagerMetricGroup taskManagerMetricGroup, String metricQueryServiceAddress, TaskExecutorBlobService taskExecutorBlobService, org.apache.flink.runtime.rpc.FatalErrorHandler fatalErrorHandler, TaskExecutorPartitionTracker partitionTracker, DelegationTokenReceiverRepository delegationTokenReceiverRepository)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletableFuture<Acknowledge>abortCheckpoint(ExecutionAttemptID executionAttemptID, long checkpointId, long latestCompletedCheckpointId, long checkpointTimestamp)Abort a checkpoint for the given task.CompletableFuture<Boolean>canBeReleased()Checks whether the task executor can be released.CompletableFuture<Acknowledge>cancelTask(ExecutionAttemptID executionAttemptID, Duration timeout)Cancel the given task.CompletableFuture<Acknowledge>confirmCheckpoint(ExecutionAttemptID executionAttemptID, long completedCheckpointId, long completedCheckpointTimestamp, long lastSubsumedCheckpointId)Confirm a checkpoint for the given task.voiddisconnectJobManager(org.apache.flink.api.common.JobID jobId, Exception cause)Disconnects the given JobManager from the TaskManager.voiddisconnectResourceManager(Exception cause)Disconnects the ResourceManager from the TaskManager.voidfreeInactiveSlots(org.apache.flink.api.common.JobID jobId, Duration timeout)Frees all currently inactive slot allocated for the given job.CompletableFuture<Acknowledge>freeSlot(AllocationID allocationId, Throwable cause, Duration timeout)Frees the slot with the given allocation ID.CompletableFuture<Collection<PartitionWithMetrics>>getAndRetainPartitionWithMetrics(org.apache.flink.api.common.JobID jobId)Get and retain all partitions and their metrics located on this task executor, the metrics mainly includes the meta information of partition(partition bytes, etc).ResourceIDgetResourceID()CompletableFuture<Void>heartbeatFromJobManager(ResourceID resourceID, AllocatedSlotReport allocatedSlotReport)Heartbeat request from the job manager.CompletableFuture<Void>heartbeatFromResourceManager(ResourceID resourceID)Heartbeat request from the resource manager.voidonStart()CompletableFuture<Void>onStop()Called to shut down the TaskManager.CompletableFuture<Acknowledge>promotePartitions(org.apache.flink.api.common.JobID jobId, Set<ResultPartitionID> partitionIds)Batch promote intermediate result partitions.CompletableFuture<Acknowledge>releaseClusterPartitions(Collection<IntermediateDataSetID> dataSetsToRelease, Duration timeout)Releases all cluster partitions belong to any of the given data sets.voidreleasePartitions(org.apache.flink.api.common.JobID jobId, Set<ResultPartitionID> partitionIds)Batch release intermediate result partitions.CompletableFuture<TransientBlobKey>requestFileUploadByName(String fileName, Duration timeout)Requests the file upload of the specified name to the cluster'sBlobServer.CompletableFuture<TransientBlobKey>requestFileUploadByNameAndType(String fileName, FileType fileType, Duration timeout)Requests the file upload of the specified name and file type to the cluster'sBlobServer.CompletableFuture<TransientBlobKey>requestFileUploadByType(FileType fileType, Duration timeout)Requests the file upload of the specified type to the cluster'sBlobServer.CompletableFuture<Collection<LogInfo>>requestLogList(Duration timeout)Requests for the historical log file names on the TaskManager.CompletableFuture<org.apache.flink.types.SerializableOptional<String>>requestMetricQueryServiceAddress(Duration timeout)Returns the gateway of Metric Query Service on the TaskManager.CompletableFuture<ProfilingInfo>requestProfiling(int duration, ProfilingInfo.ProfilingMode mode, Duration timeout)Requests the profiling from this TaskManager.CompletableFuture<Collection<ProfilingInfo>>requestProfilingList(Duration timeout)Requests for the historical profiling file names on the TaskManager.CompletableFuture<Acknowledge>requestSlot(SlotID slotId, org.apache.flink.api.common.JobID jobId, AllocationID allocationId, ResourceProfile resourceProfile, String targetAddress, ResourceManagerId resourceManagerId, Duration timeout)Requests a slot from the TaskManager.CompletableFuture<ThreadDumpInfo>requestThreadDump(Duration timeout)Requests the thread dump from this TaskManager.CompletableFuture<TaskThreadInfoResponse>requestThreadInfoSamples(Collection<ExecutionAttemptID> taskExecutionAttemptIds, ThreadInfoSamplesRequest requestParams, Duration timeout)Request a thread info sample from the given tasks.CompletableFuture<Acknowledge>sendOperatorEventToTask(ExecutionAttemptID executionAttemptID, OperatorID operatorId, org.apache.flink.util.SerializedValue<OperatorEvent> evt)Sends an operator event to an operator in a task executed by the Task Manager (Task Executor).CompletableFuture<Acknowledge>submitTask(TaskDeploymentDescriptor tdd, JobMasterId jobMasterId, Duration timeout)Submit aTaskto theTaskExecutor.CompletableFuture<Acknowledge>triggerCheckpoint(ExecutionAttemptID executionAttemptID, long checkpointId, long checkpointTimestamp, CheckpointOptions checkpointOptions)Trigger the checkpoint for the given task.CompletableFuture<Acknowledge>updateDelegationTokens(ResourceManagerId resourceManagerId, byte[] tokens)Sends new delegation tokens to this TaskManager.CompletableFuture<Acknowledge>updatePartitions(ExecutionAttemptID executionAttemptID, Iterable<PartitionInfo> partitionInfos, Duration timeout)Update the task where the given partitions can be found.-
Methods inherited from class org.apache.flink.runtime.rpc.RpcEndpoint
callAsync, closeAsync, getAddress, getEndpointId, getHostname, getMainThreadExecutor, getMainThreadExecutor, getRpcService, getSelfGateway, getTerminationFuture, internalCallOnStart, internalCallOnStop, isRunning, registerResource, runAsync, scheduleRunAsync, scheduleRunAsync, start, stop, unregisterResource, validateRunsInMainThread
-
-
-
-
Field Detail
-
TASK_MANAGER_NAME
public static final String TASK_MANAGER_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TaskExecutor
public TaskExecutor(org.apache.flink.runtime.rpc.RpcService rpcService, TaskManagerConfiguration taskManagerConfiguration, HighAvailabilityServices haServices, TaskManagerServices taskExecutorServices, ExternalResourceInfoProvider externalResourceInfoProvider, HeartbeatServices heartbeatServices, TaskManagerMetricGroup taskManagerMetricGroup, @Nullable String metricQueryServiceAddress, TaskExecutorBlobService taskExecutorBlobService, org.apache.flink.runtime.rpc.FatalErrorHandler fatalErrorHandler, TaskExecutorPartitionTracker partitionTracker, DelegationTokenReceiverRepository delegationTokenReceiverRepository)
-
-
Method Detail
-
canBeReleased
public CompletableFuture<Boolean> canBeReleased()
Description copied from interface:TaskExecutorGatewayChecks whether the task executor can be released. It cannot be released if there're unconsumed result partitions.- Specified by:
canBeReleasedin interfaceTaskExecutorGateway- Returns:
- Future flag indicating whether the task executor can be released.
-
requestLogList
public CompletableFuture<Collection<LogInfo>> requestLogList(Duration timeout)
Description copied from interface:TaskExecutorGatewayRequests for the historical log file names on the TaskManager.- Specified by:
requestLogListin interfaceTaskExecutorGateway- Returns:
- A Tuple2 Array with all log file names with its length.
-
onStart
public void onStart() throws Exception- Overrides:
onStartin classorg.apache.flink.runtime.rpc.RpcEndpoint- Throws:
Exception
-
onStop
public CompletableFuture<Void> onStop()
Called to shut down the TaskManager. The method closes all TaskManager services.- Overrides:
onStopin classorg.apache.flink.runtime.rpc.RpcEndpoint
-
requestThreadInfoSamples
public CompletableFuture<TaskThreadInfoResponse> requestThreadInfoSamples(Collection<ExecutionAttemptID> taskExecutionAttemptIds, ThreadInfoSamplesRequest requestParams, Duration timeout)
Description copied from interface:TaskExecutorThreadInfoGatewayRequest a thread info sample from the given tasks.- Specified by:
requestThreadInfoSamplesin interfaceTaskExecutorThreadInfoGateway- Parameters:
taskExecutionAttemptIds- identifying the task to samplerequestParams- parameters of the requesttimeout- of the request- Returns:
- Future of stack trace sample response
-
submitTask
public CompletableFuture<Acknowledge> submitTask(TaskDeploymentDescriptor tdd, JobMasterId jobMasterId, Duration timeout)
Description copied from interface:TaskExecutorGatewaySubmit aTaskto theTaskExecutor.- Specified by:
submitTaskin interfaceTaskExecutorGateway- Parameters:
tdd- describing the task to submitjobMasterId- identifying the submitting JobMastertimeout- of the submit operation- Returns:
- Future acknowledge of the successful operation
-
cancelTask
public CompletableFuture<Acknowledge> cancelTask(ExecutionAttemptID executionAttemptID, Duration timeout)
Description copied from interface:TaskExecutorGatewayCancel the given task.- Specified by:
cancelTaskin interfaceTaskExecutorGateway- Parameters:
executionAttemptID- identifying the tasktimeout- for the cancel operation- Returns:
- Future acknowledge if the task is successfully canceled
-
updatePartitions
public CompletableFuture<Acknowledge> updatePartitions(ExecutionAttemptID executionAttemptID, Iterable<PartitionInfo> partitionInfos, Duration timeout)
Description copied from interface:TaskExecutorGatewayUpdate the task where the given partitions can be found.- Specified by:
updatePartitionsin interfaceTaskExecutorGateway- Parameters:
executionAttemptID- identifying the taskpartitionInfos- telling where the partition can be retrieved fromtimeout- for the update partitions operation- Returns:
- Future acknowledge if the partitions have been successfully updated
-
releasePartitions
public void releasePartitions(org.apache.flink.api.common.JobID jobId, Set<ResultPartitionID> partitionIds)Description copied from interface:TaskExecutorGatewayBatch release intermediate result partitions.- Specified by:
releasePartitionsin interfaceTaskExecutorGateway- Parameters:
jobId- id of the job that the partitions belong topartitionIds- partition ids to release
-
promotePartitions
public CompletableFuture<Acknowledge> promotePartitions(org.apache.flink.api.common.JobID jobId, Set<ResultPartitionID> partitionIds)
Description copied from interface:TaskExecutorGatewayBatch promote intermediate result partitions.- Specified by:
promotePartitionsin interfaceTaskExecutorGateway- Parameters:
jobId- id of the job that the partitions belong topartitionIds- partition ids to release- Returns:
- Future acknowledge that the partitions are successfully promoted.
-
releaseClusterPartitions
public CompletableFuture<Acknowledge> releaseClusterPartitions(Collection<IntermediateDataSetID> dataSetsToRelease, Duration timeout)
Description copied from interface:TaskExecutorGatewayReleases all cluster partitions belong to any of the given data sets.- Specified by:
releaseClusterPartitionsin interfaceTaskExecutorGateway- Parameters:
dataSetsToRelease- data sets for which all cluster partitions should be releasedtimeout- for the partitions release operation- Returns:
- Future acknowledge that the request was received
-
heartbeatFromJobManager
public CompletableFuture<Void> heartbeatFromJobManager(ResourceID resourceID, AllocatedSlotReport allocatedSlotReport)
Description copied from interface:TaskExecutorGatewayHeartbeat request from the job manager.- Specified by:
heartbeatFromJobManagerin interfaceTaskExecutorGateway- Parameters:
resourceID- unique id of the job manager- Returns:
- future which is completed exceptionally if the operation fails
-
heartbeatFromResourceManager
public CompletableFuture<Void> heartbeatFromResourceManager(ResourceID resourceID)
Description copied from interface:TaskExecutorGatewayHeartbeat request from the resource manager.- Specified by:
heartbeatFromResourceManagerin interfaceTaskExecutorGateway- Parameters:
resourceID- unique id of the resource manager- Returns:
- future which is completed exceptionally if the operation fails
-
triggerCheckpoint
public CompletableFuture<Acknowledge> triggerCheckpoint(ExecutionAttemptID executionAttemptID, long checkpointId, long checkpointTimestamp, CheckpointOptions checkpointOptions)
Description copied from interface:TaskExecutorGatewayTrigger the checkpoint for the given task. The checkpoint is identified by the checkpoint ID and the checkpoint timestamp.- Specified by:
triggerCheckpointin interfaceTaskExecutorGateway- Parameters:
executionAttemptID- identifying the taskcheckpointId- unique id for the checkpointcheckpointTimestamp- is the timestamp when the checkpoint has been initiatedcheckpointOptions- for performing the checkpoint- Returns:
- Future acknowledge if the checkpoint has been successfully triggered
-
confirmCheckpoint
public CompletableFuture<Acknowledge> confirmCheckpoint(ExecutionAttemptID executionAttemptID, long completedCheckpointId, long completedCheckpointTimestamp, long lastSubsumedCheckpointId)
Description copied from interface:TaskExecutorGatewayConfirm a checkpoint for the given task. The checkpoint is identified by the checkpoint ID and the checkpoint timestamp.- Specified by:
confirmCheckpointin interfaceTaskExecutorGateway- Parameters:
executionAttemptID- identifying the taskcompletedCheckpointId- unique id for the completed checkpointcompletedCheckpointTimestamp- is the timestamp when the checkpoint has been initiatedlastSubsumedCheckpointId- unique id for the checkpoint to be subsumed- Returns:
- Future acknowledge if the checkpoint has been successfully confirmed
-
abortCheckpoint
public CompletableFuture<Acknowledge> abortCheckpoint(ExecutionAttemptID executionAttemptID, long checkpointId, long latestCompletedCheckpointId, long checkpointTimestamp)
Description copied from interface:TaskExecutorGatewayAbort a checkpoint for the given task. The checkpoint is identified by the checkpoint ID and the checkpoint timestamp.- Specified by:
abortCheckpointin interfaceTaskExecutorGateway- Parameters:
executionAttemptID- identifying the taskcheckpointId- unique id for the checkpointlatestCompletedCheckpointId- the id of the latest completed checkpointcheckpointTimestamp- is the timestamp when the checkpoint has been initiated- Returns:
- Future acknowledge if the checkpoint has been successfully confirmed
-
requestSlot
public CompletableFuture<Acknowledge> requestSlot(SlotID slotId, org.apache.flink.api.common.JobID jobId, AllocationID allocationId, ResourceProfile resourceProfile, String targetAddress, ResourceManagerId resourceManagerId, Duration timeout)
Description copied from interface:TaskExecutorGatewayRequests a slot from the TaskManager.- Specified by:
requestSlotin interfaceTaskExecutorGateway- Parameters:
slotId- slot id for the requestjobId- for which to request a slotallocationId- id for the requestresourceProfile- of requested slot, used only for dynamic slot allocation and will be ignored otherwisetargetAddress- to which to offer the requested slotsresourceManagerId- current leader id of the ResourceManagertimeout- for the operation- Returns:
- answer to the slot request
-
freeSlot
public CompletableFuture<Acknowledge> freeSlot(AllocationID allocationId, Throwable cause, Duration timeout)
Description copied from interface:TaskExecutorGatewayFrees the slot with the given allocation ID.- Specified by:
freeSlotin interfaceTaskExecutorGateway- Parameters:
allocationId- identifying the slot to freecause- of the freeing operationtimeout- for the operation- Returns:
- Future acknowledge which is returned once the slot has been freed
-
freeInactiveSlots
public void freeInactiveSlots(org.apache.flink.api.common.JobID jobId, Duration timeout)Description copied from interface:TaskExecutorGatewayFrees all currently inactive slot allocated for the given job.- Specified by:
freeInactiveSlotsin interfaceTaskExecutorGateway- Parameters:
jobId- job for which all inactive slots should be releasedtimeout- for the operation
-
requestFileUploadByType
public CompletableFuture<TransientBlobKey> requestFileUploadByType(FileType fileType, Duration timeout)
Description copied from interface:TaskExecutorGatewayRequests the file upload of the specified type to the cluster'sBlobServer.- Specified by:
requestFileUploadByTypein interfaceTaskExecutorGateway- Parameters:
fileType- to uploadtimeout- for the asynchronous operation- Returns:
- Future which is completed with the
TransientBlobKeyof the uploaded file.
-
requestFileUploadByName
public CompletableFuture<TransientBlobKey> requestFileUploadByName(String fileName, Duration timeout)
Description copied from interface:TaskExecutorGatewayRequests the file upload of the specified name to the cluster'sBlobServer.- Specified by:
requestFileUploadByNamein interfaceTaskExecutorGateway- Parameters:
fileName- to uploadtimeout- for the asynchronous operation- Returns:
- Future which is completed with the
TransientBlobKeyof the uploaded file.
-
requestFileUploadByNameAndType
public CompletableFuture<TransientBlobKey> requestFileUploadByNameAndType(String fileName, FileType fileType, Duration timeout)
Description copied from interface:TaskExecutorGatewayRequests the file upload of the specified name and file type to the cluster'sBlobServer.- Specified by:
requestFileUploadByNameAndTypein interfaceTaskExecutorGateway- Parameters:
fileName- to uploadfileType- to uploadtimeout- for the asynchronous operation- Returns:
- Future which is completed with the
TransientBlobKeyof the uploaded file.
-
requestMetricQueryServiceAddress
public CompletableFuture<org.apache.flink.types.SerializableOptional<String>> requestMetricQueryServiceAddress(Duration timeout)
Description copied from interface:TaskExecutorGatewayReturns the gateway of Metric Query Service on the TaskManager.- Specified by:
requestMetricQueryServiceAddressin interfaceTaskExecutorGateway- Returns:
- Future gateway of Metric Query Service on the TaskManager.
-
disconnectJobManager
public void disconnectJobManager(org.apache.flink.api.common.JobID jobId, Exception cause)Description copied from interface:TaskExecutorGatewayDisconnects the given JobManager from the TaskManager.- Specified by:
disconnectJobManagerin interfaceTaskExecutorGateway- Parameters:
jobId- JobID for which the JobManager was the leadercause- for the disconnection from the JobManager
-
disconnectResourceManager
public void disconnectResourceManager(Exception cause)
Description copied from interface:TaskExecutorGatewayDisconnects the ResourceManager from the TaskManager.- Specified by:
disconnectResourceManagerin interfaceTaskExecutorGateway- Parameters:
cause- for the disconnection from the ResourceManager
-
sendOperatorEventToTask
public CompletableFuture<Acknowledge> sendOperatorEventToTask(ExecutionAttemptID executionAttemptID, OperatorID operatorId, org.apache.flink.util.SerializedValue<OperatorEvent> evt)
Description copied from interface:TaskExecutorOperatorEventGatewaySends an operator event to an operator in a task executed by the Task Manager (Task Executor).The reception is acknowledged (future is completed) when the event has been dispatched to the
AbstractInvokable.dispatchOperatorEvent(OperatorID, SerializedValue)method. It is not guaranteed that the event is processed successfully within the implementation. These cases are up to the task and event sender to handle (for example with an explicit response message upon success, or by triggering failure/recovery upon exception).- Specified by:
sendOperatorEventToTaskin interfaceTaskExecutorGateway- Specified by:
sendOperatorEventToTaskin interfaceTaskExecutorOperatorEventGateway
-
requestThreadDump
public CompletableFuture<ThreadDumpInfo> requestThreadDump(Duration timeout)
Description copied from interface:TaskExecutorGatewayRequests the thread dump from this TaskManager.- Specified by:
requestThreadDumpin interfaceTaskExecutorGateway- Parameters:
timeout- timeout for the asynchronous operation- Returns:
- the
ThreadDumpInfofor this TaskManager.
-
updateDelegationTokens
public CompletableFuture<Acknowledge> updateDelegationTokens(ResourceManagerId resourceManagerId, byte[] tokens)
Description copied from interface:TaskExecutorGatewaySends new delegation tokens to this TaskManager.- Specified by:
updateDelegationTokensin interfaceTaskExecutorGateway- Parameters:
resourceManagerId- current leader id of the ResourceManagertokens- new tokens- Returns:
- Future acknowledge of the successful operation
-
getAndRetainPartitionWithMetrics
public CompletableFuture<Collection<PartitionWithMetrics>> getAndRetainPartitionWithMetrics(org.apache.flink.api.common.JobID jobId)
Description copied from interface:TaskExecutorGatewayGet and retain all partitions and their metrics located on this task executor, the metrics mainly includes the meta information of partition(partition bytes, etc).- Specified by:
getAndRetainPartitionWithMetricsin interfaceTaskExecutorGateway- Parameters:
jobId- ID of the target job- Returns:
- All partitions belong to the target job and their metrics
-
requestProfiling
public CompletableFuture<ProfilingInfo> requestProfiling(int duration, ProfilingInfo.ProfilingMode mode, Duration timeout)
Description copied from interface:TaskExecutorGatewayRequests the profiling from this TaskManager.- Specified by:
requestProfilingin interfaceTaskExecutorGateway- Parameters:
duration- profiling durationmode- profiling modeProfilingInfo.ProfilingModetimeout- timeout for the asynchronous operation- Returns:
- the
ProfilingInfofor this TaskManager.
-
requestProfilingList
public CompletableFuture<Collection<ProfilingInfo>> requestProfilingList(Duration timeout)
Description copied from interface:TaskExecutorGatewayRequests for the historical profiling file names on the TaskManager.- Specified by:
requestProfilingListin interfaceTaskExecutorGateway- Returns:
- A Collection with all profiling instances information.
-
getResourceID
public ResourceID getResourceID()
-
-