use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class RunningTaskRecoveryWithDownNodeTest method action.
@Test
public void action() throws Throwable {
this.createNodes();
JobId jobid = this.submitJob();
this.waitForAllTasksToRun(jobid);
this.killSchedulerAndNodes();
long timeForSchedulerToBeUp = this.recordSchedulerRestartTime();
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
JobState jobState = scheduler.getJobState(jobid);
this.checkTasks(jobState);
this.waitForJobToFinish(jobid);
this.checkJobResult(jobid, scheduler);
this.checkSchedulerStateRecoveryDoesNotWaitTaskPingAttemptTimesFrequency(timeForSchedulerToBeUp);
}
use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class RunningTaskRecoveryWithRecoveredNodeTestBase method action.
@Test
public void action() throws Throwable {
nodes = schedulerHelper.createRMNodeStarterNodes(RunningTaskRecoveryWithForkedTaskExecutorTest.class.getSimpleName(), NB_NODES);
JobId jobid = schedulerHelper.submitJob(new File(JOB_DESCRIPTOR.toURI()).getAbsolutePath());
schedulerHelper.waitForEventJobRunning(jobid);
TaskState taskState = schedulerHelper.getSchedulerInterface().getJobState(jobid).getTasks().get(0);
schedulerHelper.waitForEventTaskRunning(taskState.getJobId(), taskState.getName());
taskState = schedulerHelper.getSchedulerInterface().getJobState(jobid).getTasks().get(0);
String firstExecutionHostInfo = taskState.getTaskInfo().getExecutionHostName();
// wait and restart scheduler
Thread.sleep(RESTART_SCHEDULER_INTER_TIME_IN_MILLISECONDS);
TestScheduler.kill();
Thread.sleep(RESTART_SCHEDULER_INTER_TIME_IN_MILLISECONDS);
schedulerHelper = new SchedulerTHelper(false, new File(getSchedulerReStartConfigurationURL().toURI()).getAbsolutePath(), new File(RM_CONFIGURATION_RESTART.toURI()).getAbsolutePath(), null, false);
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
TestListenJobLogs.TestAppender appender = new TestListenJobLogs.TestAppender(LOGGER_NAME);
String loggerName = Log4JTaskLogs.JOB_LOGGER_PREFIX + jobid;
logForwardingService.removeAllAppenders(LOGGER_NAME);
logForwardingService.addAppender(loggerName, appender);
scheduler.listenJobLogs(jobid, logForwardingService.getAppenderProvider());
System.out.println("Number of nodes: " + schedulerHelper.getResourceManager().getState().getAllNodes().size());
for (String freeNodeUrl : schedulerHelper.getResourceManager().getState().getFreeNodes()) {
// previous executing node should not be free when the nodes are added back to the rm
Assert.assertFalse(firstExecutionHostInfo.contains(freeNodeUrl));
}
// we should have just one running task
JobState jobState = scheduler.getJobState(jobid);
Assert.assertEquals(0, jobState.getNumberOfPendingTasks());
Assert.assertEquals(1, jobState.getNumberOfRunningTasks());
taskState = jobState.getTasks().get(0);
Assert.assertEquals(firstExecutionHostInfo, taskState.getTaskInfo().getExecutionHostName());
appender.waitForLoggingEvent(LOG_EVENT_TIMEOUT, TASK_LOG_OUTPUT_STARTING_STRING + MAXIMUM_STEP_IN_TASK_LOOP);
schedulerHelper.waitForEventJobFinished(jobid);
TaskResult taskResult = scheduler.getJobResult(jobid).getResult(TASK_NAME);
Assert.assertFalse(taskResult.hadException());
Assert.assertEquals(OK_TASK_RESULT_VALUE, taskResult.value());
String logs = taskResult.getOutput().getStdoutLogs();
for (int i = 0; i < MAXIMUM_STEP_IN_TASK_LOOP; i++) {
Assert.assertTrue(logs.contains(TASK_LOG_OUTPUT_STARTING_STRING + i));
}
}
use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class TestOperationsWhenUnlinked method checkJobResult.
private void checkJobResult(Scheduler scheduler, JobId jobId, int expectedTasksNumber) throws Throwable {
JobResult jobResult = scheduler.getJobResult(jobId);
assertEquals("Unexpected number of task results", expectedTasksNumber, jobResult.getAllResults().size());
for (TaskResult taskResult : jobResult.getAllResults().values()) {
log("Task " + taskResult.getTaskId());
if (taskResult.getException() != null) {
fail("Unexpected task result exception:" + taskResult.getException());
}
assertEquals(taskResult.value(), "Nothing");
}
}
use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class TestOperationsWhenUnlinked method testSubmitAndPause.
@Test
public void testSubmitAndPause() throws Throwable {
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
log("Submitting job");
JobId jobId1 = scheduler.submit(createJob());
log("Killing RM");
rmHelper.killRM();
log("Waiting RM_DOWN event");
schedulerHelper.waitForEventSchedulerState(SchedulerEvent.RM_DOWN, EVENT_TIMEOUT);
log("Submitting new job");
JobId jobId2 = scheduler.submit(createJob());
if (!scheduler.pauseJob(jobId2)) {
fail("Failed to pause job " + jobId2);
}
if (!scheduler.resumeJob(jobId2)) {
fail("Failed to resume job " + jobId2);
}
log("Creating new RM");
rmHelper = new RMTHelper();
rmHelper.startRM(null, pnp_port);
ResourceManager rm = rmHelper.getResourceManager();
testNode = RMTHelper.createNode("test-node");
String nodeUrl = testNode.getNode().getNodeInformation().getURL();
rm.addNode(nodeUrl);
rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
log("Linking new RM");
if (!scheduler.linkResourceManager(rmHelper.getLocalUrl())) {
fail("Failed to link another RM");
}
log("Waiting when jobs finish");
schedulerHelper.waitForEventJobFinished(jobId1, EVENT_TIMEOUT);
schedulerHelper.waitForEventJobFinished(jobId2, EVENT_TIMEOUT);
checkJobResult(scheduler, jobId1, 1);
checkJobResult(scheduler, jobId2, 1);
}
use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class TestOperationsWhenUnlinked method createConfigAndStart.
@Before
public void createConfigAndStart() throws Exception {
if (TestScheduler.isStarted()) {
SchedulerTHelper.log("Killing previous scheduler.");
TestScheduler.kill();
}
// set property SCHEDULER_RMCONNECTION_AUTO_CONNECT to false so that RM failure is detected more fast
File configurationFile = new File(SchedulerTestConfiguration.SCHEDULER_DEFAULT_CONFIGURATION.toURI());
Properties properties = new Properties();
properties.load(new FileInputStream(configurationFile));
config = tmpFolder.newFile("scheduler_config.ini");
properties.put(PASchedulerProperties.SCHEDULER_RMCONNECTION_AUTO_CONNECT.getKey(), "false");
properties.store(new FileOutputStream(config), null);
rmHelper = new RMTHelper();
rmHelper.startRM(null, pnp_port);
schedulerHelper = new SchedulerTHelper(false, config.getAbsolutePath(), null, rmHelper.getLocalUrl());
}
Aggregations