Search in sources :

Example 11 with SleepJobConfig

use of alluxio.job.SleepJobConfig in project alluxio by Alluxio.

the class JobMasterTest method cancel.

@Test
public void cancel() throws Exception {
    mockStatic(PlanCoordinator.class);
    PlanCoordinator coordinator = PowerMockito.mock(PlanCoordinator.class);
    when(PlanCoordinator.create(any(CommandManager.class), any(JobServerContext.class), anyList(), anyLong(), any(JobConfig.class), any(Consumer.class))).thenReturn(coordinator);
    SleepJobConfig config = new SleepJobConfig(10000);
    long jobId = mJobMaster.run(config);
    mJobMaster.cancel(jobId);
    verify(coordinator).cancel();
}
Also used : JobServerContext(alluxio.job.JobServerContext) CommandManager(alluxio.master.job.command.CommandManager) Consumer(java.util.function.Consumer) SleepJobConfig(alluxio.job.SleepJobConfig) PlanCoordinator(alluxio.master.job.plan.PlanCoordinator) SleepJobConfig(alluxio.job.SleepJobConfig) JobConfig(alluxio.job.JobConfig) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 12 with SleepJobConfig

use of alluxio.job.SleepJobConfig in project alluxio by Alluxio.

the class PlanTrackerTest method addJob.

private long addJob(PlanTracker tracker, int sleepTimeMs) throws Exception {
    long jobId = mJobIdGenerator.getNewJobId();
    tracker.run(new SleepJobConfig(sleepTimeMs), mCommandManager, mMockJobServerContext, mWorkers, jobId);
    return jobId;
}
Also used : SleepJobConfig(alluxio.job.SleepJobConfig)

Example 13 with SleepJobConfig

use of alluxio.job.SleepJobConfig in project alluxio by Alluxio.

the class TaskExecutorTest method runFailure.

@Test
public void runFailure() throws Exception {
    long jobId = 1;
    long taskId = 2;
    JobConfig jobConfig = new SleepJobConfig(10);
    Serializable taskArgs = Lists.newArrayList(1);
    RunTaskContext context = mock(RunTaskContext.class);
    @SuppressWarnings("unchecked") PlanDefinition<JobConfig, Serializable, Serializable> planDefinition = mock(PlanDefinition.class);
    when(mRegistry.getJobDefinition(eq(jobConfig))).thenReturn(planDefinition);
    when(planDefinition.runTask(eq(jobConfig), any(Serializable.class), any(RunTaskContext.class))).thenThrow(new UnsupportedOperationException("failure"));
    RunTaskCommand command = RunTaskCommand.newBuilder().setJobConfig(ByteString.copyFrom(SerializationUtils.serialize(jobConfig))).setTaskArgs(ByteString.copyFrom(SerializationUtils.serialize(taskArgs))).build();
    TaskExecutor executor = new TaskExecutor(jobId, taskId, command, context, mTaskExecutorManager);
    executor.run();
    verify(mTaskExecutorManager).notifyTaskFailure(eq(jobId), eq(taskId), any());
}
Also used : RunTaskCommand(alluxio.grpc.RunTaskCommand) Serializable(java.io.Serializable) RunTaskContext(alluxio.job.RunTaskContext) SleepJobConfig(alluxio.job.SleepJobConfig) JobConfig(alluxio.job.JobConfig) SleepJobConfig(alluxio.job.SleepJobConfig) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 14 with SleepJobConfig

use of alluxio.job.SleepJobConfig in project alluxio by Alluxio.

the class JobMasterIntegrationTest method restartMasterAndReregisterWorker.

@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.JOB_MASTER_LOST_WORKER_INTERVAL, "10000000" })
public void restartMasterAndReregisterWorker() throws Exception {
    long jobId = mJobMaster.run(new SleepJobConfig(1));
    JobTestUtils.waitForJobStatus(mJobMaster, jobId, Status.COMPLETED);
    mJobMaster.stop();
    mJobMaster.start(true);
    CommonUtils.waitFor("Worker to register with restarted job master", () -> !mJobMaster.getWorkerInfoList().isEmpty(), WaitForOptions.defaults().setTimeoutMs(10 * Constants.SECOND_MS));
    final long firstWorkerId = mJobMaster.getWorkerInfoList().get(0).getId();
    mLocalAlluxioJobCluster.restartWorker();
    CommonUtils.waitFor("Restarted worker to register with job master", () -> {
        List<WorkerInfo> workerInfo = mJobMaster.getWorkerInfoList();
        return !workerInfo.isEmpty() && workerInfo.get(0).getId() != firstWorkerId;
    }, WaitForOptions.defaults().setTimeoutMs(10 * Constants.SECOND_MS));
    // The restarted worker should replace the original worker since they have the same address.
    assertEquals(1, mJobMaster.getWorkerInfoList().size());
}
Also used : WorkerInfo(alluxio.wire.WorkerInfo) SleepJobConfig(alluxio.job.SleepJobConfig) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 15 with SleepJobConfig

use of alluxio.job.SleepJobConfig in project alluxio by Alluxio.

the class CompositeIntegrationTest method waitSequential.

@Test
public void waitSequential() throws Exception {
    CompositeConfig config = new CompositeConfig(Lists.newArrayList(new SleepJobConfig(1000000), new SleepJobConfig(1)), true);
    long jobId = mJobMaster.run(config);
    JobInfo status = mJobMaster.getStatus(jobId);
    assertEquals(Status.RUNNING, status.getStatus());
    assertEquals(1, status.getChildren().size());
}
Also used : JobInfo(alluxio.job.wire.JobInfo) SleepJobConfig(alluxio.job.SleepJobConfig) JobIntegrationTest(alluxio.job.JobIntegrationTest) Test(org.junit.Test)

Aggregations

SleepJobConfig (alluxio.job.SleepJobConfig)17 Test (org.junit.Test)16 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)6 JobInfo (alluxio.job.wire.JobInfo)5 JobConfig (alluxio.job.JobConfig)4 JobIntegrationTest (alluxio.job.JobIntegrationTest)3 JobServerContext (alluxio.job.JobServerContext)2 CompositeConfig (alluxio.job.workflow.composite.CompositeConfig)2 CommandManager (alluxio.master.job.command.CommandManager)2 WorkerInfo (alluxio.wire.WorkerInfo)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 ResourceExhaustedException (alluxio.exception.status.ResourceExhaustedException)1 RunTaskCommand (alluxio.grpc.RunTaskCommand)1 RunTaskContext (alluxio.job.RunTaskContext)1 TestPlanConfig (alluxio.job.TestPlanConfig)1 PlanConfig (alluxio.job.plan.PlanConfig)1 PlanInfo (alluxio.job.plan.meta.PlanInfo)1 Status (alluxio.job.wire.Status)1 WorkflowInfo (alluxio.job.wire.WorkflowInfo)1 JobMaster (alluxio.master.job.JobMaster)1