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