use of org.vcell.util.document.VCInfoContainer in project vcell by virtualcell.
the class ClientDocumentManager method initAllDatabaseInfos.
/**
* Insert the method's description here.
* Creation date: (9/25/2003 7:45:19 AM)
* @return cbit.vcell.modeldb.VCInfoContainer
*/
public synchronized void initAllDatabaseInfos() throws DataAccessException {
clear();
VCInfoContainer vcInfoContainer = null;
try {
System.out.println("ClientDocumentManager.initAllDatabaseInfos()");
long time1 = System.currentTimeMillis();
//
// gets BioModelMetaDatas, MathModelMetaDatas, all VersionInfos, and ResultSetInfos
//
vcInfoContainer = sessionManager.getUserMetaDbServer().getVCInfoContainer();
PerformanceMonitorEvent pme = new PerformanceMonitorEvent(this, getUser(), new PerformanceData("ClientDocumentManager.initAllDatabaseInfos()", MessageEvent.LOGON_STAT, new PerformanceDataEntry[] { new PerformanceDataEntry("remote call duration", Double.toString(((double) System.currentTimeMillis() - time1) / 1000.0)) }));
} catch (RemoteProxyException e) {
handleRemoteProxyException(e);
throw new DataAccessException("RemoteProxyException: " + e.getMessage());
}
//
// BioModelInfos
//
{
bioModelInfoHash.clear();
BioModelInfo[] bioModelInfos = vcInfoContainer.getBioModelInfos();
if (bioModelInfos != null) {
for (int i = 0; i < bioModelInfos.length; i++) {
bioModelInfoHash.put(bioModelInfos[i].getVersion().getVersionKey(), bioModelInfos[i]);
}
}
}
//
// Geometries
//
{
geoInfoHash.clear();
GeometryInfo[] geometryInfos = vcInfoContainer.getGeometryInfos();
if (geometryInfos != null) {
for (int i = 0; i < geometryInfos.length; i++) {
geoInfoHash.put(geometryInfos[i].getVersion().getVersionKey(), geometryInfos[i]);
}
}
}
//
// MathModelInfos
//
{
mathModelInfoHash.clear();
MathModelInfo[] mathModelInfos = vcInfoContainer.getMathModelInfos();
if (mathModelInfos != null) {
for (int i = 0; i < mathModelInfos.length; i++) {
mathModelInfoHash.put(mathModelInfos[i].getVersion().getVersionKey(), mathModelInfos[i]);
}
}
}
//
// VCImageInfos
//
{
imgInfoHash.clear();
VCImageInfo[] vcImageInfos = vcInfoContainer.getVCImageInfos();
if (vcImageInfos != null) {
for (int i = 0; i < vcImageInfos.length; i++) {
imgInfoHash.put(vcImageInfos[i].getVersion().getVersionKey(), vcImageInfos[i]);
}
}
}
fireDatabaseRefresh(new DatabaseEvent(this, DatabaseEvent.REFRESH, null, null));
}
use of org.vcell.util.document.VCInfoContainer 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;
}
}
use of org.vcell.util.document.VCInfoContainer in project vcell by virtualcell.
the class HealthService method loginLoop.
private void loginLoop() {
try {
Thread.sleep(LOGIN_LOOP_START_DELAY);
} catch (InterruptedException e1) {
}
while (true) {
long id = loginStartEvent();
try {
UserLoginInfo userLoginInfo = new UserLoginInfo(testUserid, testPassword);
RemoteProxyVCellConnectionFactory vcellConnectionFactory = new RemoteProxyVCellConnectionFactory(host, port, userLoginInfo);
VCellConnection vcellConnection = vcellConnectionFactory.createVCellConnection();
VCInfoContainer vcInfoContainer = vcellConnection.getUserMetaDbServer().getVCInfoContainer();
loginSuccess(id);
} catch (Throwable e) {
loginFailed(id, e.getMessage());
}
try {
Thread.sleep(LOGIN_LOOP_SLEEP);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
use of org.vcell.util.document.VCInfoContainer in project vcell by virtualcell.
the class RemoteProxyVCellConnectionFactoryTest method test.
@Test
public void test() throws IOException {
BiomodelRepresentation[] biomodelReps = apiClient.getBioModels(new BioModelsQuerySpec());
assertNotNull(biomodelReps);
VCInfoContainer vcInfoContainer = null;
try {
vcInfoContainer = vcConn.getUserMetaDbServer().getVCInfoContainer();
} catch (DataAccessException | RemoteProxyException e) {
e.printStackTrace();
fail("exception");
}
assertNotNull(vcInfoContainer);
}
use of org.vcell.util.document.VCInfoContainer in project vcell by virtualcell.
the class DbDriver method getVCInfoContainer.
/**
* Insert the method's description here.
* Creation date: (9/24/2003 12:54:32 PM)
* @return cbit.vcell.modeldb.VCInfoContainer
*/
public static VCInfoContainer getVCInfoContainer(User user, Connection con, DatabaseSyntax dbSyntax) throws SQLException, DataAccessException {
VCInfoContainer results = null;
//
VCImageInfo[] vcImageInfos = null;
GeometryInfo[] geometryInfos = null;
MathModelInfo[] mathModelInfos = null;
BioModelInfo[] bioModelInfos = null;
//
StringBuffer sql = null;
String special = null;
ResultSet rset = null;
boolean enableSpecial = true;
boolean enableDistinct = true;
Statement stmt = con.createStatement();
try {
//
// BioModelInfos
//
{
double beginTime = System.currentTimeMillis();
special = " ORDER BY " + BioModelTable.table.name.getQualifiedColName() + "," + BioModelTable.table.versionBranchID.getQualifiedColName() + "," + BioModelTable.table.versionDate.getQualifiedColName();
sql = new StringBuffer(BioModelTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), dbSyntax));
sql.insert(7, Table.SQL_GLOBAL_HINT);
rset = stmt.executeQuery(sql.toString());
ArrayList<BioModelInfo> tempInfos = new ArrayList<BioModelInfo>();
Set<String> distinctV = new HashSet<String>();
while (rset.next()) {
BioModelInfo versionInfo = (BioModelInfo) BioModelTable.table.getInfo(rset, con, dbSyntax);
if (!distinctV.contains(versionInfo.getVersion().getVersionKey().toString())) {
tempInfos.add(versionInfo);
distinctV.add(versionInfo.getVersion().getVersionKey().toString());
}
}
rset.close();
if (tempInfos.size() > 0) {
bioModelInfos = new BioModelInfo[tempInfos.size()];
tempInfos.toArray(bioModelInfos);
}
if (lg.isInfoEnabled()) {
lg.info("BioModelInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
}
}
//
// MathModelInfos
//
{
double beginTime = System.currentTimeMillis();
special = " ORDER BY " + MathModelTable.table.name.getQualifiedColName() + "," + MathModelTable.table.versionBranchID.getQualifiedColName() + "," + MathModelTable.table.versionDate.getQualifiedColName();
sql = new StringBuffer(MathModelTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), dbSyntax));
sql.insert(7, Table.SQL_GLOBAL_HINT);
rset = stmt.executeQuery(sql.toString());
ArrayList<MathModelInfo> tempInfos = new ArrayList<MathModelInfo>();
Set<String> distinctV = new HashSet<String>();
while (rset.next()) {
MathModelInfo versionInfo = (MathModelInfo) MathModelTable.table.getInfo(rset, con, dbSyntax);
if (!distinctV.contains(versionInfo.getVersion().getVersionKey().toString())) {
tempInfos.add(versionInfo);
distinctV.add(versionInfo.getVersion().getVersionKey().toString());
}
}
rset.close();
if (tempInfos.size() > 0) {
mathModelInfos = new MathModelInfo[tempInfos.size()];
tempInfos.toArray(mathModelInfos);
}
if (lg.isInfoEnabled()) {
lg.info("MathModelInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
}
}
//
// VCImageInfos
//
{
double beginTime = System.currentTimeMillis();
special = " ORDER BY " + ImageTable.table.name.getQualifiedColName() + "," + ImageTable.table.versionBranchID.getQualifiedColName() + "," + ImageTable.table.versionDate.getQualifiedColName();
sql = new StringBuffer(ImageTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), true, dbSyntax));
sql.insert(7, Table.SQL_GLOBAL_HINT);
rset = stmt.executeQuery(sql.toString());
ArrayList<VCImageInfo> tempInfos = new ArrayList<VCImageInfo>();
Set<String> distinctV = new HashSet<String>();
while (rset.next()) {
VCImageInfo versionInfo = (VCImageInfo) ImageTable.table.getInfo(rset, con, dbSyntax);
if (!distinctV.contains(versionInfo.getVersion().getVersionKey().toString())) {
tempInfos.add(versionInfo);
distinctV.add(versionInfo.getVersion().getVersionKey().toString());
}
}
rset.close();
if (tempInfos.size() > 0) {
vcImageInfos = new VCImageInfo[tempInfos.size()];
tempInfos.toArray(vcImageInfos);
}
if (lg.isInfoEnabled()) {
lg.info("ImageInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
}
}
//
// GeometeryInfos
//
{
double beginTime = System.currentTimeMillis();
special = " ORDER BY " + GeometryTable.table.name.getQualifiedColName() + "," + GeometryTable.table.versionBranchID.getQualifiedColName() + "," + GeometryTable.table.versionDate.getQualifiedColName();
sql = new StringBuffer(GeometryTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), true, dbSyntax));
sql.insert(7, Table.SQL_GLOBAL_HINT + (enableDistinct ? "DISTINCT " : ""));
rset = stmt.executeQuery(sql.toString());
ArrayList<GeometryInfo> tempInfos = new ArrayList<GeometryInfo>();
Set<String> distinctV = new HashSet<String>();
while (rset.next()) {
GeometryInfo versionInfo = (GeometryInfo) GeometryTable.table.getInfo(rset, con);
if (!distinctV.contains(versionInfo.getVersion().getVersionKey().toString())) {
tempInfos.add(versionInfo);
distinctV.add(versionInfo.getVersion().getVersionKey().toString());
}
}
rset.close();
if (tempInfos.size() > 0) {
geometryInfos = new GeometryInfo[tempInfos.size()];
tempInfos.toArray(geometryInfos);
}
if (lg.isInfoEnabled()) {
lg.info("GeometryInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
}
}
} finally {
if (stmt != null) {
stmt.close();
}
}
results = new VCInfoContainer(user, vcImageInfos, geometryInfos, mathModelInfos, bioModelInfos);
return results;
}
Aggregations