Search in sources :

Example 1 with InvalidChannelException

use of org.ow2.proactive.scheduler.synchronization.InvalidChannelException in project scheduling by ow2-proactive.

the class SignalApiTest method testReadyForSignalWithVariables.

@Test
public void testReadyForSignalWithVariables() throws SignalApiException, InvalidChannelException {
    String signalName = "test_signal_1";
    JobVariable jobVariable1 = new JobVariable("name1", "value1");
    JobVariable jobVariable2 = new JobVariable("name2", "value2");
    List<JobVariable> jobVariables = new ArrayList<>();
    jobVariables.add(jobVariable1);
    jobVariables.add(jobVariable2);
    signalApi.readyForSignal(signalName, jobVariables);
    Assert.assertTrue(((Signal) synchronizationInternal.get(USER, TASK_ID, SIGNALS_CHANNEL + JOB_ID.value(), READY_PREFIX + signalName)).getName().equals(signalName));
    Assert.assertNotNull((synchronizationInternal.get(USER, TASK_ID, SIGNALS_CHANNEL + JOB_ID.value(), READY_PREFIX + signalName)));
    Assert.assertEquals(jobVariables, ((Signal) synchronizationInternal.get(USER, TASK_ID, SIGNALS_CHANNEL + JOB_ID.value(), READY_PREFIX + signalName)).getInputVariables());
}
Also used : JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Example 2 with InvalidChannelException

use of org.ow2.proactive.scheduler.synchronization.InvalidChannelException in project scheduling by ow2-proactive.

the class AOSynchronization method executeWaitPredicateFunction.

/**
 * Extract from the request the parameters corresponding to the waitUntil method call, then execute waitUntil with these parameters
 * @param request request used to extract parameters
 * @return the result of the waitUntil method call
 */
private boolean executeWaitPredicateFunction(Request request) throws InvalidChannelException, CompilationException {
    // extract the parameters which match the waitUntil call
    int paramIndex = 0;
    String originator = (String) request.getParameter(paramIndex++);
    TaskId taskId = (TaskId) request.getParameter(paramIndex++);
    String channel = (String) request.getParameter(paramIndex++);
    String key = (String) request.getParameter(paramIndex++);
    String predicate = (String) request.getParameter(paramIndex);
    return this.executeWaitPredicate(originator, taskId, channel, key, predicate);
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId)

Example 3 with InvalidChannelException

use of org.ow2.proactive.scheduler.synchronization.InvalidChannelException 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 4 with InvalidChannelException

use of org.ow2.proactive.scheduler.synchronization.InvalidChannelException in project scheduling by ow2-proactive.

the class SchedulerFrontend method validateJobSignal.

@Override
@ImmediateService
public List<JobVariable> validateJobSignal(String jobId, String signalName, Map<String, String> updatedVariables) throws NotConnectedException, UnknownJobException, PermissionException, SignalApiException, JobValidationException {
    if (updatedVariables == null || updatedVariables.isEmpty()) {
        return null;
    }
    String currentUser = frontendState.getCurrentUser();
    logger.debug("Request to validate signal " + signalName + " on job " + jobId + " received from " + currentUser);
    final JobId jobIdObject = JobIdImpl.makeJobId(jobId);
    frontendState.checkPermissions("addJobSignal", frontendState.getIdentifiedJob(jobIdObject), YOU_DO_NOT_HAVE_PERMISSION_TO_SEND_SIGNALS_TO_THIS_JOB);
    String readyPrefix = SignalApiImpl.READY_PREFIX;
    if (StringUtils.isBlank(signalName.trim())) {
        throw new SignalApiException("Empty signals are not allowed");
    }
    try {
        TaskId taskId = createFakeTaskId(jobId);
        publicStore.createChannelIfAbsent(SIGNAL_ORIGINATOR, taskId, signalsChannel + jobId, true);
        Signal signal = (Signal) publicStore.get(SIGNAL_ORIGINATOR, taskId, signalsChannel + jobId, readyPrefix + signalName);
        if (signal != null) {
            DefaultModelJobValidatorServiceProvider validatorServiceProvider = new DefaultModelJobValidatorServiceProvider();
            Map<String, Serializable> serializableUpdatedVariables = new LinkedHashMap<>();
            serializableUpdatedVariables.putAll(updatedVariables);
            validatorServiceProvider.validateVariables(signal.getInputVariables(), serializableUpdatedVariables, this, this);
            return signal.getInputVariables();
        } else {
            throw new SignalApiException("Signal not found");
        }
    } catch (InvalidChannelException e) {
        throw new SignalApiException("Could not read signals channel", e);
    } catch (IOException e) {
        throw new SignalApiException("Could not add signalName for the job " + jobId, e);
    }
}
Also used : InvalidChannelException(org.ow2.proactive.scheduler.synchronization.InvalidChannelException) Signal(org.ow2.proactive.scheduler.signal.Signal) DefaultModelJobValidatorServiceProvider(org.ow2.proactive.scheduler.common.job.factories.spi.model.DefaultModelJobValidatorServiceProvider) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) SignalApiException(org.ow2.proactive.scheduler.signal.SignalApiException) JobId(org.ow2.proactive.scheduler.common.job.JobId) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 5 with InvalidChannelException

use of org.ow2.proactive.scheduler.synchronization.InvalidChannelException in project scheduling by ow2-proactive.

the class SchedulerFrontend method addJobSignal.

@Override
@ImmediateService
public Set<String> addJobSignal(String jobId, String signalName, Map<String, String> updatedVariables) throws NotConnectedException, UnknownJobException, PermissionException, SignalApiException, JobValidationException {
    String currentUser = frontendState.getCurrentUser();
    logger.info("Request to send signalName " + signalName + " on job " + jobId + " received from " + currentUser);
    final JobId jobIdObject = JobIdImpl.makeJobId(jobId);
    frontendState.checkPermissions("addJobSignal", frontendState.getIdentifiedJob(jobIdObject), YOU_DO_NOT_HAVE_PERMISSION_TO_SEND_SIGNALS_TO_THIS_JOB);
    if (StringUtils.isBlank(signalName.trim())) {
        throw new SignalApiException("Empty signals are not allowed");
    }
    try {
        TaskId taskId = createFakeTaskId(jobId);
        publicStore.createChannelIfAbsent(SIGNAL_ORIGINATOR, taskId, signalsChannel + jobId, true);
        Set<String> signals = publicStore.keySet(SIGNAL_ORIGINATOR, taskId, signalsChannel + jobId);
        String readyPrefix = SignalApiImpl.READY_PREFIX;
        if (!(signals.contains(readyPrefix + signalName) || signalName.startsWith(readyPrefix))) {
            throw new SignalApiException("Job " + jobId + " is not ready to receive the signalName " + signalName);
        }
        // Remove the existing ready signalName, add the signalName and return the set of signals
        Signal readySignal = (Signal) publicStore.get(SIGNAL_ORIGINATOR, taskId, signalsChannel + jobId, readyPrefix + signalName);
        setUpdatedVariables(updatedVariables, readySignal);
        publicStore.remove(SIGNAL_ORIGINATOR, taskId, signalsChannel + jobId, readyPrefix + signalName);
        publicStore.put(SIGNAL_ORIGINATOR, taskId, signalsChannel + jobId, signalName, readySignal);
        Set<String> finalSignals = publicStore.keySet(SIGNAL_ORIGINATOR, taskId, signalsChannel + jobId);
        return finalSignals;
    } catch (InvalidChannelException e) {
        throw new SignalApiException("Could not read signals channel", e);
    } catch (IOException e) {
        throw new SignalApiException("Could not add signalName for the job " + jobId, e);
    }
}
Also used : InvalidChannelException(org.ow2.proactive.scheduler.synchronization.InvalidChannelException) Signal(org.ow2.proactive.scheduler.signal.Signal) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) SignalApiException(org.ow2.proactive.scheduler.signal.SignalApiException) JobId(org.ow2.proactive.scheduler.common.job.JobId) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Aggregations

TaskId (org.ow2.proactive.scheduler.common.task.TaskId)4 ImmediateService (org.objectweb.proactive.annotation.ImmediateService)3 JobId (org.ow2.proactive.scheduler.common.job.JobId)2 JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)2 Signal (org.ow2.proactive.scheduler.signal.Signal)2 SignalApiException (org.ow2.proactive.scheduler.signal.SignalApiException)2 InvalidChannelException (org.ow2.proactive.scheduler.synchronization.InvalidChannelException)2 java.io (java.io)1 URI (java.net.URI)1 Charset (java.nio.charset.Charset)1 KeyException (java.security.KeyException)1 PublicKey (java.security.PublicKey)1 java.util (java.util)1 ExecutorService (java.util.concurrent.ExecutorService)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 Subject (javax.security.auth.Subject)1 javax.xml.transform (javax.xml.transform)1