当前位置: 首页>>代码示例>>Java>>正文


Java RbdSnapInfo类代码示例

本文整理汇总了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());
}
 
开发者ID:kurthuwig,项目名称:rados-java,代码行数:41,代码来源:RbdImage.java


注:本文中的com.ceph.rbd.jna.RbdSnapInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。