示例#1
0
 private void replicateLedgerFragment(
     LedgerHandle lh,
     final LedgerFragment ledgerFragment,
     final Map<Integer, BookieSocketAddress> targetBookieAddresses)
     throws InterruptedException, BKException {
   SyncCounter syncCounter = new SyncCounter();
   ResultCallBack resultCallBack = new ResultCallBack(syncCounter);
   SingleFragmentCallback cb =
       new SingleFragmentCallback(
           resultCallBack,
           lh,
           ledgerFragment.getFirstEntryId(),
           getReplacedBookiesMap(ledgerFragment, targetBookieAddresses));
   syncCounter.inc();
   Set<BookieSocketAddress> targetBookieSet = new HashSet<BookieSocketAddress>();
   targetBookieSet.addAll(targetBookieAddresses.values());
   asyncRecoverLedgerFragment(lh, ledgerFragment, cb, targetBookieSet);
   syncCounter.block(0);
   if (syncCounter.getrc() != BKException.Code.OK) {
     throw BKException.create(bkc.getReturnRc(syncCounter.getrc()));
   }
 }
示例#2
0
  /**
   * Open a ledger as an administrator without recovering the ledger. This means that no digest
   * password checks are done. Otherwise, the call is identical to BookKeeper#openLedgerNoRecovery
   *
   * @param lId ledger identifier
   * @see BookKeeper#openLedgerNoRecovery
   */
  public LedgerHandle openLedgerNoRecovery(final long lId)
      throws InterruptedException, BKException {
    SyncCounter counter = new SyncCounter();
    counter.inc();
    new LedgerOpenOp(bkc, lId, new SyncOpenCallback(), counter).initiateWithoutRecovery();
    /*
     * Wait
     */
    counter.block(0);
    if (counter.getrc() != BKException.Code.OK) {
      throw BKException.create(counter.getrc());
    }

    return counter.getLh();
  }
示例#3
0
 @Override
 public void processResult(int rc, String s, Object obj) {
   sync.setrc(rc);
   sync.dec();
 }