public void recoverBookieData(
      final Set<BookieSocketAddress> bookiesSrc, boolean dryrun, boolean skipOpenLedgers)
      throws InterruptedException, BKException {
    SyncObject sync = new SyncObject();
    // Call the async method to recover bookie data.
    asyncRecoverBookieData(
        bookiesSrc,
        dryrun,
        skipOpenLedgers,
        new RecoverCallback() {
          @Override
          public void recoverComplete(int rc, Object ctx) {
            LOG.info("Recover bookie operation completed with rc: " + rc);
            SyncObject syncObj = (SyncObject) ctx;
            synchronized (syncObj) {
              syncObj.rc = rc;
              syncObj.value = true;
              syncObj.notify();
            }
          }
        },
        sync);

    // Wait for the async method to complete.
    synchronized (sync) {
      while (sync.value == false) {
        sync.wait();
      }
    }
    if (sync.rc != BKException.Code.OK) {
      throw BKException.create(sync.rc);
    }
  }
 public SortedMap<Long, LedgerMetadata> getLedgersContainBookies(Set<BookieSocketAddress> bookies)
     throws InterruptedException, BKException {
   final SyncObject sync = new SyncObject();
   final AtomicReference<SortedMap<Long, LedgerMetadata>> resultHolder =
       new AtomicReference<SortedMap<Long, LedgerMetadata>>(null);
   asyncGetLedgersContainBookies(
       bookies,
       new GenericCallback<SortedMap<Long, LedgerMetadata>>() {
         @Override
         public void operationComplete(int rc, SortedMap<Long, LedgerMetadata> result) {
           LOG.info("GetLedgersContainBookies completed with rc : {}", rc);
           synchronized (sync) {
             sync.rc = rc;
             sync.value = true;
             resultHolder.set(result);
             sync.notify();
           }
         }
       });
   synchronized (sync) {
     while (sync.value == false) {
       sync.wait();
     }
   }
   if (sync.rc != BKException.Code.OK) {
     throw BKException.create(sync.rc);
   }
   return resultHolder.get();
 }