use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class ServerJobAndTaskLogs method getJobLog.
public static String getJobLog(JobId jobId, Set<TaskId> tasks) {
String jobLog = readLog(JobLogger.getJobLogRelativePath(jobId));
if (jobLog == null) {
return "Cannot retrieve logs for job " + jobId;
}
StringBuilder result = new StringBuilder();
result.append("================= Job ").append(jobId).append(" logs =================\n");
result.append(jobLog);
for (TaskId taskId : tasks) {
result.append("\n================ Task ").append(taskId).append(" logs =================\n");
result.append(getTaskLog(taskId));
}
return result.toString();
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestJobInstantGetTaskResult method testJobInstantGetTaskResult.
@Test
public void testJobInstantGetTaskResult() throws Throwable {
// create Scheduler client as an active object
SubmitJob client = (SubmitJob) PAActiveObject.newActive(SubmitJob.class.getName(), new Object[] {});
// begin to use the client : must be a futur result in order to start the scheduler at next step
client.begin();
// create job
TaskFlowJob job = new TaskFlowJob();
for (int i = 0; i < 50; i++) {
JavaTask t = new JavaTask();
t.setExecutableClassName(ResultAsArray.class.getName());
t.setName("task" + i);
job.addTask(t);
}
JobId id = schedulerHelper.submitJob(job);
client.setJobId(id);
schedulerHelper.waitForEventJobRemoved(id);
PAActiveObject.terminateActiveObject(client, true);
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestLoadJobs method checkJobs.
private void checkJobs(List<JobInfo> jobs, JobId... expectedIds) {
Set<JobId> jobIds = new HashSet<>(jobs.size());
for (JobInfo job : jobs) {
jobIds.add(job.getJobId());
logger.info("Job " + job.getJobId() + " has status '" + job.getStatus() + "'");
}
for (JobId expectedId : expectedIds) {
final boolean expectedJobIdContained = jobIds.contains(expectedId);
logger.info("Checking if " + jobs + " contains " + expectedId + "? " + expectedJobIdContained);
assertTrue(expectedJobIdContained);
}
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TaskUsingCredentialsTest method jobs_using_third_party_credentials.
private void jobs_using_third_party_credentials() throws Exception {
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
scheduler.putThirdPartyCredential("MY_APP_PASSWORD", "superpassword");
TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
if (OperatingSystem.getOperatingSystem() == org.objectweb.proactive.utils.OperatingSystem.unix) {
NativeTask nativeTask = new NativeTask();
nativeTask.setCommandLine("echo", "$credentials_MY_APP_PASSWORD");
job.addTask(nativeTask);
}
JobId jobId = scheduler.submit(job);
schedulerHelper.waitForEventJobFinished(jobId);
JobResult jobResult = schedulerHelper.getJobResult(jobId);
for (TaskResult taskResult : jobResult.getAllResults().values()) {
assertTrue("task " + taskResult.getTaskId().getReadableName() + " did not print the credential", taskResult.getOutput().getAllLogs(false).contains("superpassword"));
}
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestThirdPartyCredentialsDefined method createAndSubmitTaskPrintingCredentials.
public String createAndSubmitTaskPrintingCredentials() throws Exception {
ScriptTask scriptTask = new ScriptTask();
scriptTask.setName("task");
scriptTask.setScript(new TaskScript(new SimpleScript("print credentials", "python")));
TaskFlowJob job = new TaskFlowJob();
job.addTask(scriptTask);
JobId id = schedulerHelper.submitJob(job);
schedulerHelper.waitForEventJobFinished(id);
JobResult jobResult = schedulerHelper.getJobResult(id);
TaskResult result = jobResult.getResult(scriptTask.getName());
return result.getOutput().getStdoutLogs(false).replaceAll("\n|\r", "");
}
Aggregations