Class ZKRegistrationManager

    • Field Detail

      • bookieRegistrationPath

        protected final java.lang.String bookieRegistrationPath
      • bookieReadonlyRegistrationPath

        protected final java.lang.String bookieReadonlyRegistrationPath
    • Constructor Detail

      • ZKRegistrationManager

        public ZKRegistrationManager​(ServerConfiguration conf,
                                     org.apache.zookeeper.ZooKeeper zk)
      • ZKRegistrationManager

        public ZKRegistrationManager​(ServerConfiguration conf,
                                     org.apache.zookeeper.ZooKeeper zk,
                                     java.lang.String ledgersRootPath)
    • Method Detail

      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface RegistrationManager
      • getCookiePath

        public java.lang.String getCookiePath​(BookieId bookieId)
        Returns the CookiePath of the bookie in the ZooKeeper.
        Parameters:
        bookieId - bookie id
        Returns:
      • checkRegNodeAndWaitExpired

        protected boolean checkRegNodeAndWaitExpired​(java.lang.String regPath)
                                              throws java.io.IOException
        Check existence of regPath and wait it expired if possible.
        Parameters:
        regPath - reg node path.
        Returns:
        true if regPath exists, otherwise return false
        Throws:
        java.io.IOException - if can't create reg path
      • serializeBookieServiceInfo

        static byte[] serializeBookieServiceInfo​(BookieServiceInfo bookieServiceInfo)
      • prepareFormat

        public boolean prepareFormat()
                              throws java.lang.Exception
        Description copied from interface: RegistrationManager
        Prepare ledgers root node, availableNode, readonly node..
        Specified by:
        prepareFormat in interface RegistrationManager
        Returns:
        Returns true if old data exists, false if not.
        Throws:
        java.lang.Exception
      • initNewCluster

        public boolean initNewCluster()
                               throws java.lang.Exception
        Description copied from interface: RegistrationManager
        Initializes new cluster by creating required znodes for the cluster. If ledgersrootpath is already existing then it will error out.
        Specified by:
        initNewCluster in interface RegistrationManager
        Returns:
        returns true if new cluster is successfully created or false if it failed to initialize.
        Throws:
        java.lang.Exception
      • nukeExistingCluster

        public boolean nukeExistingCluster()
                                    throws java.lang.Exception
        Description copied from interface: RegistrationManager
        Nukes existing cluster metadata.
        Specified by:
        nukeExistingCluster in interface RegistrationManager
        Returns:
        returns true if cluster metadata is successfully nuked or false if it failed to nuke the cluster metadata.
        Throws:
        java.lang.Exception
      • format

        public boolean format()
                       throws java.lang.Exception
        Description copied from interface: RegistrationManager
        Do format boolean.
        Specified by:
        format in interface RegistrationManager
        Returns:
        Returns true if success do format, false if not.
        Throws:
        java.lang.Exception
      • isBookieRegistered

        public boolean isBookieRegistered​(BookieId bookieId)
                                   throws BookieException
        Description copied from interface: RegistrationManager
        Checks if Bookie with the given BookieId is registered as readwrite or readonly bookie.
        Specified by:
        isBookieRegistered in interface RegistrationManager
        Parameters:
        bookieId - bookie id
        Returns:
        returns true if a bookie with bookieid is currently registered as readwrite or readonly bookie.
        Throws:
        BookieException