Package org.apache.zookeeper.server
Class ServerCnxnFactory
- java.lang.Object
- 
- org.apache.zookeeper.server.ServerCnxnFactory
 
- 
- Direct Known Subclasses:
- NettyServerCnxnFactory,- NIOServerCnxnFactory
 
 public abstract class ServerCnxnFactory extends Object 
- 
- 
Field SummaryFields Modifier and Type Field Description protected Set<ServerCnxn>cnxnsLoginloginprotected intmaxCnxnsprotected SaslServerCallbackHandlersaslServerCallbackHandlerprotected booleansecureprotected ZooKeeperServerzkServerstatic intZOOKEEPER_MAX_CONNECTION_DEFAULTstatic StringZOOKEEPER_SERVER_CNXN_FACTORY
 - 
Constructor SummaryConstructors Constructor Description ServerCnxnFactory()
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddSession(long sessionId, ServerCnxn cnxn)abstract voidcloseAll(ServerCnxn.DisconnectReason reason)booleancloseSession(long sessionId, ServerCnxn.DisconnectReason reason)voidconfigure(InetSocketAddress addr, int maxcc)voidconfigure(InetSocketAddress addr, int maxcc, int backlog)abstract voidconfigure(InetSocketAddress addr, int maxcc, int backlog, boolean secure)protected voidconfigureSaslLogin()Initialize the server SASL if specified.static ServerCnxnFactorycreateFactory()static ServerCnxnFactorycreateFactory(int clientPort, int maxClientCnxns)static ServerCnxnFactorycreateFactory(int clientPort, int maxClientCnxns, int backlog)static ServerCnxnFactorycreateFactory(InetSocketAddress addr, int maxClientCnxns)static ServerCnxnFactorycreateFactory(InetSocketAddress addr, int maxClientCnxns, int backlog)abstract Iterable<Map<String,Object>>getAllConnectionInfo(boolean brief)abstract Iterable<ServerCnxn>getConnections()abstract InetSocketAddressgetLocalAddress()abstract intgetLocalPort()abstract intgetMaxClientCnxnsPerHost()Maximum number of connections allowed from particular host (ip)intgetMaxCnxns()Maximum number of connections allowed in the ZooKeeper systemintgetNumAliveConnections()abstract intgetSocketListenBacklog()The maximum queue length of the ZooKeeper server's socketstatic StringgetUserName()User who has started the ZooKeeper server user, it will be the logged-in user.ZooKeeperServergetZooKeeperServer()protected voidinitMaxCnxns()booleanisSecure()abstract voidjoin()protected booleanlimitTotalNumberOfCnxns()Ensure total number of connections are less than the maxCnxnsabstract voidreconfigure(InetSocketAddress addr)voidregisterConnection(ServerCnxn serverCnxn)voidremoveCnxnFromSessionMap(ServerCnxn cnxn)abstract voidresetAllConnectionStats()abstract voidsetMaxClientCnxnsPerHost(int max)Maximum number of connections allowed from particular host (ip)voidsetZooKeeperServer(ZooKeeperServer zks)abstract voidshutdown()abstract voidstart()voidstartup(ZooKeeperServer zkServer)abstract voidstartup(ZooKeeperServer zkServer, boolean startServer)voidunregisterConnection(ServerCnxn serverCnxn)
 
- 
- 
- 
Field Detail- 
ZOOKEEPER_SERVER_CNXN_FACTORYpublic static final String ZOOKEEPER_SERVER_CNXN_FACTORY - See Also:
- Constant Field Values
 
 - 
ZOOKEEPER_MAX_CONNECTION_DEFAULTpublic static final int ZOOKEEPER_MAX_CONNECTION_DEFAULT - See Also:
- Constant Field Values
 
 - 
secureprotected boolean secure 
 - 
maxCnxnsprotected int maxCnxns 
 - 
saslServerCallbackHandlerprotected SaslServerCallbackHandler saslServerCallbackHandler 
 - 
loginpublic Login login 
 - 
zkServerprotected ZooKeeperServer zkServer 
 - 
cnxnsprotected final Set<ServerCnxn> cnxns 
 
- 
 - 
Method Detail- 
addSessionpublic void addSession(long sessionId, ServerCnxn cnxn)
 - 
removeCnxnFromSessionMappublic void removeCnxnFromSessionMap(ServerCnxn cnxn) 
 - 
closeSessionpublic 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.
 
 - 
getLocalPortpublic abstract int getLocalPort() 
 - 
getConnectionspublic abstract Iterable<ServerCnxn> getConnections() 
 - 
getNumAliveConnectionspublic int getNumAliveConnections() 
 - 
getZooKeeperServerpublic final ZooKeeperServer getZooKeeperServer() 
 - 
configurepublic void configure(InetSocketAddress addr, int maxcc) throws IOException - Throws:
- IOException
 
 - 
configurepublic void configure(InetSocketAddress addr, int maxcc, int backlog) throws IOException - Throws:
- IOException
 
 - 
configurepublic abstract void configure(InetSocketAddress addr, int maxcc, int backlog, boolean secure) throws IOException - Throws:
- IOException
 
 - 
reconfigurepublic abstract void reconfigure(InetSocketAddress addr) 
 - 
getMaxClientCnxnsPerHostpublic abstract int getMaxClientCnxnsPerHost() Maximum number of connections allowed from particular host (ip)
 - 
setMaxClientCnxnsPerHostpublic abstract void setMaxClientCnxnsPerHost(int max) Maximum number of connections allowed from particular host (ip)
 - 
isSecurepublic boolean isSecure() 
 - 
startuppublic void startup(ZooKeeperServer zkServer) throws IOException, InterruptedException - Throws:
- IOException
- InterruptedException
 
 - 
startuppublic abstract void startup(ZooKeeperServer zkServer, boolean startServer) throws IOException, InterruptedException - Throws:
- IOException
- InterruptedException
 
 - 
getSocketListenBacklogpublic abstract int getSocketListenBacklog() The maximum queue length of the ZooKeeper server's socket
 - 
joinpublic abstract void join() throws InterruptedException- Throws:
- InterruptedException
 
 - 
shutdownpublic abstract void shutdown() 
 - 
startpublic abstract void start() 
 - 
setZooKeeperServerpublic final void setZooKeeperServer(ZooKeeperServer zks) 
 - 
closeAllpublic abstract void closeAll(ServerCnxn.DisconnectReason reason) 
 - 
createFactorypublic static ServerCnxnFactory createFactory() throws IOException - Throws:
- IOException
 
 - 
createFactorypublic static ServerCnxnFactory createFactory(int clientPort, int maxClientCnxns) throws IOException - Throws:
- IOException
 
 - 
createFactorypublic static ServerCnxnFactory createFactory(int clientPort, int maxClientCnxns, int backlog) throws IOException - Throws:
- IOException
 
 - 
createFactorypublic static ServerCnxnFactory createFactory(InetSocketAddress addr, int maxClientCnxns) throws IOException - Throws:
- IOException
 
 - 
createFactorypublic static ServerCnxnFactory createFactory(InetSocketAddress addr, int maxClientCnxns, int backlog) throws IOException - Throws:
- IOException
 
 - 
getLocalAddresspublic abstract InetSocketAddress getLocalAddress() 
 - 
resetAllConnectionStatspublic abstract void resetAllConnectionStats() 
 - 
getAllConnectionInfopublic abstract Iterable<Map<String,Object>> getAllConnectionInfo(boolean brief) 
 - 
unregisterConnectionpublic void unregisterConnection(ServerCnxn serverCnxn) 
 - 
registerConnectionpublic void registerConnection(ServerCnxn serverCnxn) 
 - 
configureSaslLoginprotected void configureSaslLogin() throws IOExceptionInitialize 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:
- IOException- if jaas.conf is missing or there's an error in it.
 
 - 
getUserNamepublic static 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
 - 
getMaxCnxnspublic int getMaxCnxns() Maximum number of connections allowed in the ZooKeeper system
 - 
initMaxCnxnsprotected void initMaxCnxns() 
 - 
limitTotalNumberOfCnxnsprotected boolean limitTotalNumberOfCnxns() Ensure total number of connections are less than the maxCnxns
 
- 
 
-