public ReportingDiskDao(String reportingFolder, AverageAggregatorProcessor averageAggregator, boolean isEnabled) { this.averageAggregator = averageAggregator; this.rawDataCacheForGraphProcessor = new RawDataCacheForGraphProcessor(); this.dataFolder = reportingFolder; this.enableRawDbDataStore = isEnabled; this.rawDataProcessor = new RawDataProcessor(enableRawDbDataStore); this.csvGenerator = new CSVGenerator(this); }
public ByteBuffer getLiveGraphData(User user, GraphPinRequest graphPinRequest) { LimitedArrayDeque<GraphValue> cache = rawStorage.get(new BaseReportingKey(user, graphPinRequest)); if (cache != null && cache.size() > graphPinRequest.skipCount) { return toByteBuffer(cache, graphPinRequest.count, graphPinRequest.skipCount); } return null; }
public byte[][] getReportingData(User user, GraphPinRequest[] requestedPins) throws NoDataException { byte[][] values = new byte[requestedPins.length][]; for (int i = 0; i < requestedPins.length; i++) { GraphPinRequest graphPinRequest = requestedPins[i]; log.debug("Getting data for graph pin : {}.", graphPinRequest); if (graphPinRequest.isValid()) { ByteBuffer byteBuffer = graphPinRequest.isLiveData() //live graph data is not on disk but in memory ? rawDataCacheForGraphProcessor.getLiveGraphData(user, graphPinRequest) : getByteBufferFromDisk(user, graphPinRequest); values[i] = byteBuffer == null ? EMPTY_BYTES : byteBuffer.array(); } else { values[i] = EMPTY_BYTES; } } if (!hasData(values)) { throw new NoDataException(); } return values; }
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)); } } } }
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(); }