@Override public void asyncMarkDelete(final Position position, final MarkDeleteCallback callback, final Object ctx) { asyncMarkDelete(position, Collections.emptyMap(), callback, ctx); }
@Override public void asyncClearBacklog(final ClearBacklogCallback callback, Object ctx) { asyncMarkDelete(ledger.getLastPosition(), new MarkDeleteCallback() { @Override public void markDeleteComplete(Object ctx) { callback.clearBacklogComplete(ctx); } @Override public void markDeleteFailed(ManagedLedgerException exception, Object ctx) { if (exception.getCause() instanceof IllegalArgumentException) { // There could be a race condition between calling clear backlog and other mark delete operations. // If we get an exception it means the backlog was already cleared in the meantime. callback.clearBacklogComplete(ctx); } else { callback.clearBacklogFailed(exception, ctx); } } }, ctx); }
@Override public void markDelete(Position position, Map<String, Long> properties) throws InterruptedException, ManagedLedgerException { checkNotNull(position); checkArgument(position instanceof PositionImpl); class Result { ManagedLedgerException exception = null; } final Result result = new Result(); final CountDownLatch counter = new CountDownLatch(1); asyncMarkDelete(position, properties, new MarkDeleteCallback() { @Override public void markDeleteComplete(Object ctx) { counter.countDown(); } @Override public void markDeleteFailed(ManagedLedgerException exception, Object ctx) { result.exception = exception; counter.countDown(); } }, null); if (!counter.await(ManagedLedgerImpl.AsyncOperationTimeoutSeconds, TimeUnit.SECONDS)) { throw new ManagedLedgerException("Timeout during mark-delete operation"); } if (result.exception != null) { throw result.exception; } }
@Override public void asyncSkipEntries(int numEntriesToSkip, IndividualDeletedEntries deletedEntries, final SkipEntriesCallback callback, Object ctx) { log.info("[{}] Skipping {} entries on cursor {}", ledger.getName(), numEntriesToSkip, name); long numDeletedMessages = 0; if (deletedEntries == IndividualDeletedEntries.Exclude) { numDeletedMessages = getNumIndividualDeletedEntriesToSkip(numEntriesToSkip); } asyncMarkDelete(ledger.getPositionAfterN(markDeletePosition, numEntriesToSkip + numDeletedMessages, PositionBound.startExcluded), new MarkDeleteCallback() { @Override public void markDeleteComplete(Object ctx) { callback.skipEntriesComplete(ctx); } @Override public void markDeleteFailed(ManagedLedgerException exception, Object ctx) { if (exception.getCause() instanceof IllegalArgumentException) { // There could be a race condition between calling clear backlog and other mark delete // operations. // If we get an exception it means the backlog was already cleared in the meantime. callback.skipEntriesComplete(ctx); } else { log.error("[{}] Skip {} entries failed for cursor {}", ledger.getName(), numEntriesToSkip, name, exception); callback.skipEntriesFailed(exception, ctx); } } }, ctx); }
@Override public void asyncMarkDelete(final Position position, final MarkDeleteCallback callback, final Object ctx) { asyncMarkDelete(position, Collections.emptyMap(), callback, ctx); }
@Override public void asyncClearBacklog(final ClearBacklogCallback callback, Object ctx) { asyncMarkDelete(ledger.getLastPosition(), new MarkDeleteCallback() { @Override public void markDeleteComplete(Object ctx) { callback.clearBacklogComplete(ctx); } @Override public void markDeleteFailed(ManagedLedgerException exception, Object ctx) { if (exception.getCause() instanceof IllegalArgumentException) { // There could be a race condition between calling clear backlog and other mark delete operations. // If we get an exception it means the backlog was already cleared in the meantime. callback.clearBacklogComplete(ctx); } else { callback.clearBacklogFailed(exception, ctx); } } }, ctx); }
@Override public void asyncClearBacklog(final ClearBacklogCallback callback, Object ctx) { asyncMarkDelete(ledger.getLastPosition(), new MarkDeleteCallback() { @Override public void markDeleteComplete(Object ctx) { callback.clearBacklogComplete(ctx); } @Override public void markDeleteFailed(ManagedLedgerException exception, Object ctx) { if (exception.getCause() instanceof IllegalArgumentException) { // There could be a race condition between calling clear backlog and other mark delete operations. // If we get an exception it means the backlog was already cleared in the meantime. callback.clearBacklogComplete(ctx); } else { callback.clearBacklogFailed(exception, ctx); } } }, ctx); }
@Override public void markDelete(Position position, Map<String, Long> properties) throws InterruptedException, ManagedLedgerException { checkNotNull(position); checkArgument(position instanceof PositionImpl); class Result { ManagedLedgerException exception = null; } final Result result = new Result(); final CountDownLatch counter = new CountDownLatch(1); asyncMarkDelete(position, properties, new MarkDeleteCallback() { @Override public void markDeleteComplete(Object ctx) { counter.countDown(); } @Override public void markDeleteFailed(ManagedLedgerException exception, Object ctx) { result.exception = exception; counter.countDown(); } }, null); if (!counter.await(ManagedLedgerImpl.AsyncOperationTimeoutSeconds, TimeUnit.SECONDS)) { throw new ManagedLedgerException("Timeout during mark-delete operation"); } if (result.exception != null) { throw result.exception; } }
@Override public void markDelete(Position position) throws InterruptedException, ManagedLedgerException { checkNotNull(position); checkArgument(position instanceof PositionImpl); class Result { ManagedLedgerException exception = null; } final Result result = new Result(); final CountDownLatch counter = new CountDownLatch(1); asyncMarkDelete(position, new MarkDeleteCallback() { @Override public void markDeleteComplete(Object ctx) { counter.countDown(); } @Override public void markDeleteFailed(ManagedLedgerException exception, Object ctx) { result.exception = exception; counter.countDown(); } }, null); if (!counter.await(ManagedLedgerImpl.AsyncOperationTimeoutSeconds, TimeUnit.SECONDS)) { throw new ManagedLedgerException("Timeout during mark-delete operation"); } if (result.exception != null) { throw result.exception; } }
@Override public void asyncSkipEntries(int numEntriesToSkip, IndividualDeletedEntries deletedEntries, final SkipEntriesCallback callback, Object ctx) { log.info("[{}] Skipping {} entries on cursor {}", ledger.getName(), numEntriesToSkip, name); long numDeletedMessages = 0; if (deletedEntries == IndividualDeletedEntries.Exclude) { numDeletedMessages = getNumIndividualDeletedEntriesToSkip(numEntriesToSkip); } asyncMarkDelete(ledger.getPositionAfterN(markDeletePosition, numEntriesToSkip + numDeletedMessages, PositionBound.startExcluded), new MarkDeleteCallback() { @Override public void markDeleteComplete(Object ctx) { callback.skipEntriesComplete(ctx); } @Override public void markDeleteFailed(ManagedLedgerException exception, Object ctx) { if (exception.getCause() instanceof IllegalArgumentException) { // There could be a race condition between calling clear backlog and other mark delete // operations. // If we get an exception it means the backlog was already cleared in the meantime. callback.skipEntriesComplete(ctx); } else { log.error("[{}] Skip {} entries failed for cursor {}", ledger.getName(), numEntriesToSkip, name, exception); callback.skipEntriesFailed(exception, ctx); } } }, ctx); }
@Override public void asyncSkipEntries(int numEntriesToSkip, IndividualDeletedEntries deletedEntries, final SkipEntriesCallback callback, Object ctx) { log.info("[{}] Skipping {} entries on cursor {}", ledger.getName(), numEntriesToSkip, name); long numDeletedMessages = 0; if (deletedEntries == IndividualDeletedEntries.Exclude) { numDeletedMessages = getNumIndividualDeletedEntriesToSkip(numEntriesToSkip); } asyncMarkDelete(ledger.getPositionAfterN(markDeletePosition, numEntriesToSkip + numDeletedMessages, PositionBound.startExcluded), new MarkDeleteCallback() { @Override public void markDeleteComplete(Object ctx) { callback.skipEntriesComplete(ctx); } @Override public void markDeleteFailed(ManagedLedgerException exception, Object ctx) { if (exception.getCause() instanceof IllegalArgumentException) { // There could be a race condition between calling clear backlog and other mark delete // operations. // If we get an exception it means the backlog was already cleared in the meantime. callback.skipEntriesComplete(ctx); } else { log.error("[{}] Skip {} entries failed for cursor {}", ledger.getName(), numEntriesToSkip, name, exception); callback.skipEntriesFailed(exception, ctx); } } }, ctx); }