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();
}
}
}
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);
}
}
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;
}
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());
}
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"));
}
Aggregations