@InterfaceAudience.Public @InterfaceStability.Unstable public interface WriteHandle extends ReadHandle, ForceableHandle
WriteAdvHandle
Modifier and Type | Method and Description |
---|---|
default long |
append(byte[] data)
Add an entry synchronously to an open ledger.
|
default long |
append(byte[] data,
int offset,
int length)
Add an entry synchronously to an open ledger.
|
default long |
append(io.netty.buffer.ByteBuf data)
Add entry synchronously to an open ledger.
|
default long |
append(java.nio.ByteBuffer data)
Add entry synchronously to an open ledger.
|
default java.util.concurrent.CompletableFuture<java.lang.Long> |
appendAsync(byte[] data)
Add an entry asynchronously to an open ledger.
|
default java.util.concurrent.CompletableFuture<java.lang.Long> |
appendAsync(byte[] data,
int offset,
int length)
Add an entry asynchronously to an open ledger.
|
java.util.concurrent.CompletableFuture<java.lang.Long> |
appendAsync(io.netty.buffer.ByteBuf data)
Add entry asynchronously to an open ledger.
|
default java.util.concurrent.CompletableFuture<java.lang.Long> |
appendAsync(java.nio.ByteBuffer data)
Add entry asynchronously to an open ledger.
|
default void |
close()
Synchronous close the write handle, any adds in flight will return errors.
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
closeAsync()
Asynchronous close the write handle, any adds in flight will return errors.
|
long |
getLastAddPushed()
Get the entry id of the last entry that has been enqueued for addition (but
may not have possibly been persisted to the ledger).
|
getLastAddConfirmed, getLength, isClosed, read, readAsync, readLastAddConfirmed, readLastAddConfirmedAndEntry, readLastAddConfirmedAndEntryAsync, readLastAddConfirmedAsync, readUnconfirmed, readUnconfirmedAsync, tryReadLastAddConfirmed, tryReadLastAddConfirmedAsync
getId, getLedgerMetadata
force
java.util.concurrent.CompletableFuture<java.lang.Long> appendAsync(io.netty.buffer.ByteBuf data)
data
- a bytebuf to be written. The bytebuf's reference count will be decremented by 1 after the
completable future is returned
do not reuse the buffer, bk-client will release it appropriately.default long append(io.netty.buffer.ByteBuf data) throws BKException, java.lang.InterruptedException
data
- a bytebuf to be written. The bytebuf's reference count will be decremented by 1 after the
call completes.
do not reuse the buffer, bk-client will release it appropriately.BKException
java.lang.InterruptedException
default java.util.concurrent.CompletableFuture<java.lang.Long> appendAsync(java.nio.ByteBuffer data)
data
- array of bytes to be written
do not reuse the buffer, bk-client will release it appropriately.default long append(java.nio.ByteBuffer data) throws BKException, java.lang.InterruptedException
data
- array of bytes to be written
do not reuse the buffer, bk-client will release it appropriately.BKException
java.lang.InterruptedException
default java.util.concurrent.CompletableFuture<java.lang.Long> appendAsync(byte[] data)
data
- array of bytes to be written
do not reuse the buffer, bk-client will release it appropriately.default long append(byte[] data) throws BKException, java.lang.InterruptedException
data
- array of bytes to be written
do not reuse the buffer, bk-client will release it appropriately.BKException
java.lang.InterruptedException
default java.util.concurrent.CompletableFuture<java.lang.Long> appendAsync(byte[] data, int offset, int length)
data
- array of bytes to be written
do not reuse the buffer, bk-client will release it appropriately.offset
- the offset in the bytes arraylength
- the length of the bytes to be appendeddefault long append(byte[] data, int offset, int length) throws BKException, java.lang.InterruptedException
data
- array of bytes to be written
do not reuse the buffer, bk-client will release it appropriately.offset
- the offset in the bytes arraylength
- the length of the bytes to be appendedBKException
java.lang.InterruptedException
long getLastAddPushed()
java.util.concurrent.CompletableFuture<java.lang.Void> closeAsync()
Closing 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.
closeAsync
in interface Handle
default void close() throws BKException, java.lang.InterruptedException
Closing 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.AutoCloseable
close
in interface Handle
BKException
java.lang.InterruptedException
Handle.closeAsync()
Copyright © 2011–2020 The Apache Software Foundation. All rights reserved.