Search in sources :

Example 1 with SimulationStatus

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

the class ClientRequestManager method stopSimulations.

public void stopSimulations(final ClientSimManager clientSimManager, final Simulation[] simulations) {
    // stop is single step operation, don't bother with tasks, thread inline
    AsynchClientTask task1 = new AsynchClientTask("stopping simulations", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            Hashtable<Simulation, Throwable> failures = new Hashtable<Simulation, Throwable>();
            if (simulations != null && simulations.length > 0) {
                for (int i = 0; i < simulations.length; i++) {
                    try {
                        SimulationInfo simInfo = simulations[i].getSimulationInfo();
                        if (simInfo != null) {
                            // check for running once more... directly from job status
                            SimulationStatus serverSimulationStatus = getServerSimulationStatus(simInfo);
                            if (serverSimulationStatus != null && serverSimulationStatus.numberOfJobsDone() < simulations[i].getScanCount()) {
                                SimulationStatus simStatus = getClientServerManager().getJobManager().stopSimulation(simInfo.getAuthoritativeVCSimulationIdentifier());
                                // updateStatus
                                clientSimManager.updateStatusFromStopRequest(simulations[i], simStatus);
                            }
                        } else {
                            // this should really not happen...
                            throw new RuntimeException(">>>>>>>>>> trying to stop an unsaved simulation...");
                        }
                    } catch (Throwable exc) {
                        exc.printStackTrace(System.out);
                        failures.put(simulations[i], exc);
                    }
                }
                hashTable.put("failures", failures);
            }
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("stopping simulations", AsynchClientTask.TASKTYPE_SWING_BLOCKING, false, false) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            @SuppressWarnings("unchecked") Hashtable<Simulation, Throwable> failures = (Hashtable<Simulation, Throwable>) hashTable.get("failures");
            if (failures != null && !failures.isEmpty()) {
                Enumeration<Simulation> en = failures.keys();
                while (en.hasMoreElements()) {
                    Simulation sim = (Simulation) en.nextElement();
                    Throwable exc = (Throwable) failures.get(sim);
                    // notify user
                    PopupGenerator.showErrorDialog(clientSimManager.getDocumentWindowManager(), "Failed to dispatch stop request for simulation'" + sim.getName() + "'\n" + exc.getMessage(), exc);
                }
            }
        }
    };
    ClientTaskDispatcher.dispatch(clientSimManager.getDocumentWindowManager().getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) Simulation(cbit.vcell.solver.Simulation) SimulationStatus(cbit.vcell.server.SimulationStatus) CSGObject(cbit.vcell.geometry.CSGObject) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 2 with SimulationStatus

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

the class MathModelWindowManager method simStatusChanged.

/**
 * Insert the method's description here.
 * Creation date: (5/14/2004 11:08:35 AM)
 * @param newMathModel cbit.vcell.mathmodel.MathModel
 */
// private void setMathModel(MathModel newMathModel) {
// resetGeometryListeners((getMathModel() != null?(getMathModel().getMathDescription() != null?getMathModel().getMathDescription().getGeometry():null):null),
// (newMathModel != null?(newMathModel.getMathDescription() != null?newMathModel.getMathDescription().getGeometry():null):null));
// 
// resetMathDescriptionListeners(
// (getMathModel() != null?getMathModel().getMathDescription():null),
// (newMathModel != null?newMathModel.getMathDescription():null));
// if (getMathModel() != null) {
// getMathModel().removePropertyChangeListener(this);
// }
// mathModel = newMathModel;
// if (getMathModel() != null) {
// getMathModel().addPropertyChangeListener(this);
// }
// }
// private void resetMathDescriptionListeners(MathDescription oldMathDescription,MathDescription newMathDescription){
// if(oldMathDescription != null){
// oldMathDescription.removePropertyChangeListener(this);
// }
// if(newMathDescription != null){
// newMathDescription.addPropertyChangeListener(this);
// }
// }
// /**
// * Insert the method's description here.
// * Creation date: (6/14/2004 10:55:40 PM)
// * @param newDocument cbit.vcell.document.VCDocument
// */
// private void showDataViewerPlotsFrame(final javax.swing.JInternalFrame plotFrame) {
// dataViewerPlotsFramesVector.add(plotFrame);
// showFrame(plotFrame);
// plotFrame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() {
// public void internalFrameClosing(javax.swing.event.InternalFrameEvent e) {
// dataViewerPlotsFramesVector.remove(plotFrame);
// }
// });
// }
// /**
// * Insert the method's description here.
// * Creation date: (6/14/2004 10:55:40 PM)
// * @param newDocument cbit.vcell.document.VCDocument
// */
// public void showDataViewerPlotsFrames(javax.swing.JInternalFrame[] plotFrames) {
// for (int i = 0; i < plotFrames.length; i++){
// showDataViewerPlotsFrame(plotFrames[i]);
// }
// }
/**
 * Insert the method's description here.
 * Creation date: (6/9/2004 3:58:21 PM)
 * @param newJobStatus cbit.vcell.messaging.db.SimulationJobStatus
 * @param progress java.lang.Double
 * @param timePoint java.lang.Double
 */
public void simStatusChanged(SimStatusEvent simStatusEvent) {
    // ** events are only generated from server side job statuses **
    KeyValue simKey = simStatusEvent.getVCSimulationIdentifier().getSimulationKey();
    // do we have the sim?
    Simulation[] sims = getMathModel().getSimulations();
    if (sims == null) {
        // we don't have it
        return;
    }
    Simulation simulation = null;
    for (int i = 0; i < sims.length; i++) {
        if (simKey.equals(sims[i].getKey()) || ((sims[i].getSimulationVersion() != null) && simKey.equals(sims[i].getSimulationVersion().getParentSimulationReference()))) {
            simulation = sims[i];
            break;
        }
    }
    if (simulation == null) {
        // we don't have it
        return;
    }
    // we have it; get current server side status
    SimulationStatus simStatus = getRequestManager().getServerSimulationStatus(simulation.getSimulationInfo());
    // if failed, notify
    if (simStatusEvent.isNewFailureEvent()) {
        String qualifier = "";
        if (simulation.getScanCount() > 1) {
            qualifier += "One job from ";
        }
        PopupGenerator.showErrorDialog(this, qualifier + "Simulation '" + simulation.getName() + "' failed\n" + simStatus.getDetails());
    }
    // update status display
    ClientSimManager simManager = simulationWorkspace.getClientSimManager();
    simManager.updateStatusFromServer(simulation);
    // is there new data?
    if (simStatusEvent.isNewDataEvent()) {
        fireNewData(new DataEvent(this, new VCSimulationDataIdentifier(simulation.getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), simStatusEvent.getJobIndex())));
    }
}
Also used : KeyValue(org.vcell.util.document.KeyValue) Simulation(cbit.vcell.solver.Simulation) SimulationStatus(cbit.vcell.server.SimulationStatus) DataEvent(cbit.vcell.simdata.DataEvent) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier)

Example 3 with SimulationStatus

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

the class ClientSimManager method updateStatusFromServer.

/**
 * Insert the method's description here.
 * Creation date: (6/9/2004 3:04:12 PM)
 */
void updateStatusFromServer(Simulation simulation) {
    // 
    // get cached status
    // 
    SimulationStatus oldStatus = getSimulationStatus(simulation);
    SimulationStatus serverStatus = getDocumentWindowManager().getRequestManager().getServerSimulationStatus(simulation.getSimulationInfo());
    SimulationStatus newStatus = null;
    if (oldStatus.isStopRequested() && serverStatus.numberOfJobsDone() < simulation.getScanCount()) {
        // if stop requested but still going, get updated server info but adjust status
        newStatus = SimulationStatus.newStopRequest(serverStatus);
    } else {
        // otherwise accept server information
        newStatus = serverStatus;
    }
    // update cache
    simHash.setSimulationStatus(simulation, newStatus);
    System.out.println("---ClientSimManager.updateStatusFromServer[newStatus=" + newStatus + "], simulation=" + simulation.toString());
    if (oldStatus != newStatus) {
        int simIndex = getSimWorkspace().getSimulationIndex(simulation);
        getSimWorkspace().firePropertyChange(SimulationWorkspace.PROPERTY_NAME_SIMULATION_STATUS, new Integer(-1), new Integer(simIndex));
    }
}
Also used : SimulationStatus(cbit.vcell.server.SimulationStatus)

Example 4 with SimulationStatus

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

the class SimulationStatusHash method changeSimulationInstances.

/**
 * Insert the method's description here.
 * Creation date: (6/7/2004 12:55:18 PM)
 * @param simulations cbit.vcell.solver.Simulation[]
 */
public void changeSimulationInstances(Simulation[] newSimulations) {
    if (newSimulations == null) {
        hash.clear();
    } else {
        Hashtable<Simulation, SimulationStatus> newHash = new Hashtable<Simulation, SimulationStatus>();
        for (int i = 0; i < newSimulations.length; i++) {
            // 
            if (newSimulations[i].getKey() == null || newSimulations[i].getIsDirty()) {
                newHash.put(newSimulations[i], SimulationStatus.newNotSaved(newSimulations[i].getScanCount()));
            // 
            // try to find status for previous instance of this simulation
            // 
            } else {
                SimulationStatus newSimStatus = null;
                Enumeration<Simulation> en = this.hash.keys();
                while (en.hasMoreElements()) {
                    Simulation sim = en.nextElement();
                    // 
                    // if simulations have the same "authoritative simulation identifier" then use this status
                    // 
                    cbit.vcell.solver.SimulationInfo oldSimInfo = sim.getSimulationInfo();
                    cbit.vcell.solver.SimulationInfo newSimInfo = newSimulations[i].getSimulationInfo();
                    if (oldSimInfo != null && newSimInfo != null && oldSimInfo.getAuthoritativeVCSimulationIdentifier().equals(newSimInfo.getAuthoritativeVCSimulationIdentifier())) {
                        // 
                        if (newSimStatus != null) {
                            System.out.println("warning: more than one match for simulation status");
                        }
                        newSimStatus = hash.get(sim);
                    }
                }
                if (newSimStatus != null) {
                    newHash.put(newSimulations[i], newSimStatus);
                } else {
                    // unknown status
                    newHash.put(newSimulations[i], SimulationStatus.newUnknown(newSimulations[i].getScanCount()));
                }
            }
        }
        hash = newHash;
    }
}
Also used : Simulation(cbit.vcell.solver.Simulation) SimulationStatus(cbit.vcell.server.SimulationStatus) Hashtable(java.util.Hashtable)

Example 5 with SimulationStatus

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

the class SimulationListPanel method editSimulation.

/**
 * Comment
 */
private void editSimulation() {
    // this should not be possible to call unless exactly one row is selected, but check anyway
    int[] selectedRows = getScrollPaneTable().getSelectedRows();
    if (selectedRows.length > 0) {
        // make sure something is selected...
        Simulation sim = (Simulation) (ivjSimulationListTableModel1.getValueAt(selectedRows[0]));
        SimulationStatus simStatus = getSimulationWorkspace().getSimulationStatus(sim);
        if (!simStatus.isRunning()) {
            // just the first one if more than one selected...
            SimulationWorkspace.editSimulation(this, getSimulationWorkspace().getSimulationOwner(), sim);
            // need to check if parallel option changed
            refreshButtonsLax();
        }
    }
}
Also used : Simulation(cbit.vcell.solver.Simulation) SimulationStatus(cbit.vcell.server.SimulationStatus)

Aggregations

SimulationStatus (cbit.vcell.server.SimulationStatus)27 Simulation (cbit.vcell.solver.Simulation)13 SimulationInfo (cbit.vcell.solver.SimulationInfo)8 ArrayList (java.util.ArrayList)8 Hashtable (java.util.Hashtable)5 KeyValue (org.vcell.util.document.KeyValue)5 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)4 SimulationJobStatus (cbit.vcell.server.SimulationJobStatus)4 BioModel (cbit.vcell.biomodel.BioModel)3 HashMap (java.util.HashMap)3 Geometry (cbit.vcell.geometry.Geometry)2 SimulationContext (cbit.vcell.mapping.SimulationContext)2 MathDescription (cbit.vcell.math.MathDescription)2 MathModel (cbit.vcell.mathmodel.MathModel)2 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)2 TestCaseNew (cbit.vcell.numericstest.TestCaseNew)2 ExpressionException (cbit.vcell.parser.ExpressionException)2 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)2 IOException (java.io.IOException)2 Vector (java.util.Vector)2