public class BookKeeper extends Object
BKException.| Modifier and Type | Class and Description |
|---|---|
static class |
BookKeeper.DigestType
There are 2 digest types that can be used for verification.
|
| Constructor and Description |
|---|
BookKeeper(ClientConfiguration conf)
Create a bookkeeper client using a configuration object.
|
BookKeeper(ClientConfiguration conf,
org.apache.zookeeper.ZooKeeper zk)
Create a bookkeeper client but use the passed in zookeeper client instead
of instantiating one.
|
BookKeeper(ClientConfiguration conf,
org.apache.zookeeper.ZooKeeper zk,
org.jboss.netty.channel.socket.ClientSocketChannelFactory channelFactory)
Create a bookkeeper client but use the passed in zookeeper client and
client socket channel factory instead of instantiating those.
|
BookKeeper(String servers)
Create a bookkeeper client.
|
| Modifier and Type | Method and Description |
|---|---|
void |
asyncCreateLedger(int ensSize,
int writeQuorumSize,
BookKeeper.DigestType digestType,
byte[] passwd,
AsyncCallback.CreateCallback cb,
Object ctx)
Creates a new ledger asynchronously.
|
void |
asyncCreateLedger(int ensSize,
int writeQuorumSize,
int ackQuorumSize,
BookKeeper.DigestType digestType,
byte[] passwd,
AsyncCallback.CreateCallback cb,
Object ctx)
Creates a new ledger asynchronously.
|
void |
asyncDeleteLedger(long lId,
AsyncCallback.DeleteCallback cb,
Object ctx)
Deletes a ledger asynchronously.
|
void |
asyncOpenLedger(long lId,
BookKeeper.DigestType digestType,
byte[] passwd,
AsyncCallback.OpenCallback cb,
Object ctx)
Open existing ledger asynchronously for reading.
|
void |
asyncOpenLedgerNoRecovery(long lId,
BookKeeper.DigestType digestType,
byte[] passwd,
AsyncCallback.OpenCallback cb,
Object ctx)
Open existing ledger asynchronously for reading, but it does not try to
recover the ledger if it is not yet closed.
|
void |
close()
Shuts down client.
|
LedgerHandle |
createLedger(BookKeeper.DigestType digestType,
byte[] passwd)
Creates a new ledger.
|
LedgerHandle |
createLedger(int ensSize,
int qSize,
BookKeeper.DigestType digestType,
byte[] passwd)
Synchronous call to create ledger.
|
LedgerHandle |
createLedger(int ensSize,
int writeQuorumSize,
int ackQuorumSize,
BookKeeper.DigestType digestType,
byte[] passwd)
Synchronous call to create ledger.
|
void |
deleteLedger(long lId)
Synchronous call to delete a ledger.
|
protected ClientConfiguration |
getConf() |
LedgerHandle |
openLedger(long lId,
BookKeeper.DigestType digestType,
byte[] passwd)
Synchronous open ledger call
|
LedgerHandle |
openLedgerNoRecovery(long lId,
BookKeeper.DigestType digestType,
byte[] passwd)
Synchronous, unsafe open ledger call
|
public BookKeeper(String servers) throws IOException, InterruptedException, org.apache.zookeeper.KeeperException
servers - A list of one of more servers on which zookeeper is running. The
client assumes that the running bookies have been registered with
zookeeper under the path
BookieWatcher.bookieRegistrationPathIOExceptionInterruptedExceptionorg.apache.zookeeper.KeeperExceptionpublic BookKeeper(ClientConfiguration conf) throws IOException, InterruptedException, org.apache.zookeeper.KeeperException
conf - Client Configuration objectIOExceptionInterruptedExceptionorg.apache.zookeeper.KeeperExceptionpublic BookKeeper(ClientConfiguration conf, org.apache.zookeeper.ZooKeeper zk) throws IOException, InterruptedException, org.apache.zookeeper.KeeperException
conf - Client Configuration object
ClientConfigurationzk - Zookeeper client instance connected to the zookeeper with which
the bookies have registeredIOExceptionInterruptedExceptionorg.apache.zookeeper.KeeperExceptionpublic BookKeeper(ClientConfiguration conf, org.apache.zookeeper.ZooKeeper zk, org.jboss.netty.channel.socket.ClientSocketChannelFactory channelFactory) throws IOException, InterruptedException, org.apache.zookeeper.KeeperException
conf - Client Configuration Object
ClientConfigurationzk - Zookeeper client instance connected to the zookeeper with which
the bookies have registered. The ZooKeeper client must be connected
before it is passed to BookKeeper. Otherwise a KeeperException is thrown.channelFactory - A factory that will be used to create connections to the bookiesIOExceptionInterruptedExceptionorg.apache.zookeeper.KeeperException - if the passed zk handle is not connectedprotected ClientConfiguration getConf()
public void asyncCreateLedger(int ensSize,
int writeQuorumSize,
BookKeeper.DigestType digestType,
byte[] passwd,
AsyncCallback.CreateCallback cb,
Object ctx)
ensSize - number of bookies over which to stripe entrieswriteQuorumSize - number of bookies each entry will be written to. each of these bookies
must acknowledge the entry before the call is completed.digestType - digest type, either MAC or CRC32passwd - passwordcb - createCallback implementationctx - optional control objectpublic void asyncCreateLedger(int ensSize,
int writeQuorumSize,
int ackQuorumSize,
BookKeeper.DigestType digestType,
byte[] passwd,
AsyncCallback.CreateCallback cb,
Object ctx)
ClientConfiguration.getReadTimeout(). Once the bookie failure is detected,
that bookie will be removed from the ensemble.
The other parameters match those of asyncCreateLedger(int, int, DigestType, byte[],
AsyncCallback.CreateCallback, Object)ensSize - number of bookies over which to stripe entrieswriteQuorumSize - number of bookies each entry will be written toackQuorumSize - number of bookies which must acknowledge an entry before the call is completeddigestType - digest type, either MAC or CRC32passwd - passwordcb - createCallback implementationctx - optional control objectpublic LedgerHandle createLedger(BookKeeper.DigestType digestType, byte[] passwd) throws BKException, InterruptedException
digestType - digest type, either MAC or CRC32passwd - passwordInterruptedExceptionBKExceptionpublic LedgerHandle createLedger(int ensSize, int qSize, BookKeeper.DigestType digestType, byte[] passwd) throws InterruptedException, BKException
asyncCreateLedger(int, int, DigestType, byte[],
AsyncCallback.CreateCallback, Object)ensSize - qSize - digestType - passwd - InterruptedExceptionBKExceptionpublic LedgerHandle createLedger(int ensSize, int writeQuorumSize, int ackQuorumSize, BookKeeper.DigestType digestType, byte[] passwd) throws InterruptedException, BKException
asyncCreateLedger(int, int, int, DigestType, byte[],
AsyncCallback.CreateCallback, Object)ensSize - writeQuorumSize - ackQuorumSize - digestType - passwd - InterruptedExceptionBKExceptionpublic void asyncOpenLedger(long lId,
BookKeeper.DigestType digestType,
byte[] passwd,
AsyncCallback.OpenCallback cb,
Object ctx)
lId - ledger identifierdigestType - digest type, either MAC or CRC32passwd - passwordctx - optional control objectLedgerHandle.asyncClose(org.apache.bookkeeper.client.AsyncCallback.CloseCallback, java.lang.Object)public void asyncOpenLedgerNoRecovery(long lId,
BookKeeper.DigestType digestType,
byte[] passwd,
AsyncCallback.OpenCallback cb,
Object ctx)
lId - ledger identifierdigestType - digest type, either MAC or CRC32passwd - passwordctx - optional control objectpublic LedgerHandle openLedger(long lId, BookKeeper.DigestType digestType, byte[] passwd) throws BKException, InterruptedException
lId - ledger identifierdigestType - digest type, either MAC or CRC32passwd - passwordInterruptedExceptionBKExceptionasyncOpenLedger(long, org.apache.bookkeeper.client.BookKeeper.DigestType, byte[], org.apache.bookkeeper.client.AsyncCallback.OpenCallback, java.lang.Object)public LedgerHandle openLedgerNoRecovery(long lId, BookKeeper.DigestType digestType, byte[] passwd) throws BKException, InterruptedException
lId - ledger identifierdigestType - digest type, either MAC or CRC32passwd - passwordInterruptedExceptionBKExceptionasyncOpenLedgerNoRecovery(long, org.apache.bookkeeper.client.BookKeeper.DigestType, byte[], org.apache.bookkeeper.client.AsyncCallback.OpenCallback, java.lang.Object)public void asyncDeleteLedger(long lId,
AsyncCallback.DeleteCallback cb,
Object ctx)
lId - ledger Idcb - deleteCallback implementationctx - optional control objectpublic void deleteLedger(long lId)
throws InterruptedException,
BKException
asyncDeleteLedger(long, AsyncCallback.DeleteCallback, Object)lId - ledgerIdInterruptedExceptionBKException.BKNoSuchLedgerExistsException - if the ledger doesn't existBKExceptionpublic void close()
throws InterruptedException,
BKException
InterruptedExceptionBKExceptionCopyright © 2014 The Apache Software Foundation. All Rights Reserved.