Search in sources :

Example 11 with SimulationJobStatus

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

the class SimulationDatabaseDirect method buildSimulationStatus.

private SimulationStatus buildSimulationStatus(SimulationStatusPersistent simStatusDB) throws ObjectNotFoundException, DataAccessException {
    SimulationStatus simulationStatus = translateToSimulationStatusTransient(simStatusDB);
    // replace SimulationJobStatus from cache when possible
    ArrayList<SimulationJobStatus> simJobStatusList = new ArrayList<SimulationJobStatus>();
    int index = 0;
    while (simulationStatus.getJobStatus(index) != null) {
        SimulationJobStatus simJobStatusDb = simulationStatus.getJobStatus(index);
        SimJobStatusKey key = new SimJobStatusKey(simJobStatusDb.getVCSimulationIdentifier().getSimulationKey(), simJobStatusDb.getJobIndex(), simJobStatusDb.getTaskID());
        SimStatusCacheEntry entry = cache.get(key);
        if (entry != null) {
            // assume cache is more recent
            simJobStatusList.add(entry.jobStatus);
        } else {
            simJobStatusList.add(simJobStatusDb);
            cache.put(key, new SimStatusCacheEntry(simJobStatusDb, null));
        }
        index++;
    }
    SimulationStatus newSimStatus = new SimulationStatus(simJobStatusList.toArray(new SimulationJobStatus[simJobStatusList.size()]));
    return newSimStatus;
}
Also used : SimulationStatus(cbit.vcell.server.SimulationStatus) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) ArrayList(java.util.ArrayList)

Example 12 with SimulationJobStatus

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

the class SimulationDatabaseDirect method translateToSimulationStatusTransient.

private SimulationStatus translateToSimulationStatusTransient(SimulationStatusPersistent simStatusPersistent) {
    ArrayList<SimulationJobStatus> simJobStatusList = new ArrayList<SimulationJobStatus>();
    if (simStatusPersistent == null) {
    }
    SimulationJobStatusPersistent[] simStatusPersistentArray = simStatusPersistent.getJobStatuses();
    if (simStatusPersistentArray == null) {
    }
    for (SimulationJobStatusPersistent stat : simStatusPersistentArray) {
        simJobStatusList.add(translateToSimulationJobStatusTransient(stat));
    }
    SimulationStatus simStatus = new SimulationStatus(simJobStatusList.toArray(new SimulationJobStatus[0]));
    return simStatus;
}
Also used : SimulationStatus(cbit.vcell.server.SimulationStatus) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) ArrayList(java.util.ArrayList) SimulationJobStatusPersistent(cbit.vcell.server.SimulationJobStatusPersistent)

Example 13 with SimulationJobStatus

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

the class SimulationDatabaseDirect method getSimulationJobStatus.

SimulationJobStatus getSimulationJobStatus(KeyValue simKey, int jobIndex, int taskID) throws DataAccessException, SQLException {
    SimJobStatusKey key = new SimJobStatusKey(simKey, jobIndex, taskID);
    SimStatusCacheEntry simStatusCacheEntry = cache.get(key);
    if (simStatusCacheEntry != null) {
        return simStatusCacheEntry.jobStatus;
    } else {
        SimulationJobStatusPersistent simJobStatusPersistent = adminDbTopLevel.getSimulationJobStatus(simKey, jobIndex, taskID, true);
        SimulationJobStatus simulationJobStatus = translateToSimulationJobStatusTransient(simJobStatusPersistent);
        cache.put(key, new SimStatusCacheEntry(simulationJobStatus, null));
        return simulationJobStatus;
    }
}
Also used : SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) SimulationJobStatusPersistent(cbit.vcell.server.SimulationJobStatusPersistent)

Example 14 with SimulationJobStatus

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

the class SimulationControllerImpl method startSimulation.

/**
 * This method was created by a SmartGuide.
 * @exception java.rmi.RemoteException The exception description.
 */
public void startSimulation(Simulation simulation) throws Exception {
    LocalVCMessageListener localVCMessageListener = new LocalVCMessageListener() {

        public void onLocalVCMessage(VCDestination destination, VCMessage vcMessage) {
            if (destination == VCellTopic.ClientStatusTopic && vcMessage.getObjectContent() instanceof SimulationJobStatus) {
                onClientStatusTopic_SimulationJobStatus(vcMessage);
            } else if (destination == VCellQueue.SimJobQueue && vcMessage.getStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY).equals(MessageConstants.MESSAGE_TYPE_SIMULATION_JOB_VALUE)) {
                onSimJobQueue_SimulationTask(vcMessage);
            } else {
                throw new RuntimeException("SimulationControllerImpl.startSimulation().objectMessageListener:: expecting object message with SimulationJobStatus to topic " + VCellTopic.ClientStatusTopic.getName() + ": received \"" + vcMessage.show() + "\"");
            }
        }
    };
    LocalVCMessageAdapter vcMessageSession = new LocalVCMessageAdapter(localVCMessageListener);
    removeSimulationJobStatusListener(localVCellConnection.getMessageCollector());
    addSimulationJobStatusListener(localVCellConnection.getMessageCollector());
    VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simulation.getKey(), simulation.getVersion().getOwner());
    simulationDispatcherEngine.onStartRequest(vcSimID, localVCellConnection.getUserLoginInfo().getUser(), simulation.getScanCount(), simulationDatabase, vcMessageSession, vcMessageSession);
    vcMessageSession.deliverAll();
    for (int jobIndex = 0; jobIndex < simulation.getScanCount(); jobIndex++) {
        SimulationJobStatus latestSimJobStatus = simulationDatabase.getLatestSimulationJobStatus(simulation.getKey(), jobIndex);
        simulationDispatcherEngine.onDispatch(simulation, latestSimJobStatus, simulationDatabase, vcMessageSession);
        vcMessageSession.deliverAll();
    }
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) VCDestination(cbit.vcell.message.VCDestination) LocalVCMessageListener(cbit.vcell.message.local.LocalVCMessageAdapter.LocalVCMessageListener) VCMessage(cbit.vcell.message.VCMessage) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) LocalVCMessageAdapter(cbit.vcell.message.local.LocalVCMessageAdapter)

Example 15 with SimulationJobStatus

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

the class SimulationControllerImpl method onClientStatusTopic_SimulationJobStatus.

private void onClientStatusTopic_SimulationJobStatus(VCMessage simJobStatusMessage) {
    Double progress = null;
    if (simJobStatusMessage.propertyExists(MessageConstants.SIMULATION_STATUS_PROGRESS_PROPERTY)) {
        progress = simJobStatusMessage.getDoubleProperty(MessageConstants.SIMULATION_STATUS_PROGRESS_PROPERTY);
    }
    Double timepoint = null;
    if (simJobStatusMessage.propertyExists(MessageConstants.SIMULATION_STATUS_TIMEPOINT_PROPERTY)) {
        timepoint = simJobStatusMessage.getDoubleProperty(MessageConstants.SIMULATION_STATUS_TIMEPOINT_PROPERTY);
    }
    SimulationJobStatus simJobStatus = (SimulationJobStatus) simJobStatusMessage.getObjectContent();
    SimulationJobStatusEvent simulationJobStatusEvent = new SimulationJobStatusEvent(SimulationControllerImpl.this, simJobStatus.getVCSimulationIdentifier().getID(), simJobStatus, progress, timepoint, simJobStatus.getVCSimulationIdentifier().getOwner().getName());
    fireSimulationJobStatusEvent(simulationJobStatusEvent);
}
Also used : SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) SimulationJobStatusEvent(cbit.rmi.event.SimulationJobStatusEvent)

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