RRD4J throws unhandled java.lang.IllegalArgumentException: null

57 views
Skip to first unread message

aes.i...@gmail.com

unread,
Jul 14, 2016, 10:28:27 AM7/14/16
to rrd4j-discuss
Hello,

I have the issu while write several datasources at once for a sample time.
A while things go well until the following message comes:

java.lang.IllegalArgumentException: null
at java.nio.Buffer.position(Buffer.java:244)
at org.rrd4j.core.RrdNioBackend.write(RrdNioBackend.java:99)
at org.rrd4j.core.RrdBackend.writeDouble(RrdBackend.java:151)
at org.rrd4j.core.RrdPrimitive.writeDouble(RrdPrimitive.java:73)
at org.rrd4j.core.RrdDoubleMatrix.set(RrdDoubleMatrix.java:18)
at org.rrd4j.core.RobinMatrix.store(RobinMatrix.java:46)
at org.rrd4j.core.Archive.finalizeStep(Archive.java:176)
at org.rrd4j.core.Archive.archive(Archive.java:122)
at org.rrd4j.core.RrdDb.archive(RrdDb.java:692)
    at org.rrd4j.core.Datasource.process(Datasource.java:179)
    at org.rrd4j.core.RrdDb.store(RrdDb.java:559)
    at org.rrd4j.core.Sample.update(Sample.java:197)
    at Demo.write(Unknown Source)
    at Demo.update(Unknown Source)
    at Demo.lambda$main$0(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)


Is there a solution for this?
with Reagrds
AES

Fabrice Bacchella

unread,
Jul 14, 2016, 3:17:38 PM7/14/16
to rrd4j-...@googlegroups.com
With what version ?

Can you write a code that reproduce that ?

If that's the case, please open a ticket on https://github.com/rrd4j/rrd4j/issues



--
You received this message because you are subscribed to the Google Groups "rrd4j-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rrd4j-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

aes.i...@gmail.com

unread,
Jul 15, 2016, 10:17:58 AM7/15/16
to rrd4j-discuss
Hi,

Yes, i can reproduce that!
The Version:
    - rrd4j version 2.2.1,
    - JDK1.8
    - Windows 7

Here the code:
import org.rrd4j.ConsolFun;
import org.rrd4j.DsType;
import org.rrd4j.core.RrdDb;
import org.rrd4j.core.RrdDef;
import org.rrd4j.core.Sample;

class Demo implements Runnable {

   
private static final int MAXDEVICES = 1;
   
private static final int MAXCHANALS = 30;
   
private static final String RRDPATH = "D:\\temp\\device0"; //"/media/usb/rrdb/device";

   
public static void main(String[] args) throws Exception {

       
System.out.println("Thread: " + Thread.currentThread().getName() + ": Start the logger test...");
       
long start = System.currentTimeMillis();

       
RrdDb rrdDb;
       
RrdDef rrdDef;

       
// Initialize rrdb files
       
for (int i = 1; i <= MAXDEVICES; i++) {
            rrdDef
= new RrdDef(RRDPATH + i + ".rrd", 60);
           
for (int n = 1; n <= MAXCHANALS; n++) {
                rrdDef
.addDatasource("chan0" + n, DsType.GAUGE, 120, Double.NaN, Double.NaN);
           
}
            rrdDef
.addArchive(ConsolFun.AVERAGE, 0.5, 1, 4320);     // 3 days     (granularity 1 min) 1MB
            rrdDef
.addArchive(ConsolFun.MIN, 0.5, 1, 4320);
            rrdDef
.addArchive(ConsolFun.MAX, 0.5, 1, 4320);

            rrdDb
= new RrdDb(rrdDef);
           
System.out.println("Estimated file size: " + rrdDef.getEstimatedSize());
            rrdDb
.close();
       
}

       
long time = System.currentTimeMillis() - start;
       
System.out.println("Created rrdb files in " + time + "ms");

       
// Store Data
       
for (int i = 1; i <= MAXDEVICES; i++) {
           
final RrdDb rrdDb2 = new RrdDb(RRDPATH + i + ".rrd");
           
final Sample sample = rrdDb2.createSample();
           
Runnable task = () -> {
               
System.out.println(Thread.currentThread().getName() + " is running.");
               
try {
                    update
(sample);
               
} catch (Exception ex) {
                    ex
.printStackTrace();
               
}
           
};
           
Thread thread1 = new Thread(task);
            thread1
.start();
       
}
   
}

   
public static synchronized void write(long time, int channelId, double value, Sample sample) throws Exception {
        sample
.setTime(time);
       
for (int n = 1; n <= MAXCHANALS; n++) {
            sample
.setValue("chan0" + n, value);
       
}
        sample
.update();
   
}

   
public static void update(Sample sample) throws Exception {
       
double cnt = 1.0;
       
while (true) {
           
for (int n = 1; n <= MAXCHANALS; n++) {
               
long now = System.currentTimeMillis() / 1000;
                write
(now, n, cnt++, sample);
               
System.out.println("Date: " + now + ", value: " + cnt++);
               
Thread.sleep(1 * 1000);
           
}
       
}
   
}

   
@Override
   
public void run() {
   
}
}
Demo.java

Fabrice Bacchella

unread,
Jul 19, 2016, 5:17:28 AM7/19/16
to rrd4j-...@googlegroups.com
I did run your test with a nightly build, everything works fine.

Your code is simple and  straightforward, so I even don't see anything that can fails.

Perhaps the rrd path :
private static final String RRDPATH = "D:\\temp\\device0"; 
RRDPATH + i + ".rrd"

So you end up accessing D:\temp\device0i.rrd. Is that what you want ? 

<Demo.java>

Reply all
Reply to author
Forward
0 new messages