Search in sources :

Example 1 with LauncherException

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;
}
Also used : LauncherException(edu.iu.dsc.tws.api.scheduler.LauncherException) ILauncher(edu.iu.dsc.tws.api.scheduler.ILauncher)

Example 2 with LauncherException

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();
    }
}
Also used : LauncherException(edu.iu.dsc.tws.api.scheduler.LauncherException) IUploader(edu.iu.dsc.tws.api.scheduler.IUploader) LocalFileSystemUploader(edu.iu.dsc.tws.rsched.uploaders.localfs.LocalFileSystemUploader) UploaderException(edu.iu.dsc.tws.api.scheduler.UploaderException) ILauncher(edu.iu.dsc.tws.api.scheduler.ILauncher)

Aggregations

ILauncher (edu.iu.dsc.tws.api.scheduler.ILauncher)2 LauncherException (edu.iu.dsc.tws.api.scheduler.LauncherException)2 IUploader (edu.iu.dsc.tws.api.scheduler.IUploader)1 UploaderException (edu.iu.dsc.tws.api.scheduler.UploaderException)1 LocalFileSystemUploader (edu.iu.dsc.tws.rsched.uploaders.localfs.LocalFileSystemUploader)1