コード例 #1
0
  public void fireEvent(@Nonnull final InstanceUsageEvent event) {
    final long receivedEventMs = getCurrentTimeMillis();

    log.debug("Received instance usage event:" + event);

    final String uuid = event.getUuid();
    if (uuid == null) {
      log.warn("Received null uuid");
      return;
    }

    if (receivedEventMs > (lastWriteMs.get() + (DEFAULT_WRITE_INTERVAL_SECS * 1000))) {
      try {
        log.info("Wrote Reporting Instance:" + uuid);
        final ReportingInstanceEventStore eventStore = getReportingInstanceEventStore();
        eventStore.insertUsageEvent(
            event.getUuid(),
            receivedEventMs,
            event.getResourceName(),
            event.getMetric(),
            event.getSequenceNum(),
            event.getDimension(),
            event.getValue(),
            event.getValueTimestamp());
      } catch (ConstraintViolationException ex) {
        log.debug(ex, ex); // info already exists for instance
      } catch (Exception ex) {
        log.error(ex, ex);
      }
    }
  }
コード例 #2
0
 private void insertEvent(InstanceUsageEvent event) {
   try {
     final ReportingInstanceEventStore eventStore = getReportingInstanceEventStore();
     eventStore.insertUsageEvent(
         event.getUuid(),
         event.getValueTimestamp(),
         event.getMetric(),
         event.getSequenceNum(),
         event.getDimension(),
         event.getValue());
   } catch (ConstraintViolationException ex) {
     log.debug(ex, ex); // info already exists for instance
   } catch (Exception ex) {
     log.error(ex, ex);
   }
 }
コード例 #3
0
 protected ReportingInstanceEventStore getReportingInstanceEventStore() {
   return ReportingInstanceEventStore.getInstance();
 }