class ReadOnlyLedgerHandle extends LedgerHandle implements org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.LedgerMetadataListener
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
ReadOnlyLedgerHandle.MetadataUpdater |
LedgerHandle.LastConfirmedCtx, LedgerHandle.NoopCloseCallbackbookieFailureHistory, bookiesHealthInfo, changingEnsemble, clientCtx, delayedWriteFailedBookies, distributionSchedule, ensembleChangeCounter, explicitLacFlushPolicy, INVALID_ENTRY_ID, INVALID_LEDGER_ID, lacUpdateHitsCounter, lacUpdateMissesCounter, lastAddConfirmed, lastAddPushed, ledgerId, ledgerKey, length, macManager, numEnsembleChanges, pendingAddOps, pendingAddsSequenceHead, throttler, timeoutFuture, writeFlags| Constructor and Description |
|---|
ReadOnlyLedgerHandle(ClientContext clientCtx,
long ledgerId,
org.apache.bookkeeper.versioning.Versioned<LedgerMetadata> metadata,
BookKeeper.DigestType digestType,
byte[] password,
boolean watch) |
| Modifier and Type | Method and Description |
|---|---|
long |
addEntry(byte[] data)
Add entry synchronously to an open ledger.
|
long |
addEntry(byte[] data,
int offset,
int length)
Add entry synchronously to an open ledger.
|
void |
asyncAddEntry(byte[] data,
AsyncCallback.AddCallback cb,
java.lang.Object ctx)
Add entry asynchronously to an open ledger.
|
void |
asyncAddEntry(byte[] data,
int offset,
int length,
AsyncCallback.AddCallback cb,
java.lang.Object ctx)
Add entry asynchronously to an open ledger, using an offset and range.
|
void |
asyncClose(AsyncCallback.CloseCallback cb,
java.lang.Object ctx)
Asynchronous close, any adds in flight will return errors.
|
void |
asyncReadLastEntry(AsyncCallback.ReadCallback cb,
java.lang.Object ctx) |
void |
close()
Synchronous close the write handle, any adds in flight will return errors.
|
(package private) java.util.concurrent.CompletableFuture<org.apache.bookkeeper.versioning.Versioned<LedgerMetadata>> |
closeRecovered() |
(package private) java.util.List<org.apache.bookkeeper.net.BookieId> |
getCurrentEnsemble()
Get the current ensemble from the ensemble list.
|
(package private) void |
handleBookieFailure(java.util.Map<java.lang.Integer,org.apache.bookkeeper.net.BookieId> failedBookies)
For a read only ledger handle, this method will only ever be called during recovery,
when we are reading forward from LAC and writing back those entries.
|
(package private) void |
handleUnrecoverableErrorDuringAdd(int rc) |
protected void |
initializeWriteHandleState() |
void |
onChanged(long lid,
org.apache.bookkeeper.versioning.Versioned<LedgerMetadata> newMetadata)
Triggered each time ledger metadata changed.
|
(package private) void |
recover(org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> finalCb) |
(package private) void |
recover(org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> finalCb,
org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.ReadEntryListener listener,
boolean forceRecovery)
Recover the ledger.
|
java.lang.String |
toString() |
addEntry, addEntry, addToLength, appendAsync, asyncAddEntry, asyncAddEntry, asyncAddEntry, asyncAddEntry, asyncAddEntry, asyncCloseInternal, asyncReadEntries, asyncReadEntriesInternal, asyncReadExplicitLastConfirmed, asyncReadLastConfirmed, asyncReadLastConfirmedAndEntry, asyncReadUnconfirmedEntries, asyncRecoveryAddEntry, asyncTryReadLastConfirmed, closeAsync, doAsyncAddEntry, doAsyncCloseInternal, drainPendingAddsAndAdjustLength, ensembleChangeLoop, errorOutPendingAdds, errorOutPendingAdds, executeOrdered, force, getBookiesHealthInfo, getCtime, getCustomMetadata, getDigestManager, getDistributionSchedule, getId, getLastAddConfirmed, getLastAddPushed, getLedgerKey, getLedgerMetadata, getLength, getNumBookies, getNumFragments, getVersionedLedgerMetadata, getWriteFlags, getWriteSetForReadOperation, hasDelayedWriteFailedBookies, isClosed, isHandleWritable, maybeHandleDelayedWriteBookieFailure, notifyWriteFailed, readAsync, readEntries, readEntriesInternalAsync, readExplicitLastConfirmed, readLastAddConfirmedAndEntryAsync, readLastAddConfirmedAsync, readLastConfirmed, readLastEntry, readUnconfirmedAsync, readUnconfirmedEntries, recordReadErrorOnBookie, registerOperationFailureOnBookie, sendAddSuccessCallbacks, setLastAddConfirmed, setLedgerMetadata, tryReadLastAddConfirmedAsync, tryReadLastConfirmed, unsetSuccessAndSendWriteRequest, updateLastConfirmed, waitForWritableclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitappend, append, append, append, appendAsync, appendAsync, appendAsyncread, readLastAddConfirmed, readLastAddConfirmedAndEntry, readUnconfirmed, tryReadLastAddConfirmedReadOnlyLedgerHandle(ClientContext clientCtx, long ledgerId, org.apache.bookkeeper.versioning.Versioned<LedgerMetadata> metadata, BookKeeper.DigestType digestType, byte[] password, boolean watch) throws java.security.GeneralSecurityException, java.lang.NumberFormatException
java.security.GeneralSecurityExceptionjava.lang.NumberFormatExceptionpublic void close()
throws java.lang.InterruptedException,
BKException
LedgerHandleClosing a ledger will ensure that all clients agree on what the last entry of the ledger is. Once the ledger has been closed, all reads from the ledger will return the same set of entries.
The close operation can error if it finds conflicting metadata when it tries to write to the metadata store. On close, the metadata state is set to closed and lastEntry and length of the ledger are fixed in the metadata. A conflict occurs if the metadata in the metadata store has a different value for the lastEntry or length. If another process has updated the metadata, setting it to closed, but have fixed the lastEntry and length to the same values as this process is trying to write, the operation completes successfully.
close in interface java.lang.AutoCloseableclose in interface Handleclose in interface WriteHandleclose in class LedgerHandlejava.lang.InterruptedExceptionBKExceptionHandle.closeAsync()public void asyncClose(AsyncCallback.CloseCallback cb, java.lang.Object ctx)
LedgerHandleClosing a ledger will ensure that all clients agree on what the last entry of the ledger is. This ensures that, once the ledger has been closed, all reads from the ledger will return the same set of entries.
asyncClose in class LedgerHandlecb - callback implementationctx - control objectpublic long addEntry(byte[] data)
throws java.lang.InterruptedException,
BKException
LedgerHandleaddEntry in class LedgerHandledata - array of bytes to be written to the ledger
do not reuse the buffer, bk-client will release it appropriatelyjava.lang.InterruptedExceptionBKExceptionpublic long addEntry(byte[] data,
int offset,
int length)
throws java.lang.InterruptedException,
BKException
LedgerHandleaddEntry in class LedgerHandledata - array of bytes to be written to the ledger
do not reuse the buffer, bk-client will release it appropriatelyoffset - offset from which to take bytes from datalength - number of bytes to take from datajava.lang.InterruptedExceptionBKExceptionpublic void asyncAddEntry(byte[] data,
AsyncCallback.AddCallback cb,
java.lang.Object ctx)
LedgerHandleasyncAddEntry in class LedgerHandledata - array of bytes to be written
do not reuse the buffer, bk-client will release it appropriatelycb - object implementing callbackinterfacectx - some control objectpublic void asyncAddEntry(byte[] data,
int offset,
int length,
AsyncCallback.AddCallback cb,
java.lang.Object ctx)
LedgerHandleasyncAddEntry in class LedgerHandledata - array of bytes to be written
do not reuse the buffer, bk-client will release it appropriatelyoffset - offset from which to take bytes from datalength - number of bytes to take from datacb - object implementing callbackinterfacectx - some control objectpublic void onChanged(long lid,
org.apache.bookkeeper.versioning.Versioned<LedgerMetadata> newMetadata)
org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.LedgerMetadataListeneronChanged in interface org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.LedgerMetadataListenerlid - ledger id.newMetadata - new ledger metadata.public java.lang.String toString()
toString in class java.lang.Objectprotected void initializeWriteHandleState()
initializeWriteHandleState in class LedgerHandlepublic void asyncReadLastEntry(AsyncCallback.ReadCallback cb, java.lang.Object ctx)
asyncReadLastEntry in class LedgerHandlevoid handleBookieFailure(java.util.Map<java.lang.Integer,org.apache.bookkeeper.net.BookieId> failedBookies)
handleBookieFailure in class LedgerHandlevoid handleUnrecoverableErrorDuringAdd(int rc)
handleUnrecoverableErrorDuringAdd in class LedgerHandlevoid recover(org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> finalCb)
void recover(org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> finalCb,
org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.ReadEntryListener listener,
boolean forceRecovery)
finalCb - callback after recovery is done.listener - read entry listener on recovery reads.forceRecovery - force the recovery procedure even the ledger metadata shows the ledger is closed.java.util.concurrent.CompletableFuture<org.apache.bookkeeper.versioning.Versioned<LedgerMetadata>> closeRecovered()
java.util.List<org.apache.bookkeeper.net.BookieId> getCurrentEnsemble()
LedgerHandleThis method is also used by ReadOnlyLedgerHandle during recovery, and when tailing a ledger.
Generally, this method should only be called by LedgerHandle and not by the operations themselves, to avoid adding more dependencies between the classes. There are too many already.
getCurrentEnsemble in class LedgerHandleCopyright © 2011–2024 The Apache Software Foundation. All rights reserved.