use of org.apache.flink.runtime.taskmanager.Task in project flink by apache.
the class TaskExecutor method stopTask.
@RpcMethod
public Acknowledge stopTask(ExecutionAttemptID executionAttemptID) throws TaskException {
final Task task = taskSlotTable.getTask(executionAttemptID);
if (task != null) {
try {
task.stopExecution();
return Acknowledge.get();
} catch (Throwable t) {
throw new TaskException("Cannot stop task for execution " + executionAttemptID + '.', t);
}
} else {
final String message = "Cannot find task to stop for execution " + executionAttemptID + '.';
log.debug(message);
throw new TaskException(message);
}
}
use of org.apache.flink.runtime.taskmanager.Task in project flink by apache.
the class TaskExecutor method triggerCheckpoint.
// ----------------------------------------------------------------------
// Checkpointing RPCs
// ----------------------------------------------------------------------
@RpcMethod
public Acknowledge triggerCheckpoint(ExecutionAttemptID executionAttemptID, long checkpointId, long checkpointTimestamp, CheckpointOptions checkpointOptions) throws CheckpointException {
log.debug("Trigger checkpoint {}@{} for {}.", checkpointId, checkpointTimestamp, executionAttemptID);
final Task task = taskSlotTable.getTask(executionAttemptID);
if (task != null) {
task.triggerCheckpointBarrier(checkpointId, checkpointTimestamp, checkpointOptions);
return Acknowledge.get();
} else {
final String message = "TaskManager received a checkpoint request for unknown task " + executionAttemptID + '.';
log.debug(message);
throw new CheckpointException(message);
}
}
use of org.apache.flink.runtime.taskmanager.Task in project flink by apache.
the class TaskExecutor method cancelTask.
@RpcMethod
public Acknowledge cancelTask(ExecutionAttemptID executionAttemptID) throws TaskException {
final Task task = taskSlotTable.getTask(executionAttemptID);
if (task != null) {
try {
task.cancelExecution();
return Acknowledge.get();
} catch (Throwable t) {
throw new TaskException("Cannot cancel task for execution " + executionAttemptID + '.', t);
}
} else {
final String message = "Cannot find task to stop for execution " + executionAttemptID + '.';
log.debug(message);
throw new TaskException(message);
}
}
use of org.apache.flink.runtime.taskmanager.Task in project flink by apache.
the class StreamTaskTest method testCancellationNotBlockedOnLock.
@Test
public void testCancellationNotBlockedOnLock() throws Exception {
SYNC_LATCH = new OneShotLatch();
StreamConfig cfg = new StreamConfig(new Configuration());
Task task = createTask(CancelLockingTask.class, cfg, new Configuration());
// start the task and wait until it runs
// execution state RUNNING is not enough, we need to wait until the stream task's run() method
// is entered
task.startTaskThread();
SYNC_LATCH.await();
// cancel the execution - this should lead to smooth shutdown
task.cancelExecution();
task.getExecutingThread().join();
assertEquals(ExecutionState.CANCELED, task.getExecutionState());
}
use of org.apache.flink.runtime.taskmanager.Task in project flink by apache.
the class StreamTaskTest method createTask.
public static Task createTask(Class<? extends AbstractInvokable> invokable, StreamConfig taskConfig, Configuration taskManagerConfig) throws Exception {
LibraryCacheManager libCache = mock(LibraryCacheManager.class);
when(libCache.getClassLoader(any(JobID.class))).thenReturn(StreamTaskTest.class.getClassLoader());
ResultPartitionManager partitionManager = mock(ResultPartitionManager.class);
ResultPartitionConsumableNotifier consumableNotifier = mock(ResultPartitionConsumableNotifier.class);
PartitionProducerStateChecker partitionProducerStateChecker = mock(PartitionProducerStateChecker.class);
Executor executor = mock(Executor.class);
NetworkEnvironment network = mock(NetworkEnvironment.class);
when(network.getResultPartitionManager()).thenReturn(partitionManager);
when(network.getDefaultIOMode()).thenReturn(IOManager.IOMode.SYNC);
when(network.createKvStateTaskRegistry(any(JobID.class), any(JobVertexID.class))).thenReturn(mock(TaskKvStateRegistry.class));
JobInformation jobInformation = new JobInformation(new JobID(), "Job Name", new SerializedValue<>(new ExecutionConfig()), new Configuration(), Collections.<BlobKey>emptyList(), Collections.<URL>emptyList());
TaskInformation taskInformation = new TaskInformation(new JobVertexID(), "Test Task", 1, 1, invokable.getName(), taskConfig.getConfiguration());
return new Task(jobInformation, taskInformation, new ExecutionAttemptID(), new AllocationID(), 0, 0, Collections.<ResultPartitionDeploymentDescriptor>emptyList(), Collections.<InputGateDeploymentDescriptor>emptyList(), 0, new TaskStateHandles(), mock(MemoryManager.class), mock(IOManager.class), network, mock(BroadcastVariableManager.class), mock(TaskManagerActions.class), mock(InputSplitProvider.class), mock(CheckpointResponder.class), libCache, mock(FileCache.class), new TestingTaskManagerRuntimeInfo(taskManagerConfig, new String[] { System.getProperty("java.io.tmpdir") }), new UnregisteredTaskMetricsGroup(), consumableNotifier, partitionProducerStateChecker, executor);
}
Aggregations