Package org.apache.zookeeper.server
Class ServerCnxnFactory
java.lang.Object
org.apache.zookeeper.server.ServerCnxnFactory
- Direct Known Subclasses:
NettyServerCnxnFactory,NIOServerCnxnFactory
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Set<ServerCnxn>protected intprotected SaslServerCallbackHandlerprotected booleanprotected ZooKeeperServerstatic final intstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSession(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 voidInitialize the server SASL if specified.static ServerCnxnFactorystatic 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) getAllConnectionInfo(boolean brief) abstract Iterable<ServerCnxn>abstract InetSocketAddressabstract intabstract intMaximum number of connections allowed from particular host (ip)intMaximum number of connections allowed in the ZooKeeper systemintabstract intThe maximum queue length of the ZooKeeper server's socketstatic StringUser who has started the ZooKeeper server user, it will be the logged-in user.final ZooKeeperServerprotected voidbooleanisSecure()abstract voidjoin()protected booleanEnsure total number of connections are less than the maxCnxnsabstract voidreconfigure(InetSocketAddress addr) voidregisterConnection(ServerCnxn serverCnxn) voidabstract voidabstract voidsetMaxClientCnxnsPerHost(int max) Maximum number of connections allowed from particular host (ip)final voidabstract voidshutdown()abstract voidstart()voidstartup(ZooKeeperServer zkServer) abstract voidstartup(ZooKeeperServer zkServer, boolean startServer) voidunregisterConnection(ServerCnxn serverCnxn)
-
Field Details
-
ZOOKEEPER_SERVER_CNXN_FACTORY
- See Also:
-
ZOOKEEPER_MAX_CONNECTION_DEFAULT
public static final int ZOOKEEPER_MAX_CONNECTION_DEFAULT- See Also:
-
secure
protected boolean secure -
maxCnxns
protected int maxCnxns -
saslServerCallbackHandler
-
login
-
zkServer
-
cnxns
-
-
Constructor Details
-
ServerCnxnFactory
public ServerCnxnFactory()
-
-
Method Details
-
addSession
-
removeCnxnFromSessionMap
-
closeSession
- 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
-
getNumAliveConnections
public int getNumAliveConnections() -
getZooKeeperServer
-
configure
- Throws:
IOException
-
configure
- Throws:
IOException
-
configure
public abstract void configure(InetSocketAddress addr, int maxcc, int backlog, boolean secure) throws IOException - Throws:
IOException
-
reconfigure
-
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
- Throws:
IOExceptionInterruptedException
-
startup
public abstract void startup(ZooKeeperServer zkServer, boolean startServer) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
getSocketListenBacklog
public abstract int getSocketListenBacklog()The maximum queue length of the ZooKeeper server's socket -
join
- Throws:
InterruptedException
-
shutdown
public abstract void shutdown() -
start
public abstract void start() -
setZooKeeperServer
-
closeAll
-
createFactory
- Throws:
IOException
-
createFactory
public static ServerCnxnFactory createFactory(int clientPort, int maxClientCnxns) throws IOException - Throws:
IOException
-
createFactory
public static ServerCnxnFactory createFactory(int clientPort, int maxClientCnxns, int backlog) throws IOException - Throws:
IOException
-
createFactory
public static ServerCnxnFactory createFactory(InetSocketAddress addr, int maxClientCnxns) throws IOException - Throws:
IOException
-
createFactory
public static ServerCnxnFactory createFactory(InetSocketAddress addr, int maxClientCnxns, int backlog) throws IOException - Throws:
IOException
-
getLocalAddress
-
resetAllConnectionStats
public abstract void resetAllConnectionStats() -
getAllConnectionInfo
-
unregisterConnection
-
registerConnection
-
configureSaslLogin
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:
IOException- if jaas.conf is missing or there's an error in it.
-
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
-