Search in sources :

Example 6 with SimulationQueueEntryStatus

use of cbit.vcell.server.SimulationQueueEntryStatus in project vcell by virtualcell.

the class SimulationJobStatusEvent method fromJsonRep.

public static SimulationJobStatusEvent fromJsonRep(Object eventSource, SimulationJobStatusEventRepresentation eventRep) {
    String simid = Simulation.createSimulationID(new KeyValue(eventRep.jobStatus.simulationKey));
    int jobIndex = eventRep.jobStatus.jobIndex;
    int taskID = eventRep.jobStatus.taskID;
    VCellServerID serverID = VCellServerID.getServerID(eventRep.jobStatus.vcellServerID);
    KeyValue simkey = new KeyValue(eventRep.jobStatus.simulationKey);
    User owner = new User(eventRep.jobStatus.owner_userid, new KeyValue(eventRep.jobStatus.onwer_userkey));
    VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simkey, owner);
    Date submitDate = eventRep.jobStatus.submitDate;
    SchedulerStatus schedulerStatus = null;
    if (eventRep.jobStatus.schedulerStatus != null) {
        schedulerStatus = SchedulerStatus.valueOf(eventRep.jobStatus.schedulerStatus.name());
    }
    HtcJobID htcJobID = null;
    Long htcJobNumber = eventRep.jobStatus.htcJobNumber;
    SimulationJobStatusRepresentation.BatchSystemType htcBatchSystemType = eventRep.jobStatus.htcBatchSystemType;
    if (htcJobNumber != null) {
        htcJobID = new HtcJobID(htcJobNumber.toString(), BatchSystemType.valueOf(htcBatchSystemType.name()));
    }
    SimulationMessage simMessage = null;
    DetailedState detailedState = DetailedState.valueOf(eventRep.jobStatus.detailedState.name());
    String message = eventRep.jobStatus.detailedStateMessage;
    if (detailedState != null) {
        simMessage = SimulationMessage.create(detailedState, message, htcJobID);
    }
    SimulationQueueEntryStatus simQueueStatus = null;
    Date queueDate = eventRep.jobStatus.queueDate;
    Integer queuePriority = eventRep.jobStatus.queuePriority;
    SimulationJobStatusRepresentation.SimulationQueueID queueId2 = eventRep.jobStatus.queueId;
    if (queueDate != null && queuePriority != null) {
        simQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationQueueID.valueOf(queueId2.name()));
    }
    SimulationExecutionStatus simExeStatus = null;
    Date startDate = eventRep.jobStatus.simexe_startDate;
    String computeHost = eventRep.jobStatus.computeHost;
    Date latestUpdateDate = eventRep.jobStatus.simexe_latestUpdateDate;
    Date endDate = eventRep.jobStatus.simexe_endDate;
    Boolean hasData = eventRep.jobStatus.hasData;
    if (latestUpdateDate != null) {
        simExeStatus = new SimulationExecutionStatus(startDate, computeHost, latestUpdateDate, endDate, hasData, htcJobID);
    }
    SimulationJobStatus jobStatus = new SimulationJobStatus(serverID, vcSimID, jobIndex, submitDate, schedulerStatus, taskID, simMessage, simQueueStatus, simExeStatus);
    Double progress = eventRep.progress;
    Double timepoint = eventRep.timePoint;
    String username = eventRep.username;
    SimulationJobStatusEvent event = new SimulationJobStatusEvent(eventSource, simid, jobStatus, progress, timepoint, username);
    return event;
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) SimulationExecutionStatus(cbit.vcell.server.SimulationExecutionStatus) KeyValue(org.vcell.util.document.KeyValue) User(org.vcell.util.document.User) SchedulerStatus(cbit.vcell.server.SimulationJobStatus.SchedulerStatus) SimulationJobStatusRepresentation(org.vcell.api.common.events.SimulationJobStatusRepresentation) DetailedState(cbit.vcell.solver.server.SimulationMessage.DetailedState) SimulationQueueEntryStatus(cbit.vcell.server.SimulationQueueEntryStatus) Date(java.util.Date) VCellServerID(org.vcell.util.document.VCellServerID) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) SimulationMessage(cbit.vcell.solver.server.SimulationMessage) HtcJobID(cbit.vcell.server.HtcJobID)

Example 7 with SimulationQueueEntryStatus

use of cbit.vcell.server.SimulationQueueEntryStatus 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);
}
Also used : SimulationExecutionStatus(cbit.vcell.server.SimulationExecutionStatus) VCellServerID(org.vcell.util.document.VCellServerID) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) HtcJobID(cbit.vcell.server.HtcJobID) SimulationQueueEntryStatus(cbit.vcell.server.SimulationQueueEntryStatus) Date(java.util.Date) StatusMessage(cbit.vcell.message.messages.StatusMessage)

Example 8 with SimulationQueueEntryStatus

use of cbit.vcell.server.SimulationQueueEntryStatus 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));
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) SimulationExecutionStatus(cbit.vcell.server.SimulationExecutionStatus) SimulationTask(cbit.vcell.messaging.server.SimulationTask) SimulationQueueEntryStatus(cbit.vcell.server.SimulationQueueEntryStatus) Date(java.util.Date) StatusMessage(cbit.vcell.message.messages.StatusMessage) FieldDataIdentifierSpec(cbit.vcell.field.FieldDataIdentifierSpec) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) SimulationJob(cbit.vcell.solver.SimulationJob) SimulationTaskMessage(cbit.vcell.message.messages.SimulationTaskMessage)

Aggregations

SimulationExecutionStatus (cbit.vcell.server.SimulationExecutionStatus)8 SimulationQueueEntryStatus (cbit.vcell.server.SimulationQueueEntryStatus)8 SimulationJobStatus (cbit.vcell.server.SimulationJobStatus)7 Date (java.util.Date)7 StatusMessage (cbit.vcell.message.messages.StatusMessage)5 HtcJobID (cbit.vcell.server.HtcJobID)5 VCellServerID (org.vcell.util.document.VCellServerID)5 SchedulerStatus (cbit.vcell.server.SimulationJobStatus.SchedulerStatus)4 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)3 SimulationMessage (cbit.vcell.solver.server.SimulationMessage)3 SimulationJobStatusRepresentation (org.vcell.api.common.events.SimulationJobStatusRepresentation)2 KeyValue (org.vcell.util.document.KeyValue)2 FieldDataIdentifierSpec (cbit.vcell.field.FieldDataIdentifierSpec)1 VCMessage (cbit.vcell.message.VCMessage)1 SimulationTaskMessage (cbit.vcell.message.messages.SimulationTaskMessage)1 WorkerEventMessage (cbit.vcell.message.messages.WorkerEventMessage)1 SimulationTask (cbit.vcell.messaging.server.SimulationTask)1 RunningStateInfo (cbit.vcell.server.RunningStateInfo)1 SimulationQueueID (cbit.vcell.server.SimulationJobStatus.SimulationQueueID)1 SimulationJob (cbit.vcell.solver.SimulationJob)1