Interface ZooKeeperServerEmbedded

  • All Superinterfaces:
    java.lang.AutoCloseable

    @Public
    @Evolving
    public interface ZooKeeperServerEmbedded
    extends java.lang.AutoCloseable
    This API allows you to start a ZooKeeper server node from Java code

    The server will run inside the same process.

    Typical usecases are:

    • Running automated tests
    • Launch ZooKeeper server with a Java based service management system

    Please take into consideration that in production usually it is better to not run the client together with the server in order to avoid race conditions, especially around how ephemeral nodes work.

    • Method Detail

      • start

        void start()
            throws java.lang.Exception
        Start the server.
        Throws:
        java.lang.Exception
      • start

        void start​(long startupTimeout)
            throws java.lang.Exception
        Start the server
        Parameters:
        startupTimeout - time to wait in millis for the server to start
        Throws:
        java.lang.Exception
      • getConnectionString

        java.lang.String getConnectionString()
                                      throws java.lang.Exception
        Get a connection string useful for the client.
        Returns:
        the connection string
        Throws:
        java.lang.Exception - in case the connection string is not available
      • getSecureConnectionString

        java.lang.String getSecureConnectionString()
                                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • close

        void close()
        Shutdown gracefully the server and wait for resources to be released.
        Specified by:
        close in interface java.lang.AutoCloseable