/** * Does the following steps: * * <ul> * <li>Prepares the temporary folders. See {@link #prepareDataFolderAndUpdateJob(Job, String, * String, String, String)} * <li>pushes all files from localInputFolderPath to the push_url location (see {@link * #pushData(Job, String)}) * <li>submits the job to the scheduler * <li>adds the job to the awaited jobs list in order to download the output data when the job * is finished * </ul> * * Note: this method is synchronous. The caller will be blocked until the the data is pushed and * the job submitted. * * @param job job object to be submitted to the Scheduler Server for execution * @param localInputFolderPath path to the folder containing the input data for this job * @param push_url the url where input data is to be pushed before the job submission * @param localOutputFolderPath path to the folder where the output data produced by tasks in this * job should be copied * @param pull_url the url where the data is to be retrieved after the job is finished * @param localOutputFolderPath * @return * @throws JobCreationException * @throws SubmissionClosedException * @throws PermissionException * @throws NotConnectedException * @throws FileSystemException */ public JobId submit( Job job, String localInputFolderPath, String push_url, String localOutputFolderPath, String pull_url) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException, FileSystemException { if (((push_url == null) || (push_url.equals(""))) && ((pull_url == null) || (pull_url.equals("")))) { logger.warn( "For the job " + job.getId() + " no push or pull urls are defined. No data will be transfered for this job from the local machine "); return super.submit(job); } String newFolderName = createNewFolderName(); String push_Url_update = prepareJobInput(job, localInputFolderPath, push_url, newFolderName); String pull_url_update = prepareJobOutput(job, localOutputFolderPath, pull_url, newFolderName); pushData(job, localInputFolderPath); JobId id = super.submit(job); AwaitedJob aj = new AwaitedJob( id.toString(), localInputFolderPath, job.getInputSpace(), push_Url_update, localOutputFolderPath, job.getOutputSpace(), pull_url_update); addAwaitedJob(aj); return id; }
/** * Tests start here. * * @throws Throwable any exception that can be thrown during the test. */ @org.junit.Test public void run() throws Throwable { String task1Name = "Task1"; String task2Name = "Task2"; String taskForked1Name = "Fork1"; String taskForked2Name = "Fork2"; TaskFlowJob job = (TaskFlowJob) JobFactory_stax.getFactory() .createJob(new File(jobDescriptor.toURI()).getAbsolutePath()); if (OperatingSystem.getOperatingSystem() == OperatingSystem.windows) { ((NativeTask) job.getTask(task1Name)) .setCommandLine("cmd", "/C", "ping", "127.0.0.1", "-n", "20", ">", "NUL"); ((NativeTask) job.getTask(taskForked1Name)) .setCommandLine("cmd", "/C", "ping", "127.0.0.1", "-n", "20", ">", "NUL"); } JobId id = SchedulerTHelper.submitJob(job); SchedulerTHelper.log("Job submitted, id " + id.toString()); SchedulerTHelper.log("Waiting for jobSubmitted Event"); Job receivedJob = SchedulerTHelper.waitForEventJobSubmitted(id); Assert.assertEquals(receivedJob.getId(), id); SchedulerTHelper.log("Waiting for job running"); JobInfo jInfo = SchedulerTHelper.waitForEventJobRunning(id); Assert.assertEquals(jInfo.getJobId(), id); Assert.assertEquals(JobStatus.RUNNING, jInfo.getStatus()); SchedulerTHelper.log("check events for task " + task1Name); TaskInfo tInfo = SchedulerTHelper.waitForEventTaskRunning(id, task1Name); Assert.assertEquals(TaskStatus.RUNNING, tInfo.getStatus()); tInfo = SchedulerTHelper.waitForEventTaskFinished(id, task1Name); Assert.assertEquals(TaskStatus.FINISHED, tInfo.getStatus()); SchedulerTHelper.log("check events for task " + task2Name); tInfo = SchedulerTHelper.waitForEventTaskRunning(id, task2Name); Assert.assertEquals(TaskStatus.RUNNING, tInfo.getStatus()); tInfo = SchedulerTHelper.waitForEventTaskFinished(id, task2Name); Assert.assertEquals(TaskStatus.FINISHED, tInfo.getStatus()); // this task reaches wall time, so finishes with faulty state SchedulerTHelper.log("check events for task " + taskForked1Name); tInfo = SchedulerTHelper.waitForEventTaskRunning(id, taskForked1Name); Assert.assertEquals(TaskStatus.RUNNING, tInfo.getStatus()); tInfo = SchedulerTHelper.waitForEventTaskFinished(id, taskForked1Name); Assert.assertEquals(TaskStatus.FAULTY, tInfo.getStatus()); // this task reaches wall time, so finishes with faulty state SchedulerTHelper.log("check events for task " + taskForked2Name); tInfo = SchedulerTHelper.waitForEventTaskRunning(id, taskForked2Name); Assert.assertEquals(TaskStatus.RUNNING, tInfo.getStatus()); tInfo = SchedulerTHelper.waitForEventTaskFinished(id, taskForked2Name); Assert.assertEquals(TaskStatus.FAULTY, tInfo.getStatus()); SchedulerTHelper.log("Waiting for job finished"); jInfo = SchedulerTHelper.waitForEventJobFinished(id); Assert.assertEquals(jInfo.getJobId(), id); Assert.assertEquals(JobStatus.FINISHED, jInfo.getStatus()); // check result are not null JobResult res = SchedulerTHelper.getJobResult(id); Assert.assertTrue(res.hadException()); Assert.assertFalse(res.getResult(task1Name).hadException()); Assert.assertNull(res.getResult(task1Name).getException()); Assert.assertFalse(res.getResult(task2Name).hadException()); Assert.assertNull(res.getResult(task2Name).getException()); Assert.assertFalse(res.getResult(taskForked1Name).hadException()); Assert.assertNull(res.getResult(taskForked1Name).getException()); Assert.assertTrue(res.getResult(taskForked2Name).hadException()); Assert.assertNotNull(res.getResult(taskForked2Name).getException()); // remove job SchedulerTHelper.removeJob(id); SchedulerTHelper.waitForEventJobRemoved(id); }