Search in sources :

Example 36 with BigString

use of org.vcell.util.BigString in project vcell by virtualcell.

the class ClientDocumentManager method saveAsNew.

/**
 * Insert the method's description here.
 * Creation date: (1/19/01 11:27:52 AM)
 */
public Geometry saveAsNew(Geometry geometry, java.lang.String newName) throws DataAccessException {
    try {
        String geometryXML = null;
        try {
            geometryXML = XmlHelper.geometryToXML(geometry);
        } catch (XmlParseException e) {
            e.printStackTrace(System.out);
            throw new DataAccessException(e.getMessage());
        }
        if (isChanged(geometry, geometryXML) == false) {
            System.out.println("<<<<<WARNING>>>>>>>ClientDocumentManger.save(Geometry), called on unchanged geometry");
            return geometry;
        }
        String savedGeometryXML = sessionManager.getUserMetaDbServer().saveGeometryAs(new BigString(geometryXML), newName).toString();
        Geometry savedGeometry = getGeometryFromDatabaseXML(savedGeometryXML);
        KeyValue savedKey = savedGeometry.getVersion().getVersionKey();
        if (xmlHash.get(savedKey) == null) {
            xmlHash.put(savedKey, savedGeometryXML);
        }
        updateGeometryRelatedHashes(savedGeometry);
        return savedGeometry;
    } catch (RemoteProxyException e) {
        e.printStackTrace(System.out);
        throw new DataAccessException(VCellErrorMessages.FAIL_SAVE_MESSAGE + "\n\n" + e.getMessage());
    }
}
Also used : Geometry(cbit.vcell.geometry.Geometry) KeyValue(org.vcell.util.document.KeyValue) BigString(org.vcell.util.BigString) XmlParseException(cbit.vcell.xml.XmlParseException) BigString(org.vcell.util.BigString) DataAccessException(org.vcell.util.DataAccessException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)

Example 37 with BigString

use of org.vcell.util.BigString in project vcell by virtualcell.

the class TestMissingSimData method startClient.

private static void startClient(VCSimulationIdentifier vcSimulationIdentifier, UserLoginInfo userLoginInfo) throws Exception {
    ClientServerInfo clientServerInfo = ClientServerInfo.createRemoteServerInfo("vcellapi.cam.uchc.edu", 8080, userLoginInfo.getUserName(), userLoginInfo.getDigestedPassword());
    VCellClient vCellClient = VCellClient.startClient(null, clientServerInfo);
    while (vCellClient.getClientServerManager() == null || vCellClient.getClientServerManager().getConnectionStatus() == null || vCellClient.getClientServerManager().getConnectionStatus().getStatus() != ConnectionStatus.CONNECTED) {
        Thread.sleep(1000);
        System.out.println("trying connect");
    }
    BigString simXML = vCellClient.getClientServerManager().getUserMetaDbServer().getSimulationXML(vcSimulationIdentifier.getSimulationKey());
    Simulation sim = XmlHelper.XMLToSim(simXML.toString());
    vCellClient.getClientServerManager().getJobManager().startSimulation(vcSimulationIdentifier, sim.getScanCount());
    SimulationStatusPersistent simulationStatus = null;
    while (true) {
        simulationStatus = vCellClient.getClientServerManager().getUserMetaDbServer().getSimulationStatus(vcSimulationIdentifier.getSimulationKey());
        System.out.println(simulationStatus);
        if (simulationStatus.isCompleted() || simulationStatus.isFailed()) {
            break;
        }
        Thread.sleep(1000);
    // MessageEvent[] messageEvents = vcellConnection.getMessageEvents();
    // for (int i = 0; messageEvents != null && i < messageEvents.length; i++) {
    // System.out.println(messageEvents[i]);
    // }
    }
}
Also used : Simulation(cbit.vcell.solver.Simulation) VCellClient(cbit.vcell.client.VCellClient) ClientServerInfo(cbit.vcell.client.server.ClientServerInfo) SimulationStatusPersistent(cbit.vcell.server.SimulationStatusPersistent) BigString(org.vcell.util.BigString)

Example 38 with BigString

use of org.vcell.util.BigString 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 39 with BigString

use of org.vcell.util.BigString 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 40 with BigString

use of org.vcell.util.BigString 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

BigString (org.vcell.util.BigString)55 DataAccessException (org.vcell.util.DataAccessException)39 KeyValue (org.vcell.util.document.KeyValue)24 XmlParseException (cbit.vcell.xml.XmlParseException)22 BioModel (cbit.vcell.biomodel.BioModel)19 XMLSource (cbit.vcell.xml.XMLSource)19 SQLException (java.sql.SQLException)16 Simulation (cbit.vcell.solver.Simulation)15 User (org.vcell.util.document.User)15 BioModelInfo (org.vcell.util.document.BioModelInfo)13 SimulationContext (cbit.vcell.mapping.SimulationContext)12 SimulationStatusPersistent (cbit.vcell.server.SimulationStatusPersistent)10 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)10 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)9 MathException (cbit.vcell.math.MathException)8 ExpressionException (cbit.vcell.parser.ExpressionException)8 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)6 Connection (java.sql.Connection)6 MessageEvent (cbit.rmi.event.MessageEvent)5 MappingException (cbit.vcell.mapping.MappingException)5