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.SelectionKey
sk
protected ZooKeeperServer
zkServer
-
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 void
close()
void
disableRecv()
void
enableRecv()
int
getInterestOps()
long
getOutstandingRequests()
java.net.InetSocketAddress
getRemoteSocketAddress()
long
getSessionId()
int
getSessionTimeout()
java.net.InetAddress
getSocketAddress()
Wrapper method to return the socket addressprotected void
incrOutstandingRequests(RequestHeader h)
protected void
internalSendBuffer(java.nio.ByteBuffer bb)
This method implements the internals of sendBuffer.protected boolean
isSocketOpen()
Only used in order to allow testingvoid
process(WatchedEvent event)
void
sendBuffer(java.nio.ByteBuffer bb)
void
sendCloseSession()
void
sendResponse(ReplyHeader h, org.apache.jute.Record r, java.lang.String tag)
protected ServerStats
serverStats()
void
setSessionId(long sessionId)
void
setSessionTimeout(int sessionTimeout)
java.lang.String
toString()
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:ServerCnxn
Wrapper method to return the socket address- Specified by:
getSocketAddress
in classServerCnxn
-
incrOutstandingRequests
protected void incrOutstandingRequests(RequestHeader h)
- Overrides:
incrOutstandingRequests
in classServerCnxn
-
disableRecv
public void disableRecv()
-
enableRecv
public void enableRecv()
-
getOutstandingRequests
public long getOutstandingRequests()
- Specified by:
getOutstandingRequests
in classServerCnxn
-
getSessionTimeout
public int getSessionTimeout()
-
toString
public java.lang.String toString()
Description copied from class:ServerCnxn
Prints detailed stats information for the connection.- Overrides:
toString
in 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:
sendResponse
in classServerCnxn
-
process
public void process(WatchedEvent event)
- Specified by:
process
in interfaceWatcher
- Specified by:
process
in classServerCnxn
-
getSessionId
public long getSessionId()
-
setSessionId
public void setSessionId(long sessionId)
-
setSessionTimeout
public void setSessionTimeout(int sessionTimeout)
-
getInterestOps
public int getInterestOps()
- Specified by:
getInterestOps
in classServerCnxn
-
getRemoteSocketAddress
public java.net.InetSocketAddress getRemoteSocketAddress()
- Specified by:
getRemoteSocketAddress
in classServerCnxn
-
serverStats
protected ServerStats serverStats()
- Specified by:
serverStats
in classServerCnxn
-
-