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;
}
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;
}
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;
}
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);
}
}
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();
}
}
}
Aggregations