Package org.apache.bookkeeper.discover
Interface RegistrationManager
-
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Implementing Classes:
NullMetadataBookieDriver.NullRegistrationManager,ZKRegistrationManager
@LimitedPrivate @Evolving public interface RegistrationManager extends java.lang.AutoCloseable
Registration manager interface, which a bookie server will use to do the registration process.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceRegistrationManager.RegistrationListenerRegistration Listener on listening the registration state.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddRegistrationListener(RegistrationManager.RegistrationListener listener)Add a listener to be triggered when an registration event occurs.voidclose()booleanformat()Do format boolean.java.lang.StringgetClusterInstanceId()Return the cluster instance id.booleaninitNewCluster()Initializes 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.booleannukeExistingCluster()Nukes existing cluster metadata.booleanprepareFormat()Prepare 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 Detail
-
close
void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
getClusterInstanceId
java.lang.String getClusterInstanceId() throws BookieExceptionReturn 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
void unregisterBookie(BookieId bookieId, boolean readOnly) throws BookieException
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
boolean isBookieRegistered(BookieId bookieId) throws BookieException
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
void writeCookie(BookieId bookieId, Versioned<byte[]> cookieData) throws BookieException
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
Versioned<byte[]> readCookie(BookieId bookieId) throws BookieException
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
void removeCookie(BookieId bookieId, Version version) throws BookieException
Remove the cookie data.- Parameters:
bookieId- bookie idversion- version of the cookie data- Throws:
BookieException- when fail to remove cookie
-
prepareFormat
boolean prepareFormat() throws java.lang.ExceptionPrepare ledgers root node, availableNode, readonly node..- Returns:
- Returns true if old data exists, false if not.
- Throws:
java.lang.Exception
-
initNewCluster
boolean initNewCluster() throws java.lang.ExceptionInitializes 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:
java.lang.Exception
-
format
boolean format() throws java.lang.ExceptionDo format boolean.- Returns:
- Returns true if success do format, false if not.
- Throws:
java.lang.Exception
-
nukeExistingCluster
boolean nukeExistingCluster() throws java.lang.ExceptionNukes existing cluster metadata.- Returns:
- returns true if cluster metadata is successfully nuked or false if it failed to nuke the cluster metadata.
- Throws:
java.lang.Exception
-
addRegistrationListener
void addRegistrationListener(RegistrationManager.RegistrationListener listener)
Add a listener to be triggered when an registration event occurs.- Parameters:
listener- the listener to be added
-
-