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); } } }
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); } }
protected ReportingInstanceEventStore getReportingInstanceEventStore() { return ReportingInstanceEventStore.getInstance(); }