use of cbit.vcell.server.HtcJobID in project vcell by virtualcell.
the class SimulationJobStatusEvent method toJsonRep.
public SimulationJobStatusEventRepresentation toJsonRep() {
String vcellServerID = this.jobStatus.getServerID().toString();
Date timeDateStamp = this.jobStatus.getTimeDateStamp();
String simulationKey = this.jobStatus.getVCSimulationIdentifier().getSimulationKey().toString();
int taskID = this.jobStatus.getTaskID();
int jobIndex = this.jobStatus.getJobIndex();
Date submitDate = this.jobStatus.getSubmitDate();
String owner_userid = this.username;
String onwer_userkey = this.jobStatus.getVCSimulationIdentifier().getOwner().getID().toString();
SimulationJobStatusRepresentation.SchedulerStatus schedulerStatus = SimulationJobStatusRepresentation.SchedulerStatus.valueOf(this.jobStatus.getSchedulerStatus().name());
SimulationJobStatusRepresentation.DetailedState detailedState = SimulationJobStatusRepresentation.DetailedState.valueOf(this.jobStatus.getSimulationMessage().getDetailedState().name());
String detailedStateMessage = this.jobStatus.getSimulationMessage().getDisplayMessage();
Long htcJobNumber = null;
String htcComputeServer = null;
SimulationJobStatusRepresentation.BatchSystemType htcBatchSystemType = null;
Date simexe_startDate = null;
Date simexe_latestUpdateDate = null;
Date simexe_endDate = null;
String computeHost = null;
Boolean hasData = null;
SimulationExecutionStatus simExeStatus = this.jobStatus.getSimulationExecutionStatus();
if (simExeStatus != null) {
HtcJobID htcJobID = simExeStatus.getHtcJobID();
if (htcJobID != null) {
htcJobNumber = htcJobID.getJobNumber();
htcComputeServer = htcJobID.getServer();
htcBatchSystemType = SimulationJobStatusRepresentation.BatchSystemType.valueOf(htcJobID.getBatchSystemType().name());
}
simexe_startDate = simExeStatus.getStartDate();
simexe_latestUpdateDate = simExeStatus.getLatestUpdateDate();
simexe_endDate = simExeStatus.getEndDate();
computeHost = simExeStatus.getComputeHost();
hasData = simExeStatus.hasData();
}
Integer queuePriority = null;
Date queueDate = null;
SimulationJobStatusRepresentation.SimulationQueueID queueId = null;
SimulationQueueEntryStatus simQueueStatus = this.jobStatus.getSimulationQueueEntryStatus();
if (simQueueStatus != null) {
queuePriority = simQueueStatus.getQueuePriority();
queueDate = simQueueStatus.getQueueDate();
queueId = SimulationJobStatusRepresentation.SimulationQueueID.valueOf(simQueueStatus.getQueueID().name());
}
SimulationJobStatusRepresentation jobStatus = new SimulationJobStatusRepresentation(vcellServerID, timeDateStamp, simulationKey, taskID, jobIndex, submitDate, owner_userid, onwer_userkey, schedulerStatus, detailedState, detailedStateMessage, htcJobNumber, htcComputeServer, htcBatchSystemType, queuePriority, queueDate, queueId, simexe_startDate, simexe_latestUpdateDate, simexe_endDate, computeHost, hasData);
SimulationJobStatusEventRepresentation eventRep = new SimulationJobStatusEventRepresentation(jobStatus, progress, timePoint, username);
return eventRep;
}
use of cbit.vcell.server.HtcJobID in project vcell by virtualcell.
the class HtcProxyTest method test_isMyJob.
@Test
public void test_isMyJob() {
System.setProperty(PropertyLoader.vcellServerIDProperty, "ALPHA");
Assert.assertTrue(HtcProxy.isMyJob(new HtcJobInfo(new HtcJobID("1200725", BatchSystemType.SLURM), true, "V_ALPHA_115785823_0_0", null, null)));
Assert.assertFalse(HtcProxy.isMyJob(new HtcJobInfo(new HtcJobID("1200725", BatchSystemType.SLURM), true, "V_BETA_115785823_0_0", null, null)));
System.setProperty(PropertyLoader.vcellServerIDProperty, "BETA");
Assert.assertTrue(HtcProxy.isMyJob(new HtcJobInfo(new HtcJobID("1200725", BatchSystemType.SLURM), true, "V_BETA_115785823_0_0", null, null)));
}
use of cbit.vcell.server.HtcJobID 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.server.HtcJobID in project vcell by virtualcell.
the class JobIdTest method sysDiff.
private void sysDiff(BatchSystemType bt) {
long n = r.nextLong();
HtcJobID x = gen(n, bt, null);
HtcJobID y = gen(n + 1, bt, null);
assertFalse(x.equals(y));
assertFalse(x.compareEqual(y));
String serverx = randomServer();
String servery = randomServer();
x = gen(n, bt, serverx);
y = gen(n + 1, bt, servery);
assertFalse(x.equals(y));
assertFalse(x.compareEqual(y));
}
use of cbit.vcell.server.HtcJobID in project vcell by virtualcell.
the class SimulationStateMachine method onWorkerEvent.
public synchronized void onWorkerEvent(WorkerEvent workerEvent, SimulationDatabase simulationDatabase, VCMessageSession session) throws DataAccessException, VCMessagingException, SQLException {
updateSolverProcessTimestamp();
WorkerEventMessage workerEventMessage = new WorkerEventMessage(workerEvent);
VCMongoMessage.sendWorkerEvent(workerEventMessage);
// as the filter of the client
String userName = workerEvent.getUserName();
int workerEventTaskID = workerEvent.getTaskID();
if (lg.isTraceEnabled())
lg.trace("onWorkerEventMessage[" + workerEvent.getEventTypeID() + "," + workerEvent.getSimulationMessage() + "][simid=" + workerEvent.getVCSimulationDataIdentifier() + ",job=" + jobIndex + ",task=" + workerEventTaskID + "]");
VCSimulationDataIdentifier vcSimDataID = workerEvent.getVCSimulationDataIdentifier();
if (vcSimDataID == null) {
VCMongoMessage.sendInfo("onWorkerEvent() ignoring WorkerEvent - no SimID in message): " + workerEvent.show());
return;
}
KeyValue simKey = vcSimDataID.getSimulationKey();
SimulationJobStatus oldSimulationJobStatus = simulationDatabase.getLatestSimulationJobStatus(simKey, jobIndex);
if (oldSimulationJobStatus == null) {
VCMongoMessage.sendInfo("onWorkerEvent() ignoring WorkerEvent, no current SimulationJobStatus: " + workerEvent.show());
return;
}
if (oldSimulationJobStatus == null || oldSimulationJobStatus.getSchedulerStatus().isDone() || oldSimulationJobStatus.getTaskID() > workerEventTaskID) {
VCMongoMessage.sendInfo("onWorkerEvent() ignoring outdated WorkerEvent, (currState=" + oldSimulationJobStatus.getSchedulerStatus().getDescription() + "): " + workerEvent.show());
return;
}
int taskID = oldSimulationJobStatus.getTaskID();
SchedulerStatus oldSchedulerStatus = oldSimulationJobStatus.getSchedulerStatus();
//
// status information (initialized as if new record)
//
Date startDate = null;
Date lastUpdateDate = null;
Date endDate = null;
boolean hasData = false;
HtcJobID htcJobID = null;
String computeHost = null;
VCellServerID vcServerID = VCellServerID.getSystemServerID();
Date submitDate = null;
Date queueDate = null;
int queuePriority = PRIORITY_DEFAULT;
SimulationJobStatus.SimulationQueueID simQueueID = SimulationJobStatus.SimulationQueueID.QUEUE_ID_WAITING;
//
// update using previously stored status (if available).
//
SimulationExecutionStatus oldSimExeStatus = oldSimulationJobStatus.getSimulationExecutionStatus();
if (oldSimExeStatus != null && oldSimExeStatus.getStartDate() != null) {
startDate = oldSimExeStatus.getStartDate();
}
if (oldSimExeStatus != null && oldSimExeStatus.getLatestUpdateDate() != null) {
lastUpdateDate = oldSimExeStatus.getLatestUpdateDate();
}
if (oldSimExeStatus != null && oldSimExeStatus.getEndDate() != null) {
endDate = oldSimExeStatus.getEndDate();
}
if (oldSimExeStatus != null && oldSimExeStatus.hasData()) {
hasData = true;
}
if (oldSimExeStatus != null && oldSimExeStatus.getComputeHost() != null) {
computeHost = oldSimExeStatus.getComputeHost();
}
if (oldSimExeStatus != null && oldSimExeStatus.getHtcJobID() != null) {
htcJobID = oldSimExeStatus.getHtcJobID();
}
vcServerID = oldSimulationJobStatus.getServerID();
submitDate = oldSimulationJobStatus.getSubmitDate();
SimulationQueueEntryStatus oldQueueStatus = oldSimulationJobStatus.getSimulationQueueEntryStatus();
if (oldQueueStatus != null && oldQueueStatus.getQueueDate() != null) {
queueDate = oldQueueStatus.getQueueDate();
}
if (oldQueueStatus != null) {
queuePriority = oldQueueStatus.getQueuePriority();
}
if (oldQueueStatus != null && oldQueueStatus.getQueueID() != null) {
simQueueID = oldQueueStatus.getQueueID();
}
//
if (workerEvent.getHtcJobID() != null) {
htcJobID = workerEvent.getHtcJobID();
}
if (workerEvent.getHostName() != null) {
computeHost = workerEvent.getHostName();
}
SimulationMessage workerEventSimulationMessage = workerEvent.getSimulationMessage();
if (workerEventSimulationMessage.getHtcJobId() != null) {
htcJobID = workerEventSimulationMessage.getHtcJobId();
}
SimulationJobStatus newJobStatus = null;
if (workerEvent.isAcceptedEvent()) {
//
if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued()) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
// new exe status
lastUpdateDate = new Date();
startDate = lastUpdateDate;
endDate = null;
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.DISPATCHED, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
}
} else if (workerEvent.isStartingEvent()) {
// only update database when the job event changes from started to running. The later progress event will not be recorded.
if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
// new exe status
lastUpdateDate = new Date();
if (startDate == null) {
startDate = lastUpdateDate;
}
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.RUNNING, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
}
} else if (workerEvent.isNewDataEvent()) {
if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
if (!oldSchedulerStatus.isRunning() || simQueueID != SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL || hasData == false) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
// new exe status
if (startDate == null) {
startDate = lastUpdateDate;
}
hasData = true;
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.RUNNING, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
}
}
} else if (workerEvent.isProgressEvent() || workerEvent.isWorkerAliveEvent()) {
if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
if (!oldSchedulerStatus.isRunning() || simQueueID != SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
// new exe status
if (startDate == null) {
startDate = lastUpdateDate;
}
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.RUNNING, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
} else if (oldSchedulerStatus.isRunning()) {
if (oldSimExeStatus != null) {
// Date latestUpdate = oldSimExeStatus.getLatestUpdateDate();
// if (System.currentTimeMillis() - latestUpdate.getTime() >= MessageConstants.INTERVAL_PING_SERVER_MS * 3 / 5) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.RUNNING, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
}
// }
}
}
} else if (workerEvent.isCompletedEvent()) {
if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
// new exe status
endDate = new Date();
hasData = true;
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.COMPLETED, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
}
} else if (workerEvent.isFailedEvent()) {
if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
// new exe status
endDate = new Date();
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.FAILED, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
}
} else if (workerEvent.isWorkerExitErrorEvent()) {
if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
// new exe status
endDate = new Date();
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
SimulationMessage simulationMessage = SimulationMessage.workerFailure("solver stopped unexpectedly, " + workerEventSimulationMessage.getDisplayMessage());
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.FAILED, taskID, simulationMessage, newQueueStatus, newExeStatus);
}
}
if (newJobStatus != null) {
if (!newJobStatus.compareEqual(oldSimulationJobStatus) || workerEvent.isProgressEvent() || workerEvent.isNewDataEvent()) {
Double progress = workerEvent.getProgress();
Double timepoint = workerEvent.getTimePoint();
RunningStateInfo runningStateInfo = null;
if (progress != null && timepoint != null) {
runningStateInfo = new RunningStateInfo(progress, timepoint);
}
simulationDatabase.updateSimulationJobStatus(newJobStatus, runningStateInfo);
StatusMessage msgForClient = new StatusMessage(newJobStatus, userName, progress, timepoint);
msgForClient.sendToClient(session);
if (lg.isTraceEnabled())
lg.trace("Send status to client: " + msgForClient);
} else {
simulationDatabase.updateSimulationJobStatus(newJobStatus);
StatusMessage msgForClient = new StatusMessage(newJobStatus, userName, null, null);
msgForClient.sendToClient(session);
if (lg.isTraceEnabled())
lg.trace("Send status to client: " + msgForClient);
}
} else if (workerEvent.isProgressEvent() || workerEvent.isNewDataEvent()) {
Double progress = workerEvent.getProgress();
Double timepoint = workerEvent.getTimePoint();
RunningStateInfo runningStateInfo = null;
if (progress != null && timepoint != null) {
runningStateInfo = new RunningStateInfo(progress, timepoint);
}
simulationDatabase.updateSimulationJobStatus(oldSimulationJobStatus, runningStateInfo);
StatusMessage msgForClient = new StatusMessage(oldSimulationJobStatus, userName, progress, timepoint);
msgForClient.sendToClient(session);
if (lg.isTraceEnabled())
lg.trace("Send status to client: " + msgForClient);
} else {
VCMongoMessage.sendInfo("onWorkerEvent() ignoring WorkerEvent (currState=" + oldSchedulerStatus.getDescription() + "): " + workerEvent.show());
}
// addStateMachineTransition(new StateMachineTransition(new WorkerStateMachineEvent(taskID, workerEvent), oldSimulationJobStatus, newJobStatus));
}
Aggregations