當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。