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 classServerCnxn.CloseRequestExceptionprotected static classServerCnxn.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>authInfoprotected static intconfCmdprotected static intconsCmdprotected longcountprotected static intcrstCmdprotected static intdumpCmdprotected static intenviCmdprotected java.util.Dateestablishedprotected static intgetTraceMaskCmdprotected static intisroCmdprotected longlastCxidprotected longlastLatencyprotected java.lang.StringlastOpprotected longlastResponseTimeprotected longlastZxidprotected longmaxLatencystatic java.lang.Objectmeprotected longminLatencyprotected static intmntrCmdprotected java.util.concurrent.atomic.AtomicLongpacketsReceivedprotected java.util.concurrent.atomic.AtomicLongpacketsSentprotected static intruokCmdprotected static intsetTraceMaskCmdprotected static intsrstCmdprotected static intsrvrCmdprotected static intstatCmdprotected longtotalLatencyprotected static intwchcCmdprotected static intwchpCmdprotected static intwchsCmdprotected ZooKeeperSaslServerzooKeeperSaslServer
-
Constructor Summary
Constructors Constructor Description ServerCnxn()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddAuthInfo(Id id)protected voiddumpConnectionInfo(java.io.PrintWriter pwriter, boolean brief)Print information about the connection.java.util.List<Id>getAuthInfo()auth info for the cnxn, returns an unmodifyable listlonggetAvgLatency()static java.lang.StringgetCommandString(int command)Return the string representation of the specified command code.java.util.DategetEstablished()abstract intgetInterestOps()longgetLastCxid()longgetLastLatency()java.lang.StringgetLastOperation()longgetLastResponseTime()longgetLastZxid()longgetMaxLatency()longgetMinLatency()abstract longgetOutstandingRequests()longgetPacketsReceived()longgetPacketsSent()abstract java.net.InetSocketAddressgetRemoteSocketAddress()abstract java.net.InetAddressgetSocketAddress()Wrapper method to return the socket addressprotected voidincrOutstandingRequests(RequestHeader h)protected longincrPacketsReceived()protected longincrPacketsSent()static booleanisEnabled(java.lang.String command)Check if the specified command is enabled.static booleanisKnown(int command)Check if the specified command code is from a known command.protected voidpacketReceived()protected voidpacketSent()abstract voidprocess(WatchedEvent event)booleanremoveAuthInfo(Id id)voidresetStats()static voidresetWhiteList()abstract voidsendResponse(ReplyHeader h, org.apache.jute.Record r, java.lang.String tag)protected abstract ServerStatsserverStats()java.lang.StringtoString()Prints detailed stats information for the connection.protected voidupdateStatsForResponse(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:
toStringin 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
-
-