use of alluxio.grpc.JobCommand in project alluxio by Alluxio.
the class CommandManagerTest method submitRunTaskCommand.
@Test
public void submitRunTaskCommand() throws Exception {
long jobId = 0L;
int taskId = 1;
JobConfig jobConfig = new TestPlanConfig("/test");
long workerId = 2L;
List<Integer> args = Lists.newArrayList(1);
mManager.submitRunTaskCommand(jobId, taskId, jobConfig, args, workerId);
List<JobCommand> commands = mManager.pollAllPendingCommands(workerId);
Assert.assertEquals(1, commands.size());
JobCommand command = commands.get(0);
Assert.assertEquals(jobId, command.getRunTaskCommand().getJobId());
Assert.assertEquals(taskId, command.getRunTaskCommand().getTaskId());
Assert.assertEquals(jobConfig, SerializationUtils.deserialize(command.getRunTaskCommand().getJobConfig().toByteArray()));
Assert.assertEquals(args, SerializationUtils.deserialize(command.getRunTaskCommand().getTaskArgs().toByteArray()));
}
use of alluxio.grpc.JobCommand in project alluxio by Alluxio.
the class CommandManagerTest method submitCancelTaskCommand.
@Test
public void submitCancelTaskCommand() {
long jobId = 0L;
int taskId = 1;
long workerId = 2L;
mManager.submitCancelTaskCommand(jobId, taskId, workerId);
List<JobCommand> commands = mManager.pollAllPendingCommands(workerId);
Assert.assertEquals(1, commands.size());
JobCommand command = commands.get(0);
Assert.assertEquals(jobId, command.getCancelTaskCommand().getJobId());
Assert.assertEquals(taskId, command.getCancelTaskCommand().getTaskId());
}
use of alluxio.grpc.JobCommand 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