@Override public ManagedCursor newNonDurableCursor(Position startCursorPosition) throws ManagedLedgerException { checkManagedLedgerIsOpen(); checkFenced(); return new NonDurableCursorImpl(bookKeeper, config, this, null, (PositionImpl) startCursorPosition); }
@Override public long getNumberOfActiveEntries() { long totalEntries = getNumberOfEntries(); PositionImpl pos = cursors.getSlowestReaderPosition(); if (pos == null) { // If there are no consumers, there are no active entries return 0; } else { // The slowest consumer will be in the first ledger in the list. We need to subtract the entries it has // already consumed in order to get the active entries count. return totalEntries - (pos.getEntryId() + 1); } }
boolean hasMoreEntries(PositionImpl position) { PositionImpl lastPositionInLedger = ledger.getLastPosition(); if (position.compareTo(lastPositionInLedger) <= 0) { return getNumberOfEntries(Range.closed(position, lastPositionInLedger)) > 0; } return false; }
@Override public long getNumberOfEntriesSinceFirstNotAckedMessage() { // sometimes for already caught up consumer: due to race condition markDeletePosition > readPosition. so, // validate it before preparing range PositionImpl markDeletePosition = this.markDeletePosition; PositionImpl readPosition = this.readPosition; return (markDeletePosition.compareTo(readPosition) < 0) ? ledger.getNumberOfEntries(Range.openClosed(markDeletePosition, readPosition)) : 0; }
public Position getNextLedgerPosition(long currentLedgerId) { Long nextExistingLedger = ledger.getNextValidLedger(currentLedgerId); return nextExistingLedger != null ? PositionImpl.get(nextExistingLedger, 0) : null; }
public EntryCache getEntryCache(ManagedLedgerImpl ml) { if (maxSize == 0) { // Cache is disabled return new EntryCacheDisabled(ml); } EntryCache newEntryCache = new EntryCacheImpl(this, ml); EntryCache currentEntryCache = caches.putIfAbsent(ml.getName(), newEntryCache); if (currentEntryCache != null) { return currentEntryCache; } else { return newEntryCache; } }
@Override public long getCacheUsedSize() { return factory.getEntryCacheManager().getSize(); }
@Override public long getCacheMaxSize() { return factory.getEntryCacheManager().getMaxSize(); }
public MarkDeleteEntry(PositionImpl newPosition, Map<String, Long> properties, MarkDeleteCallback callback, Object ctx) { this.newPosition = PositionImpl.get(newPosition); this.properties = properties; this.callback = callback; this.ctx = ctx; } }
/** * Tells whether the managed ledger has any active-cursor registered. * * @return true if at least a cursor exists */ public boolean hasActiveCursors() { return !activeCursors.isEmpty(); }
@Override public void operationComplete(Void result, Stat stat) { cursorLedgerStat = stat; callback.operationComplete(result, stat); }
@Override public void markDelete(Position position, Map<String, Long> properties) throws ManagedLedgerException { this.position = position; container.cursorUpdated(this, (PositionImpl) position); }
@Override public void markDeleteFailed(ManagedLedgerException exception, Object ctx) { finalCallback.operationFailed(exception); } }, null);
@Override public void operationFailed(MetaStoreException e) { callback.operationFailed(e); } });
@Override protected EntryImpl newObject(Handle<EntryImpl> handle) { return new EntryImpl(handle); } };
@Override public CompletableFuture<LastConfirmedAndEntry> readLastAddConfirmedAndEntryAsync(long entryId, long timeOutInMillis, boolean parallel) { return unsupported(); }
@Override public void operationFailed(MetaStoreException e) { callback.operationFailed(e); } });
@Override public void operationFailed(ManagedLedgerException exception) { callback.operationFailed(exception); } });