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 interface
RegistrationManager.RegistrationListener
Registration Listener on listening the registration state.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addRegistrationListener(RegistrationManager.RegistrationListener listener)
Add a listener to be triggered when an registration event occurs.void
close()
boolean
format()
Do format boolean.java.lang.String
getClusterInstanceId()
Return the cluster instance id.boolean
initNewCluster()
Initializes new cluster by creating required znodes for the cluster.boolean
isBookieRegistered(BookieId bookieId)
Checks if Bookie with the given BookieId is registered as readwrite or readonly bookie.boolean
nukeExistingCluster()
Nukes existing cluster metadata.boolean
prepareFormat()
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.void
registerBookie(BookieId bookieId, boolean readOnly, BookieServiceInfo serviceInfo)
Registering the bookie server as bookieId.void
removeCookie(BookieId bookieId, Version version)
Remove the cookie data.void
unregisterBookie(BookieId bookieId, boolean readOnly)
Unregistering the bookie server as bookieId.void
writeCookie(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:
close
in interfacejava.lang.AutoCloseable
-
getClusterInstanceId
java.lang.String getClusterInstanceId() throws BookieException
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
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.Exception
Prepare 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.Exception
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:
java.lang.Exception
-
format
boolean format() throws java.lang.Exception
Do format boolean.- Returns:
- Returns true if success do format, false if not.
- Throws:
java.lang.Exception
-
nukeExistingCluster
boolean nukeExistingCluster() throws java.lang.Exception
Nukes 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
-
-