Search in sources :

Example 1 with HtcJobNotFoundException

use of cbit.vcell.message.server.htc.HtcJobNotFoundException in project vcell by virtualcell.

the class SlurmProxy method killJobSafe.

@Override
public void killJobSafe(HtcJobInfo htcJobInfo) throws ExecutableException, HtcException {
    final String JOB_CMD_DELETE = PropertyLoader.getProperty(PropertyLoader.slurm_cmd_scancel, "scancel");
    String[] cmd = new String[] { JOB_CMD_DELETE, "--jobname", htcJobInfo.getJobName(), Long.toString(htcJobInfo.getHtcJobID().getJobNumber()) };
    try {
        // CommandOutput commandOutput = commandService.command(cmd, new int[] { 0, QDEL_JOB_NOT_FOUND_RETURN_CODE });
        if (LG.isDebugEnabled()) {
            LG.debug("killing SLURM job htcJobId=" + htcJobInfo + ": '" + CommandOutput.concatCommandStrings(cmd) + "'");
        }
        CommandOutput commandOutput = commandService.command(cmd, new int[] { 0, SCANCEL_JOB_NOT_FOUND_RETURN_CODE });
        Integer exitStatus = commandOutput.getExitStatus();
        String standardOut = commandOutput.getStandardOutput();
        if (exitStatus != null && exitStatus.intValue() == SCANCEL_JOB_NOT_FOUND_RETURN_CODE && standardOut != null && standardOut.toLowerCase().contains(SCANCEL_UNKNOWN_JOB_RESPONSE.toLowerCase())) {
            LG.error("failed to cancel SLURM htcJobId=" + htcJobInfo + ", job not found");
            throw new HtcJobNotFoundException(standardOut, htcJobInfo);
        }
    } catch (ExecutableException e) {
        LG.error("failed to cancel SLURM htcJobId=" + htcJobInfo, e);
        if (!e.getMessage().toLowerCase().contains(SCANCEL_UNKNOWN_JOB_RESPONSE.toLowerCase())) {
            throw e;
        } else {
            throw new HtcJobNotFoundException(e.getMessage(), htcJobInfo);
        }
    }
}
Also used : ExecutableException(org.vcell.util.exe.ExecutableException) HtcJobNotFoundException(cbit.vcell.message.server.htc.HtcJobNotFoundException) CommandOutput(cbit.vcell.message.server.cmd.CommandService.CommandOutput)

Example 2 with HtcJobNotFoundException

use of cbit.vcell.message.server.htc.HtcJobNotFoundException in project vcell by virtualcell.

the class SlurmProxy method killJob.

@Override
public void killJob(HtcJobID htcJobId) throws ExecutableException, HtcException {
    String[] cmd = new String[] { Slurm_HOME + JOB_CMD_DELETE, Long.toString(htcJobId.getJobNumber()) };
    try {
        // CommandOutput commandOutput = commandService.command(cmd, new int[] { 0, QDEL_JOB_NOT_FOUND_RETURN_CODE });
        if (LG.isDebugEnabled()) {
            LG.debug("killing SLURM job htcJobId=" + htcJobId + ": '" + CommandOutput.concatCommandStrings(cmd) + "'");
        }
        CommandOutput commandOutput = commandService.command(cmd, new int[] { 0, SCANCEL_JOB_NOT_FOUND_RETURN_CODE });
        Integer exitStatus = commandOutput.getExitStatus();
        String standardOut = commandOutput.getStandardOutput();
        if (exitStatus != null && exitStatus.intValue() == SCANCEL_JOB_NOT_FOUND_RETURN_CODE && standardOut != null && standardOut.toLowerCase().contains(SCANCEL_UNKNOWN_JOB_RESPONSE.toLowerCase())) {
            LG.error("failed to cancel SLURM htcJobId=" + htcJobId + ", job not found");
            throw new HtcJobNotFoundException(standardOut, htcJobId);
        }
    } catch (ExecutableException e) {
        LG.error("failed to cancel SLURM htcJobId=" + htcJobId, e);
        if (!e.getMessage().toLowerCase().contains(SCANCEL_UNKNOWN_JOB_RESPONSE.toLowerCase())) {
            throw e;
        } else {
            throw new HtcJobNotFoundException(e.getMessage(), htcJobId);
        }
    }
}
Also used : ExecutableException(org.vcell.util.exe.ExecutableException) HtcJobNotFoundException(cbit.vcell.message.server.htc.HtcJobNotFoundException) CommandOutput(cbit.vcell.message.server.cmd.CommandService.CommandOutput)

Example 3 with HtcJobNotFoundException

use of cbit.vcell.message.server.htc.HtcJobNotFoundException in project vcell by virtualcell.

the class SlurmProxy method killJobUnsafe.

@Override
public void killJobUnsafe(HtcJobID htcJobId) throws ExecutableException, HtcException {
    final String JOB_CMD_DELETE = PropertyLoader.getProperty(PropertyLoader.slurm_cmd_scancel, "scancel");
    String[] cmd = new String[] { JOB_CMD_DELETE, Long.toString(htcJobId.getJobNumber()) };
    try {
        // CommandOutput commandOutput = commandService.command(cmd, new int[] { 0, QDEL_JOB_NOT_FOUND_RETURN_CODE });
        if (LG.isDebugEnabled()) {
            LG.debug("killing SLURM job htcJobId=" + htcJobId + ": '" + CommandOutput.concatCommandStrings(cmd) + "'");
        }
        CommandOutput commandOutput = commandService.command(cmd, new int[] { 0, SCANCEL_JOB_NOT_FOUND_RETURN_CODE });
        Integer exitStatus = commandOutput.getExitStatus();
        String standardOut = commandOutput.getStandardOutput();
        if (exitStatus != null && exitStatus.intValue() == SCANCEL_JOB_NOT_FOUND_RETURN_CODE && standardOut != null && standardOut.toLowerCase().contains(SCANCEL_UNKNOWN_JOB_RESPONSE.toLowerCase())) {
            LG.error("failed to cancel SLURM htcJobId=" + htcJobId + ", job not found");
            throw new HtcJobNotFoundException(standardOut, htcJobId);
        }
    } catch (ExecutableException e) {
        LG.error("failed to cancel SLURM htcJobId=" + htcJobId, e);
        if (!e.getMessage().toLowerCase().contains(SCANCEL_UNKNOWN_JOB_RESPONSE.toLowerCase())) {
            throw e;
        } else {
            throw new HtcJobNotFoundException(e.getMessage(), htcJobId);
        }
    }
}
Also used : ExecutableException(org.vcell.util.exe.ExecutableException) HtcJobNotFoundException(cbit.vcell.message.server.htc.HtcJobNotFoundException) CommandOutput(cbit.vcell.message.server.cmd.CommandService.CommandOutput)

Aggregations

CommandOutput (cbit.vcell.message.server.cmd.CommandService.CommandOutput)3 HtcJobNotFoundException (cbit.vcell.message.server.htc.HtcJobNotFoundException)3 ExecutableException (org.vcell.util.exe.ExecutableException)3