Search in sources :

Example 11 with JobIdData

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);
}
Also used : Job2XMLTransformer(org.ow2.proactive.scheduler.common.job.factories.Job2XMLTransformer) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) KeyStoreException(java.security.KeyStoreException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) KeyManagementException(java.security.KeyManagementException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) IOException(java.io.IOException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException) TimeoutException(java.util.concurrent.TimeoutException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) SignalApiException(org.ow2.proactive.scheduler.signal.SignalApiException)

Example 12 with 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));
}
Also used : PrefixPropertyGenerator(objectFaker.propertyGenerator.PrefixPropertyGenerator) JobIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData) TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) FixedPropertyGenerator(objectFaker.propertyGenerator.FixedPropertyGenerator) Before(org.junit.Before)

Example 13 with JobIdData

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());
}
Also used : PrefixPropertyGenerator(objectFaker.propertyGenerator.PrefixPropertyGenerator) JobIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData) ScriptEngineManager(javax.script.ScriptEngineManager) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 14 with JobIdData

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);
    }
}
Also used : JobIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException)

Example 15 with JobIdData

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);
    }
}
Also used : JobIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData) File(java.io.File) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException) JobCreationRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.JobCreationRestException) InvalidPathException(java.nio.file.InvalidPathException)

Aggregations

JobIdData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData)9 IOException (java.io.IOException)7 File (java.io.File)5 FileInputStream (java.io.FileInputStream)5 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)4 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)4 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)4 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)4 FileOutputStream (java.io.FileOutputStream)3 InputStream (java.io.InputStream)3 KeyManagementException (java.security.KeyManagementException)3 KeyStoreException (java.security.KeyStoreException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 ArrayList (java.util.ArrayList)3 TimeoutException (java.util.concurrent.TimeoutException)3 POST (javax.ws.rs.POST)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 Test (org.junit.Test)3 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)3