use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestMultipleHostsRequest method testMultipleHostsRequest.
@Test
public void testMultipleHostsRequest() throws Throwable {
String task1Name = "task1";
switch(OperatingSystem.getOperatingSystem()) {
case windows:
// set system Property for executable path
System.setProperty(executablePathPropertyName, new File(executablePathWindows.toURI()).getAbsolutePath());
break;
case unix:
SchedulerTHelper.setExecutable(new File(executablePath.toURI()).getAbsolutePath());
// set system Property for executable path
System.setProperty(executablePathPropertyName, new File(executablePath.toURI()).getAbsolutePath());
break;
default:
throw new IllegalStateException("Unsupported operating system");
}
// test submission and event reception
TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
JobId id = schedulerHelper.submitJob(job);
schedulerHelper.addExtraNodes(3);
log("Job submitted, id " + id.toString());
log("Waiting for jobSubmitted Event");
JobState receivedState = schedulerHelper.waitForEventJobSubmitted(id);
assertEquals(receivedState.getId(), id);
log("Waiting for job running");
JobInfo jInfo = schedulerHelper.waitForEventJobRunning(id);
assertEquals(jInfo.getJobId(), id);
assertEquals(JobStatus.RUNNING, jInfo.getStatus());
schedulerHelper.waitForEventTaskRunning(id, task1Name);
TaskInfo tInfo = schedulerHelper.waitForEventTaskFinished(id, task1Name);
log(schedulerHelper.getSchedulerInterface().getTaskResult(id, "task1").getOutput().getAllLogs(false));
assertEquals(TaskStatus.FINISHED, tInfo.getStatus());
schedulerHelper.waitForEventJobFinished(id);
JobResult res = schedulerHelper.getJobResult(id);
// check that there is one exception in results
assertTrue(res.getExceptionResults().isEmpty());
// remove job
schedulerHelper.removeJob(id);
schedulerHelper.waitForEventJobRemoved(id);
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestJobSchedulingStarvationAndPriority method computeMinMaxStartingTime.
/**
* Computes min start time and max start time for all tasks which match a given pattern
* If a task in the set did not start, then the set max will be Long.MAX_VALUE
*/
Pair<Long, Long> computeMinMaxStartingTime(Scheduler scheduler, JobId jobId, String taskNameFilter) throws Exception {
long min = Long.MAX_VALUE;
long max = -1;
for (TaskState state : scheduler.getJobState(jobId).getTasks()) {
if (state.getName().matches(taskNameFilter)) {
long startTime = state.getStartTime() > -1 ? state.getStartTime() : Long.MAX_VALUE;
min = Math.min(min, startTime);
max = Math.max(max, startTime);
}
}
return new ImmutablePair<>(min, max);
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class SchedulerFrontend method restartAllInErrorTasks.
@Override
public boolean restartAllInErrorTasks(String jobId) throws NotConnectedException, UnknownJobException, PermissionException {
final JobId jobIdObject = JobIdImpl.makeJobId(jobId);
frontendState.checkPermissions("restartAllInErrorTasks", frontendState.getIdentifiedJob(jobIdObject), YOU_DO_NOT_HAVE_PERMISSION_TO_RESTART_IN_ERROR_TASKS_IN_THIS_JOB);
return schedulingService.restartAllInErrorTasks(jobIdObject);
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class SchedulerFrontend method getTaskServerLogs.
@Override
@ImmediateService
public String getTaskServerLogs(String jobId, String taskName) throws UnknownJobException, UnknownTaskException, NotConnectedException, PermissionException {
JobId id = JobIdImpl.makeJobId(jobId);
frontendState.checkPermissions("getTaskServerLogs", frontendState.getIdentifiedJob(id), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_LOGS_OF_THIS_JOB);
for (TaskId taskId : frontendState.getJobTasks(id)) {
if (taskId.getReadableName().equals(taskName)) {
return ServerJobAndTaskLogs.getTaskLog(taskId);
}
}
throw new UnknownTaskException("Unknown task " + taskName + " in job " + jobId);
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class SchedulerFrontend method submit.
/**
* {@inheritDoc}
*/
@Override
@ImmediateService
public JobId submit(Job userJob) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException {
try {
if (logger.isDebugEnabled()) {
logger.debug("New job submission requested : " + userJob.getName());
}
// check if the scheduler is stopped
if (!schedulingService.isSubmitPossible()) {
String msg = "Scheduler is stopped, cannot submit job";
logger.info(msg);
throw new SubmissionClosedException(msg);
}
UserIdentificationImpl ident = frontendState.checkPermission("submit", YOU_DO_NOT_HAVE_PERMISSION_TO_SUBMIT_A_JOB);
InternalJob job = frontendState.createJob(userJob, ident);
schedulingService.submitJob(job);
frontendState.jobSubmitted(job, ident);
return job.getId();
} catch (Exception e) {
logger.warn("Error when submitting job.", e);
throw e;
}
}
Aggregations