Search in sources :

Example 21 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class SchedulerFrontend method insertJobSignals.

private JobInfo insertJobSignals(JobInfo jobInfo) {
    String jobid = jobInfo.getJobId().value();
    if (checkJobPermissionMethod(jobid, "addJobSignal")) {
        try {
            TaskId taskId = createFakeTaskId(jobInfo.getJobId().value());
            if (publicStore.channelExists(SIGNAL_ORIGINATOR, taskId, signalsChannel + jobid)) {
                Set<Map.Entry<String, Serializable>> signalEntries = publicStore.entrySet(SIGNAL_ORIGINATOR, taskId, signalsChannel + jobid);
                Set<String> signalsToBeAdded = signalEntries.stream().map(entry -> entry.getKey()).collect(Collectors.toSet());
                List<Signal> signalList = signalEntries.stream().map(entry -> (Signal) entry.getValue()).collect(Collectors.toList());
                Map<String, Map<String, JobVariable>> detailedSignalsToBeAdded = new LinkedHashMap<>();
                signalList.forEach(signal -> {
                    Map<String, JobVariable> variableMap = new LinkedHashMap<>();
                    if (signal.getInputVariables() != null) {
                        signal.getInputVariables().forEach(jobVariable -> variableMap.put(jobVariable.getName(), jobVariable));
                    }
                    detailedSignalsToBeAdded.put(signal.getName(), variableMap);
                });
                Set<String> jobSignals = jobInfo.getSignals();
                Map<String, Map<String, JobVariable>> jobDetailedSignals = jobInfo.getDetailedSignals();
                if (signalsToBeAdded != null && !signalsToBeAdded.isEmpty()) {
                    jobSignals.addAll(signalsToBeAdded);
                    jobInfo.setSignals(jobSignals);
                }
                if (detailedSignalsToBeAdded != null && !detailedSignalsToBeAdded.isEmpty()) {
                    jobDetailedSignals.putAll(detailedSignalsToBeAdded);
                    jobInfo.setDetailedSignals(jobDetailedSignals);
                }
            }
        } catch (InvalidChannelException e) {
            logger.warn("Could not retrieve the signals of the job " + jobid);
        }
    }
    return jobInfo;
}
Also used : FileSystemException(org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException) TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) KeyException(java.security.KeyException) NodeSet(org.ow2.proactive.utils.NodeSet) YOU_DO_NOT_HAVE_PERMISSION_TO_LIST_THIRD_PARTY_CREDENTIALS_IN_THE_SCHEDULER(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_LIST_THIRD_PARTY_CREDENTIALS_IN_THE_SCHEDULER) StreamResult(javax.xml.transform.stream.StreamResult) StringUtils(org.apache.commons.lang3.StringUtils) PASchedulerProperties(org.ow2.proactive.scheduler.core.properties.PASchedulerProperties) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) SchedulerUserInfo(org.ow2.proactive.scheduler.job.SchedulerUserInfo) YOU_DO_NOT_HAVE_PERMISSION_TO_KILL_THE_SCHEDULER(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_KILL_THE_SCHEDULER) Body(org.objectweb.proactive.Body) YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB) DefaultModelJobValidatorServiceProvider(org.ow2.proactive.scheduler.common.job.factories.spi.model.DefaultModelJobValidatorServiceProvider) ImmediateService(org.objectweb.proactive.annotation.ImmediateService) YOU_DO_NOT_HAVE_PERMISSION_TO_FINISH_THIS_TASK(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_FINISH_THIS_TASK) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) YOU_DO_NOT_HAVE_PERMISSION_TO_REGISTER_SERVICE_TO_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_REGISTER_SERVICE_TO_THIS_JOB) TaskIdImpl(org.ow2.proactive.scheduler.task.TaskIdImpl) YOU_DO_NOT_HAVE_PERMISSION_TO_PREEMPT_THIS_TASK(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_PREEMPT_THIS_TASK) JobFactory(org.ow2.proactive.scheduler.common.job.factories.JobFactory) YOU_DO_NOT_HAVE_PERMISSION_TO_REMOVE_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_REMOVE_THIS_JOB) RMProxy(org.ow2.proactive.scheduler.core.rmproxies.RMProxy) SynchronizationInternal(org.ow2.proactive.scheduler.synchronization.SynchronizationInternal) InitActive(org.objectweb.proactive.InitActive) EndActive(org.objectweb.proactive.EndActive) TaskCouldNotRestartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotRestartException) TaskStatesPage(org.ow2.proactive.scheduler.common.task.TaskStatesPage) InvalidChannelException(org.ow2.proactive.scheduler.synchronization.InvalidChannelException) SchedulerConnection(org.ow2.proactive.scheduler.common.SchedulerConnection) IOUtils(org.apache.commons.io.IOUtils) SchedulerAuthentication(org.ow2.proactive.scheduler.authentication.SchedulerAuthentication) YOU_DO_NOT_HAVE_PERMISSION_TO_KILL_THIS_TASK(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_KILL_THIS_TASK) YOU_DO_NOT_HAVE_PERMISSION_TO_START_THE_SCHEDULER(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_START_THE_SCHEDULER) YOU_DO_NOT_HAVE_PERMISSION_TO_REMOVE_THIRD_PARTY_CREDENTIALS_FROM_THE_SCHEDULER(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_REMOVE_THIRD_PARTY_CREDENTIALS_FROM_THE_SCHEDULER) JobFilterCriteria(org.ow2.proactive.scheduler.common.JobFilterCriteria) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_RESULT_OF_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_RESULT_OF_THIS_JOB) java.util(java.util) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) StreamSource(javax.xml.transform.stream.StreamSource) TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) YOU_DO_NOT_HAVE_PERMISSION_TO_RESTART_THIS_TASK(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_RESTART_THIS_TASK) Service(org.objectweb.proactive.Service) UserData(org.ow2.proactive.authentication.UserData) AlreadyConnectedException(org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) Signal(org.ow2.proactive.scheduler.signal.Signal) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) YOU_DO_NOT_HAVE_PERMISSIONS_TO_GET_THE_LOGS_OF_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSIONS_TO_GET_THE_LOGS_OF_THIS_JOB) TaskCouldNotStartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotStartException) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) YOU_DO_NOT_HAVE_PERMISSION_TO_LISTEN_THE_LOG_OF_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_LISTEN_THE_LOG_OF_THIS_JOB) YOU_DO_NOT_HAVE_PERMISSION_TO_FREEZE_THE_SCHEDULER(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_FREEZE_THE_SCHEDULER) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Credentials(org.ow2.proactive.authentication.crypto.Credentials) YOU_DO_NOT_HAVE_PERMISSION_TO_RESUME_THE_SCHEDULER(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_RESUME_THE_SCHEDULER) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) YOU_DO_NOT_HAVE_PERMISSION_TO_RESTART_IN_ERROR_TASKS_IN_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_RESTART_IN_ERROR_TASKS_IN_THIS_JOB) javax.xml.transform(javax.xml.transform) YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_LOGS_OF_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_LOGS_OF_THIS_JOB) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) SchedulerEventListener(org.ow2.proactive.scheduler.common.SchedulerEventListener) YOU_DO_NOT_HAVE_PERMISSION_TO_DO_THIS_OPERATION(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_DO_THIS_OPERATION) SchedulerAccountsManager(org.ow2.proactive.scheduler.core.account.SchedulerAccountsManager) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) DataSpacesFileObject(org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject) RunActive(org.objectweb.proactive.RunActive) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) YOU_DO_NOT_HAVE_PERMISSION_TO_DETACH_SERVICE_TO_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_DETACH_SERVICE_TO_THIS_JOB) AppenderProvider(org.ow2.proactive.scheduler.common.util.logforwarder.AppenderProvider) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl) YOU_DO_NOT_HAVE_PERMISSION_TO_PAUSE_THE_SCHEDULER(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_PAUSE_THE_SCHEDULER) SchedulerEvent(org.ow2.proactive.scheduler.common.SchedulerEvent) RMConnection(org.ow2.proactive.resourcemanager.frontend.RMConnection) SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) Task(org.ow2.proactive.scheduler.common.task.Task) YOU_DO_NOT_HAVE_PERMISSION_TO_SHUTDOWN_THE_SCHEDULER(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_SHUTDOWN_THE_SCHEDULER) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) PAExecutors(org.ow2.proactive.utils.PAExecutors) Logger(org.apache.log4j.Logger) YOU_DO_NOT_HAVE_PERMISSION_TO_GET_TASK_STATES(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_GET_TASK_STATES) YOU_DO_NOT_HAVE_PERMISSION_TO_GET_TASK_IDS(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_GET_TASK_IDS) YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THIS_JOB) URI(java.net.URI) SchedulerSpaceInterface(org.ow2.proactive.scheduler.common.SchedulerSpaceInterface) JobValidationException(org.ow2.proactive.scheduler.common.exception.JobValidationException) Policy(org.ow2.proactive.scheduler.policy.Policy) Request(org.objectweb.proactive.core.body.request.Request) SchedulerJMXHelper(org.ow2.proactive.scheduler.core.jmx.SchedulerJMXHelper) JobId(org.ow2.proactive.scheduler.common.job.JobId) YOU_DO_NOT_HAVE_PERMISSION_TO_STOP_THE_SCHEDULER(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_STOP_THE_SCHEDULER) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) JobPriority(org.ow2.proactive.scheduler.common.job.JobPriority) RMProxiesManager(org.ow2.proactive.scheduler.core.rmproxies.RMProxiesManager) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) Page(org.ow2.proactive.scheduler.common.Page) JobState(org.ow2.proactive.scheduler.common.job.JobState) Collectors(java.util.stream.Collectors) YOU_DO_NOT_HAVE_PERMISSION_TO_KILL_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_KILL_THIS_JOB) Tools(org.ow2.proactive.utils.Tools) YOU_DO_NOT_HAVE_PERMISSION_TO_ADD_EXTERNAL_ENDPOINT_URL_TO_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_ADD_EXTERNAL_ENDPOINT_URL_TO_THIS_JOB) ActiveObject(org.objectweb.proactive.extensions.annotation.ActiveObject) SchedulerState(org.ow2.proactive.scheduler.common.SchedulerState) SchedulerPortalConfiguration(org.ow2.proactive.scheduler.util.SchedulerPortalConfiguration) YOU_DO_NOT_HAVE_PERMISSION_TO_ENABLE_VISE_THIS_TASK(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_ENABLE_VISE_THIS_TASK) HybridEncryptionUtil(org.ow2.proactive.authentication.crypto.HybridEncryptionUtil) TableSizeMonitorRunner(org.ow2.proactive.scheduler.core.helpers.TableSizeMonitorRunner) YOU_DO_NOT_HAVE_PERMISSION_TO_SEND_SIGNALS_TO_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_SEND_SIGNALS_TO_THIS_JOB) ServerJobAndTaskLogs(org.ow2.proactive.scheduler.util.ServerJobAndTaskLogs) UniqueID(org.objectweb.proactive.core.UniqueID) SignalApiImpl(org.ow2.proactive.scheduler.signal.SignalApiImpl) JobSortParameter(org.ow2.proactive.scheduler.common.JobSortParameter) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) Job(org.ow2.proactive.scheduler.common.job.Job) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) SchedulerStatus(org.ow2.proactive.scheduler.common.SchedulerStatus) PAActiveObject(org.objectweb.proactive.api.PAActiveObject) YOU_DO_NOT_HAVE_PERMISSION_TO_PAUSE_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_PAUSE_THIS_JOB) DatabaseManagerException(org.ow2.proactive.db.DatabaseManagerException) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskSkippedException(org.ow2.proactive.scheduler.common.exception.TaskSkippedException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) JobsMemoryMonitorRunner(org.ow2.proactive.scheduler.core.helpers.JobsMemoryMonitorRunner) Charset(java.nio.charset.Charset) SortParameter(org.ow2.proactive.db.SortParameter) ExecutorService(java.util.concurrent.ExecutorService) IdentifiedJob(org.ow2.proactive.scheduler.job.IdentifiedJob) NamedThreadFactory(org.objectweb.proactive.utils.NamedThreadFactory) YOU_DO_NOT_HAVE_PERMISSION_TO_RESUME_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_RESUME_THIS_JOB) PublicKey(java.security.PublicKey) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) SchedulerConstants(org.ow2.proactive.scheduler.common.SchedulerConstants) Subject(javax.security.auth.Subject) TimeUnit(java.util.concurrent.TimeUnit) ProActiveException(org.objectweb.proactive.core.ProActiveException) ClientsPolicy(org.ow2.proactive.policy.ClientsPolicy) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) SignalApiException(org.ow2.proactive.scheduler.signal.SignalApiException) java.io(java.io) JobUsage(org.ow2.proactive.scheduler.common.usage.JobUsage) AOSynchronization(org.ow2.proactive.scheduler.synchronization.AOSynchronization) YOU_DO_NOT_HAVE_PERMISSION_TO_PUT_THIRD_PARTY_CREDENTIALS_IN_THE_SCHEDULER(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_PUT_THIRD_PARTY_CREDENTIALS_IN_THE_SCHEDULER) YOU_DO_NOT_HAVE_PERMISSION_TO_SUBMIT_A_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_SUBMIT_A_JOB) RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) YOU_DO_NOT_HAVE_PERMISSION_TO_RELOAD_POLICY_CONFIGURATION(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_RELOAD_POLICY_CONFIGURATION) SimpleTaskLogs(org.ow2.proactive.scheduler.common.task.SimpleTaskLogs) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) YOU_DO_NOT_HAVE_PERMISSION_TO_REMOVE_EXTERNAL_ENDPOINT_URL_TO_THIS_JOB(org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_REMOVE_EXTERNAL_ENDPOINT_URL_TO_THIS_JOB) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) InvalidChannelException(org.ow2.proactive.scheduler.synchronization.InvalidChannelException) Signal(org.ow2.proactive.scheduler.signal.Signal) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Example 22 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class TerminationData method getStringSerializableMap.

public VariablesMap getStringSerializableMap(SchedulingService service, TaskTerminationData taskToTerminate) throws Exception {
    VariablesMap variablesMap = new VariablesMap();
    RunningTaskData taskData = taskToTerminate.taskData;
    TaskResultImpl taskResult = taskToTerminate.taskResult;
    InternalJob internalJob = taskToTerminate.internalJob;
    if (taskToTerminate.terminationStatus == ABORTED || taskResult == null) {
        List<InternalTask> iDependences = taskData.getTask().getIDependences();
        if (iDependences != null) {
            taskData.getTask().updateParentTasksResults(service);
            getResultsFromListOfTaskResults(variablesMap.getInheritedMap(), taskData.getTask().getParentTasksResults());
        } else {
            if (internalJob != null) {
                for (Map.Entry<String, JobVariable> jobVariableEntry : internalJob.getVariables().entrySet()) {
                    variablesMap.getInheritedMap().put(jobVariableEntry.getKey(), jobVariableEntry.getValue().getValue());
                }
            }
        }
        variablesMap.getInheritedMap().put(SchedulerVars.PA_TASK_SUCCESS.toString(), Boolean.toString(false));
    } else if (taskResult.hadException()) {
        variablesMap.setInheritedMap(fillMapWithTaskResult(taskResult, false));
    } else {
        variablesMap.setInheritedMap(fillMapWithTaskResult(taskResult, true));
    }
    variablesMap.setScopeMap(getNonInheritedScopeVariables(variablesMap.getInheritedMap(), taskData.getTask().getScopeVariables(), taskData.getTask().getVariables()));
    return variablesMap;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) VariablesMap(org.ow2.proactive.scheduler.task.utils.VariablesMap) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) HashMap(java.util.HashMap) Map(java.util.Map) VariablesMap(org.ow2.proactive.scheduler.task.utils.VariablesMap)

Example 23 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class JobData method toInternalJob.

InternalJob toInternalJob() {
    JobId jobIdInstance = new JobIdImpl(getId(), getJobName());
    JobInfoImpl jobInfo = createJobInfo(jobIdInstance);
    InternalJob internalJob = new InternalTaskFlowJob();
    internalJob.setCredentials(getCredentials());
    internalJob.setJobInfo(jobInfo);
    internalJob.setParentId(getParentId());
    internalJob.setGenericInformation(getGenericInformation());
    internalJob.setVariables(variablesToJobVariables());
    internalJob.setProjectName(getProjectName());
    internalJob.setOwner(getOwner());
    internalJob.setDescription(getDescription());
    internalJob.setInputSpace(getInputSpace());
    internalJob.setOutputSpace(getOutputSpace());
    internalJob.setGlobalSpace(getGlobalSpace());
    internalJob.setUserSpace(getGlobalSpace());
    internalJob.setMaxNumberOfExecution(getMaxNumberOfExecution());
    internalJob.setOnTaskError(OnTaskError.getInstance(this.onTaskErrorString));
    if (getTaskRetryDelay() != null) {
        internalJob.setTaskRetryDelay(getTaskRetryDelay());
    }
    internalJob.setScheduledTimeForRemoval(getScheduledTimeForRemoval());
    try {
        internalJob.setResultMap(SerializationUtil.deserializeVariableMap(getResultMap()));
    } catch (IOException | ClassNotFoundException e) {
        logger.error("error when serializing result map variables " + e);
    }
    List<JobContent> jobContentList = getJobContent();
    if (jobContentList != null && jobContentList.size() > 0) {
        internalJob.setJobContent(jobContentList.get(0).getInitJobContent());
        if (internalJob.getJobContent() != null) {
            GlobalVariablesData globalVariablesData = GlobalVariablesParser.getInstance().getVariablesFor(internalJob.getJobContent());
            Map<String, JobVariable> globalVariables = new LinkedHashMap<>();
            Map<String, JobVariable> configuredGlobalVariables = globalVariablesData.getVariables();
            for (String variableName : configuredGlobalVariables.keySet()) {
                if (internalJob.getVariables().containsKey(variableName)) {
                    globalVariables.put(variableName, internalJob.getVariables().get(variableName));
                } else {
                    globalVariables.put(variableName, configuredGlobalVariables.get(variableName));
                }
            }
            internalJob.setGlobalVariables(globalVariables);
            Map<String, String> globalGenericInfo = new LinkedHashMap<>();
            Map<String, String> configuredGlobalGenericInfo = globalVariablesData.getGenericInformation();
            for (String giName : configuredGlobalGenericInfo.keySet()) {
                if (internalJob.getGenericInformation().containsKey(giName)) {
                    globalGenericInfo.put(giName, internalJob.getGenericInformation().get(giName));
                } else {
                    globalGenericInfo.put(giName, configuredGlobalGenericInfo.get(giName));
                }
            }
            internalJob.setGlobalGenericInformation(globalGenericInfo);
        }
    }
    return internalJob;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) GlobalVariablesData(org.ow2.proactive.scheduler.common.job.factories.globalvariables.GlobalVariablesData) IOException(java.io.IOException) LinkedHashMap(java.util.LinkedHashMap) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 24 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class JobData method jobDataVariableToTaskVariable.

private static JobVariable jobDataVariableToTaskVariable(JobDataVariable jobDataVariable) {
    if (jobDataVariable == null) {
        return null;
    }
    JobVariable jobVariable = new JobVariable();
    jobVariable.setModel(jobDataVariable.getModel());
    jobVariable.setValue(jobDataVariable.getValue());
    jobVariable.setName(jobDataVariable.getName());
    jobVariable.setDescription(jobDataVariable.getDescription());
    jobVariable.setGroup(jobDataVariable.getGroup());
    jobVariable.setAdvanced(jobDataVariable.getAdvanced());
    return jobVariable;
}
Also used : JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Example 25 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class TaskResultCreatorTest method testThatJobVariablesAreUsedIfTaskHasNoParents.

@Test
public void testThatJobVariablesAreUsedIfTaskHasNoParents() throws UnknownTaskException {
    TaskResultCreator taskResultCreator = new TaskResultCreator();
    SchedulerDBManager mockedschedulerDbManager = mock(SchedulerDBManager.class);
    when(mockedschedulerDbManager.loadTasksResults(any(JobId.class), any(List.class))).thenThrow(new DatabaseManagerException());
    InternalJob mockedInternalJob = this.getMockedInternalJobTaskFlowType(this.getMockedJobDescriptorWithPausedTaskWithoutParent());
    Map<String, JobVariable> fakeVariableMap = new HashMap<>();
    fakeVariableMap.put("TestVar", new JobVariable("TestVar", "h234"));
    when(mockedInternalJob.getVariables()).thenReturn(fakeVariableMap);
    Map<String, String> fakeReplacementVariableMap = new HashMap<>();
    fakeReplacementVariableMap.put("TestVar", "h234");
    when(mockedInternalJob.getVariablesAsReplacementMap()).thenReturn(fakeReplacementVariableMap);
    TaskResult taskResult = taskResultCreator.getTaskResult(mockedschedulerDbManager, mockedInternalJob, this.getMockedInternalTask());
    verify(mockedInternalJob, atLeastOnce()).getVariablesAsReplacementMap();
    assertThat(new String(taskResult.getPropagatedVariables().get("TestVar")), is("h234"));
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) HashMap(java.util.HashMap) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) List(java.util.List) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) JobId(org.ow2.proactive.scheduler.common.job.JobId) DatabaseManagerException(org.ow2.proactive.db.DatabaseManagerException) Test(org.junit.Test)

Aggregations

JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)51 Test (org.junit.Test)19 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)17 HashMap (java.util.HashMap)15 LinkedHashMap (java.util.LinkedHashMap)9 Job (org.ow2.proactive.scheduler.common.job.Job)8 JobId (org.ow2.proactive.scheduler.common.job.JobId)8 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)7 JobValidationException (org.ow2.proactive.scheduler.common.exception.JobValidationException)6 Task (org.ow2.proactive.scheduler.common.task.Task)6 TaskVariable (org.ow2.proactive.scheduler.common.task.TaskVariable)6 IOException (java.io.IOException)5 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)5 SimpleScript (org.ow2.proactive.scripting.SimpleScript)5 TaskScript (org.ow2.proactive.scripting.TaskScript)5 NonTerminatingJob (functionaltests.jobs.NonTerminatingJob)4 SimpleJob (functionaltests.jobs.SimpleJob)4 FileNotFoundException (java.io.FileNotFoundException)4 XMLStreamException (javax.xml.stream.XMLStreamException)4 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)4