com.caucho.server.cluster
Class ServerConnector

java.lang.Object
  extended by com.caucho.server.cluster.ServerConnector

public class ServerConnector
extends java.lang.Object

Defines a member of the cluster. A ClusterClient obtained with #getClient is used to actually communicate with this ClusterServer when it is active in another instance of Resin .


Constructor Summary
ServerConnector(ClusterServer server)
           
 
Method Summary
 void allocateLoadBalance()
          Allocate a connection for load balancing.
 void busy()
          Called when the server responds with "busy", e.g.
 boolean canConnect()
          Returns true if can connect to the client.
 boolean canOpenSoft()
          Returns true if the server can open a connection.
 boolean canOpenSoftOrRecycle()
          Returns true if the server can open a connection.
 void clearRecycle()
          Clears the recycled connections, e.g.
 void close()
          Close the client
 void disable()
          Disable the client
 void enable()
          Enable the client
 void enableSessionOnly()
          Session only
 void failConnect()
          Called when the socket read/write fails.
 void failSocket()
          Called when the socket read/write fails.
 void freeLoadBalance()
          Free a connection for load balancing.
 int getActiveCount()
          Returns the number of active connections.
 java.lang.String getAddress()
          Returns the hostname of the target server.
 ServerConnectorMXBean getAdmin()
          Returns the admin.
 long getBusyCountTotal()
          Returns the count of busy connections.
 Cluster getCluster()
          Gets the owning cluster.
 ClusterPort getClusterPort()
          Gets the cluster port.
 long getConnectCountTotal()
          Returns the total number of successful socket connections
 double getCpuLoadAvg()
          Gets the CPU load avg
 java.lang.String getDebugId()
          Returns the debug id.
 long getFailCountTotal()
          Returns the total number of failed connect attempts.
 java.lang.String getId()
          Returns the user-readable id of the target server.
 int getIdleCount()
          Returns the number of idle connections.
 int getIndex()
          Returns the index of this connection in the connection group.
 long getKeepaliveCountTotal()
          Returns the number of times a keepalive connection has been used.
 java.util.Date getLastBusyTime()
          Returns the time of the last busy.
 java.util.Date getLastFailConnectTime()
          Returns the time of the last failure.
 java.util.Date getLastFailTime()
          Returns the time of the last failure.
 long getLastSuccessTime()
          Returns the time of the last failure.
 double getLatencyFactor()
          Returns the latency factory
 int getLoadBalanceAllocateCount()
          Returns the number of load balance allocations
 long getLoadBalanceConnectTimeout()
          Returns the socket timeout when connecting to the target server.
 long getLoadBalanceIdleTime()
          Returns how long the connection can be cached in the free pool.
 long getLoadBalanceRecoverTime()
          Returns how long the connection will be treated as dead.
 long getLoadBalanceSocketTimeout()
          Returns the socket timeout when reading from the target server.
 long getLoadBalanceWarmupTime()
          Returns the time in milliseconds for the slow start throttling.
 int getLoadBalanceWeight()
          Returns the load balance weight.
 javax.management.ObjectName getObjectName()
          Returns the object name.
 int getPort()
          Gets the port of the target server.
 java.lang.String getState()
          Returns the lifecycle state.
 void init()
          Initialize
 boolean isActive()
          Returns true if the server is active.
 boolean isDead()
          Returns true if the server is dead.
 boolean isEnabled()
          Return true if active.
 ClusterStream open()
          Open a stream to the target server for the load balancer.
 ClusterStream openForSession()
          Open a stream to the target server for a session.
 ClusterStream openIfLive()
          Open a stream to the target server object persistence.
 ClusterStream openSoft()
          Open a stream to the target server.
 void setCpuLoadAvg(double load)
          Sets the CPU load avg (from backend).
 void start()
          Enable the client.
 void stop()
          Disable the client.
 void toBusy()
           
 void toFail()
           
 java.lang.String toString()
           
 void wake()
          We now know that the server is live, e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServerConnector

public ServerConnector(ClusterServer server)
Method Detail

getCluster

public Cluster getCluster()
Gets the owning cluster.


getObjectName

public javax.management.ObjectName getObjectName()
Returns the object name.


getAdmin

public ServerConnectorMXBean getAdmin()
Returns the admin.


getClusterPort

public ClusterPort getClusterPort()
Gets the cluster port.


getId

public java.lang.String getId()
Returns the user-readable id of the target server.


getIndex

public int getIndex()
Returns the index of this connection in the connection group.


getAddress

public java.lang.String getAddress()
Returns the hostname of the target server.


getPort

public int getPort()
Gets the port of the target server.


getLoadBalanceWarmupTime

public long getLoadBalanceWarmupTime()
Returns the time in milliseconds for the slow start throttling.


getLoadBalanceConnectTimeout

public long getLoadBalanceConnectTimeout()
Returns the socket timeout when connecting to the target server.


getLoadBalanceSocketTimeout

public long getLoadBalanceSocketTimeout()
Returns the socket timeout when reading from the target server.


getLoadBalanceIdleTime

public long getLoadBalanceIdleTime()
Returns how long the connection can be cached in the free pool.


getLoadBalanceRecoverTime

public long getLoadBalanceRecoverTime()
Returns how long the connection will be treated as dead.


getLoadBalanceWeight

public int getLoadBalanceWeight()
Returns the load balance weight.


init

public void init()
          throws java.lang.Exception
Initialize

Throws:
java.lang.Exception

getActiveCount

public int getActiveCount()
Returns the number of active connections.


getIdleCount

public int getIdleCount()
Returns the number of idle connections.


getLoadBalanceAllocateCount

public int getLoadBalanceAllocateCount()
Returns the number of load balance allocations


allocateLoadBalance

public void allocateLoadBalance()
Allocate a connection for load balancing.


freeLoadBalance

public void freeLoadBalance()
Free a connection for load balancing.


getConnectCountTotal

public long getConnectCountTotal()
Returns the total number of successful socket connections


getKeepaliveCountTotal

public long getKeepaliveCountTotal()
Returns the number of times a keepalive connection has been used.


getFailCountTotal

public long getFailCountTotal()
Returns the total number of failed connect attempts.


getLastFailTime

public java.util.Date getLastFailTime()
Returns the time of the last failure.


getLastFailConnectTime

public java.util.Date getLastFailConnectTime()
Returns the time of the last failure.


getLastSuccessTime

public long getLastSuccessTime()
Returns the time of the last failure.


getLatencyFactor

public double getLatencyFactor()
Returns the latency factory


getBusyCountTotal

public long getBusyCountTotal()
Returns the count of busy connections.


getLastBusyTime

public java.util.Date getLastBusyTime()
Returns the time of the last busy.


setCpuLoadAvg

public void setCpuLoadAvg(double load)
Sets the CPU load avg (from backend).


getCpuLoadAvg

public double getCpuLoadAvg()
Gets the CPU load avg


getDebugId

public java.lang.String getDebugId()
Returns the debug id.


isActive

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


isDead

public boolean isDead()
Returns true if the server is dead.


enable

public void enable()
Enable the client


disable

public void disable()
Disable the client


getState

public java.lang.String getState()
Returns the lifecycle state.


canOpenSoftOrRecycle

public boolean canOpenSoftOrRecycle()
Returns true if the server can open a connection.


canOpenSoft

public boolean canOpenSoft()
Returns true if the server can open a connection.


isEnabled

public boolean isEnabled()
Return true if active.


toBusy

public void toBusy()

toFail

public void toFail()

failSocket

public void failSocket()
Called when the socket read/write fails.


failConnect

public void failConnect()
Called when the socket read/write fails.


busy

public void busy()
Called when the server responds with "busy", e.g. HTTP 503


start

public void start()
Enable the client.


stop

public void stop()
Disable the client.


enableSessionOnly

public void enableSessionOnly()
Session only


openSoft

public ClusterStream openSoft()
Open a stream to the target server.

Returns:
the socket's read/write pair.

openIfLive

public ClusterStream openIfLive()
Open a stream to the target server object persistence.

Returns:
the socket's read/write pair.

openForSession

public ClusterStream openForSession()
Open a stream to the target server for a session.

Returns:
the socket's read/write pair.

open

public ClusterStream open()
Open a stream to the target server for the load balancer.

Returns:
the socket's read/write pair.

wake

public void wake()
We now know that the server is live, e.g. if a sibling has contacted us.


clearRecycle

public void clearRecycle()
Clears the recycled connections, e.g. on detection of backend server going down.


close

public void close()
Close the client


canConnect

public boolean canConnect()
Returns true if can connect to the client.


toString

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