Search in sources :

Example 1 with JobCommand

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()));
}
Also used : TestPlanConfig(alluxio.job.TestPlanConfig) JobCommand(alluxio.grpc.JobCommand) JobConfig(alluxio.job.JobConfig) Test(org.junit.Test)

Example 2 with JobCommand

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());
}
Also used : JobCommand(alluxio.grpc.JobCommand) Test(org.junit.Test)

Example 3 with JobCommand

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));
    }
}
Also used : TaskInfo(alluxio.job.wire.TaskInfo) JobInfo(alluxio.grpc.JobInfo) JobCommand(alluxio.grpc.JobCommand) JobWorkerHealth(alluxio.job.wire.JobWorkerHealth) IOException(java.io.IOException) AlluxioException(alluxio.exception.AlluxioException)

Aggregations

JobCommand (alluxio.grpc.JobCommand)3 Test (org.junit.Test)2 AlluxioException (alluxio.exception.AlluxioException)1 JobInfo (alluxio.grpc.JobInfo)1 JobConfig (alluxio.job.JobConfig)1 TestPlanConfig (alluxio.job.TestPlanConfig)1 JobWorkerHealth (alluxio.job.wire.JobWorkerHealth)1 TaskInfo (alluxio.job.wire.TaskInfo)1 IOException (java.io.IOException)1