use of alluxio.job.wire.TaskInfo in project alluxio by Alluxio.
the class PlanInfo method addTask.
/**
* Registers a task.
*
* @param taskId the task id
* @param workerInfo the worker info
* @param args the arguments
*/
public void addTask(long taskId, WorkerInfo workerInfo, Object args) {
TaskInfo oldValue = mTaskIdToInfo.putIfAbsent(taskId, new TaskInfo(mId, taskId, Status.CREATED, workerInfo.getAddress(), args));
// the task is expected to not exist in the map.
Preconditions.checkState(oldValue == null, String.format("JobId %d cannot add duplicate taskId %d", mId, taskId));
}
use of alluxio.job.wire.TaskInfo in project alluxio by Alluxio.
the class CommandHandlingExecutor method heartbeat.
@Override
public void heartbeat() {
mHealthReporter.compute();
if (mHealthReporter.isHealthy()) {
mTaskExecutorManager.unthrottle();
} else {
mTaskExecutorManager.throttle();
}
JobWorkerHealth jobWorkerHealth = new JobWorkerHealth(JobWorkerIdRegistry.getWorkerId(), mHealthReporter.getCpuLoadAverage(), mTaskExecutorManager.getTaskExecutorPoolSize(), mTaskExecutorManager.getNumActiveTasks(), mTaskExecutorManager.unfinishedTasks(), mWorkerNetAddress.getHost());
List<TaskInfo> taskStatusList = mTaskExecutorManager.getAndClearTaskUpdates();
List<alluxio.grpc.JobCommand> commands;
List<JobInfo> taskProtoList = taskStatusList.stream().map(TaskInfo::toProto).collect(Collectors.toList());
try {
commands = mMasterClient.heartbeat(jobWorkerHealth, taskProtoList);
} catch (AlluxioException | IOException e) {
// Restore the task updates so that they can be accessed in the next heartbeat.
mTaskExecutorManager.restoreTaskUpdates(taskStatusList);
// TODO(yupeng) better error handling
LOG.error("Failed to heartbeat", e);
return;
}
for (JobCommand command : commands) {
mCommandHandlingService.execute(new CommandHandler(command));
}
}
use of alluxio.job.wire.TaskInfo in project alluxio by Alluxio.
the class TaskExecutorManager method notifyTaskCompletion.
/**
* Notifies the completion of the task.
*
* @param jobId the job id
* @param taskId the task id
* @param result the task execution result
*/
public synchronized void notifyTaskCompletion(long jobId, long taskId, Serializable result) {
Pair<Long, Long> id = new Pair<>(jobId, taskId);
TaskInfo taskInfo = mUnfinishedTasks.get(id);
taskInfo.setStatus(Status.COMPLETED);
taskInfo.setResult(result);
finishTask(id);
LOG.info("Task {} for job {} completed.", taskId, jobId);
}
use of alluxio.job.wire.TaskInfo in project alluxio by Alluxio.
the class TaskExecutorManager method notifyTaskRunning.
/**
* Noitfy the start of the task.
*
* @param jobId the job id
* @param taskId the task id
*/
public synchronized void notifyTaskRunning(long jobId, long taskId) {
Pair<Long, Long> id = new Pair<>(jobId, taskId);
TaskInfo taskInfo = mUnfinishedTasks.get(id);
taskInfo.setStatus(Status.RUNNING);
LOG.info("Task {} for job {} started", taskId, jobId);
}
use of alluxio.job.wire.TaskInfo in project alluxio by Alluxio.
the class TaskExecutorManager method notifyTaskFailure.
/**
* Notifies the failure of the task.
*
* @param jobId the job id
* @param taskId the task id
* @param t the thrown exception
*/
public synchronized void notifyTaskFailure(long jobId, long taskId, Throwable t) {
Pair<Long, Long> id = new Pair<>(jobId, taskId);
TaskInfo taskInfo = mUnfinishedTasks.get(id);
taskInfo.setStatus(Status.FAILED);
String errorMessage;
if (ServerConfiguration.getBoolean(PropertyKey.DEBUG)) {
errorMessage = Throwables.getStackTraceAsString(t);
} else {
errorMessage = t.getMessage();
}
taskInfo.setErrorType(ErrorUtils.getErrorType(t));
if (errorMessage != null) {
taskInfo.setErrorMessage(errorMessage);
}
finishTask(id);
LOG.info("Task {} for job {} failed: {}", taskId, jobId, errorMessage);
SAMPLING_LOGGER.info("Stack trace for taskId: {} jobId: {} : {}", taskId, jobId, Throwables.getStackTraceAsString(t));
}
Aggregations