Package org.apache.zookeeper.server
Class ServerCnxn
- java.lang.Object
-
- org.apache.zookeeper.server.ServerCnxn
-
- All Implemented Interfaces:
Watcher
- Direct Known Subclasses:
NettyServerCnxn
,NIOServerCnxn
public abstract class ServerCnxn extends java.lang.Object implements Watcher
Interface to a Server connection - represents a connection from a client to the server.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ServerCnxn.CloseRequestException
protected static class
ServerCnxn.EndOfStreamException
-
Nested classes/interfaces inherited from interface org.apache.zookeeper.Watcher
Watcher.Event
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<Id>
authInfo
protected static int
confCmd
protected static int
consCmd
protected long
count
protected static int
crstCmd
protected static int
dumpCmd
protected static int
enviCmd
protected java.util.Date
established
protected static int
getTraceMaskCmd
protected static int
isroCmd
protected long
lastCxid
protected long
lastLatency
protected java.lang.String
lastOp
protected long
lastResponseTime
protected long
lastZxid
protected long
maxLatency
static java.lang.Object
me
protected long
minLatency
protected static int
mntrCmd
protected java.util.concurrent.atomic.AtomicLong
packetsReceived
protected java.util.concurrent.atomic.AtomicLong
packetsSent
protected static int
ruokCmd
protected static int
setTraceMaskCmd
protected static int
srstCmd
protected static int
srvrCmd
protected static int
statCmd
protected long
totalLatency
protected static int
wchcCmd
protected static int
wchpCmd
protected static int
wchsCmd
protected ZooKeeperSaslServer
zooKeeperSaslServer
-
Constructor Summary
Constructors Constructor Description ServerCnxn()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addAuthInfo(Id id)
protected void
dumpConnectionInfo(java.io.PrintWriter pwriter, boolean brief)
Print information about the connection.java.util.List<Id>
getAuthInfo()
auth info for the cnxn, returns an unmodifyable listlong
getAvgLatency()
static java.lang.String
getCommandString(int command)
Return the string representation of the specified command code.java.util.Date
getEstablished()
abstract int
getInterestOps()
long
getLastCxid()
long
getLastLatency()
java.lang.String
getLastOperation()
long
getLastResponseTime()
long
getLastZxid()
long
getMaxLatency()
long
getMinLatency()
abstract long
getOutstandingRequests()
long
getPacketsReceived()
long
getPacketsSent()
abstract java.net.InetSocketAddress
getRemoteSocketAddress()
abstract java.net.InetAddress
getSocketAddress()
Wrapper method to return the socket addressprotected void
incrOutstandingRequests(RequestHeader h)
protected long
incrPacketsReceived()
protected long
incrPacketsSent()
static boolean
isEnabled(java.lang.String command)
Check if the specified command is enabled.static boolean
isKnown(int command)
Check if the specified command code is from a known command.protected void
packetReceived()
protected void
packetSent()
abstract void
process(WatchedEvent event)
boolean
removeAuthInfo(Id id)
void
resetStats()
static void
resetWhiteList()
abstract void
sendResponse(ReplyHeader h, org.apache.jute.Record r, java.lang.String tag)
protected abstract ServerStats
serverStats()
java.lang.String
toString()
Prints detailed stats information for the connection.protected void
updateStatsForResponse(long cxid, long zxid, java.lang.String op, long start, long end)
-
-
-
Field Detail
-
me
public static final java.lang.Object me
-
authInfo
protected java.util.ArrayList<Id> authInfo
-
zooKeeperSaslServer
protected ZooKeeperSaslServer zooKeeperSaslServer
-
confCmd
protected static final int confCmd
-
consCmd
protected static final int consCmd
-
crstCmd
protected static final int crstCmd
-
dumpCmd
protected static final int dumpCmd
-
enviCmd
protected static final int enviCmd
-
getTraceMaskCmd
protected static final int getTraceMaskCmd
-
ruokCmd
protected static final int ruokCmd
-
setTraceMaskCmd
protected static final int setTraceMaskCmd
-
srvrCmd
protected static final int srvrCmd
-
srstCmd
protected static final int srstCmd
-
statCmd
protected static final int statCmd
-
wchcCmd
protected static final int wchcCmd
-
wchpCmd
protected static final int wchpCmd
-
wchsCmd
protected static final int wchsCmd
-
mntrCmd
protected static final int mntrCmd
-
isroCmd
protected static final int isroCmd
-
established
protected final java.util.Date established
-
packetsReceived
protected final java.util.concurrent.atomic.AtomicLong packetsReceived
-
packetsSent
protected final java.util.concurrent.atomic.AtomicLong packetsSent
-
minLatency
protected long minLatency
-
maxLatency
protected long maxLatency
-
lastOp
protected java.lang.String 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
-
-
Method Detail
-
sendResponse
public abstract void sendResponse(ReplyHeader h, org.apache.jute.Record r, java.lang.String tag) throws java.io.IOException
- Throws:
java.io.IOException
-
process
public abstract void process(WatchedEvent event)
-
getAuthInfo
public java.util.List<Id> getAuthInfo()
auth info for the cnxn, returns an unmodifyable list
-
addAuthInfo
public void addAuthInfo(Id id)
-
removeAuthInfo
public boolean removeAuthInfo(Id id)
-
getSocketAddress
public abstract java.net.InetAddress getSocketAddress()
Wrapper method to return the socket address
-
resetWhiteList
public static void resetWhiteList()
-
getCommandString
public static java.lang.String getCommandString(int command)
Return the string representation of the specified command code.
-
isKnown
public static boolean isKnown(int command)
Check if the specified command code is from a known command.- Parameters:
command
- The integer code of command.- Returns:
- true if the specified command is known, false otherwise.
-
isEnabled
public static boolean isEnabled(java.lang.String command)
Check if the specified command is enabled. In ZOOKEEPER-2693 we introduce a configuration option to only allow a specific set of white listed commands to execute. A command will only be executed if it is also configured in the white list.- Parameters:
command
- The command string.- Returns:
- true if the specified command is enabled.
-
packetReceived
protected void packetReceived()
-
packetSent
protected void packetSent()
-
serverStats
protected abstract ServerStats serverStats()
-
resetStats
public void resetStats()
-
incrPacketsReceived
protected long incrPacketsReceived()
-
incrOutstandingRequests
protected void incrOutstandingRequests(RequestHeader h)
-
incrPacketsSent
protected long incrPacketsSent()
-
updateStatsForResponse
protected void updateStatsForResponse(long cxid, long zxid, java.lang.String op, long start, long end)
-
getEstablished
public java.util.Date getEstablished()
-
getOutstandingRequests
public abstract long getOutstandingRequests()
-
getPacketsReceived
public long getPacketsReceived()
-
getPacketsSent
public long getPacketsSent()
-
getMinLatency
public long getMinLatency()
-
getAvgLatency
public long getAvgLatency()
-
getMaxLatency
public long getMaxLatency()
-
getLastOperation
public java.lang.String getLastOperation()
-
getLastCxid
public long getLastCxid()
-
getLastZxid
public long getLastZxid()
-
getLastResponseTime
public long getLastResponseTime()
-
getLastLatency
public long getLastLatency()
-
toString
public java.lang.String toString()
Prints detailed stats information for the connection.- Overrides:
toString
in classjava.lang.Object
- See Also:
for brief stats
-
getRemoteSocketAddress
public abstract java.net.InetSocketAddress getRemoteSocketAddress()
-
getInterestOps
public abstract int getInterestOps()
-
dumpConnectionInfo
protected void dumpConnectionInfo(java.io.PrintWriter pwriter, boolean brief)
Print information about the connection.- Parameters:
brief
- iff true prints brief details, otw full detail
-
-