Search in sources :

Example 1 with MonitorElemCapHandler

use of com.creditease.monitor.captureframework.spi.MonitorElemCapHandler in project uavstack by uavorg.

the class StandardMonitor method doCapture.

@Override
public void doCapture(String captureId, CaptureContext context, CapturePhase capPhase) {
    if (captureId == null) {
        return;
    }
    // step 1: see if it is a valid captureId
    MonitorElement[] elems = mr.getElementByCapId(captureId);
    for (MonitorElement elem : elems) {
        // if the monitor element is not enabled, just skip it
        if (elem.isEnabled() == false)
            continue;
        // step 2: get capture class
        String capClassName = elem.getCapClass();
        // step 3: check if there is one handler exists, if not new one
        MonitorElemCapHandler caphandler = selectHandler(capClassName);
        // step 4: invoke handler
        if (caphandler != null) {
            try {
                invokeCaphandler(context, capPhase, elem, caphandler);
            } catch (Exception e) {
                log.error("captureHandler[" + capClassName + "] execution [" + capPhase + "] fails ", e);
            // ignore
            }
        }
    }
}
Also used : MonitorElemCapHandler(com.creditease.monitor.captureframework.spi.MonitorElemCapHandler) MonitorElement(com.creditease.monitor.captureframework.spi.MonitorElement)

Example 2 with MonitorElemCapHandler

use of com.creditease.monitor.captureframework.spi.MonitorElemCapHandler in project uavstack by uavorg.

the class StandardMonitor method doPreStore.

@Override
public void doPreStore() {
    MonitorRepository cmr = getRepository();
    MonitorElement[] elems = cmr.getElements();
    for (MonitorElement elem : elems) {
        MonitorElemCapHandler caphandler = selectHandler(elem.getCapClass());
        if (caphandler == null)
            continue;
        MonitorElementInstance[] instances = elem.getInstances();
        for (MonitorElementInstance instance : instances) {
            try {
                caphandler.preStore(instance);
            } catch (Exception e) {
                log.error("captureHandler[" + caphandler.getClass().getName() + "] execution [preStore] fails ", e);
            // ignore
            }
        }
    }
}
Also used : MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance) MonitorRepository(com.creditease.monitor.captureframework.spi.MonitorRepository) StandardMonitorRepository(com.creditease.monitor.captureframework.repository.StandardMonitorRepository) MonitorElemCapHandler(com.creditease.monitor.captureframework.spi.MonitorElemCapHandler) MonitorElement(com.creditease.monitor.captureframework.spi.MonitorElement)

Aggregations

MonitorElemCapHandler (com.creditease.monitor.captureframework.spi.MonitorElemCapHandler)2 MonitorElement (com.creditease.monitor.captureframework.spi.MonitorElement)2 StandardMonitorRepository (com.creditease.monitor.captureframework.repository.StandardMonitorRepository)1 MonitorElementInstance (com.creditease.monitor.captureframework.spi.MonitorElementInstance)1 MonitorRepository (com.creditease.monitor.captureframework.spi.MonitorRepository)1