use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData in project scheduling by ow2-proactive.
the class SchedulerClient method submit.
@Override
public JobId submit(Job job) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException {
JobIdData jobIdData = null;
try {
InputStream is = (new Job2XMLTransformer()).jobToxml((TaskFlowJob) job);
jobIdData = restApiClient().submitXml(sid, is);
} catch (Exception e) {
throwNCEOrPEOrSCEOrJCE(e);
}
return jobId(jobIdData);
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData in project scheduling by ow2-proactive.
the class ListTaskStatesCommandTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
JobIdData jobId = jobIdFaker.fake();
taskStateFaker = new DataFaker<TaskStateData>(TaskStateData.class);
taskStateFaker.setGenerator("taskInfo.jobId", new FixedPropertyGenerator<JobIdData>(jobId));
taskStateFaker.setGenerator("taskInfo.taskId.readableName", new PrefixPropertyGenerator("task", 1));
taskStateFaker.setGenerator("name", new PrefixPropertyGenerator("task", 1));
taskStateFaker.setGenerator("tag", new FixedPropertyGenerator("LOOP-T2-1"));
this.taskData = this.taskStateFaker.fakeList(6);
this.taskDataFiltered = new ArrayList<>();
this.taskDataFiltered.add(this.taskData.get(0));
this.taskDataFiltered.add(this.taskData.get(1));
this.taskDataFiltered.add(this.taskData.get(2));
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData in project scheduling by ow2-proactive.
the class AbstractSchedulerCommandTest method setUp.
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
jobIdFaker = new DataFaker<JobIdData>(JobIdData.class);
jobIdFaker.setGenerator("readableName", new PrefixPropertyGenerator("job", 1));
when(context.getRestClient()).thenReturn(restClient);
when(restClient.getScheduler()).thenReturn(restApi);
when(context.resultStack()).thenReturn(stack);
capturedOutput = new ByteArrayOutputStream();
userInput = new StringBuffer();
ScriptEngineManager mgr = new ScriptEngineManager();
engine = mgr.getEngineByExtension("js");
when(context.getEngine()).thenReturn(engine);
when(context.getProperty(eq(AbstractIModeCommand.TERMINATE), any(Class.class), anyBoolean())).thenReturn(false);
// Mockito.when(ApplicationContextImpl.currentContext()).thenReturn(context);
ApplicationContextImpl.mockCurrentContext(context.newApplicationContextHolder());
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData in project scheduling by ow2-proactive.
the class ReSubmitJobCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
try {
JobIdData newJobId = currentContext.getRestClient().reSubmit(currentContext.getSessionId(), jobId, JobKeyValueTransformer.transformJsonStringToMap(variables), JobKeyValueTransformer.transformJsonStringToMap(genericInfos));
writeLine(currentContext, "Job('%s') successfully re-submitted as Job('%d')", jobId, newJobId.getId());
resultStack(currentContext).push(jobId);
} catch (Exception e) {
handleError(String.format("An error occurred while re-submitting Job('%s') output %s:", jobId, e.getMessage()), e, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData in project scheduling by ow2-proactive.
the class SubmitJobCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
try {
validateFilePath(currentContext);
File jobFile = new File(pathname);
String contentType = URLConnection.getFileNameMap().getContentTypeFor(pathname);
JobIdData jobId;
try (FileInputStream inputStream = new FileInputStream(jobFile)) {
if (APPLICATION_XML.getMimeType().equals(contentType)) {
jobId = currentContext.getRestClient().submitXml(currentContext.getSessionId(), inputStream, map(this.variables), map(this.genericInfos));
} else {
jobId = currentContext.getRestClient().submitJobArchive(currentContext.getSessionId(), inputStream, map(this.variables), map(this.genericInfos));
}
}
writeLine(currentContext, "Job('%s') successfully submitted: job('%d')", pathname, jobId.getId());
resultStack(currentContext).push(jobId);
} catch (Exception e) {
handleError(String.format("An error occurred while attempting to submit job('%s'):", pathname), e, currentContext);
}
}
Aggregations