public class BookKeeperAdmin
extends java.lang.Object
implements java.lang.AutoCloseable
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
BookKeeperAdmin.LedgerEntriesIterable |
(package private) class |
BookKeeperAdmin.LedgerEntriesIterator |
static class |
BookKeeperAdmin.ResultCallBack
This is the class for getting the replication result.
|
(package private) static class |
BookKeeperAdmin.SyncObject |
| Constructor and Description |
|---|
BookKeeperAdmin(BookKeeper bkc) |
BookKeeperAdmin(BookKeeper bkc,
org.apache.bookkeeper.stats.StatsLogger statsLogger)
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(java.lang.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 |
|---|---|
static boolean |
areEntriesOfLedgerStoredInTheBookie(long ledgerId,
org.apache.bookkeeper.net.BookieId bookieAddress,
org.apache.bookkeeper.meta.LedgerManager ledgerManager) |
static boolean |
areEntriesOfLedgerStoredInTheBookie(long ledgerId,
org.apache.bookkeeper.net.BookieId bookieAddress,
LedgerMetadata ledgerMetadata) |
void |
asyncGetLedgersContainBookies(java.util.Set<org.apache.bookkeeper.net.BookieId> bookies,
org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback<java.util.SortedMap<java.lang.Long,LedgerMetadata>> callback) |
java.util.concurrent.CompletableFuture<org.apache.bookkeeper.util.AvailabilityOfEntriesOfLedger> |
asyncGetListOfEntriesOfLedger(org.apache.bookkeeper.net.BookieId address,
long ledgerId)
Makes async request for getting list of entries of ledger from a bookie
and returns Future for the result.
|
void |
asyncOpenLedger(long lId,
AsyncCallback.OpenCallback cb,
java.lang.Object ctx)
Open a ledger as an administrator.
|
void |
asyncOpenLedgerNoRecovery(long lId,
AsyncCallback.OpenCallback cb,
java.lang.Object ctx)
Open a ledger as an administrator without recovering the ledger.
|
void |
asyncRecoverBookieData(org.apache.bookkeeper.net.BookieId bookieSrc,
AsyncCallback.RecoverCallback cb,
java.lang.Object context)
Async method to rebuild and recover the ledger fragments data that was
stored on the source bookie.
|
void |
asyncRecoverBookieData(long lid,
java.util.Set<org.apache.bookkeeper.net.BookieId> bookieSrc,
boolean dryrun,
boolean skipOpenLedgers,
AsyncCallback.RecoverCallback callback,
java.lang.Object context)
Recover a specific ledger.
|
void |
asyncRecoverBookieData(java.util.Set<org.apache.bookkeeper.net.BookieId> bookieSrc,
AsyncCallback.RecoverCallback cb,
java.lang.Object context) |
void |
asyncRecoverBookieData(java.util.Set<org.apache.bookkeeper.net.BookieId> bookieSrc,
boolean dryrun,
boolean skipOpenLedgers,
AsyncCallback.RecoverCallback cb,
java.lang.Object context) |
void |
close()
Gracefully release resources that this client uses.
|
void |
decommissionBookie(org.apache.bookkeeper.net.BookieId bookieAddress)
Triggers AuditTask by resetting lostBookieRecoveryDelay and then make
sure the ledgers stored in the given decommissioning bookie are properly
replicated and they are not underreplicated because of the given bookie.
|
static boolean |
format(ServerConfiguration conf,
boolean isInteractive,
boolean force)
Format the BookKeeper metadata in zookeeper.
|
(package private) static java.lang.String |
formatEnsemble(java.util.List<org.apache.bookkeeper.net.BookieId> ensemble,
java.util.Set<org.apache.bookkeeper.net.BookieId> bookiesSrc,
char marker) |
java.util.Collection<org.apache.bookkeeper.net.BookieId> |
getAllBookies()
Get a list of all bookies including the not available ones.
|
java.util.Collection<org.apache.bookkeeper.net.BookieId> |
getAvailableBookies()
Get a list of the available bookies.
|
org.apache.bookkeeper.proto.BookieAddressResolver |
getBookieAddressResolver() |
org.apache.bookkeeper.discover.BookieServiceInfo |
getBookieServiceInfo(java.lang.String bookiedId) |
ClientConfiguration |
getConf() |
LedgerMetadata |
getLedgerMetadata(LedgerHandle lh) |
java.util.SortedMap<java.lang.Long,LedgerMetadata> |
getLedgersContainBookies(java.util.Set<org.apache.bookkeeper.net.BookieId> bookies) |
int |
getLostBookieRecoveryDelay()
Returns the current LostBookieRecoveryDelay value (in seconds) in Zookeeper.
|
java.util.Collection<org.apache.bookkeeper.net.BookieId> |
getReadOnlyBookies()
Get a list of readonly bookies synchronously.
|
static boolean |
initBookie(ServerConfiguration conf)
Initializes bookie, by making sure that the journalDir, ledgerDirs and
indexDirs are empty and there is no registered Bookie with this BookieId.
|
static boolean |
initNewCluster(ServerConfiguration conf)
Intializes new cluster by creating required znodes for the cluster.
|
EnsemblePlacementPolicy.PlacementPolicyAdherence |
isEnsembleAdheringToPlacementPolicy(java.util.List<org.apache.bookkeeper.net.BookieId> ensembleBookiesList,
int writeQuorumSize,
int ackQuorumSize)
returns boolean value specifying if the ensemble of the segment is
adhering to the ensemble placement policy for the given writeQuorumSize
and ackQuorumSize.
|
java.lang.Iterable<java.lang.Long> |
listLedgers()
This method returns an iterable object for the list of ledger identifiers of
the ledgers currently available.
|
static boolean |
nukeExistingCluster(ServerConfiguration conf,
java.lang.String ledgersRootPath,
java.lang.String instanceId,
boolean force)
Nukes existing cluster metadata.
|
LedgerHandle |
openLedger(long lId)
Open a ledger as an administrator.
|
LedgerHandle |
openLedgerNoRecovery(long lId)
Open a ledger as an administrator without recovering the ledger.
|
java.lang.Iterable<LedgerEntry> |
readEntries(long ledgerId,
long firstEntry,
long lastEntry)
Read entries from a ledger synchronously.
|
void |
recoverBookieData(org.apache.bookkeeper.net.BookieId bookieSrc)
Synchronous method to rebuild and recover the ledger fragments data that
was stored on the source bookie.
|
void |
recoverBookieData(long lid,
java.util.Set<org.apache.bookkeeper.net.BookieId> bookiesSrc,
boolean dryrun,
boolean skipOpenLedgers) |
void |
recoverBookieData(java.util.Set<org.apache.bookkeeper.net.BookieId> bookiesSrc) |
void |
recoverBookieData(java.util.Set<org.apache.bookkeeper.net.BookieId> bookiesSrc,
boolean dryrun,
boolean skipOpenLedgers) |
void |
replicateLedgerFragment(LedgerHandle lh,
LedgerFragment ledgerFragment,
java.util.function.BiConsumer<java.lang.Long,java.lang.Long> onReadEntryFailureCallback)
Replicate the Ledger fragment to target Bookie passed.
|
void |
setLostBookieRecoveryDelay(int lostBookieRecoveryDelay)
Setter for LostBookieRecoveryDelay value (in seconds) in Zookeeper.
|
void |
triggerAudit()
Trigger AuditTask by resetting lostBookieRecoveryDelay to its current
value.
|
void |
watchReadOnlyBookiesChanged(org.apache.bookkeeper.discover.RegistrationClient.RegistrationListener listener)
Notify when the available list of read only bookies changes.
|
void |
watchWritableBookiesChanged(org.apache.bookkeeper.discover.RegistrationClient.RegistrationListener listener)
Notify when the available list of bookies changes.
|
public BookKeeperAdmin(java.lang.String zkServers)
throws java.io.IOException,
java.lang.InterruptedException,
BKException
zkServers - Comma separated list of hostname:port pairs for the ZooKeeper
servers cluster.java.io.IOException - throws this exception if there is an error instantiating the
ZooKeeper client.java.lang.InterruptedException - Throws this exception if there is an error instantiating the
BookKeeper client.BKException - Throws this exception if there is an error instantiating the
BookKeeper client.public BookKeeperAdmin(ClientConfiguration conf) throws java.io.IOException, java.lang.InterruptedException, BKException
conf - Client Configuration Objectjava.io.IOException - throws this exception if there is an error instantiating the
ZooKeeper client.java.lang.InterruptedException - Throws this exception if there is an error instantiating the
BookKeeper client.BKException - Throws this exception if there is an error instantiating the
BookKeeper client.public BookKeeperAdmin(BookKeeper bkc, org.apache.bookkeeper.stats.StatsLogger statsLogger)
bkc - - bookkeeper instancestatsLogger - - stats loggerpublic BookKeeperAdmin(BookKeeper bkc)
public ClientConfiguration getConf()
public void close()
throws java.lang.InterruptedException,
BKException
close in interface java.lang.AutoCloseablejava.lang.InterruptedException - if there is an error shutting down the clients that this
class uses.BKExceptionpublic java.util.Collection<org.apache.bookkeeper.net.BookieId> getAvailableBookies()
throws BKException
BKExceptionpublic java.util.Collection<org.apache.bookkeeper.net.BookieId> getAllBookies()
throws BKException
BKExceptionpublic org.apache.bookkeeper.proto.BookieAddressResolver getBookieAddressResolver()
public org.apache.bookkeeper.discover.BookieServiceInfo getBookieServiceInfo(java.lang.String bookiedId)
throws BKException
BKExceptionpublic java.util.Collection<org.apache.bookkeeper.net.BookieId> getReadOnlyBookies()
throws BKException
BKException - if there are issues trying to read the list.public void watchWritableBookiesChanged(org.apache.bookkeeper.discover.RegistrationClient.RegistrationListener listener)
throws BKException
listener - the listener to notifyBKExceptionpublic void watchReadOnlyBookiesChanged(org.apache.bookkeeper.discover.RegistrationClient.RegistrationListener listener)
throws BKException
listener - the listener to notifyBKExceptionpublic void asyncOpenLedger(long lId,
AsyncCallback.OpenCallback cb,
java.lang.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 java.lang.InterruptedException, BKException
lId - - ledger identifierjava.lang.InterruptedExceptionBKExceptionBookKeeper.openLedger(long, org.apache.bookkeeper.client.BookKeeper.DigestType, byte[])public void asyncOpenLedgerNoRecovery(long lId,
AsyncCallback.OpenCallback cb,
java.lang.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 java.lang.InterruptedException, BKException
lId - ledger identifierjava.lang.InterruptedExceptionBKExceptionBookKeeper.openLedgerNoRecovery(long, org.apache.bookkeeper.client.BookKeeper.DigestType, byte[])public java.lang.Iterable<LedgerEntry> readEntries(long ledgerId, long firstEntry, long lastEntry) throws java.lang.InterruptedException, BKException
ledgerId - firstEntry - lastEntry - java.lang.InterruptedExceptionBKExceptionpublic java.util.SortedMap<java.lang.Long,LedgerMetadata> getLedgersContainBookies(java.util.Set<org.apache.bookkeeper.net.BookieId> bookies) throws java.lang.InterruptedException, BKException
java.lang.InterruptedExceptionBKExceptionpublic void asyncGetLedgersContainBookies(java.util.Set<org.apache.bookkeeper.net.BookieId> bookies,
org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback<java.util.SortedMap<java.lang.Long,LedgerMetadata>> callback)
public void recoverBookieData(org.apache.bookkeeper.net.BookieId bookieSrc)
throws java.lang.InterruptedException,
BKException
bookieSrc - Source bookie that had a failure. We want to replicate the
ledger fragments that were stored there.java.lang.InterruptedExceptionBKExceptionpublic void recoverBookieData(java.util.Set<org.apache.bookkeeper.net.BookieId> bookiesSrc)
throws java.lang.InterruptedException,
BKException
java.lang.InterruptedExceptionBKExceptionpublic void recoverBookieData(java.util.Set<org.apache.bookkeeper.net.BookieId> bookiesSrc,
boolean dryrun,
boolean skipOpenLedgers)
throws java.lang.InterruptedException,
BKException
java.lang.InterruptedExceptionBKExceptionpublic void recoverBookieData(long lid,
java.util.Set<org.apache.bookkeeper.net.BookieId> bookiesSrc,
boolean dryrun,
boolean skipOpenLedgers)
throws java.lang.InterruptedException,
BKException
java.lang.InterruptedExceptionBKExceptionpublic void asyncRecoverBookieData(org.apache.bookkeeper.net.BookieId bookieSrc,
AsyncCallback.RecoverCallback cb,
java.lang.Object context)
bookieSrc - Source bookie that had a failure. We want to replicate the
ledger fragments that were stored there.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 asyncRecoverBookieData(java.util.Set<org.apache.bookkeeper.net.BookieId> bookieSrc,
AsyncCallback.RecoverCallback cb,
java.lang.Object context)
public void asyncRecoverBookieData(java.util.Set<org.apache.bookkeeper.net.BookieId> bookieSrc,
boolean dryrun,
boolean skipOpenLedgers,
AsyncCallback.RecoverCallback cb,
java.lang.Object context)
public void asyncRecoverBookieData(long lid,
java.util.Set<org.apache.bookkeeper.net.BookieId> bookieSrc,
boolean dryrun,
boolean skipOpenLedgers,
AsyncCallback.RecoverCallback callback,
java.lang.Object context)
lid - ledger to recoverbookieSrc - Source bookies that had a failure. We want to replicate the ledger fragments that were stored there.dryrun - dryrun the recover procedure.skipOpenLedgers - Skip recovering open ledgers.callback - RecoverCallback to invoke once all of the data on the dead
bookie has been recovered and replicated.context - Context for the RecoverCallback to call.static java.lang.String formatEnsemble(java.util.List<org.apache.bookkeeper.net.BookieId> ensemble,
java.util.Set<org.apache.bookkeeper.net.BookieId> bookiesSrc,
char marker)
public void replicateLedgerFragment(LedgerHandle lh, LedgerFragment ledgerFragment, java.util.function.BiConsumer<java.lang.Long,java.lang.Long> onReadEntryFailureCallback) throws java.lang.InterruptedException, BKException
lh - - ledgerHandleledgerFragment - - LedgerFragment to replicatejava.lang.InterruptedExceptionBKExceptionpublic static boolean format(ServerConfiguration conf, boolean isInteractive, boolean force) throws java.lang.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.java.lang.Exceptionpublic static boolean initNewCluster(ServerConfiguration conf) throws java.lang.Exception
conf - java.lang.Exceptionpublic static boolean nukeExistingCluster(ServerConfiguration conf, java.lang.String ledgersRootPath, java.lang.String instanceId, boolean force) throws java.lang.Exception
conf - ledgersRootPath - instanceId - force - java.lang.Exceptionpublic static boolean initBookie(ServerConfiguration conf) throws java.lang.Exception
conf - java.lang.Exceptionpublic java.lang.Iterable<java.lang.Long> listLedgers()
throws java.io.IOException
java.io.IOException - if the list of ledger identifiers cannot be read from the
metadata storepublic LedgerMetadata getLedgerMetadata(LedgerHandle lh)
public void setLostBookieRecoveryDelay(int lostBookieRecoveryDelay)
throws org.apache.bookkeeper.replication.ReplicationException.CompatibilityException,
org.apache.zookeeper.KeeperException,
java.lang.InterruptedException,
org.apache.bookkeeper.replication.ReplicationException.UnavailableException
lostBookieRecoveryDelay - lostBookieRecoveryDelay value (in seconds) to setorg.apache.bookkeeper.replication.ReplicationException.CompatibilityExceptionorg.apache.zookeeper.KeeperExceptionjava.lang.InterruptedExceptionorg.apache.bookkeeper.replication.ReplicationException.UnavailableExceptionpublic int getLostBookieRecoveryDelay()
throws org.apache.bookkeeper.replication.ReplicationException.CompatibilityException,
org.apache.zookeeper.KeeperException,
java.lang.InterruptedException,
org.apache.bookkeeper.replication.ReplicationException.UnavailableException
org.apache.bookkeeper.replication.ReplicationException.CompatibilityExceptionorg.apache.zookeeper.KeeperExceptionjava.lang.InterruptedExceptionorg.apache.bookkeeper.replication.ReplicationException.UnavailableExceptionpublic void triggerAudit()
throws org.apache.bookkeeper.replication.ReplicationException.CompatibilityException,
org.apache.zookeeper.KeeperException,
java.lang.InterruptedException,
org.apache.bookkeeper.replication.ReplicationException.UnavailableException,
java.io.IOException
org.apache.bookkeeper.replication.ReplicationException.CompatibilityExceptionorg.apache.zookeeper.KeeperExceptionjava.lang.InterruptedExceptionorg.apache.bookkeeper.replication.ReplicationException.UnavailableExceptionjava.io.IOExceptionpublic void decommissionBookie(org.apache.bookkeeper.net.BookieId bookieAddress)
throws org.apache.bookkeeper.replication.ReplicationException.CompatibilityException,
org.apache.bookkeeper.replication.ReplicationException.UnavailableException,
org.apache.zookeeper.KeeperException,
java.lang.InterruptedException,
java.io.IOException,
org.apache.bookkeeper.replication.ReplicationException.BKAuditException,
java.util.concurrent.TimeoutException,
BKException
bookieAddress - address of the decommissioning bookieorg.apache.bookkeeper.replication.ReplicationException.CompatibilityExceptionorg.apache.bookkeeper.replication.ReplicationException.UnavailableExceptionorg.apache.zookeeper.KeeperExceptionjava.lang.InterruptedExceptionjava.io.IOExceptionorg.apache.bookkeeper.replication.ReplicationException.BKAuditExceptionjava.util.concurrent.TimeoutExceptionBKExceptionpublic static boolean areEntriesOfLedgerStoredInTheBookie(long ledgerId,
org.apache.bookkeeper.net.BookieId bookieAddress,
org.apache.bookkeeper.meta.LedgerManager ledgerManager)
public static boolean areEntriesOfLedgerStoredInTheBookie(long ledgerId,
org.apache.bookkeeper.net.BookieId bookieAddress,
LedgerMetadata ledgerMetadata)
public EnsemblePlacementPolicy.PlacementPolicyAdherence isEnsembleAdheringToPlacementPolicy(java.util.List<org.apache.bookkeeper.net.BookieId> ensembleBookiesList, int writeQuorumSize, int ackQuorumSize)
ensembleBookiesList - ensemble of the segmentwriteQuorumSize - writeQuorumSize of the ledgerackQuorumSize - ackQuorumSize of the ledgerpublic java.util.concurrent.CompletableFuture<org.apache.bookkeeper.util.AvailabilityOfEntriesOfLedger> asyncGetListOfEntriesOfLedger(org.apache.bookkeeper.net.BookieId address,
long ledgerId)
address - BookieId of the bookieledgerId - ledgerIdCopyright © 2011–2024 The Apache Software Foundation. All rights reserved.