當前位置: 首頁>>代碼示例>>Java>>正文


Java CreateCallback類代碼示例

本文整理匯總了Java中org.apache.bookkeeper.client.AsyncCallback.CreateCallback的典型用法代碼示例。如果您正苦於以下問題:Java CreateCallback類的具體用法?Java CreateCallback怎麽用?Java CreateCallback使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CreateCallback類屬於org.apache.bookkeeper.client.AsyncCallback包,在下文中一共展示了CreateCallback類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: asyncCreateLedger

import org.apache.bookkeeper.client.AsyncCallback.CreateCallback; //導入依賴的package包/類
@Override
public void asyncCreateLedger(int ensSize, int writeQuorumSize, int ackQuorumSize, final DigestType digestType,
        final byte[] passwd, final CreateCallback cb, final Object ctx) {
    if (stopped.get()) {
        cb.createComplete(BKException.Code.WriteException, null, ctx);
        return;
    }

    executor.execute(new Runnable() {
        public void run() {
            if (getProgrammedFailStatus()) {
                if (failReturnCode != BkTimeoutOperation) {
                    cb.createComplete(failReturnCode, null, ctx);
                }
                return;
            }

            if (stopped.get()) {
                cb.createComplete(BKException.Code.WriteException, null, ctx);
                return;
            }

            try {
                long id = sequence.getAndIncrement();
                log.info("Creating ledger {}", id);
                MockLedgerHandle lh = new MockLedgerHandle(MockBookKeeper.this, id, digestType, passwd);
                ledgers.put(id, lh);
                cb.createComplete(0, lh, ctx);
            } catch (Throwable t) {
            }
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-pulsar,代碼行數:34,代碼來源:MockBookKeeper.java

示例2: asyncCreateLedger

import org.apache.bookkeeper.client.AsyncCallback.CreateCallback; //導入依賴的package包/類
/**
 * Creates a new ledger asynchronously. To create a ledger, we need to specify
 * the ensemble size, the quorum size, the digest type, a password, a callback
 * implementation, and an optional control object. The ensemble size is how
 * many bookies the entries should be striped among and the quorum size is the
 * degree of replication of each entry. The digest type is either a MAC or a
 * CRC. Note that the CRC option is not able to protect a client against a
 * bookie that replaces an entry. The password is used not only to
 * authenticate access to a ledger, but also to verify entries in ledgers.
 * 
 * @param ensSize
 *          ensemble size
 * @param qSize
 *          quorum size
 * @param digestType
 *          digest type, either MAC or CRC32
 * @param passwd
 *          password
 * @param cb
 *          createCallback implementation
 * @param ctx
 *          optional control object
 */
public void asyncCreateLedger(int ensSize, int qSize, DigestType digestType,
    byte[] passwd, CreateCallback cb, Object ctx) {

  new LedgerCreateOp(this, ensSize, qSize, digestType, passwd, cb, ctx)
      .initiate();

}
 
開發者ID:gerritjvv,項目名稱:bigstreams,代碼行數:31,代碼來源:BookKeeper.java

示例3: LedgerCreateOp

import org.apache.bookkeeper.client.AsyncCallback.CreateCallback; //導入依賴的package包/類
/**
* Constructor
* 
* @param bk
*       BookKeeper object
* @param ensembleSize
*       ensemble size
* @param quorumSize
*       quorum size
* @param digestType
*       digest type, either MAC or CRC32
* @param passwd
*       passowrd
* @param cb
*       callback implementation
* @param ctx
*       optional control object
*/

LedgerCreateOp(BookKeeper bk, int ensembleSize, int quorumSize, DigestType digestType, byte[] passwd, CreateCallback cb, Object ctx) {
    this.bk = bk;
    this.metadata = new LedgerMetadata(ensembleSize, quorumSize);
    this.digestType = digestType;
    this.passwd = passwd;
    this.cb = cb;
    this.ctx = ctx;
}
 
開發者ID:gerritjvv,項目名稱:bigstreams,代碼行數:28,代碼來源:LedgerCreateOp.java


注:本文中的org.apache.bookkeeper.client.AsyncCallback.CreateCallback類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。