/** * Callback used by the {@link org.apache.gobblin.metrics.MetricContext} to notify the object of a new * {@link org.apache.gobblin.metrics.GobblinTrackingEvent}. * @param notification {@link org.apache.gobblin.metrics.notification.Notification} to process. */ public void notificationCallback(Notification notification) { if (notification instanceof EventNotification) { addEventToReportingQueue(((EventNotification) notification).getEvent()); } }
/** * Add {@link org.apache.gobblin.metrics.GobblinTrackingEvent} to the events queue. * @param event {@link org.apache.gobblin.metrics.GobblinTrackingEvent} to add to queue. */ public void addEventToReportingQueue(GobblinTrackingEvent event) { if (this.reportingQueue.size() > QUEUE_CAPACITY * 2 / 3) { immediatelyScheduleReport(); } try { if (!this.reportingQueue.offer(sanitizeEvent(event), 10, TimeUnit.SECONDS)) { log.error("Enqueuing of event {} at reporter with class {} timed out. Sending of events is probably stuck.", event, this.getClass().getCanonicalName()); } } catch (InterruptedException ie) { log.warn("Enqueuing of event {} at reporter with class {} was interrupted.", event, this.getClass().getCanonicalName(), ie); } }
@Nullable @Override public Void apply(Notification notification) { notificationCallback(notification); return null; } });
@Override public void run() { report(); } });
/** * Report all {@link org.apache.gobblin.metrics.GobblinTrackingEvent}s in the queue. */ @Override public void report() { reportEventQueue(this.reportingQueue); }
@Override public void close() { try { this.metricContext.removeNotificationTarget(this.notificationTargetKey); report(); this.closer.close(); } catch (Exception e) { LOGGER.warn("Exception when closing EventReporter", e); } finally { super.close(); } }
/** * Report all {@link org.apache.gobblin.metrics.GobblinTrackingEvent}s in the queue. */ @Override public void report() { reportEventQueue(this.reportingQueue); }
/** * Add {@link org.apache.gobblin.metrics.GobblinTrackingEvent} to the events queue. * @param event {@link org.apache.gobblin.metrics.GobblinTrackingEvent} to add to queue. */ public void addEventToReportingQueue(GobblinTrackingEvent event) { if (this.reportingQueue.size() > QUEUE_CAPACITY * 2 / 3) { immediatelyScheduleReport(); } try { if (!this.reportingQueue.offer(sanitizeEvent(event), 10, TimeUnit.SECONDS)) { log.error("Enqueuing of event {} at reporter with class {} timed out. Sending of events is probably stuck.", event, this.getClass().getCanonicalName()); } } catch (InterruptedException ie) { log.warn("Enqueuing of event {} at reporter with class {} was interrupted.", event, this.getClass().getCanonicalName(), ie); } }
@Override public void run() { report(); } });
@Nullable @Override public Void apply(Notification notification) { notificationCallback(notification); return null; } });
/** * Callback used by the {@link org.apache.gobblin.metrics.MetricContext} to notify the object of a new * {@link org.apache.gobblin.metrics.GobblinTrackingEvent}. * @param notification {@link org.apache.gobblin.metrics.notification.Notification} to process. */ public void notificationCallback(Notification notification) { if (notification instanceof EventNotification) { addEventToReportingQueue(((EventNotification) notification).getEvent()); } }
@Override public void close() { try { this.metricContext.removeNotificationTarget(this.notificationTargetKey); report(); this.closer.close(); } catch (Exception e) { LOGGER.warn("Exception when closing EventReporter", e); } finally { super.close(); } }