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();
}
}
}
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;
}
Aggregations