use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.
the class NoVncSecuredTargetResolver method doResolve.
// package-protected for testing
InetSocketAddress doResolve(String sessionId, String jobId, String taskName) {
if (sessionId == null || jobId == null || taskName == null) {
LOGGER.warn("One of the web socket path parameter is missing (sessionId, jobId, taskName).");
return null;
}
Session session = SharedSessionStore.getInstance().get(sessionId);
if (session == null) {
LOGGER.warn("Unknown sessionId.");
return null;
}
SchedulerProxyUserInterface scheduler = session.getScheduler();
try {
TaskResult taskResult = scheduler.getTaskResult(jobId, taskName);
List<String> paRemoteConnectionLines = retrievePaRemoteConnectionLines(session, jobId, taskResult);
String taskId = retrieveTaskId(taskName, scheduler.getJobState(jobId));
return resolveVncTargetFromLogs(paRemoteConnectionLines, jobId, taskId);
} catch (NotConnectedException e) {
LOGGER.warn("Failed to connect to scheduler", e);
} catch (UnknownJobException e) {
LOGGER.warn("Job does not exist", e);
} catch (UnknownTaskException e) {
LOGGER.warn("Task does not exist", e);
} catch (PermissionException e) {
LOGGER.warn("Not allowed to access task", e);
}
return null;
}
use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.
the class AbstractRestFuncTestCase method createJob.
protected Job createJob(Class<?> clazz) throws Exception {
TaskFlowJob job = new TaskFlowJob();
job.setName(clazz.getSimpleName());
job.setPriority(JobPriority.NORMAL);
job.setOnTaskError(OnTaskError.CANCEL_JOB);
job.setDescription("Test " + clazz.getSimpleName());
job.setMaxNumberOfExecution(1);
JavaTask task = new JavaTask();
task.setName(getTaskNameForClass(clazz));
task.setExecutableClassName(clazz.getName());
task.setMaxNumberOfExecution(1);
task.setOnTaskError(OnTaskError.CANCEL_JOB);
String classpath = RestFuncTUtils.getClassPath(clazz);
ForkEnvironment forkEnvironment = new ForkEnvironment();
forkEnvironment.addAdditionalClasspath(classpath);
task.setForkEnvironment(forkEnvironment);
job.addTask(task);
return job;
}
use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.
the class AbstractRestFuncTestCase method createJobManyTasks.
protected Job createJobManyTasks(String jobName, Class<?>... clazzes) throws Exception {
TaskFlowJob job = new TaskFlowJob();
job.setName(jobName);
job.setPriority(JobPriority.NORMAL);
job.setDescription("Test " + jobName);
job.setMaxNumberOfExecution(1);
for (Class<?> clazz : clazzes) {
JavaTask task = new JavaTask();
task.setName(clazz.getSimpleName() + "Task");
task.setExecutableClassName(clazz.getName());
task.setMaxNumberOfExecution(1);
String classpath = RestFuncTUtils.getClassPath(clazz);
ForkEnvironment forkEnvironment = new ForkEnvironment();
forkEnvironment.addAdditionalClasspath(classpath);
task.setForkEnvironment(forkEnvironment);
job.addTask(task);
}
return job;
}
use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.
the class DozerMappingTest method createJobState.
private JobState createJobState() {
return new ClientJobState(new JobState() {
@Override
public void update(TaskInfo taskInfo) {
}
@Override
public void update(JobInfo jobInfo) {
}
@Override
public JobInfo getJobInfo() {
return new JobInfoImpl();
}
@Override
public ArrayList<TaskState> getTasks() {
return new ArrayList<>(getHMTasks().values());
}
@Override
public Map<TaskId, TaskState> getHMTasks() {
TaskId taskId = TaskIdImpl.createTaskId(new JobIdImpl(42, "job"), "remoteVisuTask", 1);
TaskState value = new ClientTaskState(new TaskState() {
@Override
public void update(TaskInfo taskInfo) {
}
@Override
public List<TaskState> getDependences() {
return null;
}
@Override
public TaskInfo getTaskInfo() {
TaskInfoImpl taskInfo = new TaskInfoImpl();
taskInfo.setTaskId(TaskIdImpl.createTaskId(new JobIdImpl(42, "job"), "remoteVisuTask", 1));
return taskInfo;
}
@Override
public int getMaxNumberOfExecutionOnFailure() {
return 0;
}
@Override
public TaskState replicate() throws Exception {
return null;
}
@Override
public int getIterationIndex() {
return 0;
}
@Override
public int getReplicationIndex() {
return 0;
}
});
return Collections.singletonMap(taskId, value);
}
@Override
public String getOwner() {
return null;
}
@Override
public JobType getType() {
return null;
}
});
}
use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.
the class SchedulerRestWorkflowFromCatalogExecutionTest method testWhenSubmittingAValidTemplateWithVariablesThenTheProvidedJobVariableIsUsed.
@Test
public void testWhenSubmittingAValidTemplateWithVariablesThenTheProvidedJobVariableIsUsed() throws Exception {
when(scheduler.submit(Matchers.<Job>any())).thenReturn(new JobIdImpl(99L, "job"));
ArgumentCaptor<Job> argumentCaptor = ArgumentCaptor.forClass(Job.class);
String workflowUrl = getBaseUriTestWorkflowsServer() + "/workflow";
JobIdData response = schedulerRest.submitFromUrl(sessionId, workflowUrl, getOneVariablePathSegment("var1", "value1"));
verify(scheduler).submit(argumentCaptor.capture());
Job interceptedJob = argumentCaptor.getValue();
Assert.assertEquals(1, interceptedJob.getVariables().size());
Assert.assertEquals("value1", interceptedJob.getVariables().get("var1").getValue());
Assert.assertEquals(99L, response.getId());
Assert.assertEquals("job", response.getReadableName());
}
Aggregations