Class 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.
    • Field Detail

      • me

        public static final java.lang.Object me
      • authInfo

        protected java.util.ArrayList<Id> authInfo
      • 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
    • Constructor Detail

      • ServerCnxn

        public ServerCnxn()
    • 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
      • 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 class java.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