com.caucho.server.port
Class Port

java.lang.Object
  extended by com.caucho.server.port.Port
All Implemented Interfaces:
EnvironmentListener, java.lang.Runnable
Direct Known Subclasses:
ClusterPort, OpenPort, ProtocolPort, SrunPort

public class Port
extends java.lang.Object
implements EnvironmentListener, java.lang.Runnable

Represents a protocol connection.


Nested Class Summary
 class Port.SuspendReaper
           
 
Constructor Summary
Port()
           
Port(ClusterServer server)
           
 
Method Summary
 boolean accept(TcpConnection conn, boolean isStart)
          Accepts a new connection.
 boolean allowKeepalive(long acceptStartTime)
          Returns true if the keepalive is allowed
 void bind()
          Starts the port listening.
 void bind(QServerSocket ss)
          Starts the port listening.
 QServerSocket bindForWatchdog()
          binds for the watchdog.
 void close()
          Shuts the Port down.
 JsseSSLFactory createJsse()
          Sets the SSL factory
 SSLFactory createOpenssl()
          Sets the SSL factory
 void environmentBind(EnvironmentClassLoader loader)
          Handles the environment bind phase
 void environmentConfigure(EnvironmentClassLoader loader)
          Handles the environment config phase
 void environmentStart(EnvironmentClassLoader loader)
          Handles the case where the environment is starting (after init).
 void environmentStop(EnvironmentClassLoader loader)
          Handles the case where the environment is stopping
 int getAcceptListenBacklog()
          The operating system listen backlog
 int getAcceptThreadMax()
          The maximum spare threads.
 int getAcceptThreadMin()
          The minimum spare threads.
 int getActiveConnectionCount()
          Returns the active connections.
 int getActiveThreadCount()
          Returns the active thread count.
 java.lang.String getAddress()
          Gets the IP address
 PortMXBean getAdmin()
           
 int getCometIdleCount()
          Returns the number of comet connections.
 int getConnectionCount()
          Returns the number of connections
 int getConnectionMax()
          Gets the connection max.
 int getDuplexCount()
          Returns the number of duplex connections.
 int getFreeKeepalive()
          Returns the accept pool.
 int getIdleThreadCount()
          Returns the count of idle threads.
 int getKeepaliveConnectionCount()
          Returns the keepalive connections.
 long getKeepaliveConnectionTimeMax()
          Gets the keepalive max.
 int getKeepaliveCount()
          Returns the number of keepalive connections
 int getKeepaliveMax()
          Gets the keepalive max.
 int getKeepaliveSelectMax()
           
 long getKeepaliveSelectThreadTimeout()
           
 int getKeepaliveThreadCount()
          Returns the number of keepalive connections
 long getKeepaliveTimeout()
           
 Lifecycle getLifecycleState()
           
 long getLifetimeClientDisconnectCount()
           
 long getLifetimeKeepaliveCount()
           
 long getLifetimeReadBytes()
           
 long getLifetimeRequestCount()
           
 long getLifetimeRequestTime()
           
 long getLifetimeWriteBytes()
           
 int getPort()
          Gets the port.
 Protocol getProtocol()
          Set protocol.
 java.lang.String getProtocolName()
          Gets the protocol name.
 int getSelectConnectionCount()
          Returns the number of connections in the select.
 AbstractSelectManager getSelectManager()
          returns the select manager.
 ProtocolDispatchServer getServer()
          Gets the server.
 java.lang.String getServerId()
          Gets the server id.
 long getSocketTimeout()
          Gets the read timeout for the accepted sockets.
 SSLFactory getSSL()
          Gets the SSL factory.
 long getSuspendTimeMax()
          Gets the suspend max.
 boolean getTcpNoDelay()
          Gets the tcp-no-delay property
 int getThreadCount()
          Returns the thread count.
 long getThrottleConcurrentMax()
          Configures the throttle.
 java.lang.String getVirtualHost()
          Gets the virtual host for IP-based virtual host.
 void init()
          Initializes the port.
 boolean isActive()
          Returns true if the port is active.
 boolean isClosed()
          Returns true if the port is closed.
 boolean isIgnoreClientDisconnect()
          Returns true for ignore-client-disconnect.
 boolean isSecure()
          Return true for secure
 boolean isSSL()
          Returns true for ssl.
 boolean matchesServerId(java.lang.String serverId)
          Returns true if the port matches the server id.
 void postBind()
           
 void run()
          The port thread is responsible for creating new connections.
 void setAcceptListenBacklog(int listen)
          Sets the operating system listen backlog
 void setAcceptThreadMax(int maxSpare)
          Sets the minimum spare listen.
 void setAcceptThreadMin(int minSpare)
          Sets the minimum spare listen.
 void setAddress(java.lang.String address)
          Sets the address
 void setClass(java.lang.Class cl)
           
 void setConnectionMax(int max)
          Sets the connection max.
 void setHost(java.lang.String address)
          Deprecated.  
 void setId(java.lang.String id)
          Sets the id.
 void setJsseSsl(JsseSSLFactory factory)
          Sets the SSL factory
 void setKeepaliveConnectionTimeMax(Period period)
          Sets the keepalive max.
 void setKeepaliveMax(int max)
          Sets the keepalive max.
 void setKeepaliveTimeout(Period period)
           
 void setMaxSpareListen(int maxSpare)
          Sets the maximum spare listen.
 void setMinSpareListen(int minSpare)
          Sets the minimum spare listen.
 void setParent(ProtocolDispatchServer parent)
          Sets the containing server.
 void setPort(int port)
          Sets the port.
 void setProtocol(Protocol protocol)
          Set protocol.
 void setReadTimeout(Period period)
          Deprecated.  
 void setSecure(boolean isSecure)
          Sets true for secure
 void setServer(ProtocolDispatchServer protocolServer)
          Sets the server.
 void setServerId(java.lang.String id)
          Sets the server id.
 void setServerSocket(QServerSocket socket)
          Sets the server socket.
 void setSocketTimeout(Period period)
          Sets the read/write timeout for the accepted sockets.
 void setSSL(SSLFactory factory)
          Sets the SSL factory
 void setSuspendTimeMax(Period period)
           
 void setTcpNoDelay(boolean tcpNoDelay)
          Sets the tcp-no-delay property
 void setThrottleConcurrentMax(int max)
          Configures the throttle.
 void setType(java.lang.Class cl)
           
 void setVirtualHost(java.lang.String host)
          Sets the virtual host for IP-based virtual host.
 void setWriteTimeout(Period period)
          Deprecated.  
 void start()
          Starts the port listening.
 java.lang.String toString()
           
 java.lang.String toURL()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Port

public Port()

Port

public Port(ClusterServer server)
Method Detail

setParent

public void setParent(ProtocolDispatchServer parent)
Sets the containing server.


setServer

public void setServer(ProtocolDispatchServer protocolServer)
Sets the server.


getServer

public ProtocolDispatchServer getServer()
Gets the server.


setId

public void setId(java.lang.String id)
Sets the id.


setServerId

public void setServerId(java.lang.String id)
Sets the server id.


getServerId

public java.lang.String getServerId()
Gets the server id.


setType

public void setType(java.lang.Class cl)

setClass

public void setClass(java.lang.Class cl)

getAdmin

public PortMXBean getAdmin()

setProtocol

public void setProtocol(Protocol protocol)
                 throws ConfigException
Set protocol.

Throws:
ConfigException

getProtocol

public Protocol getProtocol()
Set protocol.


getProtocolName

public java.lang.String getProtocolName()
Gets the protocol name.


setAddress

public void setAddress(java.lang.String address)
                throws java.net.UnknownHostException
Sets the address

Throws:
java.net.UnknownHostException

setHost

public void setHost(java.lang.String address)
             throws java.net.UnknownHostException
Deprecated. 

Throws:
java.net.UnknownHostException

getAddress

public java.lang.String getAddress()
Gets the IP address


setPort

public void setPort(int port)
Sets the port.


getPort

public int getPort()
Gets the port.


setVirtualHost

public void setVirtualHost(java.lang.String host)
Sets the virtual host for IP-based virtual host.


getVirtualHost

public java.lang.String getVirtualHost()
Gets the virtual host for IP-based virtual host.


setSSL

public void setSSL(SSLFactory factory)
Sets the SSL factory


createOpenssl

public SSLFactory createOpenssl()
                         throws ConfigException
Sets the SSL factory

Throws:
ConfigException

createJsse

public JsseSSLFactory createJsse()
Sets the SSL factory


setJsseSsl

public void setJsseSsl(JsseSSLFactory factory)
Sets the SSL factory


getSSL

public SSLFactory getSSL()
Gets the SSL factory.


isSSL

public boolean isSSL()
Returns true for ssl.


setSecure

public void setSecure(boolean isSecure)
Sets true for secure


isSecure

public boolean isSecure()
Return true for secure


setServerSocket

public void setServerSocket(QServerSocket socket)
Sets the server socket.


setAcceptThreadMin

public void setAcceptThreadMin(int minSpare)
                        throws ConfigException
Sets the minimum spare listen.

Throws:
ConfigException

getAcceptThreadMin

public int getAcceptThreadMin()
The minimum spare threads.


setAcceptThreadMax

public void setAcceptThreadMax(int maxSpare)
                        throws ConfigException
Sets the minimum spare listen.

Throws:
ConfigException

getAcceptThreadMax

public int getAcceptThreadMax()
The maximum spare threads.


setAcceptListenBacklog

public void setAcceptListenBacklog(int listen)
                            throws ConfigException
Sets the operating system listen backlog

Throws:
ConfigException

getAcceptListenBacklog

public int getAcceptListenBacklog()
The operating system listen backlog


setConnectionMax

public void setConnectionMax(int max)
Sets the connection max.


getConnectionMax

public int getConnectionMax()
Gets the connection max.


isIgnoreClientDisconnect

public boolean isIgnoreClientDisconnect()
Returns true for ignore-client-disconnect.


setSocketTimeout

public void setSocketTimeout(Period period)
Sets the read/write timeout for the accepted sockets.


setReadTimeout

public void setReadTimeout(Period period)
Deprecated. 

Sets the read timeout for the accepted sockets.


getSocketTimeout

public long getSocketTimeout()
Gets the read timeout for the accepted sockets.


getTcpNoDelay

public boolean getTcpNoDelay()
Gets the tcp-no-delay property


setTcpNoDelay

public void setTcpNoDelay(boolean tcpNoDelay)
Sets the tcp-no-delay property


setThrottleConcurrentMax

public void setThrottleConcurrentMax(int max)
Configures the throttle.


getThrottleConcurrentMax

public long getThrottleConcurrentMax()
Configures the throttle.


setWriteTimeout

public void setWriteTimeout(Period period)
Deprecated. 

Sets the write timeout for the accepted sockets.


setMinSpareListen

public void setMinSpareListen(int minSpare)
                       throws ConfigException
Sets the minimum spare listen.

Throws:
ConfigException

setMaxSpareListen

public void setMaxSpareListen(int maxSpare)
                       throws ConfigException
Sets the maximum spare listen.

Throws:
ConfigException

getConnectionCount

public int getConnectionCount()
Returns the number of connections


getCometIdleCount

public int getCometIdleCount()
Returns the number of comet connections.


getDuplexCount

public int getDuplexCount()
Returns the number of duplex connections.


getLifetimeRequestCount

public long getLifetimeRequestCount()

getLifetimeKeepaliveCount

public long getLifetimeKeepaliveCount()

getLifetimeClientDisconnectCount

public long getLifetimeClientDisconnectCount()

getLifetimeRequestTime

public long getLifetimeRequestTime()

getLifetimeReadBytes

public long getLifetimeReadBytes()

getLifetimeWriteBytes

public long getLifetimeWriteBytes()

setKeepaliveMax

public void setKeepaliveMax(int max)
Sets the keepalive max.


getKeepaliveMax

public int getKeepaliveMax()
Gets the keepalive max.


setKeepaliveConnectionTimeMax

public void setKeepaliveConnectionTimeMax(Period period)
Sets the keepalive max.


getKeepaliveConnectionTimeMax

public long getKeepaliveConnectionTimeMax()
Gets the keepalive max.


getSuspendTimeMax

public long getSuspendTimeMax()
Gets the suspend max.


setSuspendTimeMax

public void setSuspendTimeMax(Period period)

setKeepaliveTimeout

public void setKeepaliveTimeout(Period period)

getKeepaliveTimeout

public long getKeepaliveTimeout()

getKeepaliveSelectThreadTimeout

public long getKeepaliveSelectThreadTimeout()

getKeepaliveSelectMax

public int getKeepaliveSelectMax()

getThreadCount

public int getThreadCount()
Returns the thread count.


getActiveThreadCount

public int getActiveThreadCount()
Returns the active thread count.


getIdleThreadCount

public int getIdleThreadCount()
Returns the count of idle threads.


getKeepaliveCount

public int getKeepaliveCount()
Returns the number of keepalive connections


getLifecycleState

public Lifecycle getLifecycleState()

isActive

public boolean isActive()
Returns true if the port is active.


getActiveConnectionCount

public int getActiveConnectionCount()
Returns the active connections.


getKeepaliveConnectionCount

public int getKeepaliveConnectionCount()
Returns the keepalive connections.


getKeepaliveThreadCount

public int getKeepaliveThreadCount()
Returns the number of keepalive connections


getSelectConnectionCount

public int getSelectConnectionCount()
Returns the number of connections in the select.


getFreeKeepalive

public int getFreeKeepalive()
Returns the accept pool.


matchesServerId

public boolean matchesServerId(java.lang.String serverId)
Returns true if the port matches the server id.


init

public void init()
          throws ConfigException
Initializes the port.

Throws:
ConfigException

bind

public void bind()
          throws java.lang.Exception
Starts the port listening.

Throws:
java.lang.Exception

bind

public void bind(QServerSocket ss)
          throws java.lang.Exception
Starts the port listening.

Throws:
java.lang.Exception

postBind

public void postBind()

bindForWatchdog

public QServerSocket bindForWatchdog()
                              throws java.io.IOException
binds for the watchdog.

Throws:
java.io.IOException

start

public void start()
           throws java.lang.Exception
Starts the port listening.

Throws:
java.lang.Exception

getSelectManager

public AbstractSelectManager getSelectManager()
returns the select manager.


accept

public boolean accept(TcpConnection conn,
                      boolean isStart)
Accepts a new connection.

Parameters:
isStart - boolean to mark the first request on the thread for bookkeeping.

allowKeepalive

public boolean allowKeepalive(long acceptStartTime)
Returns true if the keepalive is allowed


isClosed

public boolean isClosed()
Returns true if the port is closed.


run

public void run()
The port thread is responsible for creating new connections.

Specified by:
run in interface java.lang.Runnable

environmentConfigure

public void environmentConfigure(EnvironmentClassLoader loader)
Handles the environment config phase

Specified by:
environmentConfigure in interface EnvironmentListener

environmentBind

public void environmentBind(EnvironmentClassLoader loader)
Handles the environment bind phase

Specified by:
environmentBind in interface EnvironmentListener

environmentStart

public void environmentStart(EnvironmentClassLoader loader)
Handles the case where the environment is starting (after init).

Specified by:
environmentStart in interface EnvironmentListener

environmentStop

public void environmentStop(EnvironmentClassLoader loader)
Handles the case where the environment is stopping

Specified by:
environmentStop in interface EnvironmentListener

close

public void close()
Shuts the Port down. The server gives connections 30 seconds to complete.


toURL

public java.lang.String toURL()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object