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