Package org.apache.zookeeper.server
Class NIOServerCnxnFactory
- java.lang.Object
-
- org.apache.zookeeper.server.ServerCnxnFactory
-
- org.apache.zookeeper.server.NIOServerCnxnFactory
-
- All Implemented Interfaces:
java.lang.Runnable
public class NIOServerCnxnFactory extends ServerCnxnFactory implements java.lang.Runnable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.zookeeper.server.ServerCnxnFactory
ServerCnxnFactory.PacketProcessor
-
-
Field Summary
-
Fields inherited from class org.apache.zookeeper.server.ServerCnxnFactory
cnxns, login, saslServerCallbackHandler, sessionMap, zkServer, ZOOKEEPER_SERVER_CNXN_FACTORY
-
-
Constructor Summary
Constructors Constructor Description NIOServerCnxnFactory()Construct a new server connection factory which will accept an unlimited number of concurrent connections from each client (up to the file descriptor limits of the operating system).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseAll()clear all the connections in the selectorvoidcloseSession(long sessionId)voidconfigure(java.net.InetSocketAddress addr, int maxcc)protected NIOServerCnxncreateConnection(java.nio.channels.SocketChannel sock, java.nio.channels.SelectionKey sk)java.lang.Iterable<ServerCnxn>getConnections()java.net.InetSocketAddressgetLocalAddress()intgetLocalPort()intgetMaxClientCnxnsPerHost()Maximum number of connections allowed from particular host (ip)voidjoin()voidremoveCnxn(NIOServerCnxn cnxn)voidrun()voidsetMaxClientCnxnsPerHost(int max)Maximum number of connections allowed from particular host (ip)voidshutdown()voidstart()voidstartup(ZooKeeperServer zks)-
Methods inherited from class org.apache.zookeeper.server.ServerCnxnFactory
addSession, configureSaslLogin, createFactory, createFactory, createFactory, getNumAliveConnections, registerConnection, setZooKeeperServer, unregisterConnection
-
-
-
-
Constructor Detail
-
NIOServerCnxnFactory
public NIOServerCnxnFactory() throws java.io.IOExceptionConstruct a new server connection factory which will accept an unlimited number of concurrent connections from each client (up to the file descriptor limits of the operating system). startup(zks) must be called subsequently.- Throws:
java.io.IOException
-
-
Method Detail
-
configure
public void configure(java.net.InetSocketAddress addr, int maxcc) throws java.io.IOException- Specified by:
configurein classServerCnxnFactory- Throws:
java.io.IOException
-
getMaxClientCnxnsPerHost
public int getMaxClientCnxnsPerHost()
Maximum number of connections allowed from particular host (ip)- Specified by:
getMaxClientCnxnsPerHostin classServerCnxnFactory
-
setMaxClientCnxnsPerHost
public void setMaxClientCnxnsPerHost(int max)
Maximum number of connections allowed from particular host (ip)- Specified by:
setMaxClientCnxnsPerHostin classServerCnxnFactory
-
start
public void start()
- Specified by:
startin classServerCnxnFactory
-
startup
public void startup(ZooKeeperServer zks) throws java.io.IOException, java.lang.InterruptedException
- Specified by:
startupin classServerCnxnFactory- Throws:
java.io.IOExceptionjava.lang.InterruptedException
-
getLocalAddress
public java.net.InetSocketAddress getLocalAddress()
- Specified by:
getLocalAddressin classServerCnxnFactory
-
getLocalPort
public int getLocalPort()
- Specified by:
getLocalPortin classServerCnxnFactory
-
removeCnxn
public void removeCnxn(NIOServerCnxn cnxn)
-
createConnection
protected NIOServerCnxn createConnection(java.nio.channels.SocketChannel sock, java.nio.channels.SelectionKey sk) throws java.io.IOException
- Throws:
java.io.IOException
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
closeAll
public void closeAll()
clear all the connections in the selector- Specified by:
closeAllin classServerCnxnFactory
-
shutdown
public void shutdown()
- Specified by:
shutdownin classServerCnxnFactory
-
closeSession
public void closeSession(long sessionId)
- Specified by:
closeSessionin classServerCnxnFactory
-
join
public void join() throws java.lang.InterruptedException- Specified by:
joinin classServerCnxnFactory- Throws:
java.lang.InterruptedException
-
getConnections
public java.lang.Iterable<ServerCnxn> getConnections()
- Specified by:
getConnectionsin classServerCnxnFactory
-
-