Search in sources :

Example 1 with HtcJobStatus

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

the class SlurmProxyTest method testSLURM.

// @Before
// public void setEnv() {
// //System.setProperty(PropertyLoader.htcSlurmHome,"/opt/slurm/");
// System.setProperty( PropertyLoader.htcLogDirExternal,"/home/htcLogs");
// System.setProperty( PropertyLoader.MPI_HOME_EXTERNAL,"/opt/mpich/");
// }
// 
// private void write(String name, String text) {
// try {
// File f = new File(name);
// HtcProxy.writeUnixStyleTextFile(f, text);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// 
// private void addExit(Container ctn) {
// final String eToken = "yada-yada";
// ExecutableCommand exitC = new ExecutableCommand(null,"echo",eToken);
// exitC.setExitCodeToken(eToken);
// ctn.add(exitC);
// 
// }
// 
// @Test
// public void tryIt( ) {
// Container ctn = new ExecutableCommand.Container();
// ExecutableCommand listdog = new ExecutableCommand(null,"ls");
// listdog.addArgument("dog");
// ctn.add(listdog);
// ctn.add(new ExecutableCommand(null,"wc","dog"));
// SlurmProxy spProxy = new SlurmProxy(null, "gerard");
// String text = spProxy.generateScript("Q_3", ctn, 1, 10.0, null);
// write("out.sh",text);
// }
// 
// @Test
// public void tryItWithExit( ) {
// Container ctn = new ExecutableCommand.Container();
// ctn.add(new ExecutableCommand(null,"ls","dog"));
// ctn.add(new ExecutableCommand(null,"wc","dog"));
// addExit(ctn);
// 
// SlurmProxy spProxy = new SlurmProxy(null, "gerard");
// String text = spProxy.generateScript("Q_3", ctn, 1, 10.0, null);
// write("outexit.sh",text);
// }
// 
// @Test(expected=UnsupportedOperationException.class)
// public void tryParallelBad( ) {
// Container ctn = new ExecutableCommand.Container();
// ctn.add(new ExecutableCommand(null,true,true,"wc","dog"));
// SlurmProxy spProxy = new SlurmProxy(null, "gerard");
// spProxy.generateScript("Q_3", ctn, 1, 10.0, null);
// }
// 
// @Test
// public void tryParallel( ) {
// Container ctn = new ExecutableCommand.Container();
// ctn.add(new ExecutableCommand(null,"ls","dog"));
// ctn.add(new ExecutableCommand(null,true,true,"wc","dog"));
// SlurmProxy spProxy = new SlurmProxy(null, "gerard");
// String text = spProxy.generateScript("Q_3", ctn, 4, 10.0, null);
// write("par.sh",text);
// }
// @Test
// public void tryParallelExit( ) {
// Container ctn = new ExecutableCommand.Container();
// addExit(ctn);
// ctn.add(new ExecutableCommand(null,"ls","dog"));
// ctn.add(new ExecutableCommand(null,true,true,"wc","dog"));
// SlurmProxy spProxy = new SlurmProxy(null, "gerard");
// String text = spProxy.generateScript("Q_3", ctn, 4, 10.0, null);
// write("parexit.sh",text);
// }
@Test
public void testSLURM() throws IOException, ExecutableException {
    System.setProperty(PropertyLoader.vcellServerIDProperty, "Test2");
    System.setProperty(PropertyLoader.htcLogDirExternal, "/Volumes/vcell/htclogs");
    VCMongoMessage.enabled = false;
    CommandServiceSshNative cmd = null;
    try {
        // for (int i=0;i<10000;i++) {
        cmd = new CommandServiceSshNative("vcell-service.cam.uchc.edu", "vcell", new File("/Users/schaff/.ssh/schaff_rsa"));
        SlurmProxy slurmProxy = new SlurmProxy(cmd, "vcell");
        Map<HtcJobID, JobInfoAndStatus> runningJobs = slurmProxy.getRunningJobs();
        for (HtcJobID job : runningJobs.keySet()) {
            HtcJobStatus jobStatus = runningJobs.get(job).status;
            System.out.println("job " + job.toString() + ", status=" + jobStatus.toString());
        }
        System.out.println("\n\n\n");
        Thread.sleep(100);
    // }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (cmd != null) {
            cmd.close();
        }
    }
}
Also used : HtcJobStatus(cbit.vcell.message.server.htc.HtcJobStatus) HtcJobID(cbit.vcell.server.HtcJobID) File(java.io.File) CommandServiceSshNative(cbit.vcell.message.server.cmd.CommandServiceSshNative) JobInfoAndStatus(cbit.vcell.message.server.htc.HtcProxy.JobInfoAndStatus) IOException(java.io.IOException) ExecutableException(org.vcell.util.exe.ExecutableException) Test(org.junit.Test)

Example 2 with HtcJobStatus

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

the class SlurmProxy method extractJobIds.

static Map<HtcJobID, JobInfoAndStatus> extractJobIds(String output) throws IOException {
    BufferedReader reader = new BufferedReader(new StringReader(output));
    String line = reader.readLine();
    if (!line.equals("JobID|JobName|Partition|User|AllocCPUS|NCPUS|NTasks|State|ExitCode")) {
        throw new RuntimeException("unexpected first line from sacct: '" + line + "'");
    }
    Map<HtcJobID, JobInfoAndStatus> statusMap = new HashMap<HtcJobID, JobInfoAndStatus>();
    while ((line = reader.readLine()) != null) {
        String[] tokens = line.split("\\|");
        String jobID = tokens[0];
        String jobName = tokens[1];
        String partition = tokens[2];
        String user = tokens[3];
        String allocCPUs = tokens[4];
        String ncpus = tokens[5];
        String ntasks = tokens[6];
        String state = tokens[7];
        String exitcode = tokens[8];
        if (jobName.equals("batch")) {
            continue;
        }
        HtcJobID htcJobID = new HtcJobID(jobID, BatchSystemType.SLURM);
        String errorPath = null;
        String outputPath = null;
        HtcJobInfo htcJobInfo = new HtcJobInfo(htcJobID, true, jobName, errorPath, outputPath);
        HtcJobStatus htcJobStatus = new HtcJobStatus(SlurmJobStatus.parseStatus(state));
        statusMap.put(htcJobID, new JobInfoAndStatus(htcJobInfo, htcJobStatus));
    }
    return statusMap;
}
Also used : HashMap(java.util.HashMap) HtcJobStatus(cbit.vcell.message.server.htc.HtcJobStatus) BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader) HtcJobID(cbit.vcell.server.HtcJobID)

Aggregations

HtcJobStatus (cbit.vcell.message.server.htc.HtcJobStatus)2 HtcJobID (cbit.vcell.server.HtcJobID)2 CommandServiceSshNative (cbit.vcell.message.server.cmd.CommandServiceSshNative)1 JobInfoAndStatus (cbit.vcell.message.server.htc.HtcProxy.JobInfoAndStatus)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 ExecutableException (org.vcell.util.exe.ExecutableException)1