public class BookKeeper extends Object
BKException
.Modifier and Type | Class and Description |
---|---|
static class |
BookKeeper.Builder |
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 |
asyncIsClosed(long lId,
AsyncCallback.IsClosedCallback cb,
Object ctx)
Check asynchronously whether the ledger with identifier lId
has been closed.
|
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.
|
static BookKeeper.Builder |
forConfig(ClientConfiguration conf) |
protected ClientConfiguration |
getConf() |
boolean |
isClosed(long lId)
Check whether the ledger with identifier lId
has been closed.
|
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.bookieRegistrationPath
IOException
InterruptedException
org.apache.zookeeper.KeeperException
public BookKeeper(ClientConfiguration conf) throws IOException, InterruptedException, org.apache.zookeeper.KeeperException
conf
- Client Configuration objectIOException
InterruptedException
org.apache.zookeeper.KeeperException
public BookKeeper(ClientConfiguration conf, org.apache.zookeeper.ZooKeeper zk) throws IOException, InterruptedException, org.apache.zookeeper.KeeperException
conf
- Client Configuration object
ClientConfiguration
zk
- Zookeeper client instance connected to the zookeeper with which
the bookies have registeredIOException
InterruptedException
org.apache.zookeeper.KeeperException
public 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
ClientConfiguration
zk
- 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 bookiesIOException
InterruptedException
org.apache.zookeeper.KeeperException
- if the passed zk handle is not connectedpublic static BookKeeper.Builder forConfig(ClientConfiguration conf)
protected 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
- passwordInterruptedException
BKException
public 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
- InterruptedException
BKException
public 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
- InterruptedException
BKException
public 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
- passwordInterruptedException
BKException
asyncOpenLedger(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
- passwordInterruptedException
BKException
asyncOpenLedgerNoRecovery(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
- ledgerIdInterruptedException
BKException.BKNoSuchLedgerExistsException
- if the ledger doesn't existBKException
public void asyncIsClosed(long lId, AsyncCallback.IsClosedCallback cb, Object ctx)
lId
- ledger identifiercb
- callback methodpublic boolean isClosed(long lId) throws BKException, InterruptedException
lId
- BKException
InterruptedException
public void close() throws InterruptedException, BKException
InterruptedException
BKException
Copyright © 2011-2014 The Apache Software Foundation. All Rights Reserved.