use of org.ow2.proactive.scheduler.synchronization.SynchronizationWrapper 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);
}
}
use of org.ow2.proactive.scheduler.synchronization.SynchronizationWrapper 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;
}
Aggregations