Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   //
   //  ========================================================================
   //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
   //  ------------------------------------------------------------------------
   //  All rights reserved. This program and the accompanying materials
   //  are made available under the terms of the Eclipse Public License v1.0
   //  and Apache License v2.0 which accompanies this distribution.
   //
   //      The Eclipse Public License is available at
  //      http://www.eclipse.org/legal/epl-v10.html
  //
  //      The Apache License v2.0 is available at
  //      http://www.opensource.org/licenses/apache2.0.php
  //
  //  You may elect to redistribute this code under either of these licenses.
  //  ========================================================================
  //
  
  package org.eclipse.jetty.server;
  
  import java.net.Socket;
  
  
Abstract Connector implementation. This abstract implementation of the Connector interface provides:
  • AbstractLifeCycle implementation
  • Implementations for connector getters and setters
  • Buffer management
  • Socket configuration
  • Base acceptor thread
  • Optional reverse proxy headers checking
  
  public abstract class AbstractConnector extends AggregateLifeCycle implements HttpBuffersConnectorDumpable
  {
      private static final Logger LOG = Log.getLogger(AbstractConnector.class);
  
      private String _name;
  
      private Server _server;
      private ThreadPool _threadPool;
      private String _host;
      private int _port = 0;
      private String _integralScheme = .;
      private int _integralPort = 0;
      private String _confidentialScheme = .;
      private int _confidentialPort = 0;
      private int _acceptQueueSize = 0;
      private int _acceptors = 1;
      private int _acceptorPriorityOffset = 0;
      private boolean _useDNS;
      private boolean _forwarded;
      private String _hostHeader;
  
      private String _forwardedCipherSuiteHeader;
      private String _forwardedSslSessionIdHeader;
      private boolean _reuseAddress = true;
  
      protected int _maxIdleTime = 200000;
      protected int _lowResourceMaxIdleTime = -1;
      protected int _soLingerTime = -1;
  
      private transient Thread[] _acceptorThreads;
  
      private final AtomicLong _statsStartedAt = new AtomicLong(-1L);

    
connections to server
  
      private final CounterStatistic _connectionStats = new CounterStatistic();
    
requests per connection
  
      private final SampleStatistic _requestStats = new SampleStatistic();
    
duration of a connection
  
     private final SampleStatistic _connectionDurationStats = new SampleStatistic();
 
     protected final HttpBuffersImpl _buffers = new HttpBuffersImpl();
 
     /* ------------------------------------------------------------ */
    
 
     public AbstractConnector()
     {
         addBean();
     }
 
     /* ------------------------------------------------------------ */
     /*
      */
     public Server getServer()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
     public void setServer(Server server)
     {
          = server;
     }
 
     /* ------------------------------------------------------------ */
     public ThreadPool getThreadPool()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    
Set the ThreadPool. The threadpool passed is added via org.eclipse.jetty.util.component.AggregateLifeCycle.addBean(java.lang.Object) so that it's lifecycle may be managed as a org.eclipse.jetty.util.component.AggregateLifeCycle.

Parameters:
pool the threadPool to set
 
     public void setThreadPool(ThreadPool pool)
     {
         removeBean();
          = pool;
         addBean();
     }
 
     /* ------------------------------------------------------------ */
    
 
     public void setHost(String host)
     {
          = host;
     }
 
     /* ------------------------------------------------------------ */
     /*
      */
     public String getHost()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
     public void setPort(int port)
     {
          = port;
     }
 
     /* ------------------------------------------------------------ */
     public int getPort()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
Returns the maxIdleTime.
 
     public int getMaxIdleTime()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    
Set the maximum Idle time for a connection, which roughly translates to the java.net.Socket.setSoTimeout(int) call, although with NIO implementations other mechanisms may be used to implement the timeout. The max idle time is applied:
  • When waiting for a new request to be received on a connection
  • When reading the headers and content of a request
  • When writing the headers and content of a response
Jetty interprets this value as the maximum time between some progress being made on the connection. So if a single byte is read or written, then the timeout (if implemented by jetty) is reset. However, in many instances, the reading/writing is delegated to the JVM, and the semantic is more strictly enforced as the maximum time a single read/write operation can take. Note, that as Jetty supports writes of memory mapped file buffers, then a write may take many 10s of seconds for large content written to a slow device.

Previously, Jetty supported separate idle timeouts and IO operation timeouts, however the expense of changing the value of soTimeout was significant, so these timeouts were merged. With the advent of NIO, it may be possible to again differentiate these values (if there is demand).

Parameters:
maxIdleTime The maxIdleTime to set.
 
     public void setMaxIdleTime(int maxIdleTime)
     {
          = maxIdleTime;
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
Returns the maxIdleTime when resources are low.
 
     public int getLowResourcesMaxIdleTime()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
maxIdleTime The maxIdleTime to set when resources are low.
 
     public void setLowResourcesMaxIdleTime(int maxIdleTime)
     {
          = maxIdleTime;
     }
 
     /* ------------------------------------------------------------ */
    

Deprecated:
Returns:
Returns the maxIdleTime when resources are low.
 
     @Deprecated
     public final int getLowResourceMaxIdleTime()
     {
         return getLowResourcesMaxIdleTime();
     }
 
     /* ------------------------------------------------------------ */
    

Deprecated:
Parameters:
maxIdleTime The maxIdleTime to set when resources are low.
 
     @Deprecated
     public final void setLowResourceMaxIdleTime(int maxIdleTime)
     {
         setLowResourcesMaxIdleTime(maxIdleTime);
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
Returns the soLingerTime.
 
     public int getSoLingerTime()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
Returns the acceptQueueSize.
 
     public int getAcceptQueueSize()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
acceptQueueSize The acceptQueueSize to set.
 
     public void setAcceptQueueSize(int acceptQueueSize)
     {
          = acceptQueueSize;
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
Returns the number of acceptor threads.
 
     public int getAcceptors()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
acceptors The number of acceptor threads to set.
 
     public void setAcceptors(int acceptors)
     {
         if (acceptors > 2 * Runtime.getRuntime().availableProcessors())
             .warn("Acceptors should be <=2*availableProcessors: " + this);
          = acceptors;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
soLingerTime The soLingerTime to set or -1 to disable.
 
     public void setSoLingerTime(int soLingerTime)
     {
          = soLingerTime;
     }
 
     /* ------------------------------------------------------------ */
     @Override
     protected void doStart() throws Exception
     {
         if ( == null)
             throw new IllegalStateException("No server");
 
         // open listener port
         open();
 
         if ( == null)
         {
              = .getThreadPool();
             addBean(,false);
         }
 
         super.doStart();
 
         // Start selector thread
         synchronized (this)
         {
              = new Thread[getAcceptors()];
 
             for (int i = 0; i < .i++)
                 if (!.dispatch(new Acceptor(i)))
                     throw new IllegalStateException("!accepting");
             if (.isLowOnThreads())
                 .warn("insufficient threads configured for {}",this);
         }
 
         .info("Started {}",this);
     }
 
     /* ------------------------------------------------------------ */
     @Override
     protected void doStop() throws Exception
     {
         try
         {
             close();
         }
         catch (IOException e)
         {
             .warn(e);
         }
 
         super.doStop();
 
         Thread[] acceptors;
         synchronized (this)
         {
             acceptors = ;
              = null;
         }
         if (acceptors != null)
         {
             for (Thread thread : acceptors)
             {
                 if (thread != null)
                     thread.interrupt();
             }
         }
     }
 
     /* ------------------------------------------------------------ */
     public void join() throws InterruptedException
     {
         Thread[] threads;
         synchronized(this)
         {
             threads=;
         }
         if (threads != null)
             for (Thread thread : threads)
                 if (thread != null)
                     thread.join();
     }
 
     /* ------------------------------------------------------------ */
     protected void configure(Socket socketthrows IOException
     {
         try
         {
             socket.setTcpNoDelay(true);
             if ( >= 0)
                 socket.setSoLinger(true, / 1000);
             else
                 socket.setSoLinger(false,0);
         }
         catch (Exception e)
         {
             .ignore(e);
         }
     }
 
     /* ------------------------------------------------------------ */
     public void customize(EndPoint endpointRequest requestthrows IOException
     {
         if (isForwarded())
             checkForwardedHeaders(endpoint,request);
     }
 
     /* ------------------------------------------------------------ */
     protected void checkForwardedHeaders(EndPoint endpointRequest requestthrows IOException
     {
         HttpFields httpFields = request.getConnection().getRequestFields();
 
         // Do SSL first
         if (getForwardedCipherSuiteHeader()!=null)
         {
             String cipher_suite=httpFields.getStringField(getForwardedCipherSuiteHeader());
             if (cipher_suite!=null)
                 request.setAttribute("javax.servlet.request.cipher_suite",cipher_suite);
         }
         if (getForwardedSslSessionIdHeader()!=null)
         {
             String ssl_session_id=httpFields.getStringField(getForwardedSslSessionIdHeader());
             if(ssl_session_id!=null)
             {
                 request.setAttribute("javax.servlet.request.ssl_session_id"ssl_session_id);
                 request.setScheme(.);
             }
         }
 
         // Retrieving headers from the request
         String forwardedHost = getLeftMostFieldValue(httpFields,getForwardedHostHeader());
         String forwardedServer = getLeftMostFieldValue(httpFields,getForwardedServerHeader());
         String forwardedFor = getLeftMostFieldValue(httpFields,getForwardedForHeader());
         String forwardedProto = getLeftMostFieldValue(httpFields,getForwardedProtoHeader());
 
         if ( != null)
         {
             // Update host header
             httpFields.put(.,);
             request.setServerName(null);
             request.setServerPort(-1);
             request.getServerName();
         }
         else if (forwardedHost != null)
         {
             // Update host header
             httpFields.put(.,forwardedHost);
             request.setServerName(null);
             request.setServerPort(-1);
             request.getServerName();
         }
         else if (forwardedServer != null)
         {
             // Use provided server name
             request.setServerName(forwardedServer);
         }
 
         if (forwardedFor != null)
         {
             request.setRemoteAddr(forwardedFor);
             InetAddress inetAddress = null;
 
             if ()
             {
                 try
                 {
                     inetAddress = InetAddress.getByName(forwardedFor);
                 }
                 catch (UnknownHostException e)
                 {
                     .ignore(e);
                 }
             }
 
             request.setRemoteHost(inetAddress == null?forwardedFor:inetAddress.getHostName());
         }
 
         if (forwardedProto != null)
         {
             request.setScheme(forwardedProto);
         }
     }
 
     /* ------------------------------------------------------------ */
     protected String getLeftMostFieldValue(HttpFields fieldsString header)
     {
         if (header == null)
             return null;
 
         String headerValue = fields.getStringField(header);
 
         if (headerValue == null)
             return null;
 
         int commaIndex = headerValue.indexOf(',');
 
         if (commaIndex == -1)
         {
             // Single value
             return headerValue;
         }
 
         // The left-most value is the farthest downstream client
         return headerValue.substring(0,commaIndex);
     }
 
     /* ------------------------------------------------------------ */
     public void persist(EndPoint endpointthrows IOException
     {
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see org.eclipse.jetty.server.Connector#getConfidentialPort()
      */
     public int getConfidentialPort()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
     /* ------------------------------------------------------------ */
     /*
      * @see org.eclipse.jetty.server.Connector#getConfidentialScheme()
      */
     public String getConfidentialScheme()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see org.eclipse.jetty.server.Connector#isConfidential(org.eclipse.jetty.server .Request)
      */
     public boolean isIntegral(Request request)
     {
         return false;
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see org.eclipse.jetty.server.Connector#getConfidentialPort()
      */
     public int getIntegralPort()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see org.eclipse.jetty.server.Connector#getIntegralScheme()
      */
     public String getIntegralScheme()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see org.eclipse.jetty.server.Connector#isConfidential(org.eclipse.jetty.server.Request)
      */
     public boolean isConfidential(Request request)
     {
         return  && request.getScheme().equalsIgnoreCase(.);
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
confidentialPort The confidentialPort to set.
 
     public void setConfidentialPort(int confidentialPort)
     {
          = confidentialPort;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
confidentialScheme The confidentialScheme to set.
 
     public void setConfidentialScheme(String confidentialScheme)
     {
          = confidentialScheme;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
integralPort The integralPort to set.
 
     public void setIntegralPort(int integralPort)
     {
          = integralPort;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
integralScheme The integralScheme to set.
 
     public void setIntegralScheme(String integralScheme)
     {
          = integralScheme;
     }
 
     /* ------------------------------------------------------------ */
     protected abstract void accept(int acceptorIDthrows IOExceptionInterruptedException;
 
     /* ------------------------------------------------------------ */
     public void stopAccept(int acceptorIDthrows Exception
     {
     }
 
     /* ------------------------------------------------------------ */
     public boolean getResolveNames()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
     public void setResolveNames(boolean resolve)
     {
          = resolve;
     }
 
     /* ------------------------------------------------------------ */
    
Is reverse proxy handling on?

Returns:
true if this connector is checking the x-forwarded-for/host/server headers
 
     public boolean isForwarded()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    
Set reverse proxy handling. If set to true, then the X-Forwarded headers (or the headers set in their place) are looked for to set the request protocol, host, server and client ip.

 
     public void setForwarded(boolean check)
     {
         if (check)
             .debug("{} is forwarded",this);
          = check;
     }
 
     /* ------------------------------------------------------------ */
     public String getHostHeader()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    
Set a forced valued for the host header to control what is returned by javax.servlet.ServletRequest.getServerName() and javax.servlet.ServletRequest.getServerPort(). This value is only used if isForwarded() is true.

Parameters:
hostHeader The value of the host header to force.
 
     public void setHostHeader(String hostHeader)
     {
          = hostHeader;
     }
 
     /* ------------------------------------------------------------ */
     /*
      *
      * @see #setForwarded(boolean)
      */
     public String getForwardedHostHeader()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
forwardedHostHeader The header name for forwarded hosts (default x-forwarded-host)
See also:
setForwarded(boolean)
 
     public void setForwardedHostHeader(String forwardedHostHeader)
     {
          = forwardedHostHeader;
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
the header name for forwarded server.
See also:
setForwarded(boolean)
 
     public String getForwardedServerHeader()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
forwardedServerHeader The header name for forwarded server (default x-forwarded-server)
See also:
setForwarded(boolean)
 
     public void setForwardedServerHeader(String forwardedServerHeader)
     {
          = forwardedServerHeader;
     }
 
     /* ------------------------------------------------------------ */
    
 
     public String getForwardedForHeader()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
forwardedRemoteAddressHeader The header name for forwarded for (default x-forwarded-for)
See also:
setForwarded(boolean)
 
     public void setForwardedForHeader(String forwardedRemoteAddressHeader)
     {
          = forwardedRemoteAddressHeader;
     }
 
     /* ------------------------------------------------------------ */
    
Get the forwardedProtoHeader.

Returns:
the forwardedProtoHeader (default X-Forwarded-For)
See also:
setForwarded(boolean)
 
     public String getForwardedProtoHeader()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    
Set the forwardedProtoHeader.

Parameters:
forwardedProtoHeader the forwardedProtoHeader to set (default X-Forwarded-For)
See also:
setForwarded(boolean)
 
     public void setForwardedProtoHeader(String forwardedProtoHeader)
     {
          = forwardedProtoHeader;
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
The header name holding a forwarded cipher suite (default null)
 
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
forwardedCipherSuite The header name holding a forwarded cipher suite (default null)
 
     public void setForwardedCipherSuiteHeader(String forwardedCipherSuite)
     {
          = forwardedCipherSuite;
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
The header name holding a forwarded SSL Session ID (default null)
 
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
forwardedSslSessionId The header name holding a forwarded SSL Session ID (default null)
 
     public void setForwardedSslSessionIdHeader(String forwardedSslSessionId)
     {
          = forwardedSslSessionId;
     }
 
     public int getRequestBufferSize()
     {
         return .getRequestBufferSize();
     }
 
     public void setRequestBufferSize(int requestBufferSize)
     {
         .setRequestBufferSize(requestBufferSize);
     }
 
     public int getRequestHeaderSize()
     {
         return .getRequestHeaderSize();
     }
 
     public void setRequestHeaderSize(int requestHeaderSize)
     {
         .setRequestHeaderSize(requestHeaderSize);
     }
 
     public int getResponseBufferSize()
     {
         return .getResponseBufferSize();
     }
 
     public void setResponseBufferSize(int responseBufferSize)
     {
         .setResponseBufferSize(responseBufferSize);
     }
 
     public int getResponseHeaderSize()
     {
         return .getResponseHeaderSize();
     }
 
     public void setResponseHeaderSize(int responseHeaderSize)
     {
         .setResponseHeaderSize(responseHeaderSize);
     }
 
     public Type getRequestBufferType()
     {
         return .getRequestBufferType();
     }
 
     public Type getRequestHeaderType()
     {
         return .getRequestHeaderType();
     }
 
     public Type getResponseBufferType()
     {
         return .getResponseBufferType();
     }
 
     public Type getResponseHeaderType()
     {
         return .getResponseHeaderType();
     }
 
     public void setRequestBuffers(Buffers requestBuffers)
     {
         .setRequestBuffers(requestBuffers);
     }
 
     public void setResponseBuffers(Buffers responseBuffers)
     {
         .setResponseBuffers(responseBuffers);
     }
 
     public Buffers getRequestBuffers()
     {
         return .getRequestBuffers();
     }
 
     public Buffers getResponseBuffers()
     {
         return .getResponseBuffers();
     }
 
     public void setMaxBuffers(int maxBuffers)
     {
         .setMaxBuffers(maxBuffers);
     }
 
     public int getMaxBuffers()
     {
         return .getMaxBuffers();
     }
 
     /* ------------------------------------------------------------ */
     @Override
     public String toString()
     {
         return String.format("%s@%s:%d",
                 getClass().getSimpleName(),
                 getHost()==null?"0.0.0.0":getHost(),
                 getLocalPort()<=0?getPort():getLocalPort());
     }
 
     /* ------------------------------------------------------------ */
     /* ------------------------------------------------------------ */
     /* ------------------------------------------------------------ */
     private class Acceptor implements Runnable
     {
         int _acceptor = 0;
 
         Acceptor(int id)
         {
              = id;
         }
 
         /* ------------------------------------------------------------ */
         public void run()
         {
             Thread current = Thread.currentThread();
             String name;
             synchronized (AbstractConnector.this)
             {
                 if ( == null)
                     return;
 
                 [] = current;
                 name = [].getName();
                 current.setName(name + " Acceptor" +  + " " + AbstractConnector.this);
             }
             int old_priority = current.getPriority();
 
             try
             {
                 current.setPriority(old_priority - );
                 while (isRunning() && getConnection() != null)
                 {
                     try
                     {
                         accept();
                     }
                     catch (EofException e)
                     {
                         .ignore(e);
                     }
                     catch (IOException e)
                     {
                         .ignore(e);
                     }
                     catch (InterruptedException x)
                     {
                         // Connector has been stopped
                         .ignore(x);
                     }
                     catch (Throwable e)
                     {
                         .warn(e);
                     }
                 }
             }
             finally
             {
                 current.setPriority(old_priority);
                 current.setName(name);
 
                 synchronized (AbstractConnector.this)
                 {
                     if ( != null)
                         [] = null;
                 }
             }
         }
     }
 
     /* ------------------------------------------------------------ */
     public String getName()
     {
         if ( == null)
              = (getHost() == null?"0.0.0.0":getHost()) + ":" + (getLocalPort() <= 0?getPort():getLocalPort());
         return ;
     }
 
     /* ------------------------------------------------------------ */
     public void setName(String name)
     {
          = name;
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
Get the number of requests handled by this connector since last call of statsReset(). If setStatsOn(false) then this is undefined.
 
     public int getRequests()
     {
         return (int).getTotal();
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
Returns the connectionsDurationTotal.
 
    public long getConnectionsDurationTotal()
    {
        return .getTotal();
    }
    /* ------------------------------------------------------------ */
    

Returns:
Number of connections accepted by the server since statsReset() called. Undefined if setStatsOn(false).
    public int getConnections()
    {
        return (int).getTotal();
    }
    /* ------------------------------------------------------------ */
    

Returns:
Number of connections currently open that were opened since statsReset() called. Undefined if setStatsOn(false).
    public int getConnectionsOpen()
    {
        return (int).getCurrent();
    }
    /* ------------------------------------------------------------ */
    

Returns:
Maximum number of connections opened simultaneously since statsReset() called. Undefined if setStatsOn(false).
    public int getConnectionsOpenMax()
    {
        return (int).getMax();
    }
    /* ------------------------------------------------------------ */
    

Returns:
Mean duration in milliseconds of open connections since statsReset() called. Undefined if setStatsOn(false).
    public double getConnectionsDurationMean()
    {
        return .getMean();
    }
    /* ------------------------------------------------------------ */
    

Returns:
Maximum duration in milliseconds of an open connection since statsReset() called. Undefined if setStatsOn(false).
    public long getConnectionsDurationMax()
    {
        return .getMax();
    }
    /* ------------------------------------------------------------ */
    

Returns:
Standard deviation of duration in milliseconds of open connections since statsReset() called. Undefined if setStatsOn(false).
    public double getConnectionsDurationStdDev()
    {
        return .getStdDev();
    }
    /* ------------------------------------------------------------ */
    

Returns:
Mean number of requests per connection since statsReset() called. Undefined if setStatsOn(false).
    public double getConnectionsRequestsMean()
    {
        return .getMean();
    }
    /* ------------------------------------------------------------ */
    

Returns:
Maximum number of requests per connection since statsReset() called. Undefined if setStatsOn(false).
    public int getConnectionsRequestsMax()
    {
        return (int).getMax();
    }
    /* ------------------------------------------------------------ */
    

Returns:
Standard deviation of number of requests per connection since statsReset() called. Undefined if setStatsOn(false).
    public double getConnectionsRequestsStdDev()
    {
        return .getStdDev();
    }
    /* ------------------------------------------------------------ */
    
Reset statistics.
    public void statsReset()
    {
        .reset();
        .reset();
    }
    /* ------------------------------------------------------------ */
    public void setStatsOn(boolean on)
    {
        if (on && .get() != -1)
            return;
        if (.isDebugEnabled())
            .debug("Statistics on = " + on + " for " + this);
        statsReset();
        .set(on?System.currentTimeMillis():-1);
    }
    /* ------------------------------------------------------------ */
    

Returns:
True if statistics collection is turned on.
    public boolean getStatsOn()
    {
        return .get() != -1;
    }
    /* ------------------------------------------------------------ */
    

Returns:
Timestamp stats were started at.
    public long getStatsOnMs()
    {
        long start = .get();
        return (start != -1)?(System.currentTimeMillis() - start):0;
    }
    /* ------------------------------------------------------------ */
    protected void connectionOpened(Connection connection)
    {
        if (.get() == -1)
            return;
        .increment();
    }
    /* ------------------------------------------------------------ */
    protected void connectionUpgraded(Connection oldConnectionConnection newConnection)
    {
        .set((oldConnection instanceof AbstractHttpConnection)?((AbstractHttpConnection)oldConnection).getRequests():0);
    }
    /* ------------------------------------------------------------ */
    protected void connectionClosed(Connection connection)
    {
        connection.onClose();
        if (.get() == -1)
            return;
        long duration = System.currentTimeMillis() - connection.getTimeStamp();
        int requests = (connection instanceof AbstractHttpConnection)?((AbstractHttpConnection)connection).getRequests():0;
        .set(requests);
        .decrement();
        .set(duration);
    }
    /* ------------------------------------------------------------ */
    

Returns:
the acceptorPriority
    public int getAcceptorPriorityOffset()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    
Set the priority offset of the acceptor threads. The priority is adjusted by this amount (default 0) to either favour the acceptance of new threads and newly active connections or to favour the handling of already dispatched connections.

Parameters:
offset the amount to alter the priority of the acceptor threads.
    public void setAcceptorPriorityOffset(int offset)
    {
         = offset;
    }
    /* ------------------------------------------------------------ */
    

Returns:
True if the the server socket will be opened in SO_REUSEADDR mode.
    public boolean getReuseAddress()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    

Parameters:
reuseAddress True if the the server socket will be opened in SO_REUSEADDR mode.
    public void setReuseAddress(boolean reuseAddress)
    {
         = reuseAddress;
    }
    /* ------------------------------------------------------------ */
    public boolean isLowResources()
    {
        if ( != null)
            return .isLowOnThreads();
        return .getThreadPool().isLowOnThreads();
    }
    /* ------------------------------------------------------------ */
    private void updateNotEqual(AtomicLong valueHolderlong comparelong value)
    {
        long oldValue = valueHolder.get();
        while (compare != oldValue)
        {
            if (valueHolder.compareAndSet(oldValue,value))
                break;
            oldValue = valueHolder.get();
        }
    }