Class BKCluster

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class BKCluster
    extends java.lang.Object
    implements java.lang.AutoCloseable
    A class runs several bookie servers for testing.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.apache.bookkeeper.conf.ClientConfiguration baseClientConf  
      protected org.apache.bookkeeper.conf.ServerConfiguration baseConf  
    • Constructor Summary

      Constructors 
      Constructor Description
      BKCluster​(java.lang.String metadataServiceUri, int numBookies, boolean clearOldData)  
    • Field Detail

      • baseConf

        protected final org.apache.bookkeeper.conf.ServerConfiguration baseConf
      • baseClientConf

        protected final org.apache.bookkeeper.conf.ClientConfiguration baseClientConf
    • Constructor Detail

      • BKCluster

        public BKCluster​(java.lang.String metadataServiceUri,
                         int numBookies,
                         boolean clearOldData)
                  throws java.lang.Exception
        Throws:
        java.lang.Exception
    • Method Detail

      • close

        public void close()
                   throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception
      • newClient

        public org.apache.bookkeeper.client.BookKeeper newClient()
                                                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • stopBKCluster

        protected void stopBKCluster()
                              throws java.lang.Exception
        Stop cluster. Also, stops all the auto recovery processes for the bookie cluster, if isAutoRecoveryEnabled is true.
        Throws:
        java.lang.Exception
      • cleanupTempDirs

        protected void cleanupTempDirs()
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • stopAllBookies

        protected void stopAllBookies()
                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • stopAllBookies

        protected void stopAllBookies​(boolean shutdownClient)
                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • startAllBookies

        protected void startAllBookies()
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • startNewBookie

        public int startNewBookie()
                           throws java.lang.Exception
        Helper method to startup a new bookie server with the indicated port number. Also, starts the auto recovery process, if the isAutoRecoveryEnabled is set true.
        Throws:
        java.io.IOException
        java.lang.Exception
      • startBookie

        protected org.apache.bookkeeper.proto.BookieServer startBookie​(org.apache.bookkeeper.conf.ServerConfiguration conf)
                                                                throws java.lang.Exception
        Helper method to startup a bookie server using a configuration object. Also, starts the auto recovery process if isAutoRecoveryEnabled is true.
        Parameters:
        conf - Server Configuration Object
        Throws:
        java.lang.Exception
      • newBaseClientConfiguration

        public static org.apache.bookkeeper.conf.ClientConfiguration newBaseClientConfiguration()