use of cbit.rmi.event.PerformanceMonitorEvent 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 cbit.rmi.event.PerformanceMonitorEvent in project vcell by virtualcell.
the class RestEventService method newEventMessage.
private void newEventMessage(MessageEvent event) {
System.out.println(getClass().getName() + ".newEventMessage(" + event.getClass().getSimpleName() + ": " + event);
if (event instanceof ExportEvent) {
ExportEvent exportEvent = (ExportEvent) event;
try {
ExportEventRepresentation exportEventRep = exportEvent.toJsonRep();
ExportEvent event2 = ExportEvent.fromJsonRep(this, exportEventRep);
if (!Compare.isEqual(event2.getFormat(), exportEvent.getFormat())) {
throw new RuntimeException("Export event round-trip failed");
}
if (!Compare.isEqual(event2.getJobID(), exportEvent.getJobID())) {
throw new RuntimeException("Export event round-trip failed");
}
Gson gson = new Gson();
String eventJSON = gson.toJson(exportEventRep);
insert(exportEventRep.username, EventType.ExportEvent, eventJSON);
} catch (Exception e) {
e.printStackTrace();
}
} else if (event instanceof SimulationJobStatusEvent) {
SimulationJobStatusEvent simJobEvent = (SimulationJobStatusEvent) event;
try {
SimulationJobStatusEventRepresentation simJobEventRep = simJobEvent.toJsonRep();
SimulationJobStatusEvent event2 = SimulationJobStatusEvent.fromJsonRep(this, simJobEventRep);
if (!Compare.isEqual(event2.getJobStatus(), simJobEvent.getJobStatus())) {
throw new RuntimeException("SimulationJobStatus event round-trip failed");
}
if (!Compare.isEqual(event2.getProgress(), simJobEvent.getProgress())) {
throw new RuntimeException("SimulationJobStatus <PROGRESS> event round-trip failed");
}
Gson gson = new Gson();
String eventJSON = gson.toJson(simJobEventRep);
insert(simJobEventRep.username, EventType.SimJob, eventJSON);
} catch (Exception e) {
e.printStackTrace();
}
} else if (event instanceof VCellMessageEvent) {
VCellMessageEvent vcellMessageEvent = (VCellMessageEvent) event;
lg.error("event of type VCellMessageEvent not supported");
} else if (event instanceof WorkerEvent) {
lg.error("event of type WorkerEvent not supported");
WorkerEvent workerEvent = (WorkerEvent) event;
} else if (event instanceof PerformanceMonitorEvent) {
lg.error("event of type PerformanceMonitorEvent not supported");
PerformanceMonitorEvent performanceMonitorEvent = (PerformanceMonitorEvent) event;
} else if (event instanceof DataJobEvent) {
lg.error("event of type DataJobEvent not supported");
DataJobEvent dataJobEvent = (DataJobEvent) event;
try {
DataJobEventRepresentation dataJobEventRep = dataJobEvent.toJsonRep();
DataJobEvent event2 = DataJobEvent.fromJsonRep(this, dataJobEventRep);
if (!Compare.isEqual(event2.getDataIdString(), dataJobEvent.getDataIdString())) {
throw new RuntimeException("DataJob event round-trip failed");
}
if (!Compare.isEqual(event2.getProgress(), dataJobEvent.getProgress())) {
throw new RuntimeException("DataJob <PROGRESS> event round-trip failed");
}
Gson gson = new Gson();
String eventJSON = gson.toJson(dataJobEventRep);
insert(dataJobEventRep.username, EventType.DataJob, eventJSON);
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of cbit.rmi.event.PerformanceMonitorEvent in project vcell by virtualcell.
the class AsynchMessageManager method poll.
private void poll() {
if (!bPoll.get()) {
if (lg.isDebugEnabled()) {
lg.debug("polling stopped");
}
return;
}
if (lg.isDebugEnabled()) {
lg.debug("polling");
}
boolean report = counter % 50 == 0;
long begin = 0;
long end = 0;
//
try {
MessageEvent[] queuedEvents = null;
if (report) {
// time the call
begin = System.currentTimeMillis();
}
synchronized (this) {
if (!clientServerManager.isStatusConnected()) {
clientServerManager.attemptReconnect();
return;
}
pollTime = BASE_POLL_SECONDS;
queuedEvents = clientServerManager.getMessageEvents();
}
if (report) {
end = System.currentTimeMillis();
}
// this is skipped if the connection has failed:w
failureCount = 0;
// deal with events, if any
if (queuedEvents != null) {
for (MessageEvent messageEvent : queuedEvents) {
onMessageEvent(messageEvent);
}
}
// report polling call performance
if (report) {
double duration = ((double) (end - begin)) / 1000;
PerformanceMonitorEvent performanceMonitorEvent = new PerformanceMonitorEvent(this, null, new PerformanceData("AsynchMessageManager.poll()", MessageEvent.POLLING_STAT, new PerformanceDataEntry[] { new PerformanceDataEntry("remote call duration", Double.toString(duration)) }));
}
} catch (Exception exc) {
System.out.println(">> polling failure << " + exc.getMessage());
pollTime = ATTEMPT_POLL_SECONDS;
failureCount++;
if (failureCount % 3 == 0) {
bPoll.set(false);
clientServerManager.setDisconnected();
}
} finally {
if (lg.isDebugEnabled()) {
lg.debug(ExecutionTrace.justClassName(this) + " poll time " + pollTime + " seconds");
}
if (bPoll.get()) {
schedule(pollTime);
}
}
}
Aggregations