Search in sources :

Example 1 with SkipEntriesCallback

use of org.apache.bookkeeper.mledger.AsyncCallbacks.SkipEntriesCallback in project pulsar by yahoo.

the class ManagedCursorImpl method skipEntries.

@Override
public void skipEntries(int numEntriesToSkip, IndividualDeletedEntries deletedEntries) throws InterruptedException, ManagedLedgerException {
    class Result {

        ManagedLedgerException exception = null;
    }
    final Result result = new Result();
    final CountDownLatch counter = new CountDownLatch(1);
    asyncSkipEntries(numEntriesToSkip, deletedEntries, new SkipEntriesCallback() {

        @Override
        public void skipEntriesComplete(Object ctx) {
            counter.countDown();
        }

        @Override
        public void skipEntriesFailed(ManagedLedgerException exception, Object ctx) {
            result.exception = exception;
            counter.countDown();
        }
    }, null);
    if (!counter.await(ManagedLedgerImpl.AsyncOperationTimeoutSeconds, TimeUnit.SECONDS)) {
        throw new ManagedLedgerException("Timeout during skip messages operation");
    }
    if (result.exception != null) {
        throw result.exception;
    }
}
Also used : ManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException) CountDownLatch(java.util.concurrent.CountDownLatch) SkipEntriesCallback(org.apache.bookkeeper.mledger.AsyncCallbacks.SkipEntriesCallback)

Example 2 with SkipEntriesCallback

use of org.apache.bookkeeper.mledger.AsyncCallbacks.SkipEntriesCallback in project incubator-pulsar by apache.

the class ManagedCursorImpl method skipEntries.

@Override
public void skipEntries(int numEntriesToSkip, IndividualDeletedEntries deletedEntries) throws InterruptedException, ManagedLedgerException {
    class Result {

        ManagedLedgerException exception = null;
    }
    final Result result = new Result();
    final CountDownLatch counter = new CountDownLatch(1);
    asyncSkipEntries(numEntriesToSkip, deletedEntries, new SkipEntriesCallback() {

        @Override
        public void skipEntriesComplete(Object ctx) {
            counter.countDown();
        }

        @Override
        public void skipEntriesFailed(ManagedLedgerException exception, Object ctx) {
            result.exception = exception;
            counter.countDown();
        }
    }, null);
    if (!counter.await(ManagedLedgerImpl.AsyncOperationTimeoutSeconds, TimeUnit.SECONDS)) {
        throw new ManagedLedgerException("Timeout during skip messages operation");
    }
    if (result.exception != null) {
        throw result.exception;
    }
}
Also used : ManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException) ManagedLedgerException.getManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException.getManagedLedgerException) ManagedLedgerImpl.createManagedLedgerException(org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.createManagedLedgerException) CountDownLatch(java.util.concurrent.CountDownLatch) SkipEntriesCallback(org.apache.bookkeeper.mledger.AsyncCallbacks.SkipEntriesCallback)

Aggregations

CountDownLatch (java.util.concurrent.CountDownLatch)2 SkipEntriesCallback (org.apache.bookkeeper.mledger.AsyncCallbacks.SkipEntriesCallback)2 ManagedLedgerException (org.apache.bookkeeper.mledger.ManagedLedgerException)2 ManagedLedgerException.getManagedLedgerException (org.apache.bookkeeper.mledger.ManagedLedgerException.getManagedLedgerException)1 ManagedLedgerImpl.createManagedLedgerException (org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.createManagedLedgerException)1