Search in sources :

Example 1 with RemoteProxyVCellConnectionFactory

use of cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory in project vcell by virtualcell.

the class ClientServerManager method connectToServer.

/**
 * Insert the method's description here.
 * Creation date: (5/12/2004 4:48:13 PM)
 */
private VCellConnection connectToServer(InteractiveContext requester) {
    VCellThreadChecker.checkRemoteInvocation();
    VCellConnection newVCellConnection = null;
    VCellConnectionFactory vcConnFactory = null;
    String badConnStr = "";
    try {
        switch(getClientServerInfo().getServerType()) {
            case SERVER_REMOTE:
                {
                    String apihost = getClientServerInfo().getApihost();
                    Integer apiport = getClientServerInfo().getApiport();
                    try {
                        badConnStr += apihost + ":" + apiport;
                        vcConnFactory = new RemoteProxyVCellConnectionFactory(apihost, apiport, getClientServerInfo().getUserLoginInfo());
                        setConnectionStatus(new ClientConnectionStatus(getClientServerInfo().getUsername(), apihost, apiport, ConnectionStatus.INITIALIZING));
                        newVCellConnection = vcConnFactory.createVCellConnection();
                    } catch (AuthenticationException ex) {
                        throw ex;
                    }
                    break;
                }
            case SERVER_LOCAL:
                {
                    new PropertyLoader();
                    LocalVCellConnectionService localVCellConnectionService = VCellServiceHelper.getInstance().loadService(LocalVCellConnectionService.class);
                    vcConnFactory = localVCellConnectionService.getLocalVCellConnectionFactory(getClientServerInfo().getUserLoginInfo());
                    setConnectionStatus(new ClientConnectionStatus(getClientServerInfo().getUsername(), null, null, ConnectionStatus.INITIALIZING));
                    newVCellConnection = vcConnFactory.createVCellConnection();
                    break;
                }
        }
        requester.clearConnectWarning();
        reconnectStat = ReconnectStatus.NOT;
    } catch (AuthenticationException aexc) {
        aexc.printStackTrace(System.out);
        requester.showErrorDialog(aexc.getMessage());
    } catch (ConnectionException cexc) {
        String msg = badConnectMessage(badConnStr) + "\n" + cexc.getMessage();
        cexc.printStackTrace(System.out);
        ErrorUtils.sendRemoteLogMessage(getClientServerInfo().getUserLoginInfo(), msg);
        if (reconnectStat != ReconnectStatus.SUBSEQUENT) {
            requester.showConnectWarning(msg);
        }
    } catch (Exception exc) {
        exc.printStackTrace(System.out);
        String msg = badConnectMessage(badConnStr) + "\nException:\n" + exc.getMessage();
        ErrorUtils.sendRemoteLogMessage(getClientServerInfo().getUserLoginInfo(), msg);
        requester.showErrorDialog(msg);
    }
    return newVCellConnection;
}
Also used : VCellConnection(cbit.vcell.server.VCellConnection) RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory) AuthenticationException(org.vcell.util.AuthenticationException) LocalVCellConnectionService(cbit.vcell.server.LocalVCellConnectionService) PropertyLoader(cbit.vcell.resource.PropertyLoader) VCellConnectionFactory(cbit.vcell.server.VCellConnectionFactory) RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory) ConnectionException(cbit.vcell.server.ConnectionException) ConnectionException(cbit.vcell.server.ConnectionException) AuthenticationException(org.vcell.util.AuthenticationException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException)

Example 2 with RemoteProxyVCellConnectionFactory

use of cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory in project vcell by virtualcell.

the class ClientFactory method createRemoteVCellConnectionFactory.

public static VCellConnectionFactory createRemoteVCellConnectionFactory(String host, int port, String userid, String password) throws Exception {
    DigestedPassword digestedPassword = new DigestedPassword(password);
    org.vcell.util.document.UserLoginInfo userLoginInfo = new org.vcell.util.document.UserLoginInfo(userid, digestedPassword);
    VCellConnectionFactory vcConnFactory = new RemoteProxyVCellConnectionFactory(host, port, userLoginInfo);
    return vcConnFactory;
}
Also used : RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory) DigestedPassword(org.vcell.util.document.UserLoginInfo.DigestedPassword) VCellConnectionFactory(cbit.vcell.server.VCellConnectionFactory) RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory)

Example 3 with RemoteProxyVCellConnectionFactory

use of cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory in project vcell by virtualcell.

the class ClientTester method VCellConnectionFactoryInit.

/**
 * This method was created in VisualAge.
 * @return VCellConnection
 * @param args java.lang.String[]
 */
protected static cbit.vcell.server.VCellConnectionFactory VCellConnectionFactoryInit(String[] args, String programName) throws Exception {
    if (args.length != 3 && args.length != 4 && args.length != 7) {
        System.err.println("usage: " + programName + " -local userid password [driverName connectionURL userid password]");
        System.err.println("usage: " + programName + " -jms userid password");
        System.err.println("usage: " + programName + " host port userid password");
        throw new Exception("cannot connect");
    }
    cbit.vcell.server.VCellConnectionFactory vcConnFactory = null;
    new cbit.vcell.resource.PropertyLoader();
    if (args[0].startsWith("-")) {
        UserLoginInfo userLoginInfo = new UserLoginInfo(args[1], new UserLoginInfo.DigestedPassword(args[2]));
        if (args[0].equalsIgnoreCase("-jms")) {
            vcConnFactory = new cbit.vcell.message.server.bootstrap.LocalVCellConnectionFactory(userLoginInfo);
        } else if (args[0].equalsIgnoreCase("-local")) {
            vcConnFactory = new cbit.vcell.message.server.bootstrap.LocalVCellConnectionFactory(userLoginInfo);
            if (args.length == 7) {
                ConnectionFactory conFactory = DatabaseService.getInstance().createConnectionFactory(args[3], args[4], args[5], args[6]);
                ((cbit.vcell.message.server.bootstrap.LocalVCellConnectionFactory) vcConnFactory).setConnectionFactory(conFactory);
            }
        }
    } else {
        String apihost = args[0];
        Integer apiport = Integer.parseInt(args[1]);
        UserLoginInfo userLoginInfo = new UserLoginInfo(args[2], new UserLoginInfo.DigestedPassword(args[3]));
        vcConnFactory = new RemoteProxyVCellConnectionFactory(apihost, apiport, userLoginInfo);
    }
    return vcConnFactory;
}
Also used : RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory) ConnectionFactory(org.vcell.db.ConnectionFactory) RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory) UserLoginInfo(org.vcell.util.document.UserLoginInfo)

Example 4 with RemoteProxyVCellConnectionFactory

use of cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory 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)

Example 5 with RemoteProxyVCellConnectionFactory

use of cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory in project vcell by virtualcell.

the class HealthService method runsimLoop.

private void runsimLoop() {
    try {
        Thread.sleep(SIMULATION_LOOP_START_DELAY);
    } catch (InterruptedException e1) {
    }
    UserLoginInfo userLoginInfo = new UserLoginInfo(testUserid, testPassword);
    while (true) {
        long id = simStartEvent();
        KeyValue savedBioModelKey = null;
        VCSimulationIdentifier runningSimId = null;
        try {
            RemoteProxyVCellConnectionFactory vcellConnectionFactory = new RemoteProxyVCellConnectionFactory(host, port, userLoginInfo);
            VCellConnection vcellConnection = vcellConnectionFactory.createVCellConnection();
            String vcmlString = IOUtils.toString(getClass().getResourceAsStream("/TestTemplate.vcml"));
            BioModel templateBioModel = XmlHelper.XMLToBioModel(new XMLSource(vcmlString));
            templateBioModel.clearVersion();
            String newBiomodelName = "test_" + System.currentTimeMillis();
            templateBioModel.setName(newBiomodelName);
            // remove all existing simulations from stored template model, and add new one
            while (templateBioModel.getNumSimulations() > 0) {
                templateBioModel.removeSimulation(templateBioModel.getSimulation(0));
            }
            MathMappingCallback callback = new MathMappingCallback() {

                @Override
                public void setProgressFraction(float fractionDone) {
                }

                @Override
                public void setMessage(String message) {
                }

                @Override
                public boolean isInterrupted() {
                    return false;
                }
            };
            templateBioModel.getSimulationContext(0).addNewSimulation("sim", callback, NetworkGenerationRequirements.ComputeFullStandardTimeout);
            BigString vcml = new BigString(XmlHelper.bioModelToXML(templateBioModel));
            String[] independentSims = new String[0];
            BigString savedBioModelVCML = vcellConnection.getUserMetaDbServer().saveBioModelAs(vcml, newBiomodelName, independentSims);
            BioModel savedBioModel = XmlHelper.XMLToBioModel(new XMLSource(savedBioModelVCML.toString()));
            savedBioModelKey = savedBioModel.getVersion().getVersionKey();
            Simulation sim = savedBioModel.getSimulation(0);
            VCSimulationIdentifier vcSimId = new VCSimulationIdentifier(sim.getKey(), sim.getVersion().getOwner());
            long eventTimestamp = System.currentTimeMillis();
            SimulationStatus simStatus = vcellConnection.getSimulationController().startSimulation(vcSimId, 1);
            simSubmitEvent(id, vcSimId);
            runningSimId = vcSimId;
            long startTime_MS = System.currentTimeMillis();
            while (simStatus.isActive()) {
                if ((System.currentTimeMillis() - startTime_MS) > SIMULATION_TIMEOUT) {
                    throw new RuntimeException("simulation took longer than " + SIMULATION_TIMEOUT + " to complete");
                }
                Thread.sleep(1000);
                MessageEvent[] messageEvents = vcellConnection.getMessageEvents();
                if (messageEvents != null) {
                    for (MessageEvent event : messageEvents) {
                        if (event instanceof SimulationJobStatusEvent) {
                            SimulationJobStatusEvent jobEvent = (SimulationJobStatusEvent) event;
                            SimulationJobStatus jobStatus = jobEvent.getJobStatus();
                            VCSimulationIdentifier eventSimId = jobStatus.getVCSimulationIdentifier();
                            if (eventSimId.getOwner().equals(userLoginInfo.getUser()) && eventSimId.getSimulationKey().equals(sim.getKey())) {
                                simStatus = SimulationStatus.updateFromJobEvent(simStatus, jobEvent);
                            }
                        }
                    }
                }
            }
            runningSimId = null;
            if (!simStatus.isCompleted()) {
                throw new RuntimeException("failed: " + simStatus.getDetails());
            }
            simSuccess(id);
        } catch (Throwable e) {
            simFailed(id, e.getMessage());
        } finally {
            // cleanup
            try {
                RemoteProxyVCellConnectionFactory vcellConnectionFactory = new RemoteProxyVCellConnectionFactory(host, port, userLoginInfo);
                VCellConnection vcellConnection = vcellConnectionFactory.createVCellConnection();
                if (runningSimId != null) {
                    try {
                        vcellConnection.getSimulationController().stopSimulation(runningSimId);
                    } catch (Exception e) {
                        e.printStackTrace(System.out);
                    }
                }
                if (savedBioModelKey != null) {
                    vcellConnection.getUserMetaDbServer().deleteBioModel(savedBioModelKey);
                }
            } catch (Exception e) {
                e.printStackTrace(System.out);
            }
        }
        try {
            Thread.sleep(SIMULATION_LOOP_SLEEP);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
Also used : VCellConnection(cbit.vcell.server.VCellConnection) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory) KeyValue(org.vcell.util.document.KeyValue) MathMappingCallback(cbit.vcell.mapping.SimulationContext.MathMappingCallback) MessageEvent(cbit.rmi.event.MessageEvent) BigString(org.vcell.util.BigString) BigString(org.vcell.util.BigString) SimulationJobStatusEvent(cbit.rmi.event.SimulationJobStatusEvent) Simulation(cbit.vcell.solver.Simulation) SimulationStatus(cbit.vcell.server.SimulationStatus) BioModel(cbit.vcell.biomodel.BioModel) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) UserLoginInfo(org.vcell.util.document.UserLoginInfo) XMLSource(cbit.vcell.xml.XMLSource)

Aggregations

RemoteProxyVCellConnectionFactory (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory)7 VCellConnection (cbit.vcell.server.VCellConnection)5 UserLoginInfo (org.vcell.util.document.UserLoginInfo)4 VCellConnectionFactory (cbit.vcell.server.VCellConnectionFactory)3 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)2 PropertyLoader (cbit.vcell.resource.PropertyLoader)2 ConnectionException (cbit.vcell.server.ConnectionException)2 LocalVCellConnectionService (cbit.vcell.server.LocalVCellConnectionService)2 Simulation (cbit.vcell.solver.Simulation)2 IOException (java.io.IOException)2 AuthenticationException (org.vcell.util.AuthenticationException)2 BigString (org.vcell.util.BigString)2 DataAccessException (org.vcell.util.DataAccessException)2 MessageEvent (cbit.rmi.event.MessageEvent)1 SimulationJobStatusEvent (cbit.rmi.event.SimulationJobStatusEvent)1 BioModel (cbit.vcell.biomodel.BioModel)1 MathMappingCallback (cbit.vcell.mapping.SimulationContext.MathMappingCallback)1 SimulationJobStatus (cbit.vcell.server.SimulationJobStatus)1 SimulationStatus (cbit.vcell.server.SimulationStatus)1 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)1