Package org.apache.bookkeeper.client
Class LedgerHandleAdv
java.lang.Object
org.apache.bookkeeper.client.LedgerHandle
org.apache.bookkeeper.client.LedgerHandleAdv
- All Implemented Interfaces:
AutoCloseable,ForceableHandle,Handle,ReadHandle,WriteAdvHandle,WriteHandle
Ledger Advanced handle extends
LedgerHandle to provide API to add entries with
user supplied entryIds. Through this interface Ledger Length may not be accurate while the
ledger being written.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classNested classes/interfaces inherited from class org.apache.bookkeeper.client.LedgerHandle
LedgerHandle.LastConfirmedCtx, LedgerHandle.NoopCloseCallback -
Field Summary
FieldsFields inherited from class org.apache.bookkeeper.client.LedgerHandle
bookieFailureHistory, bookiesHealthInfo, changingEnsemble, clientCtx, delayedWriteFailedBookies, distributionSchedule, ensembleChangeCounter, executor, explicitLacFlushPolicy, INVALID_ENTRY_ID, INVALID_LEDGER_ID, lacUpdateHitsCounter, lacUpdateMissesCounter, lastAddConfirmed, lastAddPushed, ledgerId, ledgerKey, length, macManager, metadataLock, notSupportBatch, numEnsembleChanges, pendingAddOps, pendingAddsSequenceHead, throttler, timeoutFuture, writeFlags -
Constructor Summary
ConstructorsConstructorDescriptionLedgerHandleAdv(ClientContext clientCtx, long ledgerId, Versioned<LedgerMetadata> metadata, BookKeeper.DigestType digestType, byte[] password, EnumSet<WriteFlag> writeFlags) -
Method Summary
Modifier and TypeMethodDescriptionlongaddEntry(long entryId, byte[] data) Add entry synchronously to an open ledger.longaddEntry(long entryId, byte[] data, int offset, int length) Add entry synchronously to an open ledger.voidasyncAddEntry(byte[] data, int offset, int length, AsyncCallback.AddCallback cb, Object ctx) LedgerHandleAdv will not allow addEntry without providing an entryId.voidasyncAddEntry(long entryId, byte[] data, int offset, int length, AsyncCallback.AddCallback cb, Object ctx) Add entry asynchronously to an open ledger, using an offset and range.voidasyncAddEntry(long entryId, byte[] data, int offset, int length, AsyncCallback.AddCallbackWithLatency cb, Object ctx) Add entry asynchronously to an open ledger, using an offset and range.voidasyncAddEntry(long entryId, byte[] data, AsyncCallback.AddCallback cb, Object ctx) Add entry asynchronously to an open ledger.voidasyncAddEntry(long entryId, io.netty.buffer.ByteBuf data, AsyncCallback.AddCallbackWithLatency cb, Object ctx) Add entry asynchronously to an open ledger, using an offset and range.voidasyncAddEntry(io.netty.buffer.ByteBuf data, AsyncCallback.AddCallback cb, Object ctx) LedgerHandleAdv will not allow addEntry without providing an entryId.protected voidOverriding part is mostly around setting entryId.writeAsync(long entryId, io.netty.buffer.ByteBuf data) Add entry asynchronously to an open ledger.Methods inherited from class org.apache.bookkeeper.client.LedgerHandle
addEntry, addEntry, addToLength, appendAsync, asyncAddEntry, asyncBatchReadEntries, asyncBatchReadEntriesInternal, asyncBatchReadUnconfirmedEntries, asyncClose, asyncCloseInternal, asyncReadEntries, asyncReadEntriesInternal, asyncReadExplicitLastConfirmed, asyncReadLastConfirmed, asyncReadLastConfirmedAndEntry, asyncReadLastEntry, asyncReadUnconfirmedEntries, asyncRecoveryAddEntry, asyncTryReadLastConfirmed, batchReadAsync, batchReadEntries, batchReadUnconfirmedEntries, close, closeAsync, doAsyncCloseInternal, drainPendingAddsAndAdjustLength, ensembleChangeLoop, errorOutPendingAdds, errorOutPendingAdds, executeOrdered, force, getBookiesHealthInfo, getCtime, getCurrentEnsemble, getCustomMetadata, getDigestManager, getDistributionSchedule, getId, getLastAddConfirmed, getLastAddPushed, getLedgerKey, getLedgerMetadata, getLength, getNumBookies, getNumFragments, getPendingAddOps, getVersionedLedgerMetadata, getWriteFlags, getWriteSetForReadOperation, handleBookieFailure, handleUnrecoverableErrorDuringAdd, hasDelayedWriteFailedBookies, initializeWriteHandleState, isClosed, isHandleWritable, maybeHandleDelayedWriteBookieFailure, notifyWriteFailed, readAsync, readEntries, readEntriesInternalAsync, readExplicitLastConfirmed, readLastAddConfirmedAndEntryAsync, readLastAddConfirmedAsync, readLastConfirmed, readLastEntry, readUnconfirmedAsync, readUnconfirmedEntries, recordReadErrorOnBookie, registerOperationFailureOnBookie, sendAddSuccessCallbacks, setLastAddConfirmed, setLedgerMetadata, tryReadLastAddConfirmedAsync, tryReadLastConfirmed, unsetSuccessAndSendWriteRequest, updateLastConfirmed, waitForWritableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.bookkeeper.client.api.ForceableHandle
forceMethods inherited from interface org.apache.bookkeeper.client.api.Handle
getId, getLedgerMetadataMethods inherited from interface org.apache.bookkeeper.client.api.ReadHandle
batchRead, batchReadAsync, getLastAddConfirmed, getLength, isClosed, read, readAsync, readLastAddConfirmed, readLastAddConfirmedAndEntry, readLastAddConfirmedAndEntryAsync, readLastAddConfirmedAsync, readUnconfirmed, readUnconfirmedAsync, tryReadLastAddConfirmed, tryReadLastAddConfirmedAsyncMethods inherited from interface org.apache.bookkeeper.client.api.WriteAdvHandle
write, write, write, write, writeAsync, writeAsync, writeAsyncMethods inherited from interface org.apache.bookkeeper.client.api.WriteHandle
append, append, append, append, appendAsync, appendAsync, appendAsync
-
Field Details
-
LOG
static final org.slf4j.Logger LOG
-
-
Constructor Details
-
LedgerHandleAdv
LedgerHandleAdv(ClientContext clientCtx, long ledgerId, Versioned<LedgerMetadata> metadata, BookKeeper.DigestType digestType, byte[] password, EnumSet<WriteFlag> writeFlags) throws GeneralSecurityException, NumberFormatException
-
-
Method Details
-
addEntry
Add entry synchronously to an open ledger.- Overrides:
addEntryin classLedgerHandle- Parameters:
entryId- entryId of the entry to adddata- array of bytes to be written to the ledger do not reuse the buffer, bk-client will release it appropriately- Returns:
- entryId that is just created.
- Throws:
InterruptedExceptionBKException
-
addEntry
public long addEntry(long entryId, byte[] data, int offset, int length) throws InterruptedException, BKException Add entry synchronously to an open ledger.- Overrides:
addEntryin classLedgerHandle- Parameters:
entryId- entryId of the entry to adddata- 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 data- Returns:
- The entryId of newly inserted entry.
- Throws:
InterruptedExceptionBKException
-
asyncAddEntry
Add entry asynchronously to an open ledger.- Overrides:
asyncAddEntryin classLedgerHandle- Parameters:
entryId- entryId of the entry to adddata- array of bytes to be written do not reuse the buffer, bk-client will release it appropriatelycb- object implementing callbackinterfacectx- some control object
-
asyncAddEntry
public void asyncAddEntry(long entryId, byte[] data, int offset, int length, AsyncCallback.AddCallback cb, Object ctx) Add entry asynchronously to an open ledger, using an offset and range.- Overrides:
asyncAddEntryin classLedgerHandle- Parameters:
entryId- entryId of the entry to adddata- 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 object- Throws:
ArrayIndexOutOfBoundsException- if offset or length is negative or offset and length sum to a value higher than the length of data.
-
asyncAddEntry
public void asyncAddEntry(long entryId, byte[] data, int offset, int length, AsyncCallback.AddCallbackWithLatency cb, Object ctx) Add entry asynchronously to an open ledger, using an offset and range.- Overrides:
asyncAddEntryin classLedgerHandle- Parameters:
entryId- entryId of the entry to adddata- 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 object- Throws:
ArrayIndexOutOfBoundsException- if offset or length is negative or offset and length sum to a value higher than the length of data.
-
asyncAddEntry
public void asyncAddEntry(long entryId, io.netty.buffer.ByteBuf data, AsyncCallback.AddCallbackWithLatency cb, Object ctx) Add entry asynchronously to an open ledger, using an offset and range. This can be used only withLedgerHandleAdvreturned through ledgers created withBookKeeper.createLedgerAdv(int, int, int, BookKeeper.DigestType, byte[]).- Overrides:
asyncAddEntryin classLedgerHandle- Parameters:
entryId- entryId of the entry to add.data- io.netty.buffer.ByteBuf of bytes to be written do not reuse the buffer, bk-client will release it appropriatelycb- object implementing callbackinterfacectx- some control object
-
doAsyncAddEntry
Overriding part is mostly around setting entryId. Though there may be some code duplication, Choose to have the override routine so the control flow is unaltered in the base class.- Overrides:
doAsyncAddEntryin classLedgerHandle
-
writeAsync
Description copied from interface:WriteAdvHandleAdd entry asynchronously to an open ledger.- Specified by:
writeAsyncin interfaceWriteAdvHandle- Parameters:
entryId- entryId to be addeddata- array of bytes to be written do not reuse the buffer, bk-client will release it appropriately.- Returns:
- an handle to the result, in case of success it will return the same value of param entryId
-
asyncAddEntry
LedgerHandleAdv will not allow addEntry without providing an entryId.- Overrides:
asyncAddEntryin classLedgerHandle
-
asyncAddEntry
public void asyncAddEntry(byte[] data, int offset, int length, AsyncCallback.AddCallback cb, Object ctx) LedgerHandleAdv will not allow addEntry without providing an entryId.- Overrides:
asyncAddEntryin classLedgerHandle- Parameters:
data- 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 object
-