Package org.apache.bookkeeper.proto
Interface BookieClient
-
- All Known Implementing Classes:
BookieClientImpl
public interface BookieClient
Low level client for talking to bookies.
-
-
Field Summary
Fields Modifier and Type Field Description static long
PENDINGREQ_NOTWRITABLE_MASK
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addEntry(BookieId address, long ledgerId, byte[] masterKey, long entryId, io.netty.util.ReferenceCounted toSend, BookkeeperInternalCallbacks.WriteCallback cb, java.lang.Object ctx, int options, boolean allowFastFail, java.util.EnumSet<WriteFlag> writeFlags)
Add an entry for ledgerledgerId
on the bookie at addressaddress
.default void
batchReadEntries(BookieId address, long ledgerId, long startEntryId, int maxCount, long maxSize, BookkeeperInternalCallbacks.BatchedReadEntryCallback cb, java.lang.Object ctx, int flags)
Batch read entries with a null masterkey, disallowing failfast.default void
batchReadEntries(BookieId address, long ledgerId, long startEntryId, int maxCount, long maxSize, BookkeeperInternalCallbacks.BatchedReadEntryCallback cb, java.lang.Object ctx, int flags, byte[] masterKey)
Batch read entries, disallowing failfast.void
batchReadEntries(BookieId address, long ledgerId, long startEntryId, int maxCount, long maxSize, BookkeeperInternalCallbacks.BatchedReadEntryCallback cb, java.lang.Object ctx, int flags, byte[] masterKey, boolean allowFastFail)
Batch read entries from bookie at addressaddress
.void
close()
Close the bookie client object.void
forceLedger(BookieId address, long ledgerId, BookkeeperInternalCallbacks.ForceLedgerCallback cb, java.lang.Object ctx)
Send a force request to the server.void
getBookieInfo(BookieId address, long requested, BookkeeperInternalCallbacks.GetBookieInfoCallback cb, java.lang.Object ctx)
Read information about the bookie, from the bookie.java.util.List<BookieId>
getFaultyBookies()
Get the list of bookies which have exhibited more error responses than a configured threshold.java.util.concurrent.CompletableFuture<AvailabilityOfEntriesOfLedger>
getListOfEntriesOfLedger(BookieId address, long ledgerId)
Makes async request for getting list of entries of ledger from a bookie and returns Future for the result.long
getNumPendingRequests(BookieId address, long ledgerId)
Get the number of outstanding requests on the channel used to connect to a bookie ataddress
for a ledger withledgerId
.boolean
isClosed()
boolean
isWritable(BookieId address, long ledgerId)
Check whether the channel used to write to a bookie channel is writable.default void
readEntry(BookieId address, long ledgerId, long entryId, BookkeeperInternalCallbacks.ReadEntryCallback cb, java.lang.Object ctx, int flags)
Read entry with a null masterkey, disallowing failfast.default void
readEntry(BookieId address, long ledgerId, long entryId, BookkeeperInternalCallbacks.ReadEntryCallback cb, java.lang.Object ctx, int flags, byte[] masterKey)
Read entry, disallowing failfast.void
readEntry(BookieId address, long ledgerId, long entryId, BookkeeperInternalCallbacks.ReadEntryCallback cb, java.lang.Object ctx, int flags, byte[] masterKey, boolean allowFastFail)
Read an entry from bookie at addressaddress
.void
readEntryWaitForLACUpdate(BookieId address, long ledgerId, long entryId, long previousLAC, long timeOutInMillis, boolean piggyBackEntry, BookkeeperInternalCallbacks.ReadEntryCallback cb, java.lang.Object ctx)
Send a long poll request to bookie, waiting for the last add confirmed to be updated.void
readLac(BookieId address, long ledgerId, BookkeeperInternalCallbacks.ReadLacCallback cb, java.lang.Object ctx)
Read the last add confirmed for ledgerledgerId
from the bookie ataddress
.void
writeLac(BookieId address, long ledgerId, byte[] masterKey, long lac, ByteBufList toSend, BookkeeperInternalCallbacks.WriteLacCallback cb, java.lang.Object ctx)
Explicitly write the last add confirmed for ledgerledgerId
to the bookie ataddress
.
-
-
-
Field Detail
-
PENDINGREQ_NOTWRITABLE_MASK
static final long PENDINGREQ_NOTWRITABLE_MASK
- See Also:
- Constant Field Values
-
-
Method Detail
-
getFaultyBookies
java.util.List<BookieId> getFaultyBookies()
Get the list of bookies which have exhibited more error responses than a configured threshold.- Returns:
- the list of faulty bookies
-
isWritable
boolean isWritable(BookieId address, long ledgerId)
Check whether the channel used to write to a bookie channel is writable. A channel becomes non-writable when its buffer become full, and will stay non-writable until some of the buffer is cleared.This can be used to apply backpressure. If a channel is not writable, requests will end up queuing.
As as we use pooling, there may be multiple channels per bookie, so we also pass the ledger ID to check the writability of the correct channel.
This has nothing to do with the bookie read-only status.
- Parameters:
address
- the address of the bookieledgerId
- the ledger we wish to send a request to
-
getNumPendingRequests
long getNumPendingRequests(BookieId address, long ledgerId)
Get the number of outstanding requests on the channel used to connect to a bookie ataddress
for a ledger withledgerId
. It is necessary to specify the ledgerId as there may be multiple channels for a single bookie if pooling is in use. If the bookie is notwritable
, then thePENDINGREQ_NOTWRITABLE_MASK
will be logically or'd with the returned value.- Parameters:
address
- the address of the bookieledgerId
- the ledger whose channel we wish to query- Returns:
- the number of requests currently outstanding
-
forceLedger
void forceLedger(BookieId address, long ledgerId, BookkeeperInternalCallbacks.ForceLedgerCallback cb, java.lang.Object ctx)
Send a force request to the server. When complete all entries which have been written forledgerId
to this bookie will be persisted on disk. This is for use withWriteFlag.DEFERRED_SYNC
.- Parameters:
address
- the address of the bookieledgerId
- the ledger whose entries we want persistedcb
- the callback notified when the request completesctx
- a context object passed to the callback on completion
-
readLac
void readLac(BookieId address, long ledgerId, BookkeeperInternalCallbacks.ReadLacCallback cb, java.lang.Object ctx)
Read the last add confirmed for ledgerledgerId
from the bookie ataddress
.- Parameters:
address
- the address of the bookieledgerId
- the ledger whose last add confirm we wish to knowcb
- the callback notified when the request completesctx
- a context object passed to the callback on completion
-
writeLac
void writeLac(BookieId address, long ledgerId, byte[] masterKey, long lac, ByteBufList toSend, BookkeeperInternalCallbacks.WriteLacCallback cb, java.lang.Object ctx)
Explicitly write the last add confirmed for ledgerledgerId
to the bookie ataddress
.- Parameters:
address
- the address of the bookieledgerId
- the ledger whose last add confirm we wish to knowmasterKey
- the master key of the ledgerlac
- the last add confirmed we wish to writetoSend
- a buffer also containing the lac, along with a digestcb
- the callback notified when the request completesctx
- a context object passed to the callback on completion
-
addEntry
void addEntry(BookieId address, long ledgerId, byte[] masterKey, long entryId, io.netty.util.ReferenceCounted toSend, BookkeeperInternalCallbacks.WriteCallback cb, java.lang.Object ctx, int options, boolean allowFastFail, java.util.EnumSet<WriteFlag> writeFlags)
Add an entry for ledgerledgerId
on the bookie at addressaddress
.- Parameters:
address
- the address of the bookieledgerId
- the ledger to which we wish to add the entryentryId
- the id of the entry we wish to addtoSend
- a buffer containing the entry and its digestcb
- the callback notified when the request completesctx
- a context object passed to the callback on completionoptions
- a bit mask of flags from BookieProtocol.FLAG_*BookieProtocol
allowFastFail
- fail the add immediately if the channel is non-writableisWritable(BookieId,long)
writeFlags
- a set of write flagsWriteFlag
-
readEntry
default void readEntry(BookieId address, long ledgerId, long entryId, BookkeeperInternalCallbacks.ReadEntryCallback cb, java.lang.Object ctx, int flags)
Read entry with a null masterkey, disallowing failfast.
-
readEntry
default void readEntry(BookieId address, long ledgerId, long entryId, BookkeeperInternalCallbacks.ReadEntryCallback cb, java.lang.Object ctx, int flags, byte[] masterKey)
Read entry, disallowing failfast.
-
readEntry
void readEntry(BookieId address, long ledgerId, long entryId, BookkeeperInternalCallbacks.ReadEntryCallback cb, java.lang.Object ctx, int flags, byte[] masterKey, boolean allowFastFail)
Read an entry from bookie at addressaddress
.- Parameters:
address
- address of the bookie to read fromledgerId
- id of the ledger the entry belongs toentryId
- id of the entry we wish to readcb
- the callback notified when the request completesctx
- a context object passed to the callback on completionflags
- a bit mask of flags from BookieProtocol.FLAG_*BookieProtocol
masterKey
- the master key of the ledger being read from. This is only required if the FLAG_DO_FENCING is specified.allowFastFail
- fail the read immediately if the channel is non-writableisWritable(BookieId,long)
-
batchReadEntries
default void batchReadEntries(BookieId address, long ledgerId, long startEntryId, int maxCount, long maxSize, BookkeeperInternalCallbacks.BatchedReadEntryCallback cb, java.lang.Object ctx, int flags)
Batch read entries with a null masterkey, disallowing failfast.
-
batchReadEntries
default void batchReadEntries(BookieId address, long ledgerId, long startEntryId, int maxCount, long maxSize, BookkeeperInternalCallbacks.BatchedReadEntryCallback cb, java.lang.Object ctx, int flags, byte[] masterKey)
Batch read entries, disallowing failfast.
-
batchReadEntries
void batchReadEntries(BookieId address, long ledgerId, long startEntryId, int maxCount, long maxSize, BookkeeperInternalCallbacks.BatchedReadEntryCallback cb, java.lang.Object ctx, int flags, byte[] masterKey, boolean allowFastFail)
Batch read entries from bookie at addressaddress
.- Parameters:
address
- address of the bookie to read fromledgerId
- id of the ledger the entry belongs tostartEntryId
- id of the entry startedmaxCount
- the total entries count in this batchmaxSize
- the total entries size in this batchcb
- the callback notified when the request completesctx
- a context object passed to the callback on completionflags
- a bit mask of flags from BookieProtocol.FLAG_*BookieProtocol
masterKey
- the master key of the ledger being read from. This is only required if the FLAG_DO_FENCING is specified.allowFastFail
- fail the read immediately if the channel is non-writableisWritable(BookieId,long)
-
readEntryWaitForLACUpdate
void readEntryWaitForLACUpdate(BookieId address, long ledgerId, long entryId, long previousLAC, long timeOutInMillis, boolean piggyBackEntry, BookkeeperInternalCallbacks.ReadEntryCallback cb, java.lang.Object ctx)
Send a long poll request to bookie, waiting for the last add confirmed to be updated. The client can also request that the full entry is returned with the new last add confirmed.- Parameters:
address
- address of bookie to send the long poll address toledgerId
- ledger whose last add confirmed we are interested inentryId
- the id of the entry we expect to readpreviousLAC
- the previous lac valuetimeOutInMillis
- number of millis to wait for LAC updatepiggyBackEntry
- whether to read the requested entry when LAC is updatedcb
- the callback notified when the request completesctx
- a context object passed to the callback on completion
-
getBookieInfo
void getBookieInfo(BookieId address, long requested, BookkeeperInternalCallbacks.GetBookieInfoCallback cb, java.lang.Object ctx)
Read information about the bookie, from the bookie.- Parameters:
address
- the address of the bookie to request information fromrequested
- a bitset specifying which pieces of information to requestBookkeeperProtocol.GetBookieInfoRequest
cb
- the callback notified when the request completesctx
- a context object passed to the callback on completion- See Also:
BookieInfoReader.BookieInfo
-
getListOfEntriesOfLedger
java.util.concurrent.CompletableFuture<AvailabilityOfEntriesOfLedger> getListOfEntriesOfLedger(BookieId address, long ledgerId)
Makes async request for getting list of entries of ledger from a bookie and returns Future for the result.- Parameters:
address
- BookieId of the bookieledgerId
- ledgerId- Returns:
- returns Future
-
isClosed
boolean isClosed()
- Returns:
- whether bookie client object has been closed
-
close
void close()
Close the bookie client object.
-
-