2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.persistence.rrd4j.internal;
15 import java.io.IOException;
16 import java.nio.file.Files;
17 import java.nio.file.Path;
18 import java.time.Instant;
19 import java.time.ZoneId;
20 import java.time.ZonedDateTime;
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.HashMap;
24 import java.util.Iterator;
25 import java.util.List;
26 import java.util.Locale;
29 import java.util.concurrent.ConcurrentHashMap;
30 import java.util.concurrent.Executors;
31 import java.util.concurrent.RejectedExecutionException;
32 import java.util.concurrent.ScheduledExecutorService;
33 import java.util.concurrent.ScheduledFuture;
34 import java.util.concurrent.TimeUnit;
36 import javax.measure.Quantity;
37 import javax.measure.Unit;
39 import org.eclipse.jdt.annotation.NonNullByDefault;
40 import org.eclipse.jdt.annotation.Nullable;
41 import org.openhab.core.OpenHAB;
42 import org.openhab.core.common.NamedThreadFactory;
43 import org.openhab.core.items.GroupItem;
44 import org.openhab.core.items.Item;
45 import org.openhab.core.items.ItemNotFoundException;
46 import org.openhab.core.items.ItemRegistry;
47 import org.openhab.core.items.ItemUtil;
48 import org.openhab.core.library.CoreItemFactory;
49 import org.openhab.core.library.items.ColorItem;
50 import org.openhab.core.library.items.ContactItem;
51 import org.openhab.core.library.items.DimmerItem;
52 import org.openhab.core.library.items.NumberItem;
53 import org.openhab.core.library.items.RollershutterItem;
54 import org.openhab.core.library.items.SwitchItem;
55 import org.openhab.core.library.types.DecimalType;
56 import org.openhab.core.library.types.OnOffType;
57 import org.openhab.core.library.types.OpenClosedType;
58 import org.openhab.core.library.types.PercentType;
59 import org.openhab.core.library.types.QuantityType;
60 import org.openhab.core.persistence.FilterCriteria;
61 import org.openhab.core.persistence.FilterCriteria.Ordering;
62 import org.openhab.core.persistence.HistoricItem;
63 import org.openhab.core.persistence.PersistenceItemInfo;
64 import org.openhab.core.persistence.PersistenceService;
65 import org.openhab.core.persistence.QueryablePersistenceService;
66 import org.openhab.core.persistence.strategy.PersistenceCronStrategy;
67 import org.openhab.core.persistence.strategy.PersistenceStrategy;
68 import org.openhab.core.types.State;
69 import org.osgi.service.component.annotations.Activate;
70 import org.osgi.service.component.annotations.Component;
71 import org.osgi.service.component.annotations.ConfigurationPolicy;
72 import org.osgi.service.component.annotations.Modified;
73 import org.osgi.service.component.annotations.Reference;
74 import org.rrd4j.ConsolFun;
75 import org.rrd4j.DsType;
76 import org.rrd4j.core.FetchData;
77 import org.rrd4j.core.FetchRequest;
78 import org.rrd4j.core.RrdDb;
79 import org.rrd4j.core.RrdDb.Builder;
80 import org.rrd4j.core.RrdDbPool;
81 import org.rrd4j.core.RrdDef;
82 import org.rrd4j.core.Sample;
83 import org.slf4j.Logger;
84 import org.slf4j.LoggerFactory;
87 * This is the implementation of the RRD4j {@link PersistenceService}. To learn
88 * more about RRD4j please visit their
89 * <a href="https://github.com/rrd4j/rrd4j">website</a>.
91 * @author Kai Kreuzer - Initial contribution
92 * @author Jan N. Klug - some improvements
93 * @author Karel Goderis - remove TimerThread dependency
96 @Component(service = { PersistenceService.class,
97 QueryablePersistenceService.class }, configurationPid = "org.openhab.rrd4j", configurationPolicy = ConfigurationPolicy.OPTIONAL)
98 public class RRD4jPersistenceService implements QueryablePersistenceService {
100 private static final String DEFAULT_OTHER = "default_other";
101 private static final String DEFAULT_NUMERIC = "default_numeric";
102 private static final String DEFAULT_QUANTIFIABLE = "default_quantifiable";
104 private static final Set<String> SUPPORTED_TYPES = Set.of(CoreItemFactory.SWITCH, CoreItemFactory.CONTACT,
105 CoreItemFactory.DIMMER, CoreItemFactory.NUMBER, CoreItemFactory.ROLLERSHUTTER, CoreItemFactory.COLOR);
107 private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(3,
108 new NamedThreadFactory("RRD4j"));
110 private final Map<String, RrdDefConfig> rrdDefs = new ConcurrentHashMap<>();
112 private static final String DATASOURCE_STATE = "state";
114 private static final Path DB_FOLDER = Path.of(OpenHAB.getUserDataFolder(), "persistence", "rrd4j").toAbsolutePath();
116 private static final RrdDbPool DATABASE_POOL = new RrdDbPool();
118 private final Logger logger = LoggerFactory.getLogger(RRD4jPersistenceService.class);
120 private final Map<String, ScheduledFuture<?>> scheduledJobs = new HashMap<>();
122 private final ItemRegistry itemRegistry;
124 public static Path getDatabasePath(String name) {
125 return DB_FOLDER.resolve(name + ".rrd");
128 public static RrdDbPool getDatabasePool() {
129 return DATABASE_POOL;
133 public RRD4jPersistenceService(final @Reference ItemRegistry itemRegistry) {
134 this.itemRegistry = itemRegistry;
138 public String getId() {
143 public String getLabel(@Nullable Locale locale) {
148 public void store(final Item item, @Nullable final String alias) {
149 if (!isSupportedItemType(item)) {
150 logger.trace("Ignoring item '{}' since its type {} is not supported", item.getName(), item.getType());
153 final String name = alias == null ? item.getName() : alias;
157 if (item instanceof NumberItem && item.getState() instanceof QuantityType) {
158 NumberItem nItem = (NumberItem) item;
159 QuantityType<?> qState = (QuantityType<?>) item.getState();
160 Unit<? extends Quantity<?>> unit = nItem.getUnit();
162 QuantityType<?> convertedState = qState.toUnit(unit);
163 if (convertedState != null) {
164 value = convertedState.doubleValue();
168 "Failed to convert state '{}' to unit '{}'. Please check your item definition for correctness.",
172 value = qState.doubleValue();
175 DecimalType state = item.getStateAs(DecimalType.class);
177 value = state.toBigDecimal().doubleValue();
184 // we could not convert the value
188 long now = System.currentTimeMillis() / 1000;
190 scheduler.schedule(() -> internalStore(name, value, now, true), 0, TimeUnit.SECONDS);
193 private synchronized void internalStore(String name, double value, long now, boolean retry) {
196 db = getDB(name, true);
197 } catch (Exception e) {
198 logger.warn("Failed to open rrd4j database '{}' to store data ({})", name, e.toString());
204 ConsolFun function = getConsolidationFunction(db);
205 if (function != ConsolFun.AVERAGE) {
207 // we store the last value again, so that the value change
208 // in the database is not interpolated, but
209 // happens right at this spot
210 if (now - 1 > db.getLastUpdateTime()) {
211 // only do it if there is not already a value
212 double lastValue = db.getLastDatasourceValue(DATASOURCE_STATE);
213 if (!Double.isNaN(lastValue)) {
214 Sample sample = db.createSample();
215 sample.setTime(now - 1);
216 sample.setValue(DATASOURCE_STATE, lastValue);
218 logger.debug("Stored '{}' as value '{}' with timestamp {} in rrd4j database (again)", name,
222 } catch (IOException e) {
223 logger.debug("Error storing last value (again): {}", e.getMessage());
227 Sample sample = db.createSample();
229 double storeValue = value;
230 if (db.getDatasource(DATASOURCE_STATE).getType() == DsType.COUNTER) { // counter values must be
231 // adjusted by stepsize
232 storeValue = value * db.getRrdDef().getStep();
234 sample.setValue(DATASOURCE_STATE, storeValue);
236 logger.debug("Stored '{}' as value '{}' with timestamp {} in rrd4j database", name, storeValue, now);
237 } catch (IllegalArgumentException e) {
238 String message = e.getMessage();
239 if (message != null && message.contains("at least one second step is required") && retry) {
240 // we try to store the value one second later
241 ScheduledFuture<?> job = scheduledJobs.get(name);
244 scheduledJobs.remove(name);
246 job = scheduler.schedule(() -> internalStore(name, value, now + 1, false), 1, TimeUnit.SECONDS);
247 scheduledJobs.put(name, job);
249 logger.warn("Could not persist '{}' to rrd4j database: {}", name, e.getMessage());
251 } catch (Exception e) {
252 logger.warn("Could not persist '{}' to rrd4j database: {}", name, e.getMessage());
256 } catch (IOException e) {
257 logger.debug("Error closing rrd4j database: {}", e.getMessage());
262 public void store(Item item) {
267 public Iterable<HistoricItem> query(FilterCriteria filter) {
268 ZonedDateTime filterBeginDate = filter.getBeginDate();
269 ZonedDateTime filterEndDate = filter.getEndDate();
270 if (filterBeginDate != null && filterEndDate != null && filterBeginDate.isAfter(filterEndDate)) {
271 throw new IllegalArgumentException("begin (" + filterBeginDate + ") before end (" + filterEndDate + ")");
274 String itemName = filter.getItemName();
275 if (itemName == null) {
276 logger.warn("Item name is missing in filter {}", filter);
279 logger.trace("Querying rrd4j database for item '{}'", itemName);
283 db = getDB(itemName, false);
284 } catch (Exception e) {
285 logger.warn("Failed to open rrd4j database '{}' for querying ({})", itemName, e.toString());
289 logger.debug("Could not find item '{}' in rrd4j database", itemName);
296 item = itemRegistry.getItem(itemName);
297 if (item instanceof NumberItem) {
298 // we already retrieve the unit here once as it is a very costly operation,
299 // see https://github.com/openhab/openhab-addons/issues/8928
300 unit = ((NumberItem) item).getUnit();
302 } catch (ItemNotFoundException e) {
303 logger.debug("Could not find item '{}' in registry", itemName);
307 long end = filterEndDate == null ? System.currentTimeMillis() / 1000
308 : filterEndDate.toInstant().getEpochSecond();
311 if (filterBeginDate == null) {
312 // as rrd goes back for years and gets more and more
313 // inaccurate, we only support descending order
314 // and a single return value
315 // if there is no begin date is given - this case is
316 // required specifically for the historicState()
317 // query, which we want to support
318 if (filter.getOrdering() == Ordering.DESCENDING && filter.getPageSize() == 1
319 && filter.getPageNumber() == 0) {
320 if (filterEndDate == null) {
321 // we are asked only for the most recent value!
322 double lastValue = db.getLastDatasourceValue(DATASOURCE_STATE);
323 if (!Double.isNaN(lastValue)) {
324 HistoricItem rrd4jItem = new RRD4jItem(itemName, mapToState(lastValue, item, unit),
325 ZonedDateTime.ofInstant(Instant.ofEpochMilli(db.getLastArchiveUpdateTime() * 1000),
326 ZoneId.systemDefault()));
327 return List.of(rrd4jItem);
335 throw new UnsupportedOperationException(
336 "rrd4j does not allow querys without a begin date, unless order is descending and a single value is requested");
339 start = filterBeginDate.toInstant().getEpochSecond();
342 // do not call method {@link RrdDb#createFetchRequest(ConsolFun, long, long, long)} if start > end to avoid
343 // an IAE to be thrown
345 logger.debug("Could not query rrd4j database for item '{}': start ({}) > end ({})", itemName, start,
350 FetchRequest request = db.createFetchRequest(getConsolidationFunction(db), start, end, 1);
351 FetchData result = request.fetchData();
353 List<HistoricItem> items = new ArrayList<>();
354 long ts = result.getFirstTimestamp();
355 long step = result.getRowCount() > 1 ? result.getStep() : 0;
356 for (double value : result.getValues(DATASOURCE_STATE)) {
357 if (!Double.isNaN(value) && (((ts >= start) && (ts <= end)) || (start == end))) {
358 RRD4jItem rrd4jItem = new RRD4jItem(itemName, mapToState(value, item, unit),
359 ZonedDateTime.ofInstant(Instant.ofEpochSecond(ts), ZoneId.systemDefault()));
360 items.add(rrd4jItem);
365 } catch (IOException e) {
366 logger.warn("Could not query rrd4j database for item '{}': {}", itemName, e.getMessage());
371 } catch (IOException e) {
372 logger.debug("Error closing rrd4j database: {}", e.getMessage());
378 public Set<PersistenceItemInfo> getItemInfo() {
382 protected synchronized @Nullable RrdDb getDB(String alias, boolean createFileIfAbsent) {
384 Path path = getDatabasePath(alias);
386 Builder builder = RrdDb.getBuilder();
387 builder.setPool(DATABASE_POOL);
389 if (Files.exists(path)) {
390 // recreate the RrdDb instance from the file
391 builder.setPath(path.toString());
392 db = builder.build();
393 } else if (createFileIfAbsent) {
394 if (!Files.exists(DB_FOLDER)) {
395 Files.createDirectories(DB_FOLDER);
397 RrdDef rrdDef = getRrdDef(alias, path);
398 if (rrdDef != null) {
399 // create a new database file
400 builder.setRrdDef(rrdDef);
401 db = builder.build();
404 "Did not create rrd4j database for item '{}' since no rrd definition could be determined. This is likely due to an unsupported item type.",
408 } catch (IOException e) {
409 logger.error("Could not create rrd4j database file '{}': {}", path, e.getMessage());
410 } catch (RejectedExecutionException e) {
411 // this happens if the system is shut down
412 logger.debug("Could not create rrd4j database file '{}': {}", path, e.getMessage());
417 private @Nullable RrdDefConfig getRrdDefConfig(String itemName) {
418 RrdDefConfig useRdc = null;
419 for (Map.Entry<String, RrdDefConfig> e : rrdDefs.entrySet()) {
420 // try to find special config
421 RrdDefConfig rdc = e.getValue();
422 if (rdc.appliesTo(itemName)) {
427 if (useRdc == null) { // not defined, use defaults
429 Item item = itemRegistry.getItem(itemName);
430 if (!isSupportedItemType(item)) {
433 if (item instanceof NumberItem) {
434 NumberItem numberItem = (NumberItem) item;
435 useRdc = numberItem.getDimension() != null ? rrdDefs.get(DEFAULT_QUANTIFIABLE)
436 : rrdDefs.get(DEFAULT_NUMERIC);
438 useRdc = rrdDefs.get(DEFAULT_OTHER);
440 } catch (ItemNotFoundException e) {
441 logger.debug("Could not find item '{}' in registry", itemName);
445 logger.trace("Using rrd definition '{}' for item '{}'.", useRdc, itemName);
449 private @Nullable RrdDef getRrdDef(String itemName, Path path) {
450 RrdDef rrdDef = new RrdDef(path.toString());
451 RrdDefConfig useRdc = getRrdDefConfig(itemName);
452 if (useRdc != null) {
453 rrdDef.setStep(useRdc.step);
454 rrdDef.setStartTime(System.currentTimeMillis() / 1000 - 1);
455 rrdDef.addDatasource(DATASOURCE_STATE, useRdc.dsType, useRdc.heartbeat, useRdc.min, useRdc.max);
456 for (RrdArchiveDef rad : useRdc.archives) {
457 rrdDef.addArchive(rad.fcn, rad.xff, rad.steps, rad.rows);
465 public ConsolFun getConsolidationFunction(RrdDb db) {
467 return db.getRrdDef().getArcDefs()[0].getConsolFun();
468 } catch (IOException e) {
469 return ConsolFun.MAX;
473 @SuppressWarnings({ "unchecked", "rawtypes" })
474 private State mapToState(double value, @Nullable Item item, @Nullable Unit unit) {
475 if (item instanceof GroupItem) {
476 item = ((GroupItem) item).getBaseItem();
479 if (item instanceof SwitchItem && !(item instanceof DimmerItem)) {
480 return value == 0.0d ? OnOffType.OFF : OnOffType.ON;
481 } else if (item instanceof ContactItem) {
482 return value == 0.0d ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
483 } else if (item instanceof DimmerItem || item instanceof RollershutterItem || item instanceof ColorItem) {
484 // make sure Items that need PercentTypes instead of DecimalTypes do receive the right information
485 return new PercentType((int) Math.round(value * 100));
486 } else if (item instanceof NumberItem) {
488 return new QuantityType(value, unit);
491 return new DecimalType(value);
494 private boolean isSupportedItemType(Item item) {
495 if (item instanceof GroupItem) {
496 final Item baseItem = ((GroupItem) item).getBaseItem();
497 if (baseItem != null) {
502 return SUPPORTED_TYPES.contains(ItemUtil.getMainItemType(item.getType()));
506 protected void activate(final Map<String, Object> config) {
511 protected void modified(final Map<String, Object> config) {
512 // clean existing definitions
515 // add default configurations
517 RrdDefConfig defaultNumeric = new RrdDefConfig(DEFAULT_NUMERIC);
518 // use 10 seconds as a step size for numeric values and allow a 10 minute silence between updates
519 defaultNumeric.setDef("GAUGE,600,U,U,10");
520 // define 5 different boxes:
521 // 1. granularity of 10s for the last hour
522 // 2. granularity of 1m for the last week
523 // 3. granularity of 15m for the last year
524 // 4. granularity of 1h for the last 5 years
525 // 5. granularity of 1d for the last 10 years
527 .addArchives("LAST,0.5,1,360:LAST,0.5,6,10080:LAST,0.5,90,36500:LAST,0.5,360,43800:LAST,0.5,8640,3650");
528 rrdDefs.put(DEFAULT_NUMERIC, defaultNumeric);
530 RrdDefConfig defaultQuantifiable = new RrdDefConfig(DEFAULT_QUANTIFIABLE);
531 // use 10 seconds as a step size for numeric values and allow a 10 minute silence between updates
532 defaultQuantifiable.setDef("GAUGE,600,U,U,10");
533 // define 5 different boxes:
534 // 1. granularity of 10s for the last hour
535 // 2. granularity of 1m for the last week
536 // 3. granularity of 15m for the last year
537 // 4. granularity of 1h for the last 5 years
538 // 5. granularity of 1d for the last 10 years
539 defaultQuantifiable.addArchives(
540 "AVERAGE,0.5,1,360:AVERAGE,0.5,6,10080:AVERAGE,0.5,90,36500:AVERAGE,0.5,360,43800:AVERAGE,0.5,8640,3650");
541 rrdDefs.put(DEFAULT_QUANTIFIABLE, defaultQuantifiable);
543 RrdDefConfig defaultOther = new RrdDefConfig(DEFAULT_OTHER);
544 // use 5 seconds as a step size for discrete values and allow a 1h silence between updates
545 defaultOther.setDef("GAUGE,3600,U,U,5");
546 // define 4 different boxes:
547 // 1. granularity of 5s for the last hour
548 // 2. granularity of 1m for the last week
549 // 3. granularity of 15m for the last year
550 // 4. granularity of 4h for the last 10 years
551 defaultOther.addArchives("LAST,0.5,1,720:LAST,0.5,12,10080:LAST,0.5,180,35040:LAST,0.5,2880,21900");
552 rrdDefs.put(DEFAULT_OTHER, defaultOther);
554 if (config.isEmpty()) {
555 logger.debug("using default configuration only");
559 Iterator<String> keys = config.keySet().iterator();
560 while (keys.hasNext()) {
561 String key = keys.next();
563 if ("service.pid".equals(key) || "component.name".equals(key)) {
564 // ignore service.pid and name
568 String[] subkeys = key.split("\\.");
569 if (subkeys.length != 2) {
570 logger.debug("config '{}' should have the format 'name.configkey'", key);
574 Object v = config.get(key);
575 if (v instanceof String) {
576 String value = (String) v;
577 String name = subkeys[0].toLowerCase();
578 String property = subkeys[1].toLowerCase();
580 if (value.isBlank()) {
581 logger.trace("Config is empty: {}", property);
584 logger.trace("Processing config: {} = {}", property, value);
587 RrdDefConfig rrdDef = rrdDefs.get(name);
588 if (rrdDef == null) {
589 rrdDef = new RrdDefConfig(name);
590 rrdDefs.put(name, rrdDef);
594 if ("def".equals(property)) {
595 rrdDef.setDef(value);
596 } else if ("archives".equals(property)) {
597 rrdDef.addArchives(value);
598 } else if ("items".equals(property)) {
599 rrdDef.addItems(value);
601 logger.debug("Unknown property {} : {}", property, value);
603 } catch (IllegalArgumentException e) {
604 logger.warn("Ignoring illegal configuration: {}", e.getMessage());
609 for (RrdDefConfig rrdDef : rrdDefs.values()) {
610 if (rrdDef.isValid()) {
611 logger.debug("Created {}", rrdDef);
613 logger.info("Removing invalid definition {}", rrdDef);
614 rrdDefs.remove(rrdDef.name);
619 private static class RrdArchiveDef {
620 public @Nullable ConsolFun fcn;
622 public int steps, rows;
625 public String toString() {
626 StringBuilder sb = new StringBuilder(" " + fcn);
627 sb.append(" xff = ").append(xff);
628 sb.append(" steps = ").append(steps);
629 sb.append(" rows = ").append(rows);
630 return sb.toString();
634 private class RrdDefConfig {
636 public @Nullable DsType dsType;
637 public int heartbeat, step;
638 public double min, max;
639 public List<RrdArchiveDef> archives;
640 public List<String> itemNames;
642 private boolean isInitialized;
644 public RrdDefConfig(String name) {
646 archives = new ArrayList<>();
647 itemNames = new ArrayList<>();
648 isInitialized = false;
651 public void setDef(String defString) {
652 String[] opts = defString.split(",");
653 if (opts.length != 5) { // check if correct number of parameters
654 logger.warn("invalid number of parameters {}: {}", name, defString);
658 if ("ABSOLUTE".equals(opts[0])) { // dsType
659 dsType = DsType.ABSOLUTE;
660 } else if ("COUNTER".equals(opts[0])) {
661 dsType = DsType.COUNTER;
662 } else if ("DERIVE".equals(opts[0])) {
663 dsType = DsType.DERIVE;
664 } else if ("GAUGE".equals(opts[0])) {
665 dsType = DsType.GAUGE;
667 logger.warn("{}: dsType {} not supported", name, opts[0]);
670 heartbeat = Integer.parseInt(opts[1]);
672 if ("U".equals(opts[2])) {
675 min = Double.parseDouble(opts[2]);
678 if ("U".equals(opts[3])) {
681 max = Double.parseDouble(opts[3]);
684 step = Integer.parseInt(opts[4]);
686 isInitialized = true; // successfully initialized
691 public void addArchives(String archivesString) {
692 String splitArchives[] = archivesString.split(":");
693 for (String archiveString : splitArchives) {
694 String[] opts = archiveString.split(",");
695 if (opts.length != 4) { // check if correct number of parameters
696 logger.warn("invalid number of parameters {}: {}", name, archiveString);
699 RrdArchiveDef arc = new RrdArchiveDef();
701 if ("AVERAGE".equals(opts[0])) {
702 arc.fcn = ConsolFun.AVERAGE;
703 } else if ("MIN".equals(opts[0])) {
704 arc.fcn = ConsolFun.MIN;
705 } else if ("MAX".equals(opts[0])) {
706 arc.fcn = ConsolFun.MAX;
707 } else if ("LAST".equals(opts[0])) {
708 arc.fcn = ConsolFun.LAST;
709 } else if ("FIRST".equals(opts[0])) {
710 arc.fcn = ConsolFun.FIRST;
711 } else if ("TOTAL".equals(opts[0])) {
712 arc.fcn = ConsolFun.TOTAL;
714 logger.warn("{}: consolidation function {} not supported", name, opts[0]);
716 arc.xff = Double.parseDouble(opts[1]);
717 arc.steps = Integer.parseInt(opts[2]);
718 arc.rows = Integer.parseInt(opts[3]);
723 public void addItems(String itemsString) {
724 Collections.addAll(itemNames, itemsString.split(","));
727 public boolean appliesTo(String item) {
728 return itemNames.contains(item);
731 public boolean isValid() { // a valid configuration must be initialized
732 // and contain at least one function
733 return isInitialized && !archives.isEmpty();
737 public String toString() {
738 StringBuilder sb = new StringBuilder(name);
739 sb.append(" = ").append(dsType);
740 sb.append(" heartbeat = ").append(heartbeat);
741 sb.append(" min/max = ").append(min).append("/").append(max);
742 sb.append(" step = ").append(step);
743 sb.append(" ").append(archives.size()).append(" archives(s) = [");
744 for (RrdArchiveDef arc : archives) {
745 sb.append(arc.toString());
748 sb.append(itemNames.size()).append(" items(s) = [");
749 for (String item : itemNames) {
750 sb.append(item).append(" ");
753 return sb.toString();
758 public List<PersistenceStrategy> getDefaultStrategies() {
759 return List.of(PersistenceStrategy.Globals.RESTORE, PersistenceStrategy.Globals.CHANGE,
760 new PersistenceCronStrategy("everyMinute", "0 * * * * ?"));