Class ControllableConnectionFactory
- java.lang.Object
-
- org.apache.zookeeper.server.ServerCnxnFactory
-
- org.apache.zookeeper.server.NIOServerCnxnFactory
-
- org.apache.zookeeper.server.controller.ControllableConnectionFactory
-
public class ControllableConnectionFactory extends NIOServerCnxnFactory
Extension of NIOServerCnxnFactory which can inject changes per controller commands. Similar extensions can implement on top of NettyServerCnxnFactory as well.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.zookeeper.server.NIOServerCnxnFactory
NIOServerCnxnFactory.SelectorThread
-
-
Field Summary
-
Fields inherited from class org.apache.zookeeper.server.NIOServerCnxnFactory
maxClientCnxns, workerPool, ZOOKEEPER_NIO_DIRECT_BUFFER_BYTES, ZOOKEEPER_NIO_NUM_SELECTOR_THREADS, ZOOKEEPER_NIO_NUM_WORKER_THREADS, ZOOKEEPER_NIO_SESSIONLESS_CNXN_TIMEOUT, ZOOKEEPER_NIO_SHUTDOWN_TIMEOUT
-
Fields inherited from class org.apache.zookeeper.server.ServerCnxnFactory
cnxns, login, maxCnxns, saslServerCallbackHandler, secure, zkServer, ZOOKEEPER_MAX_CONNECTION_DEFAULT, ZOOKEEPER_SERVER_CNXN_FACTORY
-
-
Constructor Summary
Constructors Constructor Description ControllableConnectionFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected NIOServerCnxn
createConnection(SocketChannel sock, SelectionKey sk, NIOServerCnxnFactory.SelectorThread selectorThread)
void
delayRequestIfNeeded()
Called by the connection to delay processing requests from the client.void
delayResponses(long delayInMs)
void
failAllFutureRequests()
void
failFutureRequests(long requestsToFail)
void
holdAllFutureResponses()
void
holdFutureResponses(long requestsToHold)
void
resetBadBehavior()
boolean
shouldFailNextRequest()
Check if we should fail the next incoming request.boolean
shouldSendResponse()
Check if we should send a response to the latest processed request (true), or eat the response to mess with the client (false).-
Methods inherited from class org.apache.zookeeper.server.NIOServerCnxnFactory
closeAll, configure, dumpConnections, getAllConnectionInfo, getConnections, getDirectBuffer, getLocalAddress, getLocalPort, getMaxClientCnxnsPerHost, getSocketListenBacklog, join, reconfigure, removeCnxn, resetAllConnectionStats, setMaxClientCnxnsPerHost, shutdown, start, startup, stop, touchCnxn
-
Methods inherited from class org.apache.zookeeper.server.ServerCnxnFactory
addSession, closeSession, configure, configure, configureSaslLogin, createFactory, createFactory, createFactory, createFactory, createFactory, getMaxCnxns, getNumAliveConnections, getUserName, getZooKeeperServer, initMaxCnxns, isSecure, limitTotalNumberOfCnxns, registerConnection, removeCnxnFromSessionMap, setZooKeeperServer, startup, unregisterConnection
-
-
-
-
Method Detail
-
createConnection
protected NIOServerCnxn createConnection(SocketChannel sock, SelectionKey sk, NIOServerCnxnFactory.SelectorThread selectorThread) throws IOException
- Overrides:
createConnection
in classNIOServerCnxnFactory
- Throws:
IOException
-
delayRequestIfNeeded
public void delayRequestIfNeeded()
Called by the connection to delay processing requests from the client.
-
shouldFailNextRequest
public boolean shouldFailNextRequest()
Check if we should fail the next incoming request. If so, decrement the remaining requests to fail.
-
shouldSendResponse
public boolean shouldSendResponse()
Check if we should send a response to the latest processed request (true), or eat the response to mess with the client (false). If so, decrement the remaining requests to eat.
-
delayResponses
public void delayResponses(long delayInMs)
-
resetBadBehavior
public void resetBadBehavior()
-
failAllFutureRequests
public void failAllFutureRequests()
-
failFutureRequests
public void failFutureRequests(long requestsToFail)
-
holdAllFutureResponses
public void holdAllFutureResponses()
-
holdFutureResponses
public void holdFutureResponses(long requestsToHold)
-
-