Search in sources :

Example 1 with JobData

use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.

the class SchedulingMethodImpl method createExecution.

/**
 * Create launcher and try to start the task.
 *
 * @param nodeSet the node set containing every available nodes that can be used for execution
 * @param node the node on which to start the task
 * @param job the job that owns the task to be started
 * @param task the task to be started
 * @param taskDescriptor the descriptor of the task to be started
 */
protected boolean createExecution(NodeSet nodeSet, Node node, InternalJob job, InternalTask task, TaskDescriptor taskDescriptor) throws Exception {
    TaskLauncher launcher = null;
    LiveJobs.JobData jobData = null;
    try {
        jobData = schedulingService.lockJob(job.getId());
        // task is not paused
        if (nodeSet.size() >= task.getNumberOfNodesNeeded() && (task.getStatus() != TaskStatus.PAUSED) && (jobData != null)) {
            // start dataspace app for this job
            DataSpaceServiceStarter dsStarter = schedulingService.getInfrastructure().getDataSpaceServiceStarter();
            job.startDataSpaceApplication(dsStarter.getNamingService(), ImmutableList.of(task));
            NodeSet nodes = new NodeSet();
            try {
                // create launcher
                launcher = task.createLauncher(node);
                activeObjectCreationRetryTimeNumber = ACTIVEOBJECT_CREATION_RETRY_TIME_NUMBER;
                nodeSet.remove(0);
                // we will need to update this code once topology will be allowed for single-node task
                if (task.isParallel()) {
                    nodes = new NodeSet(nodeSet);
                    task.getExecuterInformation().addNodes(nodes);
                    nodeSet.clear();
                }
                // set nodes in the executable container
                task.getExecutableContainer().setNodes(nodes);
                tlogger.debug(task.getId(), "deploying");
                // above 500 parent tasks, it is worth adjusting.
                if (taskDescriptor.getParents().size() > 500) {
                    dotaskActionTimeout = (int) (taskDescriptor.getParents().size() / 500.0 * PASchedulerProperties.SCHEDULER_STARTTASK_TIMEOUT.getValueAsInt());
                } else {
                    // reset the dotaskActionTimeout to its default value otherwise.
                    dotaskActionTimeout = PASchedulerProperties.SCHEDULER_STARTTASK_TIMEOUT.getValueAsInt();
                }
                boolean taskRecoverable = getRMProxiesManager().getRmProxy().areNodesRecoverable(nodes);
                String terminateNotificationNodeURL = PAActiveObject.getActiveObjectNode(terminateNotification).getNodeInformation().getURL();
                TaskRecoveryData taskRecoveryData = new TaskRecoveryData(terminateNotificationNodeURL, taskRecoverable);
                threadPool.submitWithTimeout(new TimedDoTaskAction(job, taskDescriptor, launcher, schedulingService, terminateNotification, corePrivateKey, taskRecoveryData), dotaskActionTimeout, TimeUnit.MILLISECONDS);
                // we advertise here that the task is started, however
                // this is not entirely true: the only thing we are sure
                // about at this point is that we submitted to the thread
                // pool the action that will call the "doTask" of the task
                // launcher. There is thus a small gap here where the task
                // is seen as started whereas it is not yet started. We
                // cannot easily move the task started notification because
                // 1) it makes the job lock acquisition less predictable
                // (because the TimeDoTaskAction will have to compete with
                // the SchedulingMethodImpl)
                // and more importantly 2) the
                // SchedulingMethodImpl#createExecution may happen to be
                // called a second time for the task that is currently being
                // started by the TimedDoTaskAction.
                finalizeStarting(job, task, node, launcher);
                return true;
            } catch (Exception t) {
                try {
                    // if there was a problem, free nodeSet for multi-nodes task
                    nodes.add(node);
                    releaseNodes(job, nodes);
                } catch (Throwable ni) {
                // miam miam
                }
                throw t;
            }
        } else {
            return false;
        }
    } finally {
        if (jobData != null) {
            jobData.unlock();
        }
    }
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) TaskLauncher(org.ow2.proactive.scheduler.task.TaskLauncher) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) TopologyDisabledException(org.ow2.proactive.resourcemanager.frontend.topology.TopologyDisabledException) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) RMProxyCreationException(org.ow2.proactive.scheduler.core.rmproxies.RMProxyCreationException) IOException(java.io.IOException) TaskRecoveryData(org.ow2.proactive.scheduler.task.internal.TaskRecoveryData)

Example 2 with JobData

use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.

the class SchedulerDBManager method batchLoadJobs.

// Executed in a transaction from the caller
private void batchLoadJobs(Session session, boolean fullState, Query jobQuery, List<Long> ids, Collection<InternalJob> jobs) {
    Map<Long, List<TaskData>> tasksMap = loadJobsTasks(session, ids);
    jobQuery.setParameterList("ids", ids);
    List<JobData> jobsList = (List<JobData>) jobQuery.list();
    for (JobData jobData : jobsList) {
        InternalJob internalJob = jobData.toInternalJob();
        internalJob.setTasks(toInternalTasks(fullState, internalJob, tasksMap.get(jobData.getId())));
        jobs.add(internalJob);
    }
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) List(java.util.List) ArrayList(java.util.ArrayList)

Example 3 with JobData

use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.

the class BaseSchedulerDBTest method saveSingleTask.

public InternalJob saveSingleTask(Task task) throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.addTask(task);
    InternalJob jobData = defaultSubmitJobAndLoadInternal(true, job);
    Assert.assertEquals(1, jobData.getTasks().size());
    return jobData;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob)

Example 4 with JobData

use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.

the class TestJobAttributes method testJobVariables.

@Test
public void testJobVariables() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    InternalJob jobData;
    HashMap<String, JobVariable> jobVariables = new HashMap<>();
    job.setVariables(jobVariables);
    jobData = defaultSubmitJobAndLoadInternal(false, job);
    Assert.assertNotNull(jobData.getVariables());
    Assert.assertTrue(jobData.getVariables().isEmpty());
    jobVariables.put("var1", new JobVariable("var1", "value1", null));
    jobVariables.put("var2", new JobVariable("var2", "value2", null));
    job.setVariables(jobVariables);
    jobVariables = new HashMap<>();
    jobVariables.put("var1", new JobVariable("var1", "value1", null));
    jobVariables.put("var2", new JobVariable("var2", "value2", null));
    job.setVariables(jobVariables);
    jobData = defaultSubmitJobAndLoadInternal(false, job);
    Assert.assertEquals(2, jobData.getVariables().size());
    Assert.assertEquals("value1", jobData.getVariables().get("var1").getValue());
    Assert.assertEquals("value2", jobData.getVariables().get("var2").getValue());
    StringBuilder longString = new StringBuilder();
    for (int i = 0; i < 100; i++) {
        longString.append("0123456789abcdefghijklmnopqrstuvwxyz");
    }
    jobVariables = new HashMap<>();
    jobVariables.put("longProperty", new JobVariable("longProperty", longString.toString()));
    job.setVariables(jobVariables);
    jobData = defaultSubmitJobAndLoadInternal(false, job);
    Assert.assertEquals(1, jobData.getVariables().size());
    Assert.assertEquals(longString.toString(), jobData.getVariables().get("longProperty").getValue());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) HashMap(java.util.HashMap) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) Test(org.junit.Test)

Example 5 with JobData

use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.

the class TestJobAttributes method testGenericInformation.

@Test
public void testGenericInformation() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    Map<String, String> genericInfo;
    InternalJob jobData;
    genericInfo = new HashMap<>();
    job.setGenericInformation(genericInfo);
    jobData = defaultSubmitJobAndLoadInternal(false, job);
    Assert.assertNotNull(jobData.getGenericInformation());
    Assert.assertTrue(jobData.getGenericInformation().isEmpty());
    genericInfo = new HashMap<>();
    genericInfo.put("p1", "v1");
    genericInfo.put("p2", "v2");
    job.setGenericInformation(genericInfo);
    jobData = defaultSubmitJobAndLoadInternal(false, job);
    Assert.assertEquals(2, jobData.getGenericInformation().size());
    Assert.assertEquals("v1", jobData.getGenericInformation().get("p1"));
    Assert.assertEquals("v2", jobData.getGenericInformation().get("p2"));
    StringBuilder longString = new StringBuilder();
    for (int i = 0; i < 100; i++) {
        longString.append("0123456789abcdefghijklmnopqrstuvwxyz");
    }
    genericInfo = new HashMap<>();
    genericInfo.put("longProperty", longString.toString());
    job.setGenericInformation(genericInfo);
    jobData = defaultSubmitJobAndLoadInternal(false, job);
    Assert.assertEquals(1, jobData.getGenericInformation().size());
    Assert.assertEquals(longString.toString(), jobData.getGenericInformation().get("longProperty"));
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test)

Aggregations

InternalJob (org.ow2.proactive.scheduler.job.InternalJob)20 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)10 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)8 Test (org.junit.Test)7 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)7 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)5 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)5 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)5 JobId (org.ow2.proactive.scheduler.common.job.JobId)4 SimpleTaskLogs (org.ow2.proactive.scheduler.common.task.SimpleTaskLogs)4 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)4 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 TaskAbortedException (org.ow2.proactive.scheduler.common.exception.TaskAbortedException)2 TaskPreemptedException (org.ow2.proactive.scheduler.common.exception.TaskPreemptedException)2 TaskRestartedException (org.ow2.proactive.scheduler.common.exception.TaskRestartedException)2 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)2 JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)2