use of org.ow2.proactive.scheduler.common.exception.InternalException in project scheduling by ow2-proactive.
the class SchedulingService method changePolicy.
public boolean changePolicy(String newPolicyClassName) {
try {
if (status.isShuttingDown()) {
logger.warn("Policy can only be changed when Scheduler is up, current state : " + status);
return false;
}
// TODO class loading ? (for now, class must be in scheduler classpath or addons)
Policy newPolicy = (Policy) Class.forName(newPolicyClassName).newInstance();
// newPolicy.setCore(this);
if (!newPolicy.reloadConfig()) {
return false;
}
// if success, change current policy
policy = newPolicy;
listener.schedulerStateUpdated(SchedulerEvent.POLICY_CHANGED);
logger.info("Policy changed ! new policy name : " + newPolicyClassName);
return true;
} catch (InstantiationException e) {
logger.error("", e);
throw new InternalException("Exception occurs while instanciating the policy !", e);
} catch (IllegalAccessException e) {
logger.error("", e);
throw new InternalException("Exception occurs while accessing the policy !", e);
} catch (ClassNotFoundException e) {
logger.error("", e);
throw new InternalException("Exception occurs while loading the policy class !", e);
}
}
use of org.ow2.proactive.scheduler.common.exception.InternalException in project scheduling by ow2-proactive.
the class InternalJobFactory method createJob.
/**
* Create a new internal job with the given job (user).
*
* @param job the user job that will be used to create the internal job.
* @return the created internal job.
* @throws JobCreationException an exception if the factory cannot create the given job.
*/
public static InternalJob createJob(Job job, Credentials cred) throws JobCreationException {
InternalJob iJob;
if (logger.isDebugEnabled()) {
logger.debug("Create job '" + job.getName() + "' - " + job.getClass().getName());
}
switch(job.getType()) {
case PARAMETER_SWEEPING:
logger.error("The type of the given job is not yet implemented !");
throw new JobCreationException("The type of the given job is not yet implemented !");
case TASKSFLOW:
iJob = createJob((TaskFlowJob) job);
break;
default:
logger.error("The type of the given job is unknown !");
throw new JobCreationException("The type of the given job is unknown !");
}
try {
// set the job common properties
iJob.setCredentials(cred);
setJobCommonProperties(job, iJob);
return iJob;
} catch (Exception e) {
logger.error("", e);
throw new InternalException("Error while creating the internalJob !", e);
}
}
use of org.ow2.proactive.scheduler.common.exception.InternalException in project scheduling by ow2-proactive.
the class EnabledListenJobLogsSupport method listenJobLogs.
@Override
public synchronized void listenJobLogs(JobId jobId, AppenderProvider appenderProvider) throws UnknownJobException {
jlogger.info(jobId, "listening logs");
// create the appender to the remote listener
Appender clientAppender = null;
try {
clientAppender = appenderProvider.getAppender();
} catch (LogForwardingException e) {
jlogger.error(jobId, "cannot create an appender", e);
throw new InternalException("Cannot create an appender for job " + jobId, e);
}
boolean logIsAlreadyInitialized = jobsToBeLogged.contains(jobId);
initJobLogging(jobId, clientAppender);
JobResult result = dbManager.loadJobResult(jobId);
if (result == null) {
throw new UnknownJobException(jobId);
}
// for finished tasks, add logs events "manually"
Collection<TaskResult> allRes = result.getAllResults().values();
for (TaskResult tr : allRes) {
this.flushTaskLogs(tr, clientAppender, jobId);
}
for (RunningTaskData taskData : liveJobs.getRunningTasks(jobId)) {
jlogger.debug(jobId, "Handling log initialization for task " + taskData.getTask().getName());
try {
TaskLauncher taskLauncher = taskData.getLauncher();
if (logIsAlreadyInitialized) {
jlogger.debug(jobId, "Call getStoredLogs");
taskLauncher.getStoredLogs(appenderProvider);
} else {
jlogger.debug(jobId, "Call activateLogs");
taskLauncher.activateLogs(lfs.getAppenderProvider());
}
} catch (Exception e) {
tlogger.error(taskData.getTask().getId(), "cannot create an appender provider", e);
}
}
if (!result.getJobInfo().getStatus().isJobAlive()) {
jlogger.info(jobId, "cleaning loggers for already finished job");
cleanLoggers(jobId);
}
}
use of org.ow2.proactive.scheduler.common.exception.InternalException in project scheduling by ow2-proactive.
the class SchedulingService method linkResourceManager.
public boolean linkResourceManager(String rmURL) {
try {
// re-link the RM
getInfrastructure().getRMProxiesManager().rebindRMProxiesManager(new URI(rmURL.trim()));
logger.info("New resource manager has been linked to the scheduler");
if (status == SchedulerStatus.UNLINKED) {
logger.info("Resume to continue the scheduling.");
listener.schedulerStateUpdated(SchedulerEvent.RM_UP);
// restart the scheduler
status = SchedulerStatus.STARTED;
listener.schedulerStateUpdated(SchedulerEvent.STARTED);
}
return true;
} catch (Exception e) {
throw new InternalException("Error while connecting the new Resource Manager !", e);
}
}
Aggregations