Search in sources :

Example 1 with VCellBootstrap

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

the class LoginChecker method attemptLogin.

private static boolean attemptLogin(SiteInfo si, String user, String password) {
    long start = 0;
    try {
        if (VERBOSE) {
            start = System.currentTimeMillis();
        }
        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);
        if (vcellConnection == null) {
            if (VERBOSE) {
                System.out.println("no connection on " + si + " in " + elapsed(start) + " seconds");
            }
            return false;
        }
        UserMetaDbServer dataServer = vcellConnection.getUserMetaDbServer();
        @SuppressWarnings("unused") BioModelInfo[] bmi = dataServer.getBioModelInfos(true);
        if (VERBOSE) {
            System.out.println("success on " + si + " in " + elapsed(start) + " seconds");
        }
        return true;
    } catch (MalformedURLException e) {
        e.printStackTrace();
        throw new Error("bad code");
    } catch (Exception e) {
        if (VERBOSE) {
            System.out.println("failed in " + elapsed(start) + " seconds");
        }
        e.printStackTrace();
        return false;
    }
}
Also used : VCellConnection(cbit.vcell.server.VCellConnection) UserMetaDbServer(cbit.vcell.server.UserMetaDbServer) MalformedURLException(java.net.MalformedURLException) VCellBootstrap(cbit.vcell.server.VCellBootstrap) BioModelInfo(org.vcell.util.document.BioModelInfo) DigestedPassword(org.vcell.util.document.UserLoginInfo.DigestedPassword) MalformedURLException(java.net.MalformedURLException) UserLoginInfo(org.vcell.util.document.UserLoginInfo)

Example 2 with VCellBootstrap

use of cbit.vcell.server.VCellBootstrap 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 3 with VCellBootstrap

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

the class NagiosVCellMonitor method checkVCell.

private CheckResults checkVCell(VCELL_CHECK_LEVEL checkLevel, String rmiHostName, int rmiPort, String rmiBootstrapStubName, String vcellNagiosPassword, int criticalTimeout, int monitorPort) throws Exception {
    SimulationStatusPersistent lastSimStatus = null;
    String vcellVersion = null;
    TreeMap<VCELL_CHECK_LEVEL, Long> levelTimesMillisec = new TreeMap<NagiosVCellMonitor.VCELL_CHECK_LEVEL, Long>();
    long startTime = System.currentTimeMillis();
    VCellConnection vcellConnection = null;
    try {
        if (rmiHostName == null || rmiPort == -1) {
            throw new UnexpectedTestStateException("Host name/ip and rmiPort required for testing, rmihostname=" + rmiHostName + " rmiport=" + rmiPort);
        }
        String rmiUrl = "//" + rmiHostName + ":" + rmiPort + "/" + rmiBootstrapStubName;
        VCellBootstrap vcellBootstrap = null;
        try {
            vcellBootstrap = (VCellBootstrap) Naming.lookup(rmiUrl);
        } catch (Exception e) {
            throw new UnexpectedTestStateException("Error during bootstrap lookup, " + e.getClass().getSimpleName() + " " + e.getMessage());
        }
        vcellVersion = vcellBootstrap.getVCellSoftwareVersion();
        levelTimesMillisec.put(VCELL_CHECK_LEVEL.RMI_ONLY_0, System.currentTimeMillis() - startTime);
        if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.CONNECT_1.ordinal()) {
            if (vcellNagiosPassword == null) {
                throw new UnexpectedTestStateException("vcellNagios Password required for " + VCELL_CHECK_LEVEL.CONNECT_1.toString() + " and above");
            }
            UserLoginInfo userLoginInfo = new UserLoginInfo(VCELL_NAGIOS_USER, new DigestedPassword(vcellNagiosPassword));
            vcellConnection = vcellBootstrap.getVCellConnection(userLoginInfo);
            levelTimesMillisec.put(VCELL_CHECK_LEVEL.CONNECT_1, System.currentTimeMillis() - startTime - levelTimesMillisec.get(VCELL_CHECK_LEVEL.RMI_ONLY_0));
            if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.INFOS_2.ordinal()) {
                VCInfoContainer vcInfoContainer = vcellConnection.getUserMetaDbServer().getVCInfoContainer();
                levelTimesMillisec.put(VCELL_CHECK_LEVEL.INFOS_2, System.currentTimeMillis() - startTime - levelTimesMillisec.get(VCELL_CHECK_LEVEL.CONNECT_1));
                if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.LOAD_3.ordinal()) {
                    KeyValue bioModelKey = null;
                    final String testModelName = "Solver Suite 5.1 (BETA only ode)";
                    for (BioModelInfo bioModelInfo : vcInfoContainer.getBioModelInfos()) {
                        if (userLoginInfo.getUserName().equals(bioModelInfo.getVersion().getOwner().getName()) && bioModelInfo.getVersion().getName().equals(testModelName)) {
                            bioModelKey = bioModelInfo.getVersion().getVersionKey();
                            break;
                        }
                    }
                    BigString bioModelXML = vcellConnection.getUserMetaDbServer().getBioModelXML(bioModelKey);
                    BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(bioModelXML.toString()));
                    bioModel.refreshDependencies();
                    levelTimesMillisec.put(VCELL_CHECK_LEVEL.LOAD_3, System.currentTimeMillis() - startTime - levelTimesMillisec.get(VCELL_CHECK_LEVEL.INFOS_2));
                    if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.DATA_4.ordinal()) {
                        final String testSimContextName = "non-spatial ODE";
                        SimulationContext simulationContext = bioModel.getSimulationContext(testSimContextName);
                        final String testSimName = "Copy of combined ida/cvode";
                        Simulation simulation = simulationContext.getSimulation(testSimName);
                        if (simulation == null) {
                            throw new UnexpectedTestStateException("Couldn't find sim '" + testSimName + "' for " + checkLevel.toString());
                        }
                        VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(simulation.getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), 0);
                        ArrayList<AnnotatedFunction> outputFunctionsList = simulationContext.getOutputFunctionContext().getOutputFunctionsList();
                        OutputContext outputContext = new OutputContext(outputFunctionsList.toArray(new AnnotatedFunction[outputFunctionsList.size()]));
                        double[] times = vcellConnection.getDataSetController().getDataSetTimes(vcSimulationDataIdentifier);
                        ODESimData odeSimData = vcellConnection.getDataSetController().getODEData(vcSimulationDataIdentifier);
                        levelTimesMillisec.put(VCELL_CHECK_LEVEL.DATA_4, System.currentTimeMillis() - startTime - levelTimesMillisec.get(VCELL_CHECK_LEVEL.LOAD_3));
                        if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.RUN_5.ordinal()) {
                            KeyValue copy1Key = null;
                            KeyValue copy2Key = null;
                            VCSimulationIdentifier testRunSimID = null;
                            try {
                                if (simulationContext.getSimulations().length != 1) {
                                    throw new UnexpectedTestStateException("Expecting only 1 sim to be copied for " + checkLevel.toString());
                                }
                                SimulationStatusPersistent simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(simulation.getVersion().getVersionKey());
                                if (!simulationStatus.isCompleted()) {
                                    throw new UnexpectedTestStateException("Expecting completed sim to copy for " + checkLevel.toString());
                                }
                                String copyModelName = testModelName + "_" + rmiHostName + "_rmi" + rmiPort + "_siteprt" + monitorPort;
                                boolean bForceCleanup = true;
                                while (true) {
                                    boolean bMessy = false;
                                    for (BioModelInfo bioModelInfo : vcInfoContainer.getBioModelInfos()) {
                                        if (userLoginInfo.getUserName().equals(bioModelInfo.getVersion().getOwner().getName()) && bioModelInfo.getVersion().getName().equals(copyModelName)) {
                                            bMessy = true;
                                            if (bForceCleanup) {
                                                try {
                                                    vcellConnection.getUserMetaDbServer().deleteBioModel(bioModelInfo.getVersion().getVersionKey());
                                                } catch (Exception e) {
                                                    e.printStackTrace();
                                                }
                                            } else {
                                                throw new MessyTestEnvironmentException("Messy test environment, not expecting " + copyModelName + " and couldn't cleanup");
                                            }
                                        }
                                    }
                                    if (!bMessy) {
                                        break;
                                    }
                                    // get new vcInfoContainer without cleaned-up model
                                    vcInfoContainer = vcellConnection.getUserMetaDbServer().getVCInfoContainer();
                                    bForceCleanup = false;
                                }
                                BigString copyBioModelXMLStr = vcellConnection.getUserMetaDbServer().saveBioModelAs(bioModelXML, copyModelName, null);
                                BioModel copyBioModel = XmlHelper.XMLToBioModel(new XMLSource(copyBioModelXMLStr.toString()));
                                copy1Key = copyBioModel.getVersion().getVersionKey();
                                copyBioModel.refreshDependencies();
                                Simulation copySim = copyBioModel.getSimulationContext(testSimContextName).copySimulation(copyBioModel.getSimulationContext(testSimContextName).getSimulation(testSimName));
                                final String copyTestSimName = "test";
                                copySim.setName(copyTestSimName);
                                copyBioModel.refreshDependencies();
                                copyBioModelXMLStr = new BigString(XmlHelper.bioModelToXML(copyBioModel));
                                copyBioModelXMLStr = vcellConnection.getUserMetaDbServer().saveBioModel(copyBioModelXMLStr, null);
                                copyBioModel = XmlHelper.XMLToBioModel(new XMLSource(copyBioModelXMLStr.toString()));
                                copy2Key = copyBioModel.getVersion().getVersionKey();
                                copyBioModel.refreshDependencies();
                                Simulation newSimulation = copyBioModel.getSimulationContext(testSimContextName).getSimulation(copyTestSimName);
                                simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(newSimulation.getVersion().getVersionKey());
                                if (simulationStatus != null && !simulationStatus.isNeverRan()) {
                                    throw new UnexpectedTestStateException("Expecting new sim to have 'never ran' status for " + checkLevel.toString());
                                }
                                testRunSimID = new VCSimulationIdentifier(newSimulation.getVersion().getVersionKey(), copyBioModel.getVersion().getOwner());
                                vcellConnection.getSimulationController().startSimulation(testRunSimID, 1);
                                lastSimStatus = simulationStatus;
                                MessageEvent[] messageEvents = null;
                                while (simulationStatus == null || (!simulationStatus.isStopped() && !simulationStatus.isCompleted() && !simulationStatus.isFailed())) {
                                    Thread.sleep(200);
                                    if (((System.currentTimeMillis() - startTime) / 1000) > criticalTimeout) {
                                        vcellConnection.getSimulationController().stopSimulation(testRunSimID);
                                        vcellConnection.getMessageEvents();
                                        break;
                                    }
                                    simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(newSimulation.getVersion().getVersionKey());
                                    if (simulationStatus != null && !simulationStatus.toString().equals((lastSimStatus == null ? null : lastSimStatus.toString()))) {
                                        lastSimStatus = simulationStatus;
                                    }
                                    if (simulationStatus != null && simulationStatus.isFailed()) {
                                        throw new Exception("time " + ((System.currentTimeMillis() - startTime) / 1000) + ", Sim execution failed key:" + testRunSimID.getSimulationKey() + " sim " + newSimulation.getName() + " model " + copyBioModel.getVersion().getName() + " messg " + simulationStatus.getFailedMessage());
                                    }
                                    messageEvents = vcellConnection.getMessageEvents();
                                }
                            } finally {
                                try {
                                    if (copy1Key != null) {
                                        vcellConnection.getUserMetaDbServer().deleteBioModel(copy1Key);
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                                try {
                                    if (copy2Key != null) {
                                        vcellConnection.getUserMetaDbServer().deleteBioModel(copy2Key);
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                                if (testRunSimID != null) {
                                    deleteSimData(testRunSimID);
                                }
                            }
                            levelTimesMillisec.put(VCELL_CHECK_LEVEL.RUN_5, System.currentTimeMillis() - startTime - levelTimesMillisec.get(VCELL_CHECK_LEVEL.DATA_4));
                        }
                    }
                }
            }
        }
        return new CheckResults(vcellVersion, levelTimesMillisec, lastSimStatus, System.currentTimeMillis() - startTime, null);
    } catch (Exception e) {
        return new CheckResults(vcellVersion, levelTimesMillisec, lastSimStatus, System.currentTimeMillis() - startTime, e);
    } finally {
        vcellConnection = null;
    }
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) KeyValue(org.vcell.util.document.KeyValue) MessageEvent(cbit.rmi.event.MessageEvent) VCellBootstrap(cbit.vcell.server.VCellBootstrap) BigString(org.vcell.util.BigString) ODESimData(cbit.vcell.solver.ode.ODESimData) DigestedPassword(org.vcell.util.document.UserLoginInfo.DigestedPassword) BigString(org.vcell.util.BigString) VCInfoContainer(org.vcell.util.document.VCInfoContainer) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) VCellConnection(cbit.vcell.server.VCellConnection) BioModelInfo(org.vcell.util.document.BioModelInfo) SimulationStatusPersistent(cbit.vcell.server.SimulationStatusPersistent) TreeMap(java.util.TreeMap) SimulationContext(cbit.vcell.mapping.SimulationContext) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) IOException(java.io.IOException) OutputContext(cbit.vcell.simdata.OutputContext) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) UserLoginInfo(org.vcell.util.document.UserLoginInfo) XMLSource(cbit.vcell.xml.XMLSource)

Example 4 with VCellBootstrap

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

the class TestMissingSimData method getVCellBootstrap.

public static VCellBootstrap getVCellBootstrap(String rmiHostName, int rmiPort, String rmiBootstrapStubName, int retryCount, boolean bWaitForNull) throws Exception {
    String rmiUrl = "//" + rmiHostName + ":" + rmiPort + "/" + rmiBootstrapStubName;
    retryCount = (retryCount < 1 ? 1 : retryCount);
    for (int i = 0; i < retryCount; i++) {
        VCellBootstrap vcellBootstrap = null;
        try {
            vcellBootstrap = (VCellBootstrap) Naming.lookup(rmiUrl);
        } catch (Exception ce) {
            if (bWaitForNull) {
                return null;
            }
            System.out.println(rmiUrl + " VCellBootstrap not responding, trying " + (retryCount - 1 - i) + " more times...");
        // probably no rmiregistry started yet, keep trying
        // throw ce;
        }
        if (!bWaitForNull && vcellBootstrap != null) {
            return vcellBootstrap;
        } else if (bWaitForNull && vcellBootstrap == null) {
            return null;
        }
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        // ignore
        }
    }
    throw new VCellBootstrapTimeoutException();
}
Also used : VCellBootstrap(cbit.vcell.server.VCellBootstrap) BigString(org.vcell.util.BigString) SQLException(java.sql.SQLException)

Example 5 with VCellBootstrap

use of cbit.vcell.server.VCellBootstrap 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)

Aggregations

VCellBootstrap (cbit.vcell.server.VCellBootstrap)7 VCellConnection (cbit.vcell.server.VCellConnection)5 BigString (org.vcell.util.BigString)5 UserLoginInfo (org.vcell.util.document.UserLoginInfo)5 DigestedPassword (org.vcell.util.document.UserLoginInfo.DigestedPassword)5 MessageEvent (cbit.rmi.event.MessageEvent)3 SimulationStatusPersistent (cbit.vcell.server.SimulationStatusPersistent)3 Simulation (cbit.vcell.solver.Simulation)3 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)3 BioModelInfo (org.vcell.util.document.BioModelInfo)3 BioModel (cbit.vcell.biomodel.BioModel)2 SimulationContext (cbit.vcell.mapping.SimulationContext)2 OutputContext (cbit.vcell.simdata.OutputContext)2 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)2 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)2 ODESimData (cbit.vcell.solver.ode.ODESimData)2 XMLSource (cbit.vcell.xml.XMLSource)2 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 KeyValue (org.vcell.util.document.KeyValue)2