Package org.apache.bookkeeper.discover
Interface RegistrationManager
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
NullMetadataBookieDriver.NullRegistrationManager,ZKRegistrationManager
Registration manager interface, which a bookie server will use to do the registration process.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceRegistration Listener on listening the registration state. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a listener to be triggered when an registration event occurs.voidclose()booleanformat()Do format boolean.Return the cluster instance id.booleanInitializes new cluster by creating required znodes for the cluster.booleanisBookieRegistered(BookieId bookieId) Checks if Bookie with the given BookieId is registered as readwrite or readonly bookie.booleanNukes existing cluster metadata.booleanPrepare ledgers root node, availableNode, readonly node..Versioned<byte[]>readCookie(BookieId bookieId) Read the cookie data, which will be used for verifying the integrity of the bookie environment.voidregisterBookie(BookieId bookieId, boolean readOnly, BookieServiceInfo serviceInfo) Registering the bookie server as bookieId.voidremoveCookie(BookieId bookieId, Version version) Remove the cookie data.voidunregisterBookie(BookieId bookieId, boolean readOnly) Unregistering the bookie server as bookieId.voidwriteCookie(BookieId bookieId, Versioned<byte[]> cookieData) Write the cookie data, which will be used for verifying the integrity of the bookie environment.
-
Method Details
-
close
void close()- Specified by:
closein interfaceAutoCloseable
-
getClusterInstanceId
Return the cluster instance id.- Returns:
- the cluster instance id.
- Throws:
BookieException
-
registerBookie
void registerBookie(BookieId bookieId, boolean readOnly, BookieServiceInfo serviceInfo) throws BookieException Registering the bookie server as bookieId.- Parameters:
bookieId- bookie idreadOnly- whether to register it as writable or readonlyserviceInfo- information about services exposed by the Bookie- Throws:
BookieException- when fail to register a bookie.
-
unregisterBookie
Unregistering the bookie server as bookieId.- Parameters:
bookieId- bookie idreadOnly- whether to register it as writable or readonly- Throws:
BookieException- when fail to unregister a bookie.
-
isBookieRegistered
Checks if Bookie with the given BookieId is registered as readwrite or readonly bookie.- Parameters:
bookieId- bookie id- Returns:
- returns true if a bookie with bookieid is currently registered as readwrite or readonly bookie.
- Throws:
BookieException
-
writeCookie
Write the cookie data, which will be used for verifying the integrity of the bookie environment.- Parameters:
bookieId- bookie idcookieData- cookie data- Throws:
BookieException- when fail to write cookie
-
readCookie
Read the cookie data, which will be used for verifying the integrity of the bookie environment.- Parameters:
bookieId- bookie id- Returns:
- versioned cookie data
- Throws:
BookieException- when fail to read cookie
-
removeCookie
Remove the cookie data.- Parameters:
bookieId- bookie idversion- version of the cookie data- Throws:
BookieException- when fail to remove cookie
-
prepareFormat
Prepare ledgers root node, availableNode, readonly node..- Returns:
- Returns true if old data exists, false if not.
- Throws:
Exception
-
initNewCluster
Initializes new cluster by creating required znodes for the cluster. If ledgersrootpath is already existing then it will error out.- Returns:
- returns true if new cluster is successfully created or false if it failed to initialize.
- Throws:
Exception
-
format
Do format boolean.- Returns:
- Returns true if success do format, false if not.
- Throws:
Exception
-
nukeExistingCluster
Nukes existing cluster metadata.- Returns:
- returns true if cluster metadata is successfully nuked or false if it failed to nuke the cluster metadata.
- Throws:
Exception
-
addRegistrationListener
Add a listener to be triggered when an registration event occurs.- Parameters:
listener- the listener to be added
-