本文整理匯總了Java中com.ceph.rbd.jna.RbdSnapInfo類的典型用法代碼示例。如果您正苦於以下問題:Java RbdSnapInfo類的具體用法?Java RbdSnapInfo怎麽用?Java RbdSnapInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RbdSnapInfo類屬於com.ceph.rbd.jna包,在下文中一共展示了RbdSnapInfo類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: snapList
import com.ceph.rbd.jna.RbdSnapInfo; //導入依賴的package包/類
/**
* List all snapshots
*
* @return List
* @throws RbdException
*/
public List<RbdSnapInfo> snapList() throws RbdException {
IntByReference numSnaps = new IntByReference(16);
RbdSnapInfo[] snaps;
while (true) {
snaps = new RbdSnapInfo[numSnaps.getValue()];
int r = rbd.rbd_snap_list(this.getPointer(), snaps, numSnaps);
if (r >= 0) {
numSnaps.setValue(r);
break;
} else if (r == -34) { /* FIXME: hard-coded -ERANGE */
numSnaps.setValue(r);
} else {
throw new RbdException("Failed listing snapshots", r);
}
}
/*
* Before clearing the backing list (well, just the name strings)
* we'll disable auto sync so that junk doesn't repopulate the info
* struct.
*
* FIXME: this is dumb, and I'm not exactly sure how to fix it, though
* it does work. Note that this should be fine as long as you don't
* re-use the RbdSnapInfo as a parameter to another native function.
*/
for (int i = 0; i < numSnaps.getValue(); i++) {
snaps[i].setAutoSynch(false);
}
rbd.rbd_snap_list_end(snaps);
return Arrays.asList(snaps).subList(0, numSnaps.getValue());
}