use of alluxio.grpc.JobInfo 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));
}
}
Aggregations