Search in sources :

Example 1 with FrontMetricGroup

use of org.apache.flink.runtime.metrics.groups.FrontMetricGroup in project flink by apache.

the class MetricRegistry method register.

// ------------------------------------------------------------------------
//  Metrics (de)registration
// ------------------------------------------------------------------------
/**
	 * Registers a new {@link Metric} with this registry.
	 *
	 * @param metric      the metric that was added
	 * @param metricName  the name of the metric
	 * @param group       the group that contains the metric
	 */
public void register(Metric metric, String metricName, AbstractMetricGroup group) {
    try {
        if (reporters != null) {
            for (int i = 0; i < reporters.size(); i++) {
                MetricReporter reporter = reporters.get(i);
                if (reporter != null) {
                    FrontMetricGroup front = new FrontMetricGroup<AbstractMetricGroup<?>>(i, group);
                    reporter.notifyOfAddedMetric(metric, metricName, front);
                }
            }
        }
        if (queryService != null) {
            MetricQueryService.notifyOfAddedMetric(queryService, metric, metricName, group);
        }
        if (metric instanceof View) {
            if (viewUpdater == null) {
                viewUpdater = new ViewUpdater(executor);
            }
            viewUpdater.notifyOfAddedView((View) metric);
        }
    } catch (Exception e) {
        LOG.error("Error while registering metric.", e);
    }
}
Also used : FrontMetricGroup(org.apache.flink.runtime.metrics.groups.FrontMetricGroup) MetricReporter(org.apache.flink.metrics.reporter.MetricReporter) View(org.apache.flink.metrics.View)

Example 2 with FrontMetricGroup

use of org.apache.flink.runtime.metrics.groups.FrontMetricGroup in project flink by apache.

the class MetricRegistry method unregister.

/**
	 * Un-registers the given {@link Metric} with this registry.
	 *
	 * @param metric      the metric that should be removed
	 * @param metricName  the name of the metric
	 * @param group       the group that contains the metric
	 */
public void unregister(Metric metric, String metricName, AbstractMetricGroup group) {
    try {
        if (reporters != null) {
            for (int i = 0; i < reporters.size(); i++) {
                MetricReporter reporter = reporters.get(i);
                if (reporter != null) {
                    FrontMetricGroup front = new FrontMetricGroup<AbstractMetricGroup<?>>(i, group);
                    reporter.notifyOfRemovedMetric(metric, metricName, front);
                }
            }
        }
        if (queryService != null) {
            MetricQueryService.notifyOfRemovedMetric(queryService, metric);
        }
        if (metric instanceof View) {
            if (viewUpdater != null) {
                viewUpdater.notifyOfRemovedView((View) metric);
            }
        }
    } catch (Exception e) {
        LOG.error("Error while registering metric.", e);
    }
}
Also used : FrontMetricGroup(org.apache.flink.runtime.metrics.groups.FrontMetricGroup) MetricReporter(org.apache.flink.metrics.reporter.MetricReporter) View(org.apache.flink.metrics.View)

Aggregations

View (org.apache.flink.metrics.View)2 MetricReporter (org.apache.flink.metrics.reporter.MetricReporter)2 FrontMetricGroup (org.apache.flink.runtime.metrics.groups.FrontMetricGroup)2