use of edu.iu.dsc.tws.api.scheduler.LauncherException in project twister2 by DSC-SPIDAL.
the class ResourceAllocator method initializeLauncher.
private ILauncher initializeLauncher() {
String launcherClass = SchedulerContext.launcherClass(config);
ILauncher launcher;
ClassLoader classLoader = ResourceAllocator.class.getClassLoader();
// create an instance of launcher
try {
launcher = ReflectionUtils.newInstance(classLoader, launcherClass);
} catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
throw new LauncherException(String.format("Failed to instantiate launcher class '%s'", launcherClass), e);
}
// initialize the launcher
launcher.initialize(config);
return launcher;
}
use of edu.iu.dsc.tws.api.scheduler.LauncherException in project twister2 by DSC-SPIDAL.
the class ResourceAllocator method killJob.
/**
* Kill the job
*
* @param jobID of the job to kill
*/
public static void killJob(String jobID, Config cnfg) {
String launcherClass = SchedulerContext.launcherClass(cnfg);
if (launcherClass == null) {
throw new RuntimeException("The launcher class must be specified");
}
ILauncher launcher;
ClassLoader classLoader = ResourceAllocator.class.getClassLoader();
// create an instance of launcher
try {
launcher = ReflectionUtils.newInstance(classLoader, launcherClass);
} catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
throw new LauncherException(String.format("Failed to instantiate launcher class '%s'", launcherClass), e);
}
// initialize the launcher and terminate the job
launcher.initialize(cnfg);
boolean killed = launcher.killJob(jobID);
if (!killed) {
LOG.log(Level.SEVERE, "Could not kill the job");
}
String uploaderClass = SchedulerContext.uploaderClass(cnfg);
if (uploaderClass == null) {
throw new RuntimeException("The uploader class must be specified");
}
IUploader uploader;
// create an instance of uploader
try {
uploader = ReflectionUtils.newInstance(classLoader, uploaderClass);
} catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
throw new UploaderException(String.format("Failed to instantiate uploader class '%s'", uploaderClass), e);
}
uploader.initialize(cnfg, jobID);
uploader.undo();
launcher.close();
uploader.close();
if (KubernetesContext.isKubernetesCluster(cnfg)) {
KubernetesController.close();
}
if (CheckpointingContext.isCheckpointingEnabled(cnfg) && !SchedulerContext.uploaderClass(cnfg).equals("edu.iu.dsc.tws.rsched.uploaders.localfs.LocalFileSystemUploader")) {
IUploader localUploader = new LocalFileSystemUploader();
localUploader.initialize(cnfg, jobID);
localUploader.undo();
}
}
Aggregations