public class BookKeeperAdmin extends Object
| Constructor and Description |
|---|
BookKeeperAdmin(BookKeeper bkc)
Constructor that takes in a BookKeeper instance .
|
BookKeeperAdmin(ClientConfiguration conf)
Constructor that takes in a configuration object so we know
how to connect to ZooKeeper to retrieve information about the BookKeeper
cluster.
|
BookKeeperAdmin(String zkServers)
Constructor that takes in a ZooKeeper servers connect string so we know
how to connect to ZooKeeper to retrieve information about the BookKeeper
cluster.
|
| Modifier and Type | Method and Description |
|---|---|
void |
asyncOpenLedger(long lId,
AsyncCallback.OpenCallback cb,
Object ctx)
Open a ledger as an administrator.
|
void |
asyncOpenLedgerNoRecovery(long lId,
AsyncCallback.OpenCallback cb,
Object ctx)
Open a ledger as an administrator without recovering the ledger.
|
void |
asyncRecoverBookieData(org.apache.bookkeeper.net.BookieSocketAddress bookieSrc,
org.apache.bookkeeper.net.BookieSocketAddress bookieDest,
AsyncCallback.RecoverCallback cb,
Object context)
Async method to rebuild and recover the ledger fragments data that was
stored on the source bookie.
|
void |
close()
Gracefully release resources that this client uses.
|
static boolean |
format(ClientConfiguration conf,
boolean isInteractive,
boolean force)
Format the BookKeeper metadata in zookeeper
|
Collection<org.apache.bookkeeper.net.BookieSocketAddress> |
getAvailableBookies()
Get a list of the available bookies.
|
LedgerMetadata |
getLedgerMetadata(LedgerHandle lh) |
Collection<org.apache.bookkeeper.net.BookieSocketAddress> |
getReadOnlyBookies()
Get a list of readonly bookies
|
Iterable<Long> |
listLedgers()
This method returns an iterable object for the list of ledger identifiers of
the ledgers currently available.
|
void |
notifyBookiesChanged(BookiesListener listener)
Notify when the available list of bookies changes.
|
LedgerHandle |
openLedger(long lId)
Open a ledger as an administrator.
|
LedgerHandle |
openLedgerNoRecovery(long lId)
Open a ledger as an administrator without recovering the ledger.
|
void |
recoverBookieData(org.apache.bookkeeper.net.BookieSocketAddress bookieSrc,
org.apache.bookkeeper.net.BookieSocketAddress bookieDest)
Synchronous method to rebuild and recover the ledger fragments data that
was stored on the source bookie.
|
void |
replicateLedgerFragment(LedgerHandle lh,
LedgerFragment ledgerFragment,
org.apache.bookkeeper.net.BookieSocketAddress targetBookieAddress)
Replicate the Ledger fragment to target Bookie passed.
|
public BookKeeperAdmin(String zkServers) throws IOException, InterruptedException, org.apache.zookeeper.KeeperException
zkServers - Comma separated list of hostname:port pairs for the ZooKeeper
servers cluster.IOException - throws this exception if there is an error instantiating the
ZooKeeper client.InterruptedException - Throws this exception if there is an error instantiating the
BookKeeper client.org.apache.zookeeper.KeeperException - Throws this exception if there is an error instantiating the
BookKeeper client.public BookKeeperAdmin(ClientConfiguration conf) throws IOException, InterruptedException, org.apache.zookeeper.KeeperException
conf - Client Configuration ObjectIOException - throws this exception if there is an error instantiating the
ZooKeeper client.InterruptedException - Throws this exception if there is an error instantiating the
BookKeeper client.org.apache.zookeeper.KeeperException - Throws this exception if there is an error instantiating the
BookKeeper client.public BookKeeperAdmin(BookKeeper bkc)
bkc - - bookkeeper instancepublic void close()
throws InterruptedException,
BKException
InterruptedException - if there is an error shutting down the clients that this
class uses.BKExceptionpublic Collection<org.apache.bookkeeper.net.BookieSocketAddress> getAvailableBookies() throws BKException
BKExceptionpublic Collection<org.apache.bookkeeper.net.BookieSocketAddress> getReadOnlyBookies()
public void notifyBookiesChanged(BookiesListener listener) throws BKException
listener - the listener to notifyBKExceptionpublic void asyncOpenLedger(long lId,
AsyncCallback.OpenCallback cb,
Object ctx)
lId - ledger identifiercb - Callback which will receive a LedgerHandle objectctx - optional context object, to be passwd to the callback (can be null)BookKeeper.asyncOpenLedger(long, org.apache.bookkeeper.client.BookKeeper.DigestType, byte[], org.apache.bookkeeper.client.AsyncCallback.OpenCallback, java.lang.Object)public LedgerHandle openLedger(long lId) throws InterruptedException, BKException
lId - - ledger identifierInterruptedExceptionBKExceptionBookKeeper.openLedger(long, org.apache.bookkeeper.client.BookKeeper.DigestType, byte[])public void asyncOpenLedgerNoRecovery(long lId,
AsyncCallback.OpenCallback cb,
Object ctx)
lId - ledger identifiercb - Callback which will receive a LedgerHandle objectctx - optional context object, to be passwd to the callback (can be null)BookKeeper.asyncOpenLedgerNoRecovery(long, org.apache.bookkeeper.client.BookKeeper.DigestType, byte[], org.apache.bookkeeper.client.AsyncCallback.OpenCallback, java.lang.Object)public LedgerHandle openLedgerNoRecovery(long lId) throws InterruptedException, BKException
lId - ledger identifierInterruptedExceptionBKExceptionBookKeeper.openLedgerNoRecovery(long, org.apache.bookkeeper.client.BookKeeper.DigestType, byte[])public void recoverBookieData(org.apache.bookkeeper.net.BookieSocketAddress bookieSrc,
org.apache.bookkeeper.net.BookieSocketAddress bookieDest)
throws InterruptedException,
BKException
bookieSrc - Source bookie that had a failure. We want to replicate the
ledger fragments that were stored there.bookieDest - Optional destination bookie that if passed, we will copy all
of the ledger fragments from the source bookie over to it.InterruptedExceptionBKExceptionpublic void asyncRecoverBookieData(org.apache.bookkeeper.net.BookieSocketAddress bookieSrc,
org.apache.bookkeeper.net.BookieSocketAddress bookieDest,
AsyncCallback.RecoverCallback cb,
Object context)
bookieSrc - Source bookie that had a failure. We want to replicate the
ledger fragments that were stored there.bookieDest - Optional destination bookie that if passed, we will copy all
of the ledger fragments from the source bookie over to it.cb - RecoverCallback to invoke once all of the data on the dead
bookie has been recovered and replicated.context - Context for the RecoverCallback to call.public void replicateLedgerFragment(LedgerHandle lh, LedgerFragment ledgerFragment, org.apache.bookkeeper.net.BookieSocketAddress targetBookieAddress) throws InterruptedException, BKException
lh - - ledgerHandleledgerFragment - - LedgerFragment to replicatetargetBookieAddress - - target Bookie, to where entries should be replicated.InterruptedExceptionBKExceptionpublic static boolean format(ClientConfiguration conf, boolean isInteractive, boolean force) throws Exception
isInteractive - Whether format should ask prompt for confirmation if old data
exists or not.force - If non interactive and force is true, then old data will be
removed without prompt.Exceptionpublic Iterable<Long> listLedgers() throws IOException
IOException - if the list of ledger identifiers cannot be read from the
metadata storepublic LedgerMetadata getLedgerMetadata(LedgerHandle lh)
Copyright © 2011-2014 The Apache Software Foundation. All Rights Reserved.