Search in sources :

Example 6 with VCellConnection

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);
}
Also used : VCellConnection(cbit.vcell.server.VCellConnection) SiteInfo(cbit.vcell.message.server.console.LoginChecker.SiteInfo) VCellBootstrap(cbit.vcell.server.VCellBootstrap) BigString(org.vcell.util.BigString) DigestedPassword(org.vcell.util.document.UserLoginInfo.DigestedPassword) UserLoginInfo(org.vcell.util.document.UserLoginInfo) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) SBMLException(org.sbml.jsbml.SBMLException) XMLStreamException(javax.xml.stream.XMLStreamException) XmlParseException(cbit.vcell.xml.XmlParseException)

Example 7 with VCellConnection

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));
    }
}
Also used : VCellConnection(cbit.vcell.server.VCellConnection) ClientDocumentManager(cbit.vcell.clientdb.ClientDocumentManager) DataAccessException(org.vcell.util.DataAccessException)

Example 8 with VCellConnection

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());
        }
    }
}
Also used : VCellConnection(cbit.vcell.server.VCellConnection) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) SolverDescription(cbit.vcell.solver.SolverDescription) MessageEvent(cbit.rmi.event.MessageEvent) VCellBootstrap(cbit.vcell.server.VCellBootstrap) SimulationStatusPersistent(cbit.vcell.server.SimulationStatusPersistent) DigestedPassword(org.vcell.util.document.UserLoginInfo.DigestedPassword) BigString(org.vcell.util.BigString) SQLException(java.sql.SQLException) Simulation(cbit.vcell.solver.Simulation) UserLoginInfo(org.vcell.util.document.UserLoginInfo)

Example 9 with VCellConnection

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();
}
Also used : VCellConnection(cbit.vcell.server.VCellConnection) BioModel(cbit.vcell.biomodel.BioModel) SimulationContext(cbit.vcell.mapping.SimulationContext) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) SBMLException(org.sbml.jsbml.SBMLException) XMLStreamException(javax.xml.stream.XMLStreamException) XmlParseException(cbit.vcell.xml.XmlParseException)

Example 10 with VCellConnection

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);
    }
}
Also used : VCellConnection(cbit.vcell.server.VCellConnection) RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory) User(org.vcell.util.document.User) Simulation(cbit.vcell.solver.Simulation) BigString(org.vcell.util.BigString) UserLoginInfo(org.vcell.util.document.UserLoginInfo) BigString(org.vcell.util.BigString) UserCancelException(org.vcell.util.UserCancelException)

Aggregations

VCellConnection (cbit.vcell.server.VCellConnection)13 UserLoginInfo (org.vcell.util.document.UserLoginInfo)8 BigString (org.vcell.util.BigString)6 VCellBootstrap (cbit.vcell.server.VCellBootstrap)5 Simulation (cbit.vcell.solver.Simulation)5 DigestedPassword (org.vcell.util.document.UserLoginInfo.DigestedPassword)5 MessageEvent (cbit.rmi.event.MessageEvent)4 BioModel (cbit.vcell.biomodel.BioModel)4 RemoteProxyVCellConnectionFactory (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory)4 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)4 IOException (java.io.IOException)4 DataAccessException (org.vcell.util.DataAccessException)4 SimulationContext (cbit.vcell.mapping.SimulationContext)3 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)3 SimulationStatusPersistent (cbit.vcell.server.SimulationStatusPersistent)3 XMLSource (cbit.vcell.xml.XMLSource)3 BioModelInfo (org.vcell.util.document.BioModelInfo)3 KeyValue (org.vcell.util.document.KeyValue)3 VCInfoContainer (org.vcell.util.document.VCInfoContainer)3 OutputContext (cbit.vcell.simdata.OutputContext)2