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 });
}
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())));
}
}
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));
}
}
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;
}
}
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();
}
}
}
Aggregations