Package org.apache.zookeeper.server
Class NIOServerCnxn
- java.lang.Object
-
- org.apache.zookeeper.server.ServerCnxn
-
- org.apache.zookeeper.server.NIOServerCnxn
-
- All Implemented Interfaces:
Watcher
public class NIOServerCnxn extends ServerCnxn
This class handles communication with clients using NIO. There is one per client, but only one thread doing the communication.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.zookeeper.server.ServerCnxn
ServerCnxn.CloseRequestException, ServerCnxn.EndOfStreamException
-
Nested classes/interfaces inherited from interface org.apache.zookeeper.Watcher
Watcher.Event
-
-
Field Summary
Fields Modifier and Type Field Description protected java.nio.channels.SelectionKeyskprotected ZooKeeperServerzkServer-
Fields inherited from class org.apache.zookeeper.server.ServerCnxn
authInfo, confCmd, consCmd, count, crstCmd, dumpCmd, enviCmd, established, getTraceMaskCmd, isroCmd, lastCxid, lastLatency, lastOp, lastResponseTime, lastZxid, maxLatency, me, minLatency, mntrCmd, packetsReceived, packetsSent, ruokCmd, setTraceMaskCmd, srstCmd, srvrCmd, statCmd, totalLatency, wchcCmd, wchpCmd, wchsCmd, zooKeeperSaslServer
-
-
Constructor Summary
Constructors Constructor Description NIOServerCnxn(ZooKeeperServer zk, java.nio.channels.SocketChannel sock, java.nio.channels.SelectionKey sk, NIOServerCnxnFactory factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voiddisableRecv()voidenableRecv()intgetInterestOps()longgetOutstandingRequests()java.net.InetSocketAddressgetRemoteSocketAddress()longgetSessionId()intgetSessionTimeout()java.net.InetAddressgetSocketAddress()Wrapper method to return the socket addressprotected voidincrOutstandingRequests(RequestHeader h)protected voidinternalSendBuffer(java.nio.ByteBuffer bb)This method implements the internals of sendBuffer.protected booleanisSocketOpen()Only used in order to allow testingvoidprocess(WatchedEvent event)voidsendBuffer(java.nio.ByteBuffer bb)voidsendCloseSession()voidsendResponse(ReplyHeader h, org.apache.jute.Record r, java.lang.String tag)protected ServerStatsserverStats()voidsetSessionId(long sessionId)voidsetSessionTimeout(int sessionTimeout)java.lang.StringtoString()Prints detailed stats information for the connection.-
Methods inherited from class org.apache.zookeeper.server.ServerCnxn
addAuthInfo, dumpConnectionInfo, getAuthInfo, getAvgLatency, getCommandString, getEstablished, getLastCxid, getLastLatency, getLastOperation, getLastResponseTime, getLastZxid, getMaxLatency, getMinLatency, getPacketsReceived, getPacketsSent, incrPacketsReceived, incrPacketsSent, isEnabled, isKnown, packetReceived, packetSent, removeAuthInfo, resetStats, resetWhiteList, updateStatsForResponse
-
-
-
-
Field Detail
-
sk
protected final java.nio.channels.SelectionKey sk
-
zkServer
protected final ZooKeeperServer zkServer
-
-
Constructor Detail
-
NIOServerCnxn
public NIOServerCnxn(ZooKeeperServer zk, java.nio.channels.SocketChannel sock, java.nio.channels.SelectionKey sk, NIOServerCnxnFactory factory) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
sendCloseSession
public void sendCloseSession()
-
sendBuffer
public void sendBuffer(java.nio.ByteBuffer bb)
-
internalSendBuffer
protected void internalSendBuffer(java.nio.ByteBuffer bb)
This method implements the internals of sendBuffer. We have separated it from send buffer to be able to catch exceptions when testing.- Parameters:
bb- Buffer to send.
-
isSocketOpen
protected boolean isSocketOpen()
Only used in order to allow testing
-
getSocketAddress
public java.net.InetAddress getSocketAddress()
Description copied from class:ServerCnxnWrapper method to return the socket address- Specified by:
getSocketAddressin classServerCnxn
-
incrOutstandingRequests
protected void incrOutstandingRequests(RequestHeader h)
- Overrides:
incrOutstandingRequestsin classServerCnxn
-
disableRecv
public void disableRecv()
-
enableRecv
public void enableRecv()
-
getOutstandingRequests
public long getOutstandingRequests()
- Specified by:
getOutstandingRequestsin classServerCnxn
-
getSessionTimeout
public int getSessionTimeout()
-
toString
public java.lang.String toString()
Description copied from class:ServerCnxnPrints detailed stats information for the connection.- Overrides:
toStringin classServerCnxn- See Also:
for brief stats
-
close
public void close()
-
sendResponse
public void sendResponse(ReplyHeader h, org.apache.jute.Record r, java.lang.String tag)
- Specified by:
sendResponsein classServerCnxn
-
process
public void process(WatchedEvent event)
- Specified by:
processin interfaceWatcher- Specified by:
processin classServerCnxn
-
getSessionId
public long getSessionId()
-
setSessionId
public void setSessionId(long sessionId)
-
setSessionTimeout
public void setSessionTimeout(int sessionTimeout)
-
getInterestOps
public int getInterestOps()
- Specified by:
getInterestOpsin classServerCnxn
-
getRemoteSocketAddress
public java.net.InetSocketAddress getRemoteSocketAddress()
- Specified by:
getRemoteSocketAddressin classServerCnxn
-
serverStats
protected ServerStats serverStats()
- Specified by:
serverStatsin classServerCnxn
-
-