I have integrated rrd4j (3.1) with mongodb (3.2). But the sample data doesn't seem to be persistent after closing RrdDb and then re initializing the object. I see the binary data getting updated in mongo db when the rrdDb.close() is called. And on open the data is being queried from mongodb and the binary data is getting updated to byte buffer. But on dumping the data after the reconnect, all the sample data is is replace by NaN. Could someone please help me on this.?
Adding the code for RrdDb intialising, Mongo Ractory creation and the dump outputs before close and after reconnect.
RrdDb intialization
RrdDef rrdDef = new RrdDef(rrdPath,(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(300))/1000,10);
rrdDef.addDatasource(dsName, DsType.GAUGE , 20, 1d, Double.MAX_VALUE);
int secondUnitStep = (int)(TimeUnit.MINUTES.toSeconds(1)/10);
int secondUnitRows = (int)(TimeUnit.HOURS.toSeconds(1)/TimeUnit.MINUTES.toSeconds(1));
rrdDef.addArchive(ConsolFun.TOTAL, 0.5, 6, 60);
RrdDb rrdDB = new RrdDb(rrdDef,rrdMongoFactory);
Rrd Mongo Factory class
package mx.july.jmx.proximity.util;
public class RrdMongoFactory extends RrdBackendFactory {
private String name;
private final DBCollection rrdCollection;
public RrdMongoFactory(String name, DBCollection rrdCollection) {
this.name = name;
this.rrdCollection = rrdCollection;
this.rrdCollection.createIndex(new BasicDBObject("path", 1), "path_idx");
RrdBackendFactory.registerAndSetAsDefaultFactory(this);
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
/** {@inheritDoc} */
@Override
protected RrdBackend open(String path, boolean readOnly) throws IOException {
return new RrdMongoDBBackend(path, rrdCollection);
}
/** {@inheritDoc} */
@Override
protected boolean exists(String path) throws IOException {
BasicDBObject query = new BasicDBObject();
query.put("path", path);
return rrdCollection.findOne(query) != null;
}
/** {@inheritDoc} */
@Override
protected boolean shouldValidateHeader(String path) throws IOException {
return false;
}
}
RrdDb dump before close
== HEADER ==
signature:RRD4J, version 0.2 lastUpdateTime:1488536144 step:10 dsCount:1 arcCount:3
== DATASOURCE ==
DS:320:GAUGE:20:1.0:1.7976931348623157E308
lastValue:8.0 nanSeconds:0 accumValue:32.0
== ARCHIVE ==
RRA:TOTAL:0.5:6:60
interval [1488532560, 1488536100]
accumValue:117.0 nanSteps:0
Robin 5/60: NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN +1.7860000000E02 NaN +1.7130000000E02 +1.6600000000E02
RrdDb dump after reconnect
== HEADER ==
signature:RRD4J, version 0.2 lastUpdateTime:1462616268 step:10 dsCount:1 arcCount:3
== DATASOURCE ==
DS:320:GAUGE:20:1.0:1.7976931348623157E308
lastValue:NaN nanSeconds:8 accumValue:0.0
== ARCHIVE ==
RRA:TOTAL:0.5:6:60
interval [1462612680, 1462616220]
accumValue:NaN nanSteps:4
Robin 0/60: NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN