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 void
closeAll()
clear all the connections in the selectorvoid
closeSession(long sessionId)
void
configure(java.net.InetSocketAddress addr, int maxcc)
protected NIOServerCnxn
createConnection(java.nio.channels.SocketChannel sock, java.nio.channels.SelectionKey sk)
java.lang.Iterable<ServerCnxn>
getConnections()
java.net.InetSocketAddress
getLocalAddress()
int
getLocalPort()
int
getMaxClientCnxnsPerHost()
Maximum number of connections allowed from particular host (ip)void
join()
void
removeCnxn(NIOServerCnxn cnxn)
void
run()
void
setMaxClientCnxnsPerHost(int max)
Maximum number of connections allowed from particular host (ip)void
shutdown()
void
start()
void
startup(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.IOException
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). 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:
configure
in classServerCnxnFactory
- Throws:
java.io.IOException
-
getMaxClientCnxnsPerHost
public int getMaxClientCnxnsPerHost()
Maximum number of connections allowed from particular host (ip)- Specified by:
getMaxClientCnxnsPerHost
in classServerCnxnFactory
-
setMaxClientCnxnsPerHost
public void setMaxClientCnxnsPerHost(int max)
Maximum number of connections allowed from particular host (ip)- Specified by:
setMaxClientCnxnsPerHost
in classServerCnxnFactory
-
start
public void start()
- Specified by:
start
in classServerCnxnFactory
-
startup
public void startup(ZooKeeperServer zks) throws java.io.IOException, java.lang.InterruptedException
- Specified by:
startup
in classServerCnxnFactory
- Throws:
java.io.IOException
java.lang.InterruptedException
-
getLocalAddress
public java.net.InetSocketAddress getLocalAddress()
- Specified by:
getLocalAddress
in classServerCnxnFactory
-
getLocalPort
public int getLocalPort()
- Specified by:
getLocalPort
in 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:
run
in interfacejava.lang.Runnable
-
closeAll
public void closeAll()
clear all the connections in the selector- Specified by:
closeAll
in classServerCnxnFactory
-
shutdown
public void shutdown()
- Specified by:
shutdown
in classServerCnxnFactory
-
closeSession
public void closeSession(long sessionId)
- Specified by:
closeSession
in classServerCnxnFactory
-
join
public void join() throws java.lang.InterruptedException
- Specified by:
join
in classServerCnxnFactory
- Throws:
java.lang.InterruptedException
-
getConnections
public java.lang.Iterable<ServerCnxn> getConnections()
- Specified by:
getConnections
in classServerCnxnFactory
-
-