Package org.apache.bookkeeper.client
Class BookieWatcherImpl
java.lang.Object
org.apache.bookkeeper.client.BookieWatcherImpl
- All Implemented Interfaces:
BookieWatcher
@StatsDoc(name="bookie_watcher",
help="Bookie watcher related stats")
class BookieWatcherImpl
extends Object
implements BookieWatcher
This class is responsible for maintaining a consistent view of what bookies
are available by reading Zookeeper (and setting watches on the bookie nodes).
When a bookie fails, the other parts of the code turn to this class to find a
replacement
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
ConstructorsConstructorDescriptionBookieWatcherImpl(ClientConfiguration conf, EnsemblePlacementPolicy placementPolicy, RegistrationClient registrationClient, BookieAddressResolver bookieAddressResolver, StatsLogger statsLogger) -
Method Summary
Modifier and TypeMethodDescriptionvoidBlocks until bookies are read from zookeeper, used in theBookKeeperconstructor.booleanDetermine if a bookie should be considered unavailable.newEnsemble(int ensembleSize, int writeQuorumSize, int ackQuorumSize, Map<String, byte[]> customMetadata) Create an ensemble with given ensembleSize and writeQuorumSize.voidquarantineBookie(BookieId bookie) Quarantine bookie so it will not be preferred to be chosen for new ensembles.voidRelease all quarantined bookies, let it can be chosen for new ensembles.replaceBookie(int ensembleSize, int writeQuorumSize, int ackQuorumSize, Map<String, byte[]> customMetadata, List<BookieId> existingBookies, int bookieIdx, Set<BookieId> excludeBookies) Choose a bookie to replace bookie bookieIdx in existingBookies.
-
Field Details
-
quarantinedBookies
-
-
Constructor Details
-
BookieWatcherImpl
public BookieWatcherImpl(ClientConfiguration conf, EnsemblePlacementPolicy placementPolicy, RegistrationClient registrationClient, BookieAddressResolver bookieAddressResolver, StatsLogger statsLogger)
-
-
Method Details
-
getBookies
- Specified by:
getBookiesin interfaceBookieWatcher- Throws:
BKException
-
getAllBookies
- Specified by:
getAllBookiesin interfaceBookieWatcher- Throws:
BKException
-
getBookieAddressResolver
- Specified by:
getBookieAddressResolverin interfaceBookieWatcher
-
getReadOnlyBookies
- Specified by:
getReadOnlyBookiesin interfaceBookieWatcher- Throws:
BKException
-
initialBlockingBookieRead
Blocks until bookies are read from zookeeper, used in theBookKeeperconstructor.- Throws:
BKException- when failed to read bookies
-
newEnsemble
public List<BookieId> newEnsemble(int ensembleSize, int writeQuorumSize, int ackQuorumSize, Map<String, byte[]> customMetadata) throws BKException.BKNotEnoughBookiesExceptionDescription copied from interface:BookieWatcherCreate an ensemble with given ensembleSize and writeQuorumSize.- Specified by:
newEnsemblein interfaceBookieWatcher- Parameters:
ensembleSize- Ensemble SizewriteQuorumSize- Write Quorum Size- Returns:
- list of bookies for new ensemble.
- Throws:
BKException.BKNotEnoughBookiesException
-
replaceBookie
public BookieId replaceBookie(int ensembleSize, int writeQuorumSize, int ackQuorumSize, Map<String, byte[]> customMetadata, List<BookieId> existingBookies, int bookieIdx, Set<BookieId> excludeBookies) throws BKException.BKNotEnoughBookiesExceptionDescription copied from interface:BookieWatcherChoose a bookie to replace bookie bookieIdx in existingBookies.- Specified by:
replaceBookiein interfaceBookieWatcherexistingBookies- list of existing bookies.bookieIdx- index of the bookie in the list to be replaced.- Returns:
- the bookie to replace.
- Throws:
BKException.BKNotEnoughBookiesException
-
quarantineBookie
Quarantine bookie so it will not be preferred to be chosen for new ensembles.- Specified by:
quarantineBookiein interfaceBookieWatcher- Parameters:
bookie-
-
releaseAllQuarantinedBookies
public void releaseAllQuarantinedBookies()Description copied from interface:BookieWatcherRelease all quarantined bookies, let it can be chosen for new ensembles.- Specified by:
releaseAllQuarantinedBookiesin interfaceBookieWatcher
-