Interface RegistrationManager

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
NullMetadataBookieDriver.NullRegistrationManager, ZKRegistrationManager

@LimitedPrivate @Evolving public interface RegistrationManager extends AutoCloseable
Registration manager interface, which a bookie server will use to do the registration process.
  • Method Details

    • close

      void close()
      Specified by:
      close in interface AutoCloseable
    • getClusterInstanceId

      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 id
      readOnly - whether to register it as writable or readonly
      serviceInfo - 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 id
      readOnly - 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 id
      cookieData - 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 id
      version - version of the cookie data
      Throws:
      BookieException - when fail to remove cookie
    • prepareFormat

      boolean prepareFormat() throws Exception
      Prepare ledgers root node, availableNode, readonly node..
      Returns:
      Returns true if old data exists, false if not.
      Throws:
      Exception
    • initNewCluster

      boolean initNewCluster() throws 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:
      Exception
    • format

      boolean format() throws Exception
      Do format boolean.
      Returns:
      Returns true if success do format, false if not.
      Throws:
      Exception
    • nukeExistingCluster

      boolean nukeExistingCluster() throws 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:
      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