public class ManagedLedgerImpl extends Object implements ManagedLedger, AsyncCallback.CreateCallback
| Modifier and Type | Class and Description |
|---|---|
static class |
ManagedLedgerImpl.PositionBound |
static class |
ManagedLedgerImpl.State |
| Modifier and Type | Field and Description |
|---|---|
protected static AtomicLongFieldUpdater<ManagedLedgerImpl> |
ADD_OP_COUNT_UPDATER |
protected static int |
AsyncOperationTimeoutSeconds |
protected BookKeeper |
bookKeeper |
protected Clock |
clock |
protected ManagedLedgerConfig |
config |
protected static int |
DEFAULT_LEDGER_DELETE_BACKOFF_TIME_SEC |
protected static int |
DEFAULT_LEDGER_DELETE_RETRIES |
protected NavigableMap<Long,MLDataFormats.ManagedLedgerInfo.LedgerInfo> |
ledgers |
protected ManagedLedgerMBeanImpl |
mbean |
protected Supplier<Boolean> |
mlOwnershipChecker |
protected String |
name |
protected Map<String,String> |
propertiesMap |
protected ManagedLedgerImpl.State |
state |
protected MetaStore |
store |
| Constructor and Description |
|---|
ManagedLedgerImpl(ManagedLedgerFactoryImpl factory,
BookKeeper bookKeeper,
MetaStore store,
ManagedLedgerConfig config,
org.apache.bookkeeper.common.util.OrderedScheduler scheduledExecutor,
String name) |
ManagedLedgerImpl(ManagedLedgerFactoryImpl factory,
BookKeeper bookKeeper,
MetaStore store,
ManagedLedgerConfig config,
org.apache.bookkeeper.common.util.OrderedScheduler scheduledExecutor,
String name,
Supplier<Boolean> mlOwnershipChecker) |
| Modifier and Type | Method and Description |
|---|---|
void |
activateCursor(ManagedCursor cursor) |
Position |
addEntry(byte[] data)
Append a new entry to the end of a managed ledger.
|
Position |
addEntry(byte[] data,
int numberOfMessages)
Append a new entry to the end of a managed ledger.
|
Position |
addEntry(byte[] data,
int offset,
int length)
Append a new entry to the end of a managed ledger.
|
Position |
addEntry(byte[] data,
int numberOfMessages,
int offset,
int length)
Append a new entry to the end of a managed ledger.
|
void |
addWaitingEntryCallBack(WaitingEntryCallBack cb) |
void |
asyncAddEntry(byte[] data,
AsyncCallbacks.AddEntryCallback callback,
Object ctx)
Append a new entry asynchronously.
|
void |
asyncAddEntry(byte[] data,
int offset,
int length,
AsyncCallbacks.AddEntryCallback callback,
Object ctx)
Append a new entry asynchronously.
|
void |
asyncAddEntry(byte[] data,
int numberOfMessages,
int offset,
int length,
AsyncCallbacks.AddEntryCallback callback,
Object ctx)
Append a new entry asynchronously.
|
void |
asyncAddEntry(io.netty.buffer.ByteBuf buffer,
AsyncCallbacks.AddEntryCallback callback,
Object ctx)
Append a new entry asynchronously.
|
void |
asyncAddEntry(io.netty.buffer.ByteBuf buffer,
int numberOfMessages,
AsyncCallbacks.AddEntryCallback callback,
Object ctx)
Append a new entry asynchronously.
|
void |
asyncClose(AsyncCallbacks.CloseCallback callback,
Object ctx)
Close the ManagedLedger asynchronously.
|
protected void |
asyncCreateLedger(BookKeeper bookKeeper,
ManagedLedgerConfig config,
BookKeeper.DigestType digestType,
AsyncCallback.CreateCallback cb,
Map<String,byte[]> metadata)
Create ledger async and schedule a timeout task to check ledger-creation is complete else it fails the callback
with TimeoutException.
|
void |
asyncDelete(AsyncCallbacks.DeleteLedgerCallback callback,
Object ctx)
Async delete a ledger.
|
void |
asyncDeleteCursor(String consumerName,
AsyncCallbacks.DeleteCursorCallback callback,
Object ctx)
Delete a ManagedCursor asynchronously.
|
void |
asyncDeleteProperty(String key,
AsyncCallbacks.UpdatePropertiesCallback callback,
Object ctx)
Async delete the property by key.
|
CompletableFuture<Position> |
asyncFindPosition(com.google.common.base.Predicate<Entry> predicate)
Find position by sequenceId.
|
void |
asyncOffloadPrefix(Position pos,
AsyncCallbacks.OffloadCallback callback,
Object ctx)
Offload as many entries before position as possible to longterm storage.
|
void |
asyncOpenCursor(String cursorName,
AsyncCallbacks.OpenCursorCallback callback,
Object ctx)
Open a ManagedCursor asynchronously.
|
void |
asyncOpenCursor(String cursorName,
CommandSubscribe.InitialPosition initialPosition,
AsyncCallbacks.OpenCursorCallback callback,
Object ctx)
Open a ManagedCursor asynchronously.
|
void |
asyncOpenCursor(String cursorName,
CommandSubscribe.InitialPosition initialPosition,
Map<String,Long> properties,
AsyncCallbacks.OpenCursorCallback callback,
Object ctx)
Open a ManagedCursor asynchronously.
|
void |
asyncReadEntry(PositionImpl position,
AsyncCallbacks.ReadEntryCallback callback,
Object ctx) |
protected void |
asyncReadEntry(org.apache.bookkeeper.client.api.ReadHandle ledger,
long firstEntry,
long lastEntry,
boolean isSlowestReader,
org.apache.bookkeeper.mledger.impl.OpReadEntry opReadEntry,
Object ctx) |
protected void |
asyncReadEntry(org.apache.bookkeeper.client.api.ReadHandle ledger,
PositionImpl position,
AsyncCallbacks.ReadEntryCallback callback,
Object ctx) |
void |
asyncSetProperties(Map<String,String> properties,
AsyncCallbacks.UpdatePropertiesCallback callback,
Object ctx)
Async update managed-ledger's properties.
|
void |
asyncSetProperty(String key,
String value,
AsyncCallbacks.UpdatePropertiesCallback callback,
Object ctx)
Async add key-value to propertiesMap.
|
void |
asyncTerminate(AsyncCallbacks.TerminateCallback callback,
Object ctx) |
CompletableFuture<Void> |
asyncTruncate()
Truncate ledgers
The truncate operation will move all cursors to the end of the topic and delete all inactive ledgers.
|
protected boolean |
checkAndCompleteLedgerOpTask(int rc,
LedgerHandle lh,
Object ctx)
check if ledger-op task is already completed by timeout-task.
|
void |
close()
Close the ManagedLedger.
|
void |
createComplete(int rc,
LedgerHandle lh,
Object ctx) |
static ManagedLedgerException |
createManagedLedgerException(int bkErrorCode) |
static ManagedLedgerException |
createManagedLedgerException(Throwable t) |
void |
deactivateCursor(ManagedCursor cursor) |
void |
delete()
Delete this ManagedLedger completely from the system.
|
void |
deleteCursor(String name)
Remove a ManagedCursor from this ManagedLedger.
|
void |
deleteProperty(String key)
Delete the property by key.
|
ManagedCursorContainer |
getActiveCursors()
Get a list of all the active cursors reading from this ManagedLedger.
|
long |
getCacheSize() |
Clock |
getClock() |
ManagedLedgerConfig |
getConfig()
Returns managed-ledger config.
|
long |
getCurrentLedgerEntries() |
long |
getCurrentLedgerSize() |
ManagedCursorContainer |
getCursors()
Get a list of all the cursors reading from this ManagedLedger
|
CompletableFuture<Long> |
getEarliestMessagePublishTimeInBacklog()
Get the publishing time of the oldest message in the backlog.
|
CompletableFuture<Long> |
getEarliestMessagePublishTimeOfPos(PositionImpl pos) |
CompletableFuture<Set<org.apache.bookkeeper.net.BookieId>> |
getEnsemblesAsync(long ledgerId) |
long |
getEntriesAddedCounter() |
long |
getEstimatedBacklogSize()
Get estimated total unconsumed or backlog size in bytes for the managed ledger, without accounting for replicas.
|
long |
getEstimatedBacklogSize(PositionImpl pos)
Get estimated backlog size from a specific position.
|
PositionImpl |
getFirstPosition() |
Position |
getLastConfirmedEntry()
Gets last confirmed entry of the managed ledger.
|
long |
getLastLedgerCreatedTimestamp() |
long |
getLastLedgerCreationFailureTimestamp() |
long |
getLastOffloadedFailureTimestamp()
Get last failed offloaded timestamp.
|
long |
getLastOffloadedLedgerId()
Get last offloaded ledgerId.
|
long |
getLastOffloadedSuccessTimestamp()
Get last suceessful offloaded timestamp.
|
CompletableFuture<MLDataFormats.ManagedLedgerInfo.LedgerInfo> |
getLedgerInfo(long ledgerId)
Get basic ledger summary.
|
CompletableFuture<String> |
getLedgerMetadata(long ledgerId) |
NavigableMap<Long,MLDataFormats.ManagedLedgerInfo.LedgerInfo> |
getLedgersInfo() |
List<MLDataFormats.ManagedLedgerInfo.LedgerInfo> |
getLedgersInfoAsList() |
ManagedLedgerInterceptor |
getManagedLedgerInterceptor()
Get the ManagedLedgerInterceptor for ManagedLedger.
|
CompletableFuture<ManagedLedgerInternalStats> |
getManagedLedgerInternalStats(boolean includeLedgerMetadata)
Get managed ledger internal stats
|
ManagedLedgerMBeanImpl |
getMBean() |
String |
getName() |
Long |
getNextValidLedger(long ledgerId) |
PositionImpl |
getNextValidPosition(PositionImpl position) |
PositionImpl |
getNextValidPositionInternal(PositionImpl position) |
long |
getNumberOfActiveEntries()
Get the total number of active entries for this managed ledger.
|
long |
getNumberOfEntries()
Get the total number of entries for this managed ledger.
|
long |
getOffloadedSize()
Return the size of all ledgers offloaded to 2nd tier storage
|
int |
getPendingAddEntriesCount() |
PositionImpl |
getPositionAfterN(PositionImpl startPosition,
long n,
ManagedLedgerImpl.PositionBound startRange)
Get the entry position at a given distance from a given position.
|
PositionImpl |
getPreviousPosition(PositionImpl position)
Get the entry position that come before the specified position in the message stream, using information from the
ledger list and each ledger entries count.
|
Map<String,String> |
getProperties()
Returns managed-ledger's properties.
|
ManagedCursor |
getSlowestConsumer()
Get the slowest consumer.
|
ManagedLedgerImpl.State |
getState() |
ManagedLedgerMXBean |
getStats() |
long |
getTotalSize()
Get the total sizes in bytes of the managed ledger, without accounting for replicas.
|
int |
getWaitingCursorsCount() |
boolean |
hasActiveCursors()
Tells whether the managed ledger has any active-cursor registered.
|
boolean |
hasMoreEntries(PositionImpl position) |
boolean |
isCursorActive(ManagedCursor cursor) |
protected boolean |
isReadOnly() |
boolean |
isTerminated()
Returns whether the managed ledger was terminated.
|
boolean |
isValidPosition(PositionImpl position)
Validate whether a specified position is valid for the current managed ledger.
|
boolean |
ledgerExists(long ledgerId) |
void |
maybeUpdateCursorBeforeTrimmingConsumedLedger() |
ManagedCursor |
newNonDurableCursor(Position startCursorPosition)
Creates a new cursor whose metadata is not backed by durable storage.
|
ManagedCursor |
newNonDurableCursor(Position startPosition,
String subscriptionName) |
ManagedCursor |
newNonDurableCursor(Position startCursorPosition,
String cursorName,
CommandSubscribe.InitialPosition initialPosition) |
Position |
offloadPrefix(Position pos)
Offload as many entries before position as possible to longterm storage.
|
ManagedCursor |
openCursor(String cursorName)
Open a ManagedCursor in this ManagedLedger.
|
ManagedCursor |
openCursor(String cursorName,
CommandSubscribe.InitialPosition initialPosition)
Open a ManagedCursor in this ManagedLedger.
|
ManagedCursor |
openCursor(String cursorName,
CommandSubscribe.InitialPosition initialPosition,
Map<String,Long> properties)
Open a ManagedCursor in this ManagedLedger.
|
void |
readyToCreateNewLedger()
Signaling managed ledger that we can resume after BK write failure
|
void |
rollCurrentLedgerIfFull()
Roll current ledger if it is full
|
void |
setConfig(ManagedLedgerConfig config)
Updates managed-ledger config.
|
void |
setEntriesAddedCounter(long count) |
void |
setProperties(Map<String,String> properties)
Update managed-ledger's properties.
|
void |
setProperty(String key,
String value)
Add key-value to propertiesMap.
|
Position |
terminate()
Terminate the managed ledger and return the last committed entry.
|
void |
trimConsumedLedgersInBackground(boolean isTruncate,
CompletableFuture<?> promise) |
void |
trimConsumedLedgersInBackground(CompletableFuture<?> promise)
Trim consumed ledgers in background
|
void |
updateLedgersIdsComplete(Stat stat) |
protected static final int AsyncOperationTimeoutSeconds
protected final BookKeeper bookKeeper
protected final String name
protected ManagedLedgerConfig config
protected final MetaStore store
protected final NavigableMap<Long,MLDataFormats.ManagedLedgerInfo.LedgerInfo> ledgers
protected static final int DEFAULT_LEDGER_DELETE_RETRIES
protected static final int DEFAULT_LEDGER_DELETE_BACKOFF_TIME_SEC
protected volatile ManagedLedgerImpl.State state
protected final ManagedLedgerMBeanImpl mbean
protected final Clock clock
protected static final AtomicLongFieldUpdater<ManagedLedgerImpl> ADD_OP_COUNT_UPDATER
public ManagedLedgerImpl(ManagedLedgerFactoryImpl factory, BookKeeper bookKeeper, MetaStore store, ManagedLedgerConfig config, org.apache.bookkeeper.common.util.OrderedScheduler scheduledExecutor, String name)
public ManagedLedgerImpl(ManagedLedgerFactoryImpl factory, BookKeeper bookKeeper, MetaStore store, ManagedLedgerConfig config, org.apache.bookkeeper.common.util.OrderedScheduler scheduledExecutor, String name, Supplier<Boolean> mlOwnershipChecker)
public String getName()
getName in interface ManagedLedgerpublic Position addEntry(byte[] data) throws InterruptedException, ManagedLedgerException
ManagedLedgeraddEntry in interface ManagedLedgerdata - data entry to be persistedManagedLedgerExceptionInterruptedExceptionpublic Position addEntry(byte[] data, int numberOfMessages) throws InterruptedException, ManagedLedgerException
ManagedLedgeraddEntry in interface ManagedLedgerdata - data entry to be persistednumberOfMessages - numberOfMessages of entryManagedLedgerExceptionInterruptedExceptionpublic Position addEntry(byte[] data, int offset, int length) throws InterruptedException, ManagedLedgerException
ManagedLedgeraddEntry in interface ManagedLedgerdata - data entry to be persistedoffset - offset in the data arraylength - number of bytesManagedLedgerExceptionInterruptedExceptionpublic Position addEntry(byte[] data, int numberOfMessages, int offset, int length) throws InterruptedException, ManagedLedgerException
ManagedLedgeraddEntry in interface ManagedLedgerdata - data entry to be persistednumberOfMessages - numberOfMessages of entryoffset - offset in the data arraylength - number of bytesManagedLedgerExceptionInterruptedExceptionpublic void asyncAddEntry(byte[] data,
AsyncCallbacks.AddEntryCallback callback,
Object ctx)
ManagedLedgerasyncAddEntry in interface ManagedLedgerdata - data entry to be persistedcallback - callback objectctx - opaque contextManagedLedger.addEntry(byte[])public void asyncAddEntry(byte[] data,
int offset,
int length,
AsyncCallbacks.AddEntryCallback callback,
Object ctx)
ManagedLedgerasyncAddEntry in interface ManagedLedgerdata - data entry to be persistedoffset - offset in the data arraylength - number of bytescallback - callback objectctx - opaque contextManagedLedger.addEntry(byte[])public void asyncAddEntry(byte[] data,
int numberOfMessages,
int offset,
int length,
AsyncCallbacks.AddEntryCallback callback,
Object ctx)
ManagedLedgerasyncAddEntry in interface ManagedLedgerdata - data entry to be persistednumberOfMessages - numberOfMessages of entryoffset - offset in the data arraylength - number of bytescallback - callback objectctx - opaque contextManagedLedger.addEntry(byte[])public void asyncAddEntry(io.netty.buffer.ByteBuf buffer,
AsyncCallbacks.AddEntryCallback callback,
Object ctx)
ManagedLedgerasyncAddEntry in interface ManagedLedgerbuffer - buffer with the data entrycallback - callback objectctx - opaque contextManagedLedger.addEntry(byte[])public void asyncAddEntry(io.netty.buffer.ByteBuf buffer,
int numberOfMessages,
AsyncCallbacks.AddEntryCallback callback,
Object ctx)
ManagedLedgerasyncAddEntry in interface ManagedLedgerbuffer - buffer with the data entrynumberOfMessages - numberOfMessages for data entrycallback - callback objectctx - opaque contextManagedLedger.addEntry(byte[])public void readyToCreateNewLedger()
ManagedLedgerreadyToCreateNewLedger in interface ManagedLedgerpublic ManagedCursor openCursor(String cursorName) throws InterruptedException, ManagedLedgerException
ManagedLedgeropenCursor in interface ManagedLedgercursorName - the name associated with the ManagedCursorManagedLedgerExceptionInterruptedExceptionpublic ManagedCursor openCursor(String cursorName, CommandSubscribe.InitialPosition initialPosition) throws InterruptedException, ManagedLedgerException
ManagedLedgerIf the cursors doesn't exist, a new one will be created and its position will be at the end of the ManagedLedger.
openCursor in interface ManagedLedgercursorName - the name associated with the ManagedCursorinitialPosition - the cursor will be set at latest position or not when first created
default is trueManagedLedgerExceptionInterruptedExceptionpublic ManagedCursor openCursor(String cursorName, CommandSubscribe.InitialPosition initialPosition, Map<String,Long> properties) throws InterruptedException, ManagedLedgerException
ManagedLedgerIf the cursors doesn't exist, a new one will be created and its position will be at the end of the ManagedLedger.
openCursor in interface ManagedLedgercursorName - the name associated with the ManagedCursorinitialPosition - the cursor will be set at latest position or not when first created
default is trueproperties - user defined properties that will be attached to the first position of the cursor, if the open
operation will trigger the creation of the cursor.ManagedLedgerExceptionInterruptedExceptionpublic void asyncOpenCursor(String cursorName, AsyncCallbacks.OpenCursorCallback callback, Object ctx)
ManagedLedgerasyncOpenCursor in interface ManagedLedgercursorName - the name associated with the ManagedCursorcallback - callback objectctx - opaque contextManagedLedger.openCursor(String)public void asyncOpenCursor(String cursorName, CommandSubscribe.InitialPosition initialPosition, AsyncCallbacks.OpenCursorCallback callback, Object ctx)
ManagedLedgerasyncOpenCursor in interface ManagedLedgercursorName - the name associated with the ManagedCursorinitialPosition - the cursor will be set at lastest position or not when first created
default is truecallback - callback objectctx - opaque contextManagedLedger.openCursor(String)public void asyncOpenCursor(String cursorName, CommandSubscribe.InitialPosition initialPosition, Map<String,Long> properties, AsyncCallbacks.OpenCursorCallback callback, Object ctx)
ManagedLedgerasyncOpenCursor in interface ManagedLedgercursorName - the name associated with the ManagedCursorinitialPosition - the cursor will be set at lastest position or not when first created
default is truecallback - callback objectctx - opaque contextManagedLedger.openCursor(String)public void asyncDeleteCursor(String consumerName, AsyncCallbacks.DeleteCursorCallback callback, Object ctx)
ManagedLedgerasyncDeleteCursor in interface ManagedLedgerconsumerName - the name associated with the ManagedCursorcallback - callback objectctx - opaque contextManagedLedger.deleteCursor(String)public void deleteCursor(String name) throws InterruptedException, ManagedLedgerException
ManagedLedgerdeleteCursor in interface ManagedLedgername - the name associated with the ManagedCursorInterruptedExceptionManagedLedgerExceptionpublic ManagedCursor newNonDurableCursor(Position startCursorPosition) throws ManagedLedgerException
ManagedLedgernewNonDurableCursor in interface ManagedLedgerstartCursorPosition - the position where the cursor should be initialized, or null to start from the current latest entry.
When starting on a particular cursor position, the first entry to be returned will be the entry next
to the specified positionManagedLedgerExceptionpublic ManagedCursor newNonDurableCursor(Position startPosition, String subscriptionName) throws ManagedLedgerException
newNonDurableCursor in interface ManagedLedgerManagedLedgerExceptionpublic ManagedCursor newNonDurableCursor(Position startCursorPosition, String cursorName, CommandSubscribe.InitialPosition initialPosition) throws ManagedLedgerException
newNonDurableCursor in interface ManagedLedgerManagedLedgerExceptionpublic ManagedCursorContainer getCursors()
ManagedLedgergetCursors in interface ManagedLedgerpublic ManagedCursorContainer getActiveCursors()
ManagedLedgergetActiveCursors in interface ManagedLedgerpublic boolean hasActiveCursors()
public long getNumberOfEntries()
ManagedLedgergetNumberOfEntries in interface ManagedLedgerpublic long getNumberOfActiveEntries()
ManagedLedgergetNumberOfActiveEntries in interface ManagedLedgerpublic long getTotalSize()
ManagedLedgergetTotalSize in interface ManagedLedgerpublic long getEstimatedBacklogSize()
ManagedLedgergetEstimatedBacklogSize in interface ManagedLedgerpublic CompletableFuture<Long> getEarliestMessagePublishTimeInBacklog()
ManagedLedgergetEarliestMessagePublishTimeInBacklog in interface ManagedLedgerpublic CompletableFuture<Long> getEarliestMessagePublishTimeOfPos(PositionImpl pos)
public long getEstimatedBacklogSize(PositionImpl pos)
public void asyncTerminate(AsyncCallbacks.TerminateCallback callback, Object ctx)
asyncTerminate in interface ManagedLedgerpublic Position terminate() throws InterruptedException, ManagedLedgerException
ManagedLedgerterminate in interface ManagedLedgerInterruptedExceptionManagedLedgerExceptionpublic boolean isTerminated()
ManagedLedgerisTerminated in interface ManagedLedgerpublic void close()
throws InterruptedException,
ManagedLedgerException
ManagedLedgerclose in interface ManagedLedgerManagedLedgerExceptionInterruptedExceptionpublic void asyncClose(AsyncCallbacks.CloseCallback callback, Object ctx)
ManagedLedgerasyncClose in interface ManagedLedgercallback - callback objectctx - opaque contextManagedLedger.close()public void createComplete(int rc,
LedgerHandle lh,
Object ctx)
createComplete in interface AsyncCallback.CreateCallbackpublic void updateLedgersIdsComplete(Stat stat)
public void rollCurrentLedgerIfFull()
ManagedLedgerrollCurrentLedgerIfFull in interface ManagedLedgerpublic CompletableFuture<Position> asyncFindPosition(com.google.common.base.Predicate<Entry> predicate)
ManagedLedgerasyncFindPosition in interface ManagedLedgerpublic ManagedLedgerInterceptor getManagedLedgerInterceptor()
ManagedLedgergetManagedLedgerInterceptor in interface ManagedLedgerpublic CompletableFuture<String> getLedgerMetadata(long ledgerId)
public CompletableFuture<MLDataFormats.ManagedLedgerInfo.LedgerInfo> getLedgerInfo(long ledgerId)
ManagedLedgergetLedgerInfo in interface ManagedLedgerpublic void asyncReadEntry(PositionImpl position, AsyncCallbacks.ReadEntryCallback callback, Object ctx)
protected void asyncReadEntry(org.apache.bookkeeper.client.api.ReadHandle ledger, PositionImpl position, AsyncCallbacks.ReadEntryCallback callback, Object ctx)
protected void asyncReadEntry(org.apache.bookkeeper.client.api.ReadHandle ledger, long firstEntry, long lastEntry, boolean isSlowestReader, org.apache.bookkeeper.mledger.impl.OpReadEntry opReadEntry, Object ctx)
public ManagedLedgerMXBean getStats()
getStats in interface ManagedLedgerpublic boolean hasMoreEntries(PositionImpl position)
public void addWaitingEntryCallBack(WaitingEntryCallBack cb)
public void maybeUpdateCursorBeforeTrimmingConsumedLedger()
public void trimConsumedLedgersInBackground(CompletableFuture<?> promise)
ManagedLedgertrimConsumedLedgersInBackground in interface ManagedLedgerpublic void trimConsumedLedgersInBackground(boolean isTruncate,
CompletableFuture<?> promise)
public void delete()
throws InterruptedException,
ManagedLedgerException
delete in interface ManagedLedgerExceptionInterruptedExceptionManagedLedgerExceptionpublic void asyncDelete(AsyncCallbacks.DeleteLedgerCallback callback, Object ctx)
ManagedLedgerasyncDelete in interface ManagedLedgerpublic Position offloadPrefix(Position pos) throws InterruptedException, ManagedLedgerException
ManagedLedgeroffloadPrefix in interface ManagedLedgerpos - the position before which entries will be offloadedInterruptedExceptionManagedLedgerException#asyncOffloadPrefix(Position,OffloadCallback,Object)public void asyncOffloadPrefix(Position pos, AsyncCallbacks.OffloadCallback callback, Object ctx)
ManagedLedgerasyncOffloadPrefix in interface ManagedLedgerpos - the position before which entries will be offloadedcallback - a callback which will be supplied with the earliest unoffloaded position on
completionctx - a context object which will be passed to the callback on completionpublic PositionImpl getPositionAfterN(PositionImpl startPosition, long n, ManagedLedgerImpl.PositionBound startRange)
startPosition - starting positionn - number of entries to skip aheadstartRange - specifies whether or not to include the start position in calculating the distancepublic PositionImpl getPreviousPosition(PositionImpl position)
position - the current positionpublic boolean isValidPosition(PositionImpl position)
position - the position to validatepublic boolean ledgerExists(long ledgerId)
public Long getNextValidLedger(long ledgerId)
public PositionImpl getNextValidPosition(PositionImpl position)
public PositionImpl getNextValidPositionInternal(PositionImpl position)
public PositionImpl getFirstPosition()
public ManagedCursor getSlowestConsumer()
ManagedLedgergetSlowestConsumer in interface ManagedLedgerpublic void activateCursor(ManagedCursor cursor)
public void deactivateCursor(ManagedCursor cursor)
public boolean isCursorActive(ManagedCursor cursor)
public List<MLDataFormats.ManagedLedgerInfo.LedgerInfo> getLedgersInfoAsList()
public NavigableMap<Long,MLDataFormats.ManagedLedgerInfo.LedgerInfo> getLedgersInfo()
public ManagedLedgerConfig getConfig()
ManagedLedgergetConfig in interface ManagedLedgerpublic void setConfig(ManagedLedgerConfig config)
ManagedLedgersetConfig in interface ManagedLedgerpublic long getEntriesAddedCounter()
public long getCurrentLedgerEntries()
public long getCurrentLedgerSize()
public long getLastLedgerCreatedTimestamp()
public long getLastLedgerCreationFailureTimestamp()
public int getWaitingCursorsCount()
public int getPendingAddEntriesCount()
public Position getLastConfirmedEntry()
ManagedLedgergetLastConfirmedEntry in interface ManagedLedgerpublic ManagedLedgerImpl.State getState()
public ManagedLedgerMBeanImpl getMBean()
public long getCacheSize()
protected boolean isReadOnly()
public static ManagedLedgerException createManagedLedgerException(int bkErrorCode)
public static ManagedLedgerException createManagedLedgerException(Throwable t)
protected void asyncCreateLedger(BookKeeper bookKeeper, ManagedLedgerConfig config, BookKeeper.DigestType digestType, AsyncCallback.CreateCallback cb, Map<String,byte[]> metadata)
bookKeeper - config - digestType - cb - metadata - public Clock getClock()
protected boolean checkAndCompleteLedgerOpTask(int rc,
LedgerHandle lh,
Object ctx)
rc - lh - ctx - public long getOffloadedSize()
ManagedLedgergetOffloadedSize in interface ManagedLedgerpublic long getLastOffloadedLedgerId()
ManagedLedgergetLastOffloadedLedgerId in interface ManagedLedgerpublic long getLastOffloadedSuccessTimestamp()
ManagedLedgergetLastOffloadedSuccessTimestamp in interface ManagedLedgerpublic long getLastOffloadedFailureTimestamp()
ManagedLedgergetLastOffloadedFailureTimestamp in interface ManagedLedgerpublic Map<String,String> getProperties()
ManagedLedgergetProperties in interface ManagedLedgerpublic void setProperty(String key, String value) throws InterruptedException, ManagedLedgerException
ManagedLedgersetProperty in interface ManagedLedgerkey - key of property to addvalue - value of property to addInterruptedExceptionManagedLedgerExceptionpublic void asyncSetProperty(String key, String value, AsyncCallbacks.UpdatePropertiesCallback callback, Object ctx)
ManagedLedgerasyncSetProperty in interface ManagedLedgerkey - key of property to addvalue - value of property to addcallback - a callback which will be supplied with the newest properties in managedLedger.ctx - a context object which will be passed to the callback on completion.public void deleteProperty(String key) throws InterruptedException, ManagedLedgerException
ManagedLedgerdeleteProperty in interface ManagedLedgerkey - key of property to deleteInterruptedExceptionManagedLedgerExceptionpublic void asyncDeleteProperty(String key, AsyncCallbacks.UpdatePropertiesCallback callback, Object ctx)
ManagedLedgerasyncDeleteProperty in interface ManagedLedgerkey - key of property to deletecallback - a callback which will be supplied with the newest properties in managedLedger.ctx - a context object which will be passed to the callback on completion.public void setProperties(Map<String,String> properties) throws InterruptedException, ManagedLedgerException
ManagedLedgersetProperties in interface ManagedLedgerproperties - key-values of propertiesInterruptedExceptionManagedLedgerExceptionpublic void asyncSetProperties(Map<String,String> properties, AsyncCallbacks.UpdatePropertiesCallback callback, Object ctx)
ManagedLedgerasyncSetProperties in interface ManagedLedgerproperties - key-values of properties.callback - a callback which will be supplied with the newest properties in managedLedger.ctx - a context object which will be passed to the callback on completion.public void setEntriesAddedCounter(long count)
public CompletableFuture<Void> asyncTruncate()
ManagedLedgerasyncTruncate in interface ManagedLedgerpublic CompletableFuture<ManagedLedgerInternalStats> getManagedLedgerInternalStats(boolean includeLedgerMetadata)
ManagedLedgergetManagedLedgerInternalStats in interface ManagedLedgerincludeLedgerMetadata - the flag to control managed ledger internal stats include ledger metadatapublic CompletableFuture<Set<org.apache.bookkeeper.net.BookieId>> getEnsemblesAsync(long ledgerId)
Copyright © 2017–2021 Apache Software Foundation. All rights reserved.