Search in sources :

Example 1 with SignalApiImpl

use of org.ow2.proactive.scheduler.signal.SignalApiImpl in project scheduling by ow2-proactive.

the class TerminationData method terminateRunningTask.

private void terminateRunningTask(SchedulingService service, TaskTerminationData taskToTerminate, RunningTaskData taskData) {
    Map<String, String> genericInformation = new HashMap<>();
    VariablesMap variables = null;
    if (taskToTerminate.internalJob != null) {
        genericInformation = taskData.getTask().getRuntimeGenericInformation();
    }
    try {
        variables = getStringSerializableMap(service, taskToTerminate);
    } catch (Exception e) {
        logger.error("Exception occurred, fail to get variables into the cleaning script: ", e);
    }
    try {
        if (taskToTerminate.terminationStatus == ABORTED) {
            taskData.getLauncher().kill();
        }
    } catch (Throwable t) {
        logger.info("Cannot terminate task launcher for task '" + taskData.getTask().getId() + "'", t);
        try {
            logger.info("Task launcher that cannot be terminated is identified by " + taskData.getLauncher().toString());
        } catch (Throwable ignore) {
            logger.info("Getting information about Task launcher failed (remote object not accessible?)");
        }
    }
    try {
        logger.debug("Releasing nodes for task '" + taskData.getTask().getId() + "'");
        RMProxiesManager proxiesManager = service.getInfrastructure().getRMProxiesManager();
        proxiesManager.getUserRMProxy(taskData.getUser(), taskData.getCredentials()).releaseNodes(taskData.getNodes(), getCleaningScript(taskToTerminate, taskData), variables, genericInformation, taskToTerminate.taskData.getTask().getId(), service.addThirdPartyCredentials(taskData.getCredentials()), new SynchronizationWrapper(taskToTerminate.internalJob.getOwner(), taskData.getTask().getId(), taskToTerminate.internalJob.getSynchronizationAPI()), new SignalApiImpl(taskToTerminate.internalJob.getOwner(), taskData.getTask().getId(), taskToTerminate.internalJob.getSynchronizationAPI()));
    } catch (Throwable t) {
        logger.info("Failed to release nodes for task '" + taskData.getTask().getId() + "'", t);
    }
}
Also used : HashMap(java.util.HashMap) SignalApiImpl(org.ow2.proactive.scheduler.signal.SignalApiImpl) VariablesMap(org.ow2.proactive.scheduler.task.utils.VariablesMap) IOException(java.io.IOException) RMProxiesManager(org.ow2.proactive.scheduler.core.rmproxies.RMProxiesManager) SynchronizationWrapper(org.ow2.proactive.scheduler.synchronization.SynchronizationWrapper)

Example 2 with SignalApiImpl

use of org.ow2.proactive.scheduler.signal.SignalApiImpl in project scheduling by ow2-proactive.

the class InternalTask method getDefaultTaskLauncherInitializer.

/**
 * Prepare and return the default task launcher initializer (ie the one that works for every launcher)<br>
 * Concrete launcher may have to add values to the created initializer to bring more information to the launcher.
 *
 * @return the default created task launcher initializer
 */
protected TaskLauncherInitializer getDefaultTaskLauncherInitializer(String sessionid) throws IOException {
    TaskLauncherInitializer tli = new TaskLauncherInitializer();
    tli.setTaskId(getId());
    tli.setJobOwner(internalJob.getJobInfo().getJobOwner());
    tli.setSchedulerRestUrl(PASchedulerProperties.SCHEDULER_REST_URL.getValueAsStringOrNull());
    tli.setCatalogRestUrl(PASchedulerProperties.CATALOG_REST_URL.getValueAsStringOrNull());
    tli.setCloudAutomationRestUrl(PASchedulerProperties.CLOUD_AUTOMATION_REST_URL.getValueAsStringOrNull());
    tli.setJobPlannerRestUrl(PASchedulerProperties.JOB_PLANNER_REST_URL.getValueAsStringOrNull());
    tli.setNotificationServiceRestUrl(PASchedulerProperties.NOTIFICATION_SERVICE_REST_URL.getValueAsStringOrNull());
    tli.setSchedulerRestPublicUrl(PASchedulerProperties.SCHEDULER_REST_PUBLIC_URL.getValueAsStringOrNull());
    tli.setCatalogRestPublicUrl(PASchedulerProperties.CATALOG_REST_PUBLIC_URL.getValueAsStringOrNull());
    tli.setCloudAutomationRestPublicUrl(PASchedulerProperties.CLOUD_AUTOMATION_REST_PUBLIC_URL.getValueAsStringOrNull());
    tli.setJobPlannerRestPublicUrl(PASchedulerProperties.JOB_PLANNER_REST_PUBLIC_URL.getValueAsStringOrNull());
    tli.setNotificationServiceRestPublicUrl(PASchedulerProperties.NOTIFICATION_SERVICE_REST_PUBLIC_URL.getValueAsStringOrNull());
    if (getPreScript() != null) {
        tli.setPreScript(getPreScript());
        tli.getPreScript().setSessionid(sessionid);
    }
    if (getPostScript() != null) {
        tli.setPostScript(getPostScript());
        tli.getPostScript().setSessionid(sessionid);
    }
    if (getFlowScript() != null) {
        tli.setControlFlowScript(getFlowScript());
        tli.getControlFlowScript().setSessionid(sessionid);
    }
    tli.setTaskInputFiles(getInputFilesList());
    tli.setTaskOutputFiles(getOutputFilesList());
    tli.setNamingService(internalJob.getTaskDataSpaceApplications().get(getId().longValue()).getNamingServiceStub());
    tli.setIterationIndex(getIterationIndex());
    tli.setReplicationIndex(getReplicationIndex());
    Map<String, String> gInfo = getRuntimeGenericInformation();
    tli.setGenericInformation(gInfo);
    tli.setGlobalGenericInformation(internalJob.getGlobalGenericInformation());
    ForkEnvironment environment = getForkEnvironment();
    if (environment != null) {
        Script environmentScript = environment.getEnvScript();
        if ((environmentScript != null) && !isScriptAuthorized(getId(), environmentScript)) {
            tli.setAuthorizedForkEnvironmentScript(false);
        }
    }
    tli.setForkEnvironment(environment);
    if (tli.getForkEnvironment() != null && tli.getForkEnvironment().getEnvScript() != null) {
        tli.getForkEnvironment().getEnvScript().setSessionid(sessionid);
    }
    if (isWallTimeSet()) {
        tli.setWalltime(getRuntimeWallTime());
    }
    tli.setPreciousLogs(isPreciousLogs());
    tli.setJobVariables(internalJob.getVariables());
    tli.setGlobalVariables(internalJob.getGlobalVariables());
    tli.setTaskVariables(getVariables());
    tli.setPingPeriod(PASchedulerProperties.SCHEDULER_NODE_PING_FREQUENCY.getValueAsInt());
    tli.setPingAttempts(PASchedulerProperties.SCHEDULER_NODE_PING_ATTEMPTS.getValueAsInt());
    tli.setSynchronizationAPI(new SynchronizationWrapper(internalJob.getOwner(), getId(), internalJob.getSynchronizationAPI()));
    tli.setSignalAPI(new SignalApiImpl(internalJob.getOwner(), getId(), internalJob.getSynchronizationAPI()));
    return tli;
}
Also used : Script(org.ow2.proactive.scripting.Script) SignalApiImpl(org.ow2.proactive.scheduler.signal.SignalApiImpl) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) TaskLauncherInitializer(org.ow2.proactive.scheduler.task.TaskLauncherInitializer) SynchronizationWrapper(org.ow2.proactive.scheduler.synchronization.SynchronizationWrapper)

Example 3 with SignalApiImpl

use of org.ow2.proactive.scheduler.signal.SignalApiImpl in project scheduling by ow2-proactive.

the class SignalApiTest method classInit.

@BeforeClass
public static void classInit() throws IOException, ActiveObjectCreationException, NodeException, AlreadyBoundException {
    CentralPAPropertyRepository.PA_CLASSLOADING_USEHTTP.setValue(false);
    if (System.getProperty("log4j.configuration") == null) {
        // While logger is not configured and it not set with sys properties, use Console logger
        Logger.getRootLogger().getLoggerRepository().resetConfiguration();
        BasicConfigurator.configure(new ConsoleAppender(new PatternLayout("%m%n")));
        Logger.getRootLogger().setLevel(Level.DEBUG);
    }
    Logger.getLogger(SignalApiImpl.class).setLevel(Level.TRACE);
    tempFolder = folder.newFolder("signal");
    Node localNode = ProActiveRuntimeImpl.getProActiveRuntime().createLocalNode("signal-node-0", true, "signal-v-node-0");
    synchronizationInternal = PAActiveObject.newActive(AOSynchronization.class, new Object[] { tempFolder.getAbsolutePath() }, localNode);
    synchronizationInternal.createChannelIfAbsent(USER, TASK_ID, SIGNALS_CHANNEL, true);
    signalApi = new SignalApiImpl(USER, TASK_ID, synchronizationInternal);
    executor = Executors.newFixedThreadPool(2);
}
Also used : AOSynchronization(org.ow2.proactive.scheduler.synchronization.AOSynchronization) Node(org.objectweb.proactive.core.node.Node) PAActiveObject(org.objectweb.proactive.api.PAActiveObject)

Aggregations

SignalApiImpl (org.ow2.proactive.scheduler.signal.SignalApiImpl)2 SynchronizationWrapper (org.ow2.proactive.scheduler.synchronization.SynchronizationWrapper)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 PAActiveObject (org.objectweb.proactive.api.PAActiveObject)1 Node (org.objectweb.proactive.core.node.Node)1 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)1 RMProxiesManager (org.ow2.proactive.scheduler.core.rmproxies.RMProxiesManager)1 AOSynchronization (org.ow2.proactive.scheduler.synchronization.AOSynchronization)1 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)1 VariablesMap (org.ow2.proactive.scheduler.task.utils.VariablesMap)1 Script (org.ow2.proactive.scripting.Script)1