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


Java AddCallback类代码示例

本文整理汇总了Java中org.apache.bookkeeper.client.AsyncCallback.AddCallback的典型用法代码示例。如果您正苦于以下问题:Java AddCallback类的具体用法?Java AddCallback怎么用?Java AddCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AddCallback类属于org.apache.bookkeeper.client.AsyncCallback包,在下文中一共展示了AddCallback类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: asyncAddEntry

import org.apache.bookkeeper.client.AsyncCallback.AddCallback; //导入依赖的package包/类
/**
 * Add entry asynchronously to an open ledger.
 * 
 * @param data
 *          array of bytes to be written
 * @param cb
 *          object implementing callbackinterface
 * @param ctx
 *          some control object
 */
public void asyncAddEntry(final byte[] data, final AddCallback cb,
    final Object ctx) {
  bk.mainWorkerPool.submitOrdered(ledgerId, new SafeRunnable() {
    @Override
    public void safeRun() {
      if (metadata.isClosed()) {
        LOG.warn("Attempt to add to closed ledger: " + ledgerId);
        cb.addComplete(BKException.Code.LedgerClosedException,
            LedgerHandle.this, -1, ctx);
        return;
      }

      long entryId = ++lastAddPushed;
      long currentLength = addToLength(data.length);
      PendingAddOp op = new PendingAddOp(LedgerHandle.this, cb, ctx, entryId);
      pendingAddOps.add(op);
      ChannelBuffer toSend = macManager.computeDigestAndPackageForSending(
              entryId, lastAddConfirmed, currentLength, data);
      op.initiate(toSend);

    }
  });
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:34,代码来源:LedgerHandle.java

示例2: PendingAddOp

import org.apache.bookkeeper.client.AsyncCallback.AddCallback; //导入依赖的package包/类
PendingAddOp(LedgerHandle lh, AddCallback cb, Object ctx, long entryId) {
    this.lh = lh;
    this.cb = cb;
    this.ctx = ctx;
    this.entryId = entryId;
    successesSoFar = new boolean[lh.metadata.quorumSize];
    numResponsesPending = successesSoFar.length;
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:9,代码来源:PendingAddOp.java

示例3: asyncAddEntry

import org.apache.bookkeeper.client.AsyncCallback.AddCallback; //导入依赖的package包/类
@Override
public void asyncAddEntry(final byte[] data, final AddCallback cb, final Object ctx) {
    asyncAddEntry(data, 0, data.length, cb, ctx);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:5,代码来源:MockLedgerHandle.java


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