public class LedgerHandle extends Object
Modifier and Type | Field and Description |
---|---|
static long |
INVALID_ENTRY_ID
Invalid entry id.
|
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,
Object ctx)
Add entry asynchronously to an open ledger.
|
void |
asyncAddEntry(byte[] data,
int offset,
int length,
AsyncCallback.AddCallback cb,
Object ctx)
Add entry asynchronously to an open ledger, using an offset and range.
|
void |
asyncClose(AsyncCallback.CloseCallback cb,
Object ctx)
Asynchronous close, any adds in flight will return errors.
|
void |
asyncReadEntries(long firstEntry,
long lastEntry,
AsyncCallback.ReadCallback cb,
Object ctx)
Read a sequence of entries asynchronously.
|
void |
asyncReadLastConfirmed(AsyncCallback.ReadLastConfirmedCallback cb,
Object ctx)
Obtains asynchronously the last confirmed write from a quorum of bookies.
|
void |
asyncTryReadLastConfirmed(AsyncCallback.ReadLastConfirmedCallback cb,
Object ctx)
Obtains asynchronously the last confirmed write from a quorum of bookies.
|
void |
close()
Close this ledger synchronously.
|
long |
getId()
Get the id of the current ledger
|
long |
getLastAddConfirmed()
Get the last confirmed entry id on this ledger.
|
long |
getLastAddPushed()
Get the entry id of the last entry that has been enqueued for addition (but
may not have possibly been persited to the ledger)
|
byte[] |
getLedgerKey()
Get the Ledger's key/password.
|
long |
getLength()
Returns the length of the ledger in bytes.
|
boolean |
isClosed()
Has the ledger been closed?
|
Enumeration<LedgerEntry> |
readEntries(long firstEntry,
long lastEntry)
Read a sequence of entries synchronously.
|
long |
readLastConfirmed()
Obtains synchronously the last confirmed write from a quorum of bookies.
|
long |
tryReadLastConfirmed()
Obtains synchronously the last confirmed write from a quorum of bookies.
|
public static final long INVALID_ENTRY_ID
public long getId()
public long getLastAddConfirmed()
INVALID_ENTRY_ID
if no entry has been confirmedreadLastConfirmed()
public long getLastAddPushed()
INVALID_ENTRY_ID
if no entry has been pushedpublic byte[] getLedgerKey()
public long getLength()
public void close() throws InterruptedException, BKException
public void asyncClose(AsyncCallback.CloseCallback cb, Object ctx)
cb
- callback implementationctx
- control objectpublic boolean isClosed()
public Enumeration<LedgerEntry> readEntries(long firstEntry, long lastEntry) throws InterruptedException, BKException
firstEntry
- id of first entry of sequence (included)lastEntry
- id of last entry of sequence (included)InterruptedException
BKException
public void asyncReadEntries(long firstEntry, long lastEntry, AsyncCallback.ReadCallback cb, Object ctx)
firstEntry
- id of first entry of sequencelastEntry
- id of last entry of sequencecb
- object implementing read callback interfacectx
- control objectpublic long addEntry(byte[] data) throws InterruptedException, BKException
data
- array of bytes to be written to the ledgerInterruptedException
BKException
public long addEntry(byte[] data, int offset, int length) throws InterruptedException, BKException
data
- array of bytes to be written to the ledgeroffset
- offset from which to take bytes from datalength
- number of bytes to take from dataInterruptedException
BKException
public void asyncAddEntry(byte[] data, AsyncCallback.AddCallback cb, Object ctx)
data
- array of bytes to be writtencb
- object implementing callbackinterfacectx
- some control objectpublic void asyncAddEntry(byte[] data, int offset, int length, AsyncCallback.AddCallback cb, Object ctx)
data
- array of bytes to be writtenoffset
- offset from which to take bytes from datalength
- number of bytes to take from datacb
- object implementing callbackinterfacectx
- some control objectArrayIndexOutOfBoundsException
- if offset or length is negative or
offset and length sum to a value higher than the length of data.public void asyncReadLastConfirmed(AsyncCallback.ReadLastConfirmedCallback cb, Object ctx)
cb
- ctx
- getLastAddConfirmed()
public void asyncTryReadLastConfirmed(AsyncCallback.ReadLastConfirmedCallback cb, Object ctx)
asyncTryReadLastConfirmed(org.apache.bookkeeper.client.AsyncCallback.ReadLastConfirmedCallback, Object)
,
but it doesn't wait all the responses from the quorum. It would callback
immediately if it received a LAC which is larger than current LAC.cb
- callback to return read last confirmedctx
- callback contextasyncTryReadLastConfirmed(org.apache.bookkeeper.client.AsyncCallback.ReadLastConfirmedCallback, Object)
public long readLastConfirmed() throws InterruptedException, BKException
INVALID_ENTRY_ID
if no entry has been confirmedInterruptedException
BKException
getLastAddConfirmed()
public long tryReadLastConfirmed() throws InterruptedException, BKException
readLastConfirmed()
, but it doesn't wait all the responses
from the quorum. It would callback immediately if it received a LAC which is larger
than current LAC.INVALID_ENTRY_ID
if no entry has been confirmedInterruptedException
BKException
readLastConfirmed()
Copyright © 2011-2014 The Apache Software Foundation. All Rights Reserved.