double[] getRrdValues() { return fetchData.getValues(dsName); }
double[] getRrdValues() { return fetchData.getValues(dsName); }
/** * Returns all archived values for a single datasource. * Returned values correspond to timestamps * returned with {@link #getTimestamps() getTimestamps()} method. * * @param dsName Datasource name. * @return Array of single datasource values. */ public double[] getValues(String dsName) { for (int dsIndex = 0; dsIndex < getColumnCount(); dsIndex++) { if (dsName.equals(dsNames[dsIndex])) { return getValues(dsIndex); } } throw new IllegalArgumentException("Datasource [" + dsName + "] not found"); }
/** * Returns all archived values for a single datasource. * Returned values correspond to timestamps * returned with {@link #getTimestamps() getTimestamps()} method. * * @param dsName Datasource name. * @return Array of single datasource values. */ public double[] getValues(String dsName) { for (int dsIndex = 0; dsIndex < getColumnCount(); dsIndex++) { if (dsName.equals(dsNames[dsIndex])) { return getValues(dsIndex); } } throw new IllegalArgumentException("Datasource [" + dsName + "] not found"); }
@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); } }