Search in sources :

Example 1 with PerformanceMonitorEvent

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));
}
Also used : VCInfoContainer(org.vcell.util.document.VCInfoContainer) PerformanceData(cbit.rmi.event.PerformanceData) PerformanceMonitorEvent(cbit.rmi.event.PerformanceMonitorEvent) PerformanceDataEntry(cbit.rmi.event.PerformanceDataEntry) DataAccessException(org.vcell.util.DataAccessException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)

Example 2 with PerformanceMonitorEvent

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();
        }
    }
}
Also used : ExportEventRepresentation(org.vcell.api.common.events.ExportEventRepresentation) ExportEvent(cbit.rmi.event.ExportEvent) SimulationJobStatusEventRepresentation(org.vcell.api.common.events.SimulationJobStatusEventRepresentation) Gson(com.google.gson.Gson) SimulationJobStatusEvent(cbit.rmi.event.SimulationJobStatusEvent) DataJobEvent(cbit.rmi.event.DataJobEvent) DataJobEventRepresentation(org.vcell.api.common.events.DataJobEventRepresentation) WorkerEvent(cbit.rmi.event.WorkerEvent) VCellMessageEvent(cbit.rmi.event.VCellMessageEvent) PerformanceMonitorEvent(cbit.rmi.event.PerformanceMonitorEvent)

Example 3 with PerformanceMonitorEvent

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);
        }
    }
}
Also used : VCellMessageEvent(cbit.rmi.event.VCellMessageEvent) MessageEvent(cbit.rmi.event.MessageEvent) PerformanceData(cbit.rmi.event.PerformanceData) PerformanceMonitorEvent(cbit.rmi.event.PerformanceMonitorEvent) PerformanceDataEntry(cbit.rmi.event.PerformanceDataEntry) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

PerformanceMonitorEvent (cbit.rmi.event.PerformanceMonitorEvent)3 PerformanceData (cbit.rmi.event.PerformanceData)2 PerformanceDataEntry (cbit.rmi.event.PerformanceDataEntry)2 VCellMessageEvent (cbit.rmi.event.VCellMessageEvent)2 DataAccessException (org.vcell.util.DataAccessException)2 DataJobEvent (cbit.rmi.event.DataJobEvent)1 ExportEvent (cbit.rmi.event.ExportEvent)1 MessageEvent (cbit.rmi.event.MessageEvent)1 SimulationJobStatusEvent (cbit.rmi.event.SimulationJobStatusEvent)1 WorkerEvent (cbit.rmi.event.WorkerEvent)1 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)1 Gson (com.google.gson.Gson)1 DataJobEventRepresentation (org.vcell.api.common.events.DataJobEventRepresentation)1 ExportEventRepresentation (org.vcell.api.common.events.ExportEventRepresentation)1 SimulationJobStatusEventRepresentation (org.vcell.api.common.events.SimulationJobStatusEventRepresentation)1 VCInfoContainer (org.vcell.util.document.VCInfoContainer)1