Search in sources :

Example 6 with SimulationJobStatus

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

the class SimulationStateMachine method onStopRequest.

public synchronized void onStopRequest(User user, SimulationJobStatus simJobStatus, SimulationDatabase simulationDatabase, VCMessageSession session) throws VCMessagingException, DataAccessException, SQLException {
    updateSolverProcessTimestamp();
    if (!user.equals(simJobStatus.getVCSimulationIdentifier().getOwner())) {
        lg.error(user + " is not authorized to stop simulation (key=" + simKey + ")");
        StatusMessage message = new StatusMessage(new SimulationJobStatus(VCellServerID.getSystemServerID(), simJobStatus.getVCSimulationIdentifier(), 0, null, SchedulerStatus.FAILED, 0, SimulationMessage.workerFailure("You are not authorized to stop this simulation!"), null, null), user.getName(), null, null);
        message.sendToClient(session);
        VCMongoMessage.sendInfo("onStopRequest(" + simJobStatus.getVCSimulationIdentifier() + ") ignoring stop simulation request - wrong user)");
        return;
    }
    // stop latest task if active
    SchedulerStatus schedulerStatus = simJobStatus.getSchedulerStatus();
    int taskID = simJobStatus.getTaskID();
    if (schedulerStatus.isActive()) {
        SimulationQueueEntryStatus simQueueEntryStatus = simJobStatus.getSimulationQueueEntryStatus();
        SimulationExecutionStatus simExeStatus = simJobStatus.getSimulationExecutionStatus();
        SimulationJobStatus newJobStatus = new SimulationJobStatus(simJobStatus.getServerID(), simJobStatus.getVCSimulationIdentifier(), jobIndex, simJobStatus.getSubmitDate(), SchedulerStatus.STOPPED, taskID, SimulationMessage.solverStopped("simulation stopped by user"), simQueueEntryStatus, simExeStatus);
        // 
        if (lg.isTraceEnabled())
            lg.trace("send " + MessageConstants.MESSAGE_TYPE_STOPSIMULATION_VALUE + " to " + VCellTopic.ServiceControlTopic.getName() + " topic");
        VCMessage msg = session.createMessage();
        msg.setStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY, MessageConstants.MESSAGE_TYPE_STOPSIMULATION_VALUE);
        msg.setLongProperty(MessageConstants.SIMKEY_PROPERTY, Long.parseLong(simKey + ""));
        msg.setIntProperty(MessageConstants.JOBINDEX_PROPERTY, jobIndex);
        msg.setIntProperty(MessageConstants.TASKID_PROPERTY, taskID);
        msg.setStringProperty(VCMessagingConstants.USERNAME_PROPERTY, user.getName());
        if (simExeStatus.getHtcJobID() != null) {
            msg.setStringProperty(MessageConstants.HTCJOBID_PROPERTY, simExeStatus.getHtcJobID().toDatabase());
        }
        session.sendTopicMessage(VCellTopic.ServiceControlTopic, msg);
        simulationDatabase.updateSimulationJobStatus(newJobStatus);
        // addStateMachineTransition(new StateMachineTransition(new StopStateMachineEvent(taskID), simJobStatus, newJobStatus));
        // update client
        StatusMessage message = new StatusMessage(newJobStatus, user.getName(), null, null);
        message.sendToClient(session);
    }
}
Also used : SimulationExecutionStatus(cbit.vcell.server.SimulationExecutionStatus) SchedulerStatus(cbit.vcell.server.SimulationJobStatus.SchedulerStatus) VCMessage(cbit.vcell.message.VCMessage) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) SimulationQueueEntryStatus(cbit.vcell.server.SimulationQueueEntryStatus) StatusMessage(cbit.vcell.message.messages.StatusMessage)

Example 7 with SimulationJobStatus

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

the class SimulationDispatcherEngine method onStopRequest.

public void onStopRequest(VCSimulationIdentifier vcSimID, User user, SimulationDatabase simulationDatabase, VCMessageSession session) throws DataAccessException, VCMessagingException, SQLException {
    KeyValue simKey = vcSimID.getSimulationKey();
    SimulationJobStatus[] allActiveSimJobStatusArray = simulationDatabase.getActiveJobs(VCellServerID.getSystemServerID());
    ArrayList<SimulationJobStatus> simJobStatusArray = new ArrayList<SimulationJobStatus>();
    for (SimulationJobStatus activeSimJobStatus : allActiveSimJobStatusArray) {
        if (activeSimJobStatus.getVCSimulationIdentifier().getSimulationKey().equals(vcSimID.getSimulationKey())) {
            simJobStatusArray.add(activeSimJobStatus);
        }
    }
    for (SimulationJobStatus simJobStatus : simJobStatusArray) {
        SimulationStateMachine simStateMachine = getSimulationStateMachine(simKey, simJobStatus.getJobIndex());
        try {
            simStateMachine.onStopRequest(user, simJobStatus, simulationDatabase, session);
        } catch (UpdateSynchronizationException e) {
            simStateMachine.onStopRequest(user, simJobStatus, simulationDatabase, session);
        }
    }
}
Also used : KeyValue(org.vcell.util.document.KeyValue) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) ArrayList(java.util.ArrayList) UpdateSynchronizationException(cbit.vcell.server.UpdateSynchronizationException)

Example 8 with SimulationJobStatus

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

the class SimulationDatabaseDirect method translateToSimulationJobStatusTransient.

private SimulationJobStatus translateToSimulationJobStatusTransient(SimulationJobStatusPersistent simJobStatus) {
    VCellServerID serverID = simJobStatus.getServerID();
    VCSimulationIdentifier vcSimID = simJobStatus.getVCSimulationIdentifier();
    int jobIndex = simJobStatus.getJobIndex();
    Date submitDate = simJobStatus.getSubmitDate();
    SchedulerStatus schedulerStatus = SimulationJobStatus.SchedulerStatus.valueOf(simJobStatus.getSchedulerStatus().name());
    int taskID = simJobStatus.getTaskID();
    SimulationMessage simMessage = SimulationMessage.fromSerializedMessage(simJobStatus.getSimulationMessage().toSerialization());
    Date queueDate = simJobStatus.getSimulationQueueEntryStatus().getQueueDate();
    int queuePriority = simJobStatus.getSimulationQueueEntryStatus().getQueuePriority();
    SimulationQueueID queueId = SimulationJobStatus.SimulationQueueID.valueOf(simJobStatus.getSimulationQueueEntryStatus().getQueueID().name());
    SimulationQueueEntryStatus simQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, queueId);
    SimulationExecutionStatus simExecStatus = new SimulationExecutionStatus(simJobStatus.getSimulationExecutionStatus().getStartDate(), simJobStatus.getSimulationExecutionStatus().getComputeHost(), simJobStatus.getSimulationExecutionStatus().getLatestUpdateDate(), simJobStatus.getSimulationExecutionStatus().getEndDate(), simJobStatus.getSimulationExecutionStatus().hasData(), simJobStatus.getSimulationExecutionStatus().getHtcJobID());
    SimulationJobStatus simJobStatusTransient = new SimulationJobStatus(serverID, vcSimID, jobIndex, submitDate, schedulerStatus, taskID, simMessage, simQueueStatus, simExecStatus);
    return simJobStatusTransient;
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) SimulationExecutionStatus(cbit.vcell.server.SimulationExecutionStatus) VCellServerID(org.vcell.util.document.VCellServerID) SchedulerStatus(cbit.vcell.server.SimulationJobStatus.SchedulerStatus) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) SimulationMessage(cbit.vcell.solver.server.SimulationMessage) SimulationQueueEntryStatus(cbit.vcell.server.SimulationQueueEntryStatus) Date(java.util.Date) SimulationQueueID(cbit.vcell.server.SimulationJobStatus.SimulationQueueID)

Example 9 with SimulationJobStatus

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

the class SimulationDatabaseDirect method translateToSimpleJobStatusTransient.

private SimpleJobStatus translateToSimpleJobStatusTransient(SimpleJobStatusPersistent simpleJobStatusPersistent, SimulationJobStatus cachedSimulationJobStatus, StateInfo cachedStateInfo) {
    SimulationJobStatus simJobStatus = null;
    if (cachedSimulationJobStatus != null) {
        simJobStatus = cachedSimulationJobStatus;
    } else {
        simJobStatus = translateToSimulationJobStatusTransient(simpleJobStatusPersistent.jobStatus);
    }
    SimpleJobStatus simpleJobStatus = new SimpleJobStatus(simpleJobStatusPersistent.simulationMetadata, simpleJobStatusPersistent.simulationDocumentLink, simJobStatus, cachedStateInfo);
    return simpleJobStatus;
}
Also used : SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) SimpleJobStatus(cbit.vcell.server.SimpleJobStatus)

Example 10 with SimulationJobStatus

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

the class SimulationDatabaseDirect method queryJobs.

@Override
public SimulationJobStatus[] queryJobs(SimpleJobStatusQuerySpec simStatusQuerySpec) throws ObjectNotFoundException, DataAccessException {
    // 
    // create corresponding SimpleJobStatus[] from SimpleJobStatusPersistent[]
    // 1) get SimpleJobStatusPersistent from database (with stored status, metadata, and documentLinks - but no stateInfo)
    // 2) if already in cache, use SimulationJobStatus and stateInfo from cache.
    // 3) if not in cache, use SimulationJobStatus from database and no stateInfo, populate cache.
    // 
    List<SimulationJobStatusPersistent> simpleJobStatusPersistentList = databaseServerImpl.getSimulationJobStatus(simStatusQuerySpec);
    ArrayList<SimulationJobStatus> simulationJobStatusList = new ArrayList<SimulationJobStatus>();
    for (SimulationJobStatusPersistent simJobStatusDb : simpleJobStatusPersistentList) {
        SimJobStatusKey key = new SimJobStatusKey(simJobStatusDb.getVCSimulationIdentifier().getSimulationKey(), simJobStatusDb.getJobIndex(), simJobStatusDb.getTaskID());
        SimStatusCacheEntry simStatusCacheEntry = cache.get(key);
        // TODO need to get this from memory cache.
        StateInfo cachedStateInfo = null;
        SimulationJobStatus latestSimulationJobStatus = null;
        if (simStatusCacheEntry != null) {
            cachedStateInfo = simStatusCacheEntry.stateInfo;
            latestSimulationJobStatus = simStatusCacheEntry.jobStatus;
        } else {
            latestSimulationJobStatus = translateToSimulationJobStatusTransient(simJobStatusDb);
            cache.put(key, new SimStatusCacheEntry(latestSimulationJobStatus, null));
        }
        SimulationJobStatus simulationJobStatus = translateToSimulationJobStatusTransient(simJobStatusDb);
        // uses latest SimulationJobStatus and StateInfo.
        simulationJobStatusList.add(simulationJobStatus);
    }
    return simulationJobStatusList.toArray(new SimulationJobStatus[simulationJobStatusList.size()]);
}
Also used : StateInfo(cbit.vcell.server.StateInfo) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) ArrayList(java.util.ArrayList) SimulationJobStatusPersistent(cbit.vcell.server.SimulationJobStatusPersistent)

Aggregations

SimulationJobStatus (cbit.vcell.server.SimulationJobStatus)29 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)9 KeyValue (org.vcell.util.document.KeyValue)9 StatusMessage (cbit.vcell.message.messages.StatusMessage)7 SimulationExecutionStatus (cbit.vcell.server.SimulationExecutionStatus)7 SimulationQueueEntryStatus (cbit.vcell.server.SimulationQueueEntryStatus)7 Date (java.util.Date)6 SimulationJobStatusEvent (cbit.rmi.event.SimulationJobStatusEvent)5 ArrayList (java.util.ArrayList)5 VCellServerID (org.vcell.util.document.VCellServerID)5 VCMessage (cbit.vcell.message.VCMessage)4 VCMessagingException (cbit.vcell.message.VCMessagingException)4 HtcJobID (cbit.vcell.server.HtcJobID)4 SimulationStatus (cbit.vcell.server.SimulationStatus)4 VCDestination (cbit.vcell.message.VCDestination)3 LocalVCMessageAdapter (cbit.vcell.message.local.LocalVCMessageAdapter)3 LocalVCMessageListener (cbit.vcell.message.local.LocalVCMessageAdapter.LocalVCMessageListener)3 SchedulerStatus (cbit.vcell.server.SimulationJobStatus.SchedulerStatus)3 SimulationJobStatusPersistent (cbit.vcell.server.SimulationJobStatusPersistent)3 SolverException (cbit.vcell.solver.SolverException)3