本文整理汇总了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());
}