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 java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<ServerCnxn>
cnxns
Login
login
protected SaslServerCallbackHandler
saslServerCallbackHandler
protected boolean
secure
protected ZooKeeperServer
zkServer
static java.lang.String
ZOOKEEPER_SERVER_CNXN_FACTORY
-
Constructor Summary
Constructors Constructor Description ServerCnxnFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
closeAll()
abstract boolean
closeSession(long sessionId)
void
configure(java.net.InetSocketAddress addr, int maxcc)
abstract void
configure(java.net.InetSocketAddress addr, int maxcc, boolean secure)
protected void
configureSaslLogin()
Initialize the server SASL if specified.static ServerCnxnFactory
createFactory()
static ServerCnxnFactory
createFactory(int clientPort, int maxClientCnxns)
static ServerCnxnFactory
createFactory(java.net.InetSocketAddress addr, int maxClientCnxns)
abstract java.lang.Iterable<java.util.Map<java.lang.String,java.lang.Object>>
getAllConnectionInfo(boolean brief)
abstract java.lang.Iterable<ServerCnxn>
getConnections()
abstract java.net.InetSocketAddress
getLocalAddress()
abstract int
getLocalPort()
abstract int
getMaxClientCnxnsPerHost()
Maximum number of connections allowed from particular host (ip)int
getNumAliveConnections()
ZooKeeperServer
getZooKeeperServer()
boolean
isSecure()
abstract void
join()
abstract void
reconfigure(java.net.InetSocketAddress addr)
void
registerConnection(ServerCnxn serverCnxn)
abstract void
resetAllConnectionStats()
abstract void
setMaxClientCnxnsPerHost(int max)
Maximum number of connections allowed from particular host (ip)void
setZooKeeperServer(ZooKeeperServer zks)
abstract void
shutdown()
abstract void
start()
void
startup(ZooKeeperServer zkServer)
abstract void
startup(ZooKeeperServer zkServer, boolean startServer)
void
unregisterConnection(ServerCnxn serverCnxn)
-
-
-
Field Detail
-
ZOOKEEPER_SERVER_CNXN_FACTORY
public static final java.lang.String ZOOKEEPER_SERVER_CNXN_FACTORY
- See Also:
- Constant Field Values
-
secure
protected boolean secure
-
saslServerCallbackHandler
protected SaslServerCallbackHandler saslServerCallbackHandler
-
login
public Login login
-
zkServer
protected ZooKeeperServer zkServer
-
cnxns
protected final java.util.Set<ServerCnxn> cnxns
-
-
Method Detail
-
getLocalPort
public abstract int getLocalPort()
-
getConnections
public abstract java.lang.Iterable<ServerCnxn> getConnections()
-
getNumAliveConnections
public int getNumAliveConnections()
-
getZooKeeperServer
public ZooKeeperServer getZooKeeperServer()
-
closeSession
public abstract boolean closeSession(long sessionId)
- Returns:
- true if the cnxn that contains the sessionId exists in this ServerCnxnFactory and it's closed. Otherwise false.
-
configure
public void configure(java.net.InetSocketAddress addr, int maxcc) throws java.io.IOException
- Throws:
java.io.IOException
-
configure
public abstract void configure(java.net.InetSocketAddress addr, int maxcc, 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
-
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)
-
closeAll
public abstract void closeAll()
-
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(java.net.InetSocketAddress addr, int maxClientCnxns) 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.
-
-