long[] getRrdTimestamps() { return fetchData.getTimestamps(); }
long[] getRrdTimestamps() { return fetchData.getTimestamps(); }
@Override public Map<TimeSeriesInfo<Double>, TimeSeriesProcessor<Double>> fetchData(String path, Instant begin, Instant end, List<TimeSeriesInfo<Double>> seriesInfo, boolean bypassCache) throws DataAdapterException { if (this.isClosed()) { throw new IllegalStateException("An attempt was made to fetch data from a closed adapter"); } Path dsPath = Path.of(path); try { FetchRequest request = rrdDbMap.get(dsPath.getParent()).createFetchRequest(ConsolFun.valueOf(dsPath.getFileName().toString()), begin.getEpochSecond(), end.getEpochSecond()); request.setFilter(seriesInfo.stream().map(s -> s.getBinding().getLabel()).toArray(String[]::new)); FetchData data = request.fetchData(); Map<TimeSeriesInfo<Double>, TimeSeriesProcessor<Double>> series = new HashMap<>(); for (int i = 0; i < data.getRowCount(); i++) { ZonedDateTime timeStamp = Instant.ofEpochSecond(data.getTimestamps()[i]).atZone(getTimeZoneId()); for (TimeSeriesInfo<Double> info : seriesInfo) { Double val = data.getValues(info.getBinding().getLabel())[i]; XYChart.Data<ZonedDateTime, Double> point = new XYChart.Data<>(timeStamp, val.isNaN() ? 0 : val); TimeSeriesProcessor<Double> seriesProcessor = series.computeIfAbsent(info, k -> new DoubleTimeSeriesProcessor()); seriesProcessor.addSample(point); } } logger.trace(() -> String.format("Built %d series with %d samples each (%d total samples)", seriesInfo.size(), data.getRowCount(), seriesInfo.size() * data.getRowCount())); return series; } catch (IOException e) { throw new FetchingDataFromAdapterException("IO Error while retrieving data from rrd db", e); } }