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, Watcher.WatcherType
-
-
Field Summary
-
Fields inherited from class org.apache.zookeeper.server.ServerCnxn
authInfo, count, established, lastCxid, lastLatency, lastOp, lastResponseTime, lastZxid, maxLatency, me, minLatency, packetsReceived, packetsSent, totalLatency, zooKeeperSaslServer
-
-
Constructor Summary
Constructors Constructor Description NIOServerCnxn(ZooKeeperServer zk, java.nio.channels.SocketChannel sock, java.nio.channels.SelectionKey sk, NIOServerCnxnFactory factory, org.apache.zookeeper.server.NIOServerCnxnFactory.SelectorThread selectorThread)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the cnxn and remove it from the factory cnxns list.static void
closeSock(java.nio.channels.SocketChannel sock)
Close resources associated with a sock.void
disableRecv()
void
disableSelectable()
void
enableRecv()
void
enableSelectable()
java.security.cert.Certificate[]
getClientCertificateChain()
int
getInterestOps()
long
getOutstandingRequests()
java.net.InetSocketAddress
getRemoteSocketAddress()
long
getSessionId()
int
getSessionTimeout()
java.net.InetAddress
getSocketAddress()
protected void
incrOutstandingRequests(org.apache.zookeeper.proto.RequestHeader h)
boolean
isSecure()
boolean
isSelectable()
protected boolean
isSocketOpen()
Only used in order to allow testingvoid
process(WatchedEvent event)
void
sendBuffer(java.nio.ByteBuffer bb)
sendBuffer pushes a byte buffer onto the outgoing buffer queue for asynchronous writes.void
sendCloseSession()
void
sendResponse(org.apache.zookeeper.proto.ReplyHeader h, org.apache.jute.Record r, java.lang.String tag)
protected ServerStats
serverStats()
void
setClientCertificateChain(java.security.cert.Certificate[] chain)
void
setSessionId(long sessionId)
void
setSessionTimeout(int sessionTimeout)
java.lang.String
toString()
Used by "dump" 4-letter command to list all connection in cnxnExpiryMap-
Methods inherited from class org.apache.zookeeper.server.ServerCnxn
addAuthInfo, cleanupWriterSocket, dumpConnectionInfo, getAuthInfo, getAvgLatency, getConnectionInfo, getEstablished, getLastCxid, getLastLatency, getLastOperation, getLastResponseTime, getLastZxid, getMaxLatency, getMinLatency, getPacketsReceived, getPacketsSent, incrPacketsReceived, incrPacketsSent, packetReceived, packetSent, removeAuthInfo, resetStats, updateStatsForResponse
-
-
-
-
Constructor Detail
-
NIOServerCnxn
public NIOServerCnxn(ZooKeeperServer zk, java.nio.channels.SocketChannel sock, java.nio.channels.SelectionKey sk, NIOServerCnxnFactory factory, org.apache.zookeeper.server.NIOServerCnxnFactory.SelectorThread selectorThread) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
sendCloseSession
public void sendCloseSession()
-
sendBuffer
public void sendBuffer(java.nio.ByteBuffer bb)
sendBuffer pushes a byte buffer onto the outgoing buffer queue for asynchronous writes.
-
isSelectable
public boolean isSelectable()
-
disableSelectable
public void disableSelectable()
-
enableSelectable
public void enableSelectable()
-
isSocketOpen
protected boolean isSocketOpen()
Only used in order to allow testing
-
incrOutstandingRequests
protected void incrOutstandingRequests(org.apache.zookeeper.proto.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()
Used by "dump" 4-letter command to list all connection in cnxnExpiryMap- Overrides:
toString
in classServerCnxn
- See Also:
for brief stats
-
close
public void close()
Close the cnxn and remove it from the factory cnxns list.
-
closeSock
public static void closeSock(java.nio.channels.SocketChannel sock)
Close resources associated with a sock.
-
sendResponse
public void sendResponse(org.apache.zookeeper.proto.ReplyHeader h, org.apache.jute.Record r, java.lang.String tag)
- Overrides:
sendResponse
in classServerCnxn
-
process
public void process(WatchedEvent event)
- Specified by:
process
in interfaceWatcher
- Specified by:
process
in classServerCnxn
-
getSessionId
public long getSessionId()
- Specified by:
getSessionId
in classServerCnxn
-
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
-
getSocketAddress
public java.net.InetAddress getSocketAddress()
-
serverStats
protected ServerStats serverStats()
- Specified by:
serverStats
in classServerCnxn
-
isSecure
public boolean isSecure()
- Specified by:
isSecure
in classServerCnxn
-
getClientCertificateChain
public java.security.cert.Certificate[] getClientCertificateChain()
- Specified by:
getClientCertificateChain
in classServerCnxn
-
setClientCertificateChain
public void setClientCertificateChain(java.security.cert.Certificate[] chain)
- Specified by:
setClientCertificateChain
in classServerCnxn
-
-