Package org.apache.zookeeper.server
Class ServerCnxn
java.lang.Object
org.apache.zookeeper.server.ServerCnxn
- All Implemented Interfaces:
ServerWatcher
,Watcher
- Direct Known Subclasses:
DumbWatcher
,NettyServerCnxn
,NIOServerCnxn
Interface to a Server connection - represents a connection from a client
to the server.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static enum
protected static class
Nested classes/interfaces inherited from interface org.apache.zookeeper.Watcher
Watcher.Event, Watcher.WatcherType
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected long
protected ServerCnxn.DisconnectReason
protected final Date
protected long
protected long
protected String
protected long
protected long
protected long
static final Object
protected long
protected final AtomicLong
protected final AtomicLong
protected long
protected ZooKeeperSaslServer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAuthInfo
(Id id) void
cleanupWriterSocket
(PrintWriter pwriter) clean up the socket related to a command and also make sure we flush the data before we do thatabstract void
close
(ServerCnxn.DisconnectReason reason) void
void
dumpConnectionInfo
(PrintWriter pwriter, boolean brief) Print information about the connection.auth info for the cnxn, returns an unmodifyable listlong
abstract Certificate[]
getConnectionInfo
(boolean brief) Returns the IP address or empty string.abstract int
long
long
long
long
long
long
long
long
long
abstract InetSocketAddress
abstract long
Get session id in hexadecimal notation.void
protected long
protected long
boolean
abstract boolean
isSecure()
boolean
isStale()
boolean
protected void
packetReceived
(long bytes) protected void
void
process
(WatchedEvent event) abstract void
process
(WatchedEvent event, List<ACL> znodeAcl) boolean
removeAuthInfo
(Id id) void
abstract void
int
sendResponse
(ReplyHeader h, Record r, String tag) abstract int
sendResponse
(ReplyHeader h, Record r, String tag, String cacheKey, Stat stat, int opCode) Serializes a ZooKeeper response and enqueues it for sending.protected ByteBuffer[]
protected byte[]
serializeRecord
(Record record) protected abstract ServerStats
abstract void
setClientCertificateChain
(Certificate[] chain) void
void
setStale()
toString()
Prints detailed stats information for the connection.protected void
updateStatsForResponse
(long cxid, long zxid, String op, long start, long end)
-
Field Details
-
me
-
zooKeeperSaslServer
-
established
-
packetsReceived
-
packetsSent
-
minLatency
protected long minLatency -
maxLatency
protected long maxLatency -
lastOp
-
lastCxid
protected long lastCxid -
lastZxid
protected long lastZxid -
lastResponseTime
protected long lastResponseTime -
lastLatency
protected long lastLatency -
count
protected long count -
totalLatency
protected long totalLatency -
disconnectReason
-
-
Constructor Details
-
ServerCnxn
-
-
Method Details
-
incrOutstandingAndCheckThrottle
-
decrOutstandingAndCheckThrottle
-
close
-
sendResponse
public abstract int sendResponse(ReplyHeader h, Record r, String tag, String cacheKey, Stat stat, int opCode) throws IOException Serializes a ZooKeeper response and enqueues it for sending. Serializes client response parts and enqueues them into outgoing queue. If both cache key and last modified zxid are provided, the serialized response is caŃhed under the provided key, the last modified zxid is stored along with the value. A cache entry is invalidated if the provided last modified zxid is more recent than the stored one. Attention: this function is not thread safe, due to caching not being thread safe.- Parameters:
h
- reply headerr
- reply payload, can be nulltag
- Jute serialization tag, can be nullcacheKey
- Key for caching the serialized payload. A null value prevents caching.stat
- Stat information for the the reply payload, used for cache invalidation. A value of 0 prevents caching.opCode
- The op code appertains to the corresponding request of the response, used to decide which cache (e.g. read response cache, list of children response cache, ...) object to look up to when applicable.- Throws:
IOException
-
sendResponse
- Throws:
IOException
-
serializeRecord
- Throws:
IOException
-
serialize
protected ByteBuffer[] serialize(ReplyHeader h, Record r, String tag, String cacheKey, Stat stat, int opCode) throws IOException - Throws:
IOException
-
sendCloseSession
public abstract void sendCloseSession() -
process
-
process
- Specified by:
process
in interfaceServerWatcher
-
getSessionId
public abstract long getSessionId() -
getAuthInfo
auth info for the cnxn, returns an unmodifyable list -
addAuthInfo
-
removeAuthInfo
-
isStale
public boolean isStale() -
setStale
public void setStale() -
isInvalid
public boolean isInvalid() -
setInvalid
public void setInvalid() -
packetReceived
protected void packetReceived(long bytes) -
packetSent
protected void packetSent() -
serverStats
-
resetStats
public void resetStats() -
incrPacketsReceived
protected long incrPacketsReceived() -
incrPacketsSent
protected long incrPacketsSent() -
updateStatsForResponse
-
getEstablished
-
getOutstandingRequests
public long getOutstandingRequests() -
getPacketsReceived
public long getPacketsReceived() -
getPacketsSent
public long getPacketsSent() -
getMinLatency
public long getMinLatency() -
getAvgLatency
public long getAvgLatency() -
getMaxLatency
public long getMaxLatency() -
getLastOperation
-
getLastCxid
public long getLastCxid() -
getLastZxid
public long getLastZxid() -
getLastResponseTime
public long getLastResponseTime() -
getLastLatency
public long getLastLatency() -
toString
Prints detailed stats information for the connection. -
getRemoteSocketAddress
-
getInterestOps
public abstract int getInterestOps() -
isSecure
public abstract boolean isSecure() -
getClientCertificateChain
-
setClientCertificateChain
-
dumpConnectionInfo
Print information about the connection.- Parameters:
brief
- iff true prints brief details, otw full detail
-
getConnectionInfo
-
cleanupWriterSocket
clean up the socket related to a command and also make sure we flush the data before we do that- Parameters:
pwriter
- the pwriter for a command socket
-
isZKServerRunning
public boolean isZKServerRunning()- Returns:
- true if the server is running, false otherwise.
-
getHostAddress
Returns the IP address or empty string. -
getSessionIdHex
Get session id in hexadecimal notation.
-