All of lore.kernel.org
 help / color / mirror / Atom feed
* Need some help with the RBD Java bindings
@ 2013-08-15 15:51 Wido den Hollander
  2013-08-15 16:57 ` Noah Watkins
  0 siblings, 1 reply; 7+ messages in thread
From: Wido den Hollander @ 2013-08-15 15:51 UTC (permalink / raw)
  To: ceph-devel

Hi,

I'm having some issues with the Java bindings for librbd and I'm not 
sure what the problem is here.

The problem is with listing snapshot of a RBD image. I test it in this 
test case:

public void testCreateAndClone() {
     try {
         ..
         ..
         image.snapCreate(snapName);
         image.snapProtect(snapName);

         List<RbdSnapInfo> snaps = image.snapList();
         assertEquals("There should only be one snapshot", 1, snaps.size());
     ..
     ..
     }
}

This test fails 95% of the time with my whole JVM crashing.

The code to blame is in RbdImage.java:

public List<RbdSnapInfo> snapList() throws RbdException {
     IntByReference numSnaps = new IntByReference(16);
     PointerByReference snaps = new PointerByReference();
     List<RbdSnapInfo> list = new ArrayList<RbdSnapInfo>();
     RbdSnapInfo snapInfo, snapInfos[];

     while (true) {
         int r = rbd.rbd_snap_list(this.getPointer(), snaps, numSnaps);
         if (r >= 0) {
             numSnaps.setValue(r);
             break;
         } else {
             throw new RbdException("Failed listing snapshots", r);
         }
     }

     Pointer p = snaps.getValue(); <<<< crash
     snapInfo = new RbdSnapInfo(p);

     ..
     ..
}

So it crashes when it wants to get the value of the snaps var.

I can't figure out why this is happening and why it isn't consistent. 
I'm not a real JNA expert and I was hoping somebody around here would be 
able to figure out what I'm doing wrong.

Any Java/JNA experts around who might have a clue?

The source of rados-java: https://github.com/wido/rados-java

-- 
Wido den Hollander
42on B.V.

Phone: +31 (0)20 700 9902
Skype: contact42on

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-08-22 14:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-15 15:51 Need some help with the RBD Java bindings Wido den Hollander
2013-08-15 16:57 ` Noah Watkins
2013-08-20 21:26   ` Noah Watkins
2013-08-21 12:11     ` Wido den Hollander
2013-08-21 19:47       ` Noah Watkins
2013-08-22  6:20         ` Wido den Hollander
2013-08-22 14:43           ` Noah Watkins

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.