use of cbit.vcell.server.VCellConnection in project vcell by virtualcell.
the class SBMLExportTest method getConnection.
static VCellConnection getConnection(String siteName, String user, String password) {
Collection<SiteInfo> sites = LoginChecker.getSiteInfos(siteName);
for (SiteInfo si : sites) {
try {
String url = si.bootStrapUrl();
VCellBootstrap vcellBootstrap = (VCellBootstrap) java.rmi.Naming.lookup(url);
DigestedPassword dp = new UserLoginInfo.DigestedPassword(password);
UserLoginInfo uli = new UserLoginInfo(user, dp);
VCellConnection vcellConnection = vcellBootstrap.getVCellConnection(uli);
return vcellConnection;
} catch (Exception e) {
System.err.println(e.getMessage());
continue;
}
}
throw new RuntimeException("No connection for site " + siteName);
}
use of cbit.vcell.server.VCellConnection in project vcell by virtualcell.
the class ClientServerManager method changeConnection.
/**
* Insert the method's description here.
* Creation date: (5/12/2004 4:48:13 PM)
*/
private void changeConnection(InteractiveContext requester, VCellConnection newVCellConnection) {
VCellThreadChecker.checkRemoteInvocation();
VCellConnection lastVCellConnection = getVcellConnection();
setVcellConnection(newVCellConnection);
if (getVcellConnection() != null) {
try {
/* new credentials; need full init */
// throw it away; doesn't properly support full reinits
// preload the document manager cache
((ClientDocumentManager) getDocumentManager()).initAllDatabaseInfos();
// load user preferences
getUserPreferences().resetFromSaved(getDocumentManager().getPreferences());
setConnectionStatus(new ClientConnectionStatus(getClientServerInfo().getUsername(), getClientServerInfo().getApihost(), getClientServerInfo().getApiport(), ConnectionStatus.CONNECTED));
} catch (DataAccessException exc) {
// unlikely, since we just connected, but it looks like we did loose the connection...
lastVCellConnection = getVcellConnection();
setVcellConnection(null);
setConnectionStatus(new ClientConnectionStatus(getClientServerInfo().getUsername(), getClientServerInfo().getApihost(), getClientServerInfo().getApiport(), ConnectionStatus.DISCONNECTED));
exc.printStackTrace(System.out);
requester.showErrorDialog("Server connection failed:\n\n" + exc.getMessage());
}
} else if (lastVCellConnection != null) {
setConnectionStatus(new ClientConnectionStatus(getClientServerInfo().getUsername(), getClientServerInfo().getApihost(), getClientServerInfo().getApiport(), ConnectionStatus.DISCONNECTED));
} else {
setConnectionStatus(new ClientConnectionStatus(null, null, null, ConnectionStatus.NOT_CONNECTED));
}
}
use of cbit.vcell.server.VCellConnection in project vcell by virtualcell.
the class TestMissingSimData method runSim.
private static void runSim(SimIDAndJobID simIDAndJobID) throws Exception {
if (notCompletedSimIDs.contains(simIDAndJobID.simID.toString())) {
// System.out.println("--skipping notCompleted");
return;
} else if (completedSimIDs.contains(simIDAndJobID.simID.toString())) {
System.out.println("-----unexpected sim rerun already completed once");
return;
}
VCSimulationIdentifier vcSimulationIdentifier = new VCSimulationIdentifier(simIDAndJobID.simID, simIDAndJobID.user);
UserLoginInfo userLoginInfo = new UserLoginInfo(simIDAndJobID.user.getName(), new DigestedPassword("xoxoxox"));
// getVcellClient().getClientServerManager().getConnectionStatus()
VCellConnection vcellConnection = userConnections.get(simIDAndJobID.user);
try {
if (vcellConnection != null) {
vcellConnection.getMessageEvents();
}
} catch (Exception e) {
e.printStackTrace();
// assume disconnected
vcellConnection = null;
}
if (vcellConnection == null) {
VCellBootstrap vCellBootstrap = getVCellBootstrap("rmi-alpha.cam.uchc.edu", 40106, "VCellBootstrapServer", 12, false);
vcellConnection = vCellBootstrap.getVCellConnection(userLoginInfo);
userConnections.put(simIDAndJobID.user, vcellConnection);
}
SimulationStatusPersistent finalSimStatus = null;
try {
SimulationStatusPersistent simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(vcSimulationIdentifier.getSimulationKey());
System.out.println("initial status=" + simulationStatus);
BigString simXML = vcellConnection.getUserMetaDbServer().getSimulationXML(vcSimulationIdentifier.getSimulationKey());
Simulation sim = XmlHelper.XMLToSim(simXML.toString());
SolverDescription solverDescription = sim.getSolverTaskDescription().getSolverDescription();
if (solverDescription.equals(SolverDescription.StochGibson) || solverDescription.equals(SolverDescription.FiniteVolume)) {
// These 2 solvers give too much trouble so skip
System.out.println("--skipping solver");
// notCompletedSimIDs.add(simIDAndJobID.simID.toString());
return;
}
int scanCount = sim.getScanCount();
vcellConnection.getSimulationController().startSimulation(vcSimulationIdentifier, scanCount);
long startTime = System.currentTimeMillis();
while (simulationStatus.isStopped() || simulationStatus.isCompleted() || simulationStatus.isFailed()) {
Thread.sleep(250);
simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(vcSimulationIdentifier.getSimulationKey());
MessageEvent[] messageEvents = vcellConnection.getMessageEvents();
if ((System.currentTimeMillis() - startTime) > 60000) {
System.out.println("-----Sim finished too fast or took too long to start");
return;
}
// System.out.println(simulationStatus);
}
SimulationStatusPersistent lastSimStatus = simulationStatus;
while (!simulationStatus.isStopped() && !simulationStatus.isCompleted() && !simulationStatus.isFailed()) {
Thread.sleep(3000);
simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(vcSimulationIdentifier.getSimulationKey());
if (!simulationStatus.toString().equals(lastSimStatus.toString())) {
lastSimStatus = simulationStatus;
System.out.println("running status=" + simulationStatus);
}
// System.out.println(simulationStatus);
MessageEvent[] messageEvents = vcellConnection.getMessageEvents();
// for (int i = 0; messageEvents != null && i < messageEvents.length; i++) {
// System.out.println(messageEvents[i]);
// }
}
finalSimStatus = simulationStatus;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return;
} finally {
System.out.println("final status=" + finalSimStatus + "\n");
if (finalSimStatus == null || !finalSimStatus.isCompleted()) {
notCompletedSimIDs.add(simIDAndJobID.simID.toString());
} else {
completedSimIDs.add(simIDAndJobID.simID.toString());
}
}
}
use of cbit.vcell.server.VCellConnection in project vcell by virtualcell.
the class SBMLExportTest method testExport.
void testExport(String site, String user, String password, String modelName) {
VCellConnection vcc = getConnection(site, user, password);
try {
BioModel bm = getBiomodelByName(vcc, modelName);
if (valid(bm, "No BioModel named " + modelName)) {
SimulationContext sc = findSpatialDeterministic(bm);
if (valid(sc, "No spatial deterministic sim context")) {
export(sc);
}
}
} catch (Exception e) {
e.printStackTrace();
}
displayFails();
}
use of cbit.vcell.server.VCellConnection in project vcell by virtualcell.
the class ServerManageConsole method resubmitSimulation.
/**
* Insert the method's description here.
* Creation date: (7/19/2004 3:32:52 PM)
* @param simKey cbit.sql.KeyValue
*/
public void resubmitSimulation(String userid, KeyValue simKey) {
try {
User user = adminDbTop.getUser(userid, true);
UserLoginInfo userLoginInfo = new UserLoginInfo(user.getName(), null);
userLoginInfo.setUser(user);
String apihost = "vcellapi.cam.uchc.edu";
Integer apiport = 8080;
RemoteProxyVCellConnectionFactory remoteProxyVCellConnectionFactory = new RemoteProxyVCellConnectionFactory(apihost, apiport, userLoginInfo);
VCellConnection vcConn = remoteProxyVCellConnectionFactory.createVCellConnection();
BigString simxml = vcConn.getUserMetaDbServer().getSimulationXML(simKey);
if (simxml == null) {
javax.swing.JOptionPane.showMessageDialog(this, "Simulation [" + simKey + "] doesn't exit, might have been deleted.", "Error", javax.swing.JOptionPane.ERROR_MESSAGE);
return;
}
Simulation sim = XmlHelper.XMLToSim(simxml.toString());
if (sim == null) {
javax.swing.JOptionPane.showMessageDialog(this, "Simulation [" + simKey + "] doesn't exit, might have been deleted.", "Error", javax.swing.JOptionPane.ERROR_MESSAGE);
return;
}
vcConn.getSimulationController().startSimulation(sim.getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), sim.getScanCount());
} catch (Exception ex) {
javax.swing.JOptionPane.showMessageDialog(this, "Resubmitting simulation failed:" + ex.getMessage(), "Error", javax.swing.JOptionPane.ERROR_MESSAGE);
}
}
Aggregations