@Override public void close() throws IOException { super.close(); }
/** * Callback used to receive notifications from the {@link RootMetricContext}. */ private void notificationCallback(Notification notification) { if (notification instanceof MetricContextCleanupNotification) { removedMetricContext(((MetricContextCleanupNotification) notification).getMetricContext()); } if (notification instanceof NewMetricContextNotification) { newMetricContext(((NewMetricContextNotification) notification).getMetricContext()); } }
/** * Add a new {@link ContextAwareReporter} to the {@link RootMetricContext} for it to manage. * @param reporter {@link ContextAwareReporter} to manage. */ public void addNewReporter(ContextAwareReporter reporter) { this.reporters.add(this.closer.register(reporter)); if (this.reportingStarted) { reporter.start(); } }
/** * Remove {@link ContextAwareReporter} from the set of managed reporters. * @param reporter {@link ContextAwareReporter} to remove. */ public void removeReporter(ContextAwareReporter reporter) { if (this.reporters.contains(reporter)) { reporter.stop(); this.reporters.remove(reporter); } }
@Override protected void removedMetricContext(InnerMetricContext context) { if (shouldReportInnerMetricContext(context)) { report(context, true); } super.removedMetricContext(context); }
/** * Stops the {@link ContextAwareReporter}. If the {@link ContextAwareReporter} has not been started, or if it has been * stopped already, and not started since, this is a no-op. */ public final void stop() { if (!this.started) { log.warn(String.format("Reporter %s has already been stopped.", this.name)); return; } try { stopImpl(); this.started = false; } catch (Exception exception) { log.warn(String.format("Reporter %s did not stop correctly.", this.name), exception); } }
/** * Starts the {@link ContextAwareReporter}. If the {@link ContextAwareReporter} has been started * (and not stopped since), this is a no-op. */ public final void start() { if (this.started) { log.warn(String.format("Reporter %s has already been started.", this.name)); return; } try { startImpl(); this.started = true; } catch (Exception exception) { log.warn(String.format("Reporter %s did not start correctly.", this.name), exception); } }
/** * Stop all {@link ContextAwareReporter}s managed by the {@link RootMetricContext}. */ public void stopReporting() { this.reportingStarted = false; for (ContextAwareReporter reporter : this.reporters) { try { reporter.stop(); } catch (Throwable throwable) { log.error(String.format("Failed to stop reporter with class %s", reporter.getClass().getCanonicalName()), throwable); } } }
@Override protected void removedMetricContext(InnerMetricContext context) { if (shouldReportInnerMetricContext(context)) { report(context, true); } super.removedMetricContext(context); }
/** * Stops the {@link ContextAwareReporter}. If the {@link ContextAwareReporter} has not been started, or if it has been * stopped already, and not started since, this is a no-op. */ public final void stop() { if (!this.started) { log.warn(String.format("Reporter %s has already been stopped.", this.name)); return; } try { stopImpl(); this.started = false; } catch (Exception exception) { log.warn(String.format("Reporter %s did not stop correctly.", this.name), exception); } }
/** * Starts the {@link ContextAwareReporter}. If the {@link ContextAwareReporter} has been started * (and not stopped since), this is a no-op. */ public final void start() { if (this.started) { log.warn(String.format("Reporter %s has already been started.", this.name)); return; } try { startImpl(); this.started = true; } catch (Exception exception) { log.warn(String.format("Reporter %s did not start correctly.", this.name), exception); } }
/** * Callback used to receive notifications from the {@link RootMetricContext}. */ private void notificationCallback(Notification notification) { if (notification instanceof MetricContextCleanupNotification) { removedMetricContext(((MetricContextCleanupNotification) notification).getMetricContext()); } if (notification instanceof NewMetricContextNotification) { newMetricContext(((NewMetricContextNotification) notification).getMetricContext()); } }
/** * Remove {@link ContextAwareReporter} from the set of managed reporters. * @param reporter {@link ContextAwareReporter} to remove. */ public void removeReporter(ContextAwareReporter reporter) { if (this.reporters.contains(reporter)) { reporter.stop(); this.reporters.remove(reporter); } }
/** * Start all {@link ContextAwareReporter}s managed by the {@link RootMetricContext}. */ public void startReporting() { this.reportingStarted = true; for (ContextAwareReporter reporter : this.reporters) { try { reporter.start(); } catch (Throwable throwable) { log.error(String.format("Failed to start reporter with class %s", reporter.getClass().getCanonicalName()), throwable); } } }
@Override public void close() throws IOException { super.close(); }
/** * Stop all {@link ContextAwareReporter}s managed by the {@link RootMetricContext}. */ public void stopReporting() { this.reportingStarted = false; for (ContextAwareReporter reporter : this.reporters) { try { reporter.stop(); } catch (Throwable throwable) { log.error(String.format("Failed to stop reporter with class %s", reporter.getClass().getCanonicalName()), throwable); } } }
/** * Add a new {@link ContextAwareReporter} to the {@link RootMetricContext} for it to manage. * @param reporter {@link ContextAwareReporter} to manage. */ public void addNewReporter(ContextAwareReporter reporter) { this.reporters.add(this.closer.register(reporter)); if (this.reportingStarted) { reporter.start(); } }
/** * Start all {@link ContextAwareReporter}s managed by the {@link RootMetricContext}. */ public void startReporting() { this.reportingStarted = true; for (ContextAwareReporter reporter : this.reporters) { try { reporter.start(); } catch (Throwable throwable) { log.error(String.format("Failed to start reporter with class %s", reporter.getClass().getCanonicalName()), throwable); } } }