@Override public void close() { System.out.println("Stopping aggregator..."); this.averageAggregator.close(); } }
@Override public void run() { try { Map<AggregationKey, AggregationValue> removedKeysMinute = process(reportingDao.averageAggregator.getMinute(), GraphGranularityType.MINUTE); Map<AggregationKey, AggregationValue> removedKeysHour = process(reportingDao.averageAggregator.getHourly(), GraphGranularityType.HOURLY); Map<AggregationKey, AggregationValue> removedKeysDay = process(reportingDao.averageAggregator.getDaily(), GraphGranularityType.DAILY); reportingDBManager.insertReporting(removedKeysMinute, GraphGranularityType.MINUTE); reportingDBManager.insertReporting(removedKeysHour, GraphGranularityType.HOURLY); reportingDBManager.insertReporting(removedKeysDay, GraphGranularityType.DAILY); reportingDBManager.insertReportingRaw(reportingDao.rawDataProcessor.rawStorage); reportingDBManager.cleanOldReportingRecords(Instant.now()); } catch (Exception e) { log.error("Error during reporting job.", e); } }
public ReportingDiskDao(String reportingFolder, boolean isEnabled) { this.averageAggregator = new AverageAggregatorProcessor(reportingFolder); this.rawDataCacheForGraphProcessor = new RawDataCacheForGraphProcessor(); this.dataFolder = reportingFolder; this.enableRawDbDataStore = isEnabled; this.rawDataProcessor = new RawDataProcessor(enableRawDbDataStore); this.csvGenerator = new CSVGenerator(this); createCSVFolder(); }
private void process(User user, DashBoard dash, int deviceId, short pin, PinType pinType, String value, long ts, double doubleVal) { if (enableRawDbDataStore) { rawDataProcessor.collect( new BaseReportingKey(user.email, user.appName, dash.id, deviceId, pinType, pin), ts, value, doubleVal); } //not a number, nothing to aggregate if (doubleVal == NumberUtil.NO_RESULT) { return; } //store history data only for the pins assigned to the superchart Widget widgetWithLogPins = user.profile.getWidgetWithLoggedPin(dash, deviceId, pin, pinType); if (widgetWithLogPins != null) { BaseReportingKey key = new BaseReportingKey(user.email, user.appName, dash.id, deviceId, pinType, pin); averageAggregator.collect(key, ts, doubleVal); if (widgetWithLogPins instanceof Superchart) { if (((Superchart) widgetWithLogPins).hasLivePeriodsSelected()) { rawDataCacheForGraphProcessor.collect(key, new GraphValue(doubleVal, ts)); } } } }