use of cbit.vcell.message.messages.StatusMessage in project vcell by virtualcell.
the class SimulationStateMachine method onSystemAbort.
public synchronized void onSystemAbort(SimulationJobStatus oldJobStatus, String failureMessage, SimulationDatabase simulationDatabase, VCMessageSession session) throws VCMessagingException, UpdateSynchronizationException, DataAccessException, SQLException {
updateSolverProcessTimestamp();
int taskID = oldJobStatus.getTaskID();
//
// status information (initialized as if new record)
//
Date startDate = null;
boolean hasData = false;
HtcJobID htcJobID = null;
String computeHost = null;
VCellServerID vcServerID = VCellServerID.getSystemServerID();
Date submitDate = null;
Date queueDate = null;
int queuePriority = PRIORITY_DEFAULT;
//
// update using previously stored status (if available).
//
SimulationExecutionStatus oldSimExeStatus = oldJobStatus.getSimulationExecutionStatus();
if (oldSimExeStatus != null && oldSimExeStatus.getStartDate() != null) {
startDate = oldSimExeStatus.getStartDate();
}
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 = oldJobStatus.getServerID();
submitDate = oldJobStatus.getSubmitDate();
SimulationQueueEntryStatus oldQueueStatus = oldJobStatus.getSimulationQueueEntryStatus();
if (oldQueueStatus != null && oldQueueStatus.getQueueDate() != null) {
queueDate = oldQueueStatus.getQueueDate();
}
if (oldQueueStatus != null) {
queuePriority = oldQueueStatus.getQueuePriority();
}
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
Date endDate = new Date();
Date lastUpdateDate = new Date();
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
SimulationJobStatus newJobStatus = new SimulationJobStatus(vcServerID, oldJobStatus.getVCSimulationIdentifier(), jobIndex, submitDate, SchedulerStatus.FAILED, taskID, SimulationMessage.jobFailed(failureMessage), newQueueStatus, newExeStatus);
simulationDatabase.updateSimulationJobStatus(newJobStatus);
// addStateMachineTransition(new StateMachineTransition(new AbortStateMachineEvent(taskID, failureMessage), oldJobStatus, newJobStatus));
String userName = VCMessagingConstants.USERNAME_PROPERTY_VALUE_ALL;
StatusMessage msgForClient = new StatusMessage(newJobStatus, userName, null, null);
msgForClient.sendToClient(session);
if (lg.isTraceEnabled())
lg.trace("Send status to client: " + msgForClient);
}
use of cbit.vcell.message.messages.StatusMessage in project vcell by virtualcell.
the class SimulationStateMachine method onDispatch.
public synchronized void onDispatch(Simulation simulation, SimulationJobStatus oldSimulationJobStatus, SimulationDatabase simulationDatabase, VCMessageSession session) throws VCMessagingException, DataAccessException, SQLException {
updateSolverProcessTimestamp();
VCSimulationIdentifier vcSimID = oldSimulationJobStatus.getVCSimulationIdentifier();
int taskID = oldSimulationJobStatus.getTaskID();
if (!oldSimulationJobStatus.getSchedulerStatus().isWaiting()) {
VCMongoMessage.sendInfo("onDispatch(" + vcSimID.getID() + ") Can't start, simulation[" + vcSimID + "] job [" + jobIndex + "] task [" + taskID + "] is already dispatched (" + oldSimulationJobStatus.getSchedulerStatus().getDescription() + ")");
throw new RuntimeException("Can't start, simulation[" + vcSimID + "] job [" + jobIndex + "] task [" + taskID + "] is already dispatched (" + oldSimulationJobStatus.getSchedulerStatus().getDescription() + ")");
}
FieldDataIdentifierSpec[] fieldDataIdentifierSpecs = simulationDatabase.getFieldDataIdentifierSpecs(simulation);
SimulationTask simulationTask = new SimulationTask(new SimulationJob(simulation, jobIndex, fieldDataIdentifierSpecs), taskID);
double requiredMemMB = simulationTask.getEstimatedMemorySizeMB();
double allowableMemMB = Double.parseDouble(PropertyLoader.getRequiredProperty(PropertyLoader.limitJobMemoryMB));
final SimulationJobStatus newSimJobStatus;
if (requiredMemMB > allowableMemMB) {
//
// fail the simulation
//
Date currentDate = new Date();
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(currentDate, PRIORITY_DEFAULT, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
SimulationExecutionStatus newSimExeStatus = new SimulationExecutionStatus(null, null, new Date(), null, false, null);
newSimJobStatus = new SimulationJobStatus(VCellServerID.getSystemServerID(), vcSimID, jobIndex, oldSimulationJobStatus.getSubmitDate(), SchedulerStatus.FAILED, taskID, SimulationMessage.jobFailed("simulation required " + requiredMemMB + "MB of memory, only " + allowableMemMB + "MB allowed"), newQueueStatus, newSimExeStatus);
simulationDatabase.updateSimulationJobStatus(newSimJobStatus);
StatusMessage message = new StatusMessage(newSimJobStatus, simulation.getVersion().getOwner().getName(), null, null);
message.sendToClient(session);
} else {
//
// dispatch the simulation, new queue status
//
Date currentDate = new Date();
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(currentDate, PRIORITY_DEFAULT, SimulationJobStatus.SimulationQueueID.QUEUE_ID_SIMULATIONJOB);
SimulationExecutionStatus newSimExeStatus = new SimulationExecutionStatus(null, null, new Date(), null, false, null);
newSimJobStatus = new SimulationJobStatus(VCellServerID.getSystemServerID(), vcSimID, jobIndex, oldSimulationJobStatus.getSubmitDate(), SchedulerStatus.DISPATCHED, taskID, SimulationMessage.MESSAGE_JOB_DISPATCHED, newQueueStatus, newSimExeStatus);
SimulationTaskMessage simTaskMessage = new SimulationTaskMessage(simulationTask);
simTaskMessage.sendSimulationTask(session);
simulationDatabase.updateSimulationJobStatus(newSimJobStatus);
StatusMessage message = new StatusMessage(newSimJobStatus, simulation.getVersion().getOwner().getName(), null, null);
message.sendToClient(session);
}
// addStateMachineTransition(new StateMachineTransition(new DispatchStateMachineEvent(taskID), oldSimulationJobStatus, newSimJobStatus));
}
Aggregations