Class RuntimeEnvironment
- java.lang.Object
-
- org.apache.flink.runtime.taskmanager.RuntimeEnvironment
-
- All Implemented Interfaces:
Environment
public class RuntimeEnvironment extends Object implements Environment
In implementation of theEnvironment
.
-
-
Constructor Summary
Constructors Constructor Description RuntimeEnvironment(JobID jobId, JobType jobType, JobVertexID jobVertexId, ExecutionAttemptID executionId, ExecutionConfig executionConfig, JobInfo jobInfo, TaskInfo taskInfo, Configuration jobConfiguration, Configuration taskConfiguration, UserCodeClassLoader userCodeClassLoader, MemoryManager memManager, SharedResources sharedResources, IOManager ioManager, BroadcastVariableManager bcVarManager, TaskStateManager taskStateManager, GlobalAggregateManager aggregateManager, AccumulatorRegistry accumulatorRegistry, TaskKvStateRegistry kvStateRegistry, InputSplitProvider splitProvider, Map<String,Future<Path>> distCacheEntries, ResultPartitionWriter[] writers, IndexedInputGate[] inputGates, TaskEventDispatcher taskEventDispatcher, CheckpointResponder checkpointResponder, TaskOperatorEventGateway operatorEventGateway, TaskManagerRuntimeInfo taskManagerInfo, TaskMetricGroup metrics, Task containingTask, ExternalResourceInfoProvider externalResourceInfoProvider, ChannelStateWriteRequestExecutorFactory channelStateExecutorFactory, TaskManagerActions taskManagerActions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acknowledgeCheckpoint(long checkpointId, CheckpointMetrics checkpointMetrics)
Confirms that the invokable has successfully completed all steps it needed to for the checkpoint with the give checkpoint-ID.void
acknowledgeCheckpoint(long checkpointId, CheckpointMetrics checkpointMetrics, TaskStateSnapshot checkpointStateHandles)
Confirms that the invokable has successfully completed all required steps for the checkpoint with the give checkpoint-ID.void
declineCheckpoint(long checkpointId, CheckpointException checkpointException)
Declines a checkpoint.void
failExternally(Throwable cause)
Marks task execution failed for an external reason (a reason other than the task code itself throwing an exception).AccumulatorRegistry
getAccumulatorRegistry()
Return the registry for accumulators which are periodically sent to the job manager.IndexedInputGate[]
getAllInputGates()
ResultPartitionWriter[]
getAllWriters()
ExecutorService
getAsyncOperationsThreadPool()
BroadcastVariableManager
getBroadcastVariableManager()
ChannelStateWriteRequestExecutorFactory
getChannelStateExecutorFactory()
CheckpointStorageAccess
getCheckpointStorageAccess()
Map<String,Future<Path>>
getDistributedCacheEntries()
ExecutionConfig
getExecutionConfig()
Returns the job specificExecutionConfig
.ExecutionAttemptID
getExecutionId()
Gets the ID of the task execution attempt.ExternalResourceInfoProvider
getExternalResourceInfoProvider()
Get theExternalResourceInfoProvider
which contains infos of available external resources.GlobalAggregateManager
getGlobalAggregateManager()
IndexedInputGate
getInputGate(int index)
InputSplitProvider
getInputSplitProvider()
Returns the input split provider assigned to this environment.IOManager
getIOManager()
Returns the currentIOManager
.Configuration
getJobConfiguration()
Returns the job-wide configuration object that was attached to the JobGraph.JobID
getJobID()
Returns the ID of the job that the task belongs to.JobInfo
getJobInfo()
Returns theJobInfo
object associated with current job.JobType
getJobType()
JobVertexID
getJobVertexId()
Gets the ID of the JobVertex for which this task executes a parallel subtask.MailboxExecutor
getMainMailboxExecutor()
MemoryManager
getMemoryManager()
Returns the currentMemoryManager
.TaskMetricGroup
getMetricGroup()
Returns the task specific metric group.TaskOperatorEventGateway
getOperatorCoordinatorEventGateway()
Gets the gateway through which operators can send events to the operator coordinators.SharedResources
getSharedResources()
Configuration
getTaskConfiguration()
Returns the task-wide configuration object, originally attached to the job vertex.TaskEventDispatcher
getTaskEventDispatcher()
TaskInfo
getTaskInfo()
Returns theTaskInfo
object associated with this subtask.TaskKvStateRegistry
getTaskKvStateRegistry()
Returns the registry forInternalKvState
instances.TaskManagerActions
getTaskManagerActions()
TaskManagerRuntimeInfo
getTaskManagerInfo()
Gets the task manager info, with configuration and hostname.TaskStateManager
getTaskStateManager()
UserCodeClassLoader
getUserCodeClassLoader()
Returns the user code class loader.ResultPartitionWriter
getWriter(int index)
void
setAsyncOperationsThreadPool(ExecutorService executorService)
void
setCheckpointStorageAccess(CheckpointStorageAccess checkpointStorageAccess)
void
setMainMailboxExecutor(MailboxExecutor mainMailboxExecutor)
-
-
-
Constructor Detail
-
RuntimeEnvironment
public RuntimeEnvironment(JobID jobId, JobType jobType, JobVertexID jobVertexId, ExecutionAttemptID executionId, ExecutionConfig executionConfig, JobInfo jobInfo, TaskInfo taskInfo, Configuration jobConfiguration, Configuration taskConfiguration, UserCodeClassLoader userCodeClassLoader, MemoryManager memManager, SharedResources sharedResources, IOManager ioManager, BroadcastVariableManager bcVarManager, TaskStateManager taskStateManager, GlobalAggregateManager aggregateManager, AccumulatorRegistry accumulatorRegistry, TaskKvStateRegistry kvStateRegistry, InputSplitProvider splitProvider, Map<String,Future<Path>> distCacheEntries, ResultPartitionWriter[] writers, IndexedInputGate[] inputGates, TaskEventDispatcher taskEventDispatcher, CheckpointResponder checkpointResponder, TaskOperatorEventGateway operatorEventGateway, TaskManagerRuntimeInfo taskManagerInfo, TaskMetricGroup metrics, Task containingTask, ExternalResourceInfoProvider externalResourceInfoProvider, ChannelStateWriteRequestExecutorFactory channelStateExecutorFactory, TaskManagerActions taskManagerActions)
-
-
Method Detail
-
getExecutionConfig
public ExecutionConfig getExecutionConfig()
Description copied from interface:Environment
Returns the job specificExecutionConfig
.- Specified by:
getExecutionConfig
in interfaceEnvironment
- Returns:
- The execution configuration associated with the current job.
-
getJobID
public JobID getJobID()
Description copied from interface:Environment
Returns the ID of the job that the task belongs to.- Specified by:
getJobID
in interfaceEnvironment
- Returns:
- the ID of the job from the original job graph
-
getJobType
public JobType getJobType()
- Specified by:
getJobType
in interfaceEnvironment
-
getJobVertexId
public JobVertexID getJobVertexId()
Description copied from interface:Environment
Gets the ID of the JobVertex for which this task executes a parallel subtask.- Specified by:
getJobVertexId
in interfaceEnvironment
- Returns:
- The JobVertexID of this task.
-
getExecutionId
public ExecutionAttemptID getExecutionId()
Description copied from interface:Environment
Gets the ID of the task execution attempt.- Specified by:
getExecutionId
in interfaceEnvironment
- Returns:
- The ID of the task execution attempt.
-
getJobInfo
public JobInfo getJobInfo()
Description copied from interface:Environment
Returns theJobInfo
object associated with current job.- Specified by:
getJobInfo
in interfaceEnvironment
- Returns:
- JobInfo for current job
-
getTaskInfo
public TaskInfo getTaskInfo()
Description copied from interface:Environment
Returns theTaskInfo
object associated with this subtask.- Specified by:
getTaskInfo
in interfaceEnvironment
- Returns:
- TaskInfo for this subtask
-
getJobConfiguration
public Configuration getJobConfiguration()
Description copied from interface:Environment
Returns the job-wide configuration object that was attached to the JobGraph.- Specified by:
getJobConfiguration
in interfaceEnvironment
- Returns:
- The job-wide configuration
-
getTaskConfiguration
public Configuration getTaskConfiguration()
Description copied from interface:Environment
Returns the task-wide configuration object, originally attached to the job vertex.- Specified by:
getTaskConfiguration
in interfaceEnvironment
- Returns:
- The task-wide configuration
-
getTaskManagerInfo
public TaskManagerRuntimeInfo getTaskManagerInfo()
Description copied from interface:Environment
Gets the task manager info, with configuration and hostname.- Specified by:
getTaskManagerInfo
in interfaceEnvironment
- Returns:
- The task manager info, with configuration and hostname.
-
getMetricGroup
public TaskMetricGroup getMetricGroup()
Description copied from interface:Environment
Returns the task specific metric group.- Specified by:
getMetricGroup
in interfaceEnvironment
- Returns:
- The MetricGroup of this task.
-
getUserCodeClassLoader
public UserCodeClassLoader getUserCodeClassLoader()
Description copied from interface:Environment
Returns the user code class loader.- Specified by:
getUserCodeClassLoader
in interfaceEnvironment
-
getMemoryManager
public MemoryManager getMemoryManager()
Description copied from interface:Environment
Returns the currentMemoryManager
.- Specified by:
getMemoryManager
in interfaceEnvironment
- Returns:
- the current
MemoryManager
.
-
getSharedResources
public SharedResources getSharedResources()
- Specified by:
getSharedResources
in interfaceEnvironment
- Returns:
- the resources shared among all tasks of this task manager.
-
getIOManager
public IOManager getIOManager()
Description copied from interface:Environment
Returns the currentIOManager
.- Specified by:
getIOManager
in interfaceEnvironment
- Returns:
- the current
IOManager
.
-
getBroadcastVariableManager
public BroadcastVariableManager getBroadcastVariableManager()
- Specified by:
getBroadcastVariableManager
in interfaceEnvironment
-
getTaskStateManager
public TaskStateManager getTaskStateManager()
- Specified by:
getTaskStateManager
in interfaceEnvironment
-
getGlobalAggregateManager
public GlobalAggregateManager getGlobalAggregateManager()
- Specified by:
getGlobalAggregateManager
in interfaceEnvironment
-
getAccumulatorRegistry
public AccumulatorRegistry getAccumulatorRegistry()
Description copied from interface:Environment
Return the registry for accumulators which are periodically sent to the job manager.- Specified by:
getAccumulatorRegistry
in interfaceEnvironment
- Returns:
- the registry
-
getTaskKvStateRegistry
public TaskKvStateRegistry getTaskKvStateRegistry()
Description copied from interface:Environment
Returns the registry forInternalKvState
instances.- Specified by:
getTaskKvStateRegistry
in interfaceEnvironment
- Returns:
- KvState registry
-
getInputSplitProvider
public InputSplitProvider getInputSplitProvider()
Description copied from interface:Environment
Returns the input split provider assigned to this environment.- Specified by:
getInputSplitProvider
in interfaceEnvironment
- Returns:
- The input split provider or
null
if no such provider has been assigned to this environment.
-
getDistributedCacheEntries
public Map<String,Future<Path>> getDistributedCacheEntries()
- Specified by:
getDistributedCacheEntries
in interfaceEnvironment
-
getWriter
public ResultPartitionWriter getWriter(int index)
- Specified by:
getWriter
in interfaceEnvironment
-
getAllWriters
public ResultPartitionWriter[] getAllWriters()
- Specified by:
getAllWriters
in interfaceEnvironment
-
getInputGate
public IndexedInputGate getInputGate(int index)
- Specified by:
getInputGate
in interfaceEnvironment
-
getAllInputGates
public IndexedInputGate[] getAllInputGates()
- Specified by:
getAllInputGates
in interfaceEnvironment
-
getTaskEventDispatcher
public TaskEventDispatcher getTaskEventDispatcher()
- Specified by:
getTaskEventDispatcher
in interfaceEnvironment
-
getExternalResourceInfoProvider
public ExternalResourceInfoProvider getExternalResourceInfoProvider()
Description copied from interface:Environment
Get theExternalResourceInfoProvider
which contains infos of available external resources.- Specified by:
getExternalResourceInfoProvider
in interfaceEnvironment
- Returns:
ExternalResourceInfoProvider
which contains infos of available external resources
-
getTaskManagerActions
public TaskManagerActions getTaskManagerActions()
- Specified by:
getTaskManagerActions
in interfaceEnvironment
-
acknowledgeCheckpoint
public void acknowledgeCheckpoint(long checkpointId, CheckpointMetrics checkpointMetrics)
Description copied from interface:Environment
Confirms that the invokable has successfully completed all steps it needed to for the checkpoint with the give checkpoint-ID. This method does not include any state in the checkpoint.- Specified by:
acknowledgeCheckpoint
in interfaceEnvironment
- Parameters:
checkpointId
- ID of this checkpointcheckpointMetrics
- metrics for this checkpoint
-
acknowledgeCheckpoint
public void acknowledgeCheckpoint(long checkpointId, CheckpointMetrics checkpointMetrics, TaskStateSnapshot checkpointStateHandles)
Description copied from interface:Environment
Confirms that the invokable has successfully completed all required steps for the checkpoint with the give checkpoint-ID. This method does include the given state in the checkpoint.- Specified by:
acknowledgeCheckpoint
in interfaceEnvironment
- Parameters:
checkpointId
- ID of this checkpointcheckpointMetrics
- metrics for this checkpointcheckpointStateHandles
- All state handles for the checkpointed state
-
declineCheckpoint
public void declineCheckpoint(long checkpointId, CheckpointException checkpointException)
Description copied from interface:Environment
Declines a checkpoint. This tells the checkpoint coordinator that this task will not be able to successfully complete a certain checkpoint.- Specified by:
declineCheckpoint
in interfaceEnvironment
- Parameters:
checkpointId
- The ID of the declined checkpoint.checkpointException
- The exception why the checkpoint was declined.
-
getOperatorCoordinatorEventGateway
public TaskOperatorEventGateway getOperatorCoordinatorEventGateway()
Description copied from interface:Environment
Gets the gateway through which operators can send events to the operator coordinators.- Specified by:
getOperatorCoordinatorEventGateway
in interfaceEnvironment
-
failExternally
public void failExternally(Throwable cause)
Description copied from interface:Environment
Marks task execution failed for an external reason (a reason other than the task code itself throwing an exception). If the task is already in a terminal state (such as FINISHED, CANCELED, FAILED), or if the task is already canceling this does nothing. Otherwise it sets the state to FAILED, and, if the invokable code is running, starts an asynchronous thread that aborts that code.This method never blocks.
- Specified by:
failExternally
in interfaceEnvironment
-
setMainMailboxExecutor
public void setMainMailboxExecutor(MailboxExecutor mainMailboxExecutor)
- Specified by:
setMainMailboxExecutor
in interfaceEnvironment
-
getMainMailboxExecutor
public MailboxExecutor getMainMailboxExecutor()
- Specified by:
getMainMailboxExecutor
in interfaceEnvironment
-
setAsyncOperationsThreadPool
public void setAsyncOperationsThreadPool(ExecutorService executorService)
- Specified by:
setAsyncOperationsThreadPool
in interfaceEnvironment
-
getAsyncOperationsThreadPool
public ExecutorService getAsyncOperationsThreadPool()
- Specified by:
getAsyncOperationsThreadPool
in interfaceEnvironment
-
setCheckpointStorageAccess
public void setCheckpointStorageAccess(CheckpointStorageAccess checkpointStorageAccess)
- Specified by:
setCheckpointStorageAccess
in interfaceEnvironment
-
getCheckpointStorageAccess
public CheckpointStorageAccess getCheckpointStorageAccess()
- Specified by:
getCheckpointStorageAccess
in interfaceEnvironment
-
getChannelStateExecutorFactory
public ChannelStateWriteRequestExecutorFactory getChannelStateExecutorFactory()
- Specified by:
getChannelStateExecutorFactory
in interfaceEnvironment
-
-