Class ServerCnxnFactory

    • Field Detail

      • ZOOKEEPER_SERVER_CNXN_FACTORY

        public static final java.lang.String ZOOKEEPER_SERVER_CNXN_FACTORY
        See Also:
        Constant Field Values
      • ZOOKEEPER_MAX_CONNECTION_DEFAULT

        public static final int ZOOKEEPER_MAX_CONNECTION_DEFAULT
        See Also:
        Constant Field Values
      • secure

        protected boolean secure
      • maxCnxns

        protected int maxCnxns
      • login

        public Login login
      • cnxns

        protected final java.util.Set<ServerCnxn> cnxns
    • Constructor Detail

      • ServerCnxnFactory

        public ServerCnxnFactory()
    • Method Detail

      • addSession

        public void addSession​(long sessionId,
                               ServerCnxn cnxn)
      • removeCnxnFromSessionMap

        public void removeCnxnFromSessionMap​(ServerCnxn cnxn)
      • closeSession

        public boolean closeSession​(long sessionId,
                                    ServerCnxn.DisconnectReason reason)
        Returns:
        true if the cnxn that contains the sessionId exists in this ServerCnxnFactory and it's closed. Otherwise false.
      • getLocalPort

        public abstract int getLocalPort()
      • getConnections

        public abstract java.lang.Iterable<ServerCnxn> getConnections()
      • getNumAliveConnections

        public int getNumAliveConnections()
      • configure

        public void configure​(java.net.InetSocketAddress addr,
                              int maxcc)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • configure

        public void configure​(java.net.InetSocketAddress addr,
                              int maxcc,
                              int backlog)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • configure

        public abstract void configure​(java.net.InetSocketAddress addr,
                                       int maxcc,
                                       int backlog,
                                       boolean secure)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • reconfigure

        public abstract void reconfigure​(java.net.InetSocketAddress addr)
      • getMaxClientCnxnsPerHost

        public abstract int getMaxClientCnxnsPerHost()
        Maximum number of connections allowed from particular host (ip)
      • setMaxClientCnxnsPerHost

        public abstract void setMaxClientCnxnsPerHost​(int max)
        Maximum number of connections allowed from particular host (ip)
      • isSecure

        public boolean isSecure()
      • startup

        public void startup​(ZooKeeperServer zkServer)
                     throws java.io.IOException,
                            java.lang.InterruptedException
        Throws:
        java.io.IOException
        java.lang.InterruptedException
      • startup

        public abstract void startup​(ZooKeeperServer zkServer,
                                     boolean startServer)
                              throws java.io.IOException,
                                     java.lang.InterruptedException
        Throws:
        java.io.IOException
        java.lang.InterruptedException
      • getSocketListenBacklog

        public abstract int getSocketListenBacklog()
        The maximum queue length of the ZooKeeper server's socket
      • join

        public abstract void join()
                           throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • shutdown

        public abstract void shutdown()
      • start

        public abstract void start()
      • setZooKeeperServer

        public final void setZooKeeperServer​(ZooKeeperServer zks)
      • createFactory

        public static ServerCnxnFactory createFactory()
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • createFactory

        public static ServerCnxnFactory createFactory​(int clientPort,
                                                      int maxClientCnxns)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • createFactory

        public static ServerCnxnFactory createFactory​(int clientPort,
                                                      int maxClientCnxns,
                                                      int backlog)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • createFactory

        public static ServerCnxnFactory createFactory​(java.net.InetSocketAddress addr,
                                                      int maxClientCnxns)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • createFactory

        public static ServerCnxnFactory createFactory​(java.net.InetSocketAddress addr,
                                                      int maxClientCnxns,
                                                      int backlog)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • getLocalAddress

        public abstract java.net.InetSocketAddress getLocalAddress()
      • resetAllConnectionStats

        public abstract void resetAllConnectionStats()
      • getAllConnectionInfo

        public abstract java.lang.Iterable<java.util.Map<java.lang.String,​java.lang.Object>> getAllConnectionInfo​(boolean brief)
      • unregisterConnection

        public void unregisterConnection​(ServerCnxn serverCnxn)
      • registerConnection

        public void registerConnection​(ServerCnxn serverCnxn)
      • configureSaslLogin

        protected void configureSaslLogin()
                                   throws java.io.IOException
        Initialize the server SASL if specified. If the user has specified a "ZooKeeperServer.LOGIN_CONTEXT_NAME_KEY" or a jaas.conf using "java.security.auth.login.config" the authentication is required and an exception is raised. Otherwise no authentication is configured and no exception is raised.
        Throws:
        java.io.IOException - if jaas.conf is missing or there's an error in it.
      • getUserName

        public static java.lang.String getUserName()
        User who has started the ZooKeeper server user, it will be the logged-in user. If no user logged-in then system user
      • getMaxCnxns

        public int getMaxCnxns()
        Maximum number of connections allowed in the ZooKeeper system
      • initMaxCnxns

        protected void initMaxCnxns()
      • limitTotalNumberOfCnxns

        protected boolean limitTotalNumberOfCnxns()
        Ensure total number of connections are less than the maxCnxns