use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class RestSmartProxyTest method testJobSubmission.
private void testJobSubmission(boolean isolateTaskOutput, boolean automaticTransfer) throws Exception {
TaskFlowJob job = createTestJob(isolateTaskOutput);
printJobXmlRepresentation(job);
DataTransferNotifier notifier = new DataTransferNotifier();
if (automaticTransfer) {
restSmartProxy.addEventListener(notifier);
}
JobId id = restSmartProxy.submit(job, inputLocalFolder.getAbsolutePath(), outputLocalFolder.getAbsolutePath(), isolateTaskOutput, automaticTransfer);
JobState jobState = waitForJobFinishState(id.toString());
assertEquals(JobStatus.FINISHED, jobState.getStatus());
if (!automaticTransfer) {
for (int i = 0; i < NB_TASKS; i++) {
restSmartProxy.pullData(id.toString(), TASK_NAME + i, outputLocalFolder.getAbsolutePath());
}
} else {
List<String> taskNames = taskNameList();
while (!taskNames.isEmpty()) {
String finishedTask = notifier.finishedTask();
if (taskNames.contains(finishedTask)) {
taskNames.remove(finishedTask);
}
}
}
// check the presence of output files
for (int i = 0; i < NB_TASKS; i++) {
String outputFileName = OUTPUT_FILE_BASE_NAME + "_" + i + OUTPUT_FILE_EXT;
File outputFile = new File(outputLocalFolder, outputFileName);
Assert.assertTrue(String.format("%s does not exist.", outputFile.getAbsolutePath()), outputFile.exists());
}
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class RestSmartProxyTest method waitForJobFinishState.
private JobState waitForJobFinishState(String jobIdAsString) throws InterruptedException, NotConnectedException, UnknownJobException, PermissionException {
JobState jobState = restSmartProxy.getJobState(jobIdAsString);
Thread.sleep(ONE_SECOND);
while (jobState.getStatus().isJobAlive()) {
jobState = restSmartProxy.getJobState(jobIdAsString);
Thread.sleep(ONE_SECOND);
}
return jobState;
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerFrontendState method jobUpdatedFullData.
@Override
public void jobUpdatedFullData(JobState jobstate) {
ClientJobState storedJobState = new ClientJobState(jobstate);
dispatchJobUpdatedFullData(storedJobState);
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerFrontendState method prepare.
/**
* Prepare the job in the frontend
*
* @param jobStates
* a temporary set of jobs
* @param js
* the current job to be prepared
* @param finished
* if the job is finished or not
*/
private void prepare(Set<JobState> jobStates, ClientJobState js, boolean finished) {
jobStates.add(js);
IdentifiedJob ij = toIdentifiedJob(js);
jobs.put(js.getId(), ij);
jobsMap.put(js.getId(), js);
ij.setFinished(finished);
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerFrontendState method getTaskPaginated.
TaskStatesPage getTaskPaginated(JobId jobId, int offset, int limit) throws UnknownJobException, NotConnectedException, PermissionException {
checkPermissions("getJobState", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_STATE_OF_THIS_JOB);
ClientJobState jobState = getClientJobState(jobId);
if (jobState == null) {
throw new UnknownJobException(jobId);
}
try {
jobState.readLock();
try {
final TaskStatesPage tasksPaginated = jobState.getTasksPaginated(offset, limit);
final List<TaskState> taskStatesCopy = (List<TaskState>) ProActiveMakeDeepCopy.WithProActiveObjectStream.makeDeepCopy(new ArrayList<>(tasksPaginated.getTaskStates()));
return new TaskStatesPage(taskStatesCopy, tasksPaginated.getSize());
} catch (Exception e) {
logger.error("Error when copying tasks page", e);
throw new IllegalStateException(e);
}
} finally {
jobState.readUnlock();
}
}
Aggregations