use of org.vcell.util.document.UserLoginInfo in project vcell by virtualcell.
the class ErrorUtils method sendRemoteLogMessage.
/**
* send message to Virtual Cell server, if not in debug mode
* @param userLoginInfo; if null, user previously set info if available
* @param message
*/
public static void sendRemoteLogMessage(UserLoginInfo argUserLoginInfo, final String message) {
final UserLoginInfo userLoginInfo = argUserLoginInfo != null ? argUserLoginInfo : ErrorUtils.loginInfo;
if (!ErrorUtils.bDebugMode && userLoginInfo != null) {
new Thread(new Runnable() {
@Override
public void run() {
try {
final String formattedMessage = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(Calendar.getInstance().getTime()) + "\n" + "vers='" + VCellSoftwareVersion.fromSystemProperty().getSoftwareVersionString() + "' java='" + userLoginInfo.getJava_version() + "' os='" + userLoginInfo.getOs_name() + "' osvers='" + userLoginInfo.getOs_version() + "' arch='" + userLoginInfo.getOs_arch() + "'\n" + message;
AmplistorUtils.uploadString(AmplistorUtils.DEFAULT_PROXY_AMPLI_VCELL_LOGS_URL + userLoginInfo.getUserName() + "_" + System.currentTimeMillis(), null, formattedMessage);
} catch (Exception e) {
e.printStackTrace();
System.err.println("Failed to upload message to Amplistor " + AmplistorUtils.DEFAULT_PROXY_AMPLI_VCELL_LOGS_URL + " : " + message);
// ignore
}
}
}).start();
} else {
System.err.println("Remote log message: " + message);
}
}
use of org.vcell.util.document.UserLoginInfo in project vcell by virtualcell.
the class HybridSolverTester method main.
public static void main(java.lang.String[] args) {
VCMongoMessage.enabled = false;
boolean bAlternate = false;
if (args.length == 12) {
bAlternate = true;
} else if (args.length != 5) {
System.out.println("usage: HybridSolverTest userid SimID times(delimited by :) dataIndexes(delimited by :) varNames(delimited by :) numRuns outputFileDirectory bCalclOnly dbPassword useridKey rmiServer rmiPort");
System.out.println("usage: HybridSolverTest userid SimID all postproc varNames(delimited by :) numRuns outputFileDirectory bCalclOnly dbPassword useridKey rmiServer rmiPort");
System.out.println("usage: HybridSolverTest mathVCMLFileName startingTrialNo numTrials varNames(delimited by :) bPrintTime vcellSite(rel,beta,...)");
System.exit(1);
}
FileWriter fw = null;
try {
if (bAlternate) {
AltArgsHelper altArgsHelper = new AltArgsHelper(args[0], args[1], args[2], args[3], args[4], Integer.parseInt(args[5]), new File(args[6]), Boolean.parseBoolean(args[7]), args[8], args[9], args[10], args[11]);
// final String user = args[0];
// final String simID = args[1];
// final int numRuns = Integer.parseInt(args[5]);
//
// final String simPrefix = "SimID_"+simID+"_";
// File userSimDataDir = new File("\\\\cfs02\\raid\\vcell\\users\\"+user);
// File outputDir = new File(args[6]);
// boolean bCalcOnly = Boolean.parseBoolean(args[7]);
// String dbPassword = args[8];
// String useridKey = args[9];
// String rmiServer = args[10];
// String rmiPort = args[11];
VCSimulationIdentifier vcSimulationIdentifier = new VCSimulationIdentifier(new KeyValue(altArgsHelper.simID), altArgsHelper.user);
UserLoginInfo userLoginInfo = new UserLoginInfo(altArgsHelper.user.getName(), new DigestedPassword(altArgsHelper.dbPassword));
File[] trialList = null;
VCellConnectionHelper vCellConnectionHelper = null;
File emptyFile = File.createTempFile("hstempty", null);
try {
if (!altArgsHelper.bCalcOnly) {
// String rmiUrl = "//" + "rmi-alpha.cam.uchc.edu" + ":" + "40106" + "/"+"VCellBootstrapServer";
// String rmiUrl = "//" + "rmi-alpha.cam.uchc.edu" + ":" + "40112" + "/"+"VCellBootstrapServer";
String rmiUrl = "//" + altArgsHelper.rmiServer + ".cam.uchc.edu" + ":" + altArgsHelper.rmiPort + "/" + "VCellBootstrapServer";
vCellConnectionHelper = new VCellConnectionHelper(userLoginInfo, rmiUrl);
for (int runIndex = 0; runIndex < altArgsHelper.numRuns; runIndex++) {
System.out.println("----- Starting run " + (runIndex + 1) + " of " + altArgsHelper.numRuns);
runSim(userLoginInfo, vcSimulationIdentifier, vCellConnectionHelper);
if (trialList == null) {
System.out.println("Sim ran, getting trial list for " + altArgsHelper.simPrefix + " please wait...");
trialList = altArgsHelper.userSimDataDir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
// }
return pathname.getName().startsWith(altArgsHelper.simPrefix) && !pathname.getName().endsWith(".simtask.xml");
}
});
}
System.out.println("----- Copying run " + (runIndex + 1) + " of " + altArgsHelper.numRuns);
File outputRunDir = makeOutputRunDir(altArgsHelper.outputDir, runIndex);
for (int j = 0; j < trialList.length; j++) {
File localCopyFile = new File(outputRunDir, trialList[j].getName());
try {
// copy remote sim data file to local
FileUtils.copyFile(trialList[j], localCopyFile);
// delete remote
trialList[j].delete();
} catch (Exception e) {
System.out.println("failed to copy '" + trialList[j].getAbsolutePath() + "', error=" + e.getMessage() + ". Putting empty file as placeholder");
try {
// copy empty file to local in place of problematic remote sim data file, later analysis will skip it
FileUtils.copyFile(emptyFile, localCopyFile);
} catch (Exception e2) {
System.out.println("Faild to copy file and failed to copy empty, " + e2.getMessage());
}
}
}
}
}
// calc stats
String dateStr = dateFormat.format(new Date());
String outPrefix = altArgsHelper.simID + "_" + dateStr + "_0";
File outputFile = new File(altArgsHelper.outputDir, outPrefix + ".csv");
while (outputFile.exists()) {
outPrefix = TokenMangler.getNextEnumeratedToken(outPrefix);
outputFile = new File(altArgsHelper.outputDir, outPrefix + ".csv");
}
fw = new FileWriter(outputFile);
fw.write("\"" + altArgsHelper.toString() + "\"\n");
for (int runIndex = 0; runIndex < altArgsHelper.numRuns; runIndex++) {
makeAltCSV(altArgsHelper, fw, runIndex, makeOutputRunDir(altArgsHelper.outputDir, runIndex));
}
fw.close();
} finally {
if (!altArgsHelper.bCalcOnly) {
File[] straglers = altArgsHelper.userSimDataDir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.getName().startsWith(altArgsHelper.simPrefix);
}
});
if (straglers != null) {
for (int i = 0; i < straglers.length; i++) {
straglers[i].delete();
}
}
}
}
} else {
String site = args[5];
HybridSolverTester hst = new HybridSolverTester(args[0], Integer.parseInt(args[1]), Integer.parseInt(args[2]), args[3], Boolean.parseBoolean(args[4]));
hst.runHybridTest(site);
}
} catch (Exception e) {
e.printStackTrace(System.out);
System.exit(1);
} finally {
if (fw != null) {
try {
fw.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
use of org.vcell.util.document.UserLoginInfo 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.UserLoginInfo 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;
}
use of org.vcell.util.document.UserLoginInfo 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;
}
Aggregations