use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.
the class Job2XMLTransformerTest method checkJobVariables.
@Test
public void checkJobVariables() throws Exception {
File xmlFile = tmpFolder.newFile();
Map<String, JobVariable> variablesMap = new HashMap<>();
JobVariable jobVar1 = new JobVariable("name1", "value1", "model1");
JobVariable jobVar2 = new JobVariable("name2", "value2", "model2", "description2", "group2", true, true);
variablesMap.put(jobVar1.getName(), jobVar1);
variablesMap.put(jobVar2.getName(), jobVar2);
TaskFlowJob job = new TaskFlowJob();
JavaTask defaultTask = new JavaTask();
defaultTask.setExecutableClassName("foo.Bar");
job.addTask(defaultTask);
job.setVariables(variablesMap);
new Job2XMLTransformer().job2xmlFile(job, xmlFile);
TaskFlowJob recreatedJob = (TaskFlowJob) (JobFactory.getFactory().createJob(xmlFile.getAbsolutePath()));
Map<String, JobVariable> resVariables = recreatedJob.getVariables();
assertEquals(2, resVariables.size());
assertEquals(jobVar1, resVariables.get("name1"));
assertEquals(jobVar2, resVariables.get("name2"));
}
use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.
the class DefaultModelJobValidatorServiceProviderTest method createJobWithSpelJobModelVariablesUnauthorizedType.
private TaskFlowJob createJobWithSpelJobModelVariablesUnauthorizedType() throws UserException {
TaskFlowJob job = new TaskFlowJob();
job.setVariables(ImmutableMap.of("var1", new JobVariable("var1", "value1", SPEL_LEFT + "T(java.lang.Runtime).getRuntime().exec('hostname').waitFor() instanceof T(Integer)" + SPEL_RIGHT)));
return job;
}
use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.
the class SchedulerClientTest method testJobSubmissionEventListener.
@Test(timeout = MAX_WAIT_TIME * 2)
public void testJobSubmissionEventListener() throws Exception {
ISchedulerClient client = clientInstance();
SchedulerEventListenerImpl listener = new SchedulerEventListenerImpl();
client.addEventListener(listener, true, SchedulerEvent.JOB_SUBMITTED, SchedulerEvent.USERS_UPDATE);
Job job = defaultJob();
Map<String, JobVariable> jobVariables = new LinkedHashMap<>();
jobVariables.put("MY_VAR", new JobVariable("MY_VAR", "MY_VALUE", "PA:NOT_EMPTY_STRING", "a test variable", "MY_GROUP", true, true));
job.setVariables(jobVariables);
JobId jobId = client.submit(job);
JobState submittedJob = listener.getSubmittedJob();
while (!submittedJob.getId().value().equals(jobId.value())) {
submittedJob = listener.getSubmittedJob();
}
UserIdentification userIdentification = listener.getLastUserUpdate();
assertTrue(userIdentification.getLastSubmitTime() != -1);
JobInfo jobInfo = client.getJobInfo(jobId.toString());
System.out.println("Variables = " + jobInfo.getVariables());
Map<String, JobVariable> stateJobVariables = jobInfo.getDetailedVariables();
assertEquals(jobVariables, stateJobVariables);
client.removeEventListener();
client.waitForJob(jobId, TimeUnit.SECONDS.toMillis(120));
}
use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.
the class TestJobAttributes method testJobAttribute.
@Test
public void testJobAttribute() throws Exception {
TaskFlowJob job = new TaskFlowJob();
job.setMaxNumberOfExecution(10);
job.setOnTaskError(OnTaskError.CANCEL_JOB);
job.setDescription("desc");
job.setProjectName("project");
job.setName("name");
job.setInputSpace("input");
job.setOutputSpace("output");
job.setGenericInformation(null);
job.setPriority(JobPriority.HIGHEST);
InternalJob jobData = defaultSubmitJob(job, DEFAULT_USER_NAME);
Assert.assertNotNull(jobData.getId());
Assert.assertEquals("name", jobData.getId().getReadableName());
jobData = loadInternalJob(true, jobData.getId());
Assert.assertNotNull(jobData.getId());
Assert.assertEquals("name", jobData.getId().getReadableName());
Assert.assertEquals(10, jobData.getMaxNumberOfExecution());
Assert.assertEquals(OnTaskError.CANCEL_JOB, jobData.getOnTaskErrorProperty().getValue());
Assert.assertEquals("name", jobData.getName());
Assert.assertEquals("desc", jobData.getDescription());
Assert.assertEquals("project", jobData.getProjectName());
Assert.assertEquals("input", jobData.getInputSpace());
Assert.assertEquals("output", jobData.getOutputSpace());
Assert.assertEquals(JobPriority.HIGHEST, jobData.getPriority());
Assert.assertNotNull(jobData.getGenericInformation());
Assert.assertTrue(jobData.getGenericInformation().isEmpty());
Map<String, JobVariable> jobDataVariables = jobData.getVariables();
Assert.assertNotNull(jobDataVariables);
Assert.assertTrue(jobDataVariables.isEmpty());
}
use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.
the class TestJobAttributes method testJobVariables.
@Test
public void testJobVariables() throws Exception {
TaskFlowJob job = new TaskFlowJob();
InternalJob jobData;
HashMap<String, JobVariable> jobVariables = new HashMap<>();
job.setVariables(jobVariables);
jobData = defaultSubmitJobAndLoadInternal(false, job);
Assert.assertNotNull(jobData.getVariables());
Assert.assertTrue(jobData.getVariables().isEmpty());
jobVariables.put("var1", new JobVariable("var1", "value1", null));
jobVariables.put("var2", new JobVariable("var2", "value2", null));
job.setVariables(jobVariables);
jobVariables = new HashMap<>();
jobVariables.put("var1", new JobVariable("var1", "value1", null));
jobVariables.put("var2", new JobVariable("var2", "value2", null));
job.setVariables(jobVariables);
jobData = defaultSubmitJobAndLoadInternal(false, job);
Assert.assertEquals(2, jobData.getVariables().size());
Assert.assertEquals("value1", jobData.getVariables().get("var1").getValue());
Assert.assertEquals("value2", jobData.getVariables().get("var2").getValue());
StringBuilder longString = new StringBuilder();
for (int i = 0; i < 100; i++) {
longString.append("0123456789abcdefghijklmnopqrstuvwxyz");
}
jobVariables = new HashMap<>();
jobVariables.put("longProperty", new JobVariable("longProperty", longString.toString()));
job.setVariables(jobVariables);
jobData = defaultSubmitJobAndLoadInternal(false, job);
Assert.assertEquals(1, jobData.getVariables().size());
Assert.assertEquals(longString.toString(), jobData.getVariables().get("longProperty").getValue());
}
Aggregations