com.sun.slamd.server
Class ResourceMonitorClientListener

java.lang.Object
  extended byjava.lang.Thread
      extended bycom.sun.slamd.server.ResourceMonitorClientListener
All Implemented Interfaces:
ConfigSubscriber, java.lang.Runnable

public class ResourceMonitorClientListener
extends java.lang.Thread
implements ConfigSubscriber

This class implements the client listener that the SLAMD server uses to listen for connections from resource monitor clients. If fewer than the maximum connections are established, then the connection will be accepted and a new connection thread will be spawned to handle operations on that monitor connection. If the maximum number of connections are already in use, then the new connection will be rejected.


Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ResourceMonitorClientListener(SLAMDServer slamdServer)
          Creates a new listener to accept resource monitor client connections.
 
Method Summary
 void connectionLost(ResourceMonitorClientConnection clientConnection)
          Indicates that the specified connection is closing and all refrences to it should be removed.
 boolean connectionsAvailable(Job job)
          Indicates whether all the resource monitor clients needed for the specified job are currently available.
 void forcefullyDisconnectAll()
          Forcefully closes the connections for all resource monitor clients connected to the SLAMD server.
 int getKeepAliveInterval()
          Retrieves the length of time that should pass between keepalive messages.
 int getMaxResponseWaitTime()
          Retrieves the maximum amount of time in seconds that a client connection should wait for a response to a solicited message before returning an error.
 ResourceMonitorClientConnection[] getMonitorClientConnections(Job job)
          Retrieves the set of resource monitor client connections for processing the specified job.
 ResourceMonitorClientConnection[] getMonitorClientList()
          Retrieves a list of the resource monitor clients that are currently connected to the SLAMD server.
 java.lang.String getNewConnectionID()
          Retrieves a connection ID that can be used to uniquely identify each client connection.
 java.lang.String getSubscriberName()
          Retrieves the name that the client listener uses to subscribe to the configuration handler in order to be notified of configuration changes.
 ParameterList getSubscriberParameters()
          Retrieves the set of configuration parameters associated with this configuration subscriber.
 void refreshSubscriberConfiguration()
          Re-reads all configuration information used by the resource client listener.
 void refreshSubscriberConfiguration(java.lang.String parameterName)
          Re-reads the configuration for the specified parameter if the parameter is applicable to the resource monitor client listener.
 void requestDisconnectAll()
          Sends a message to each client indicating that it should disconnect itself from the SLAMD server.
 boolean requireAuthentication()
          Indicates whether this client listener requries clients to authenticate.
 void run()
          Creates the server socket and listens for new connections.
 void startListening()
          Indicates that the listener should start listening for client connections.
 void stopListening()
          Indicates that the listener should stop listening for client connections.
 void waitForStop()
          This method will not return until the client listener has actually stopped.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceMonitorClientListener

public ResourceMonitorClientListener(SLAMDServer slamdServer)
Creates a new listener to accept resource monitor client connections.

Parameters:
slamdServer - The SLAMD server with which this listener is associated.
Method Detail

startListening

public void startListening()
Indicates that the listener should start listening for client connections.


stopListening

public void stopListening()
Indicates that the listener should stop listening for client connections. It will also notify all connected clients that the listener is shutting down.


waitForStop

public void waitForStop()
This method will not return until the client listener has actually stopped. Note that it does not stop the listener -- you should first call the stopListening method to signal the listener that it needs to stop.


run

public void run()
Creates the server socket and listens for new connections. If the connection will be accepted, then a new connection thread will be spawned to handle it. If the connection will not be accepted, then it will be rejected here.

Specified by:
run in interface java.lang.Runnable

getMonitorClientConnections

public ResourceMonitorClientConnection[] getMonitorClientConnections(Job job)
Retrieves the set of resource monitor client connections for processing the specified job.

Parameters:
job - The job for which the connections are to be retrieved.
Returns:
The appropriate set of monitor clients for the specified job, or null if the requested set of monitor clients are not available.

getMonitorClientList

public ResourceMonitorClientConnection[] getMonitorClientList()
Retrieves a list of the resource monitor clients that are currently connected to the SLAMD server.

Returns:
The set of resource monitor clients that are currently connected.

getNewConnectionID

public java.lang.String getNewConnectionID()
Retrieves a connection ID that can be used to uniquely identify each client connection.

Returns:
A connection ID that can be used to uniquely identify each client connection.

requireAuthentication

public boolean requireAuthentication()
Indicates whether this client listener requries clients to authenticate.

Returns:
true if clients are required to authenticate, or false if they are not.

requestDisconnectAll

public void requestDisconnectAll()
Sends a message to each client indicating that it should disconnect itself from the SLAMD server. If any clients are currently processing jobs, then those clients will be given an opportunity to send their results to the SLAMD server.


forcefullyDisconnectAll

public void forcefullyDisconnectAll()
Forcefully closes the connections for all resource monitor clients connected to the SLAMD server. If any clients are currently processing a job, then no information will be available for that job from those clients.


connectionLost

public void connectionLost(ResourceMonitorClientConnection clientConnection)
Indicates that the specified connection is closing and all refrences to it should be removed.

Parameters:
clientConnection - The connection that is shutting down.

connectionsAvailable

public boolean connectionsAvailable(Job job)
Indicates whether all the resource monitor clients needed for the specified job are currently available.

Parameters:
job - The job that specifies which monitor clients are needed.
Returns:
true if all requested monitor clients are available, or false if not.

getKeepAliveInterval

public int getKeepAliveInterval()
Retrieves the length of time that should pass between keepalive messages. A keepalive message will be sent if there has been no interaction with the client for the specified period of time.

Returns:
The length of time that should pass between keepalive messages.

getMaxResponseWaitTime

public int getMaxResponseWaitTime()
Retrieves the maximum amount of time in seconds that a client connection should wait for a response to a solicited message before returning an error.

Returns:
The maximum amount of time in seconds that a client connection should wait for a response to a solicited message before returning an error.

getSubscriberName

public java.lang.String getSubscriberName()
Retrieves the name that the client listener uses to subscribe to the configuration handler in order to be notified of configuration changes.

Specified by:
getSubscriberName in interface ConfigSubscriber
Returns:
The name that the client listener uses to subscribe to the configuration handler in order to be notified of configuration changes.

getSubscriberParameters

public ParameterList getSubscriberParameters()
Retrieves the set of configuration parameters associated with this configuration subscriber.

Specified by:
getSubscriberParameters in interface ConfigSubscriber
Returns:
The set of configuration parameters associated with this configuration subscriber.

refreshSubscriberConfiguration

public void refreshSubscriberConfiguration()
Re-reads all configuration information used by the resource client listener. In this case, the only configuration parameter for this listener is the port number, and that cannot change without restarting the SLAMD server. Therefore, this method does nothing.

Specified by:
refreshSubscriberConfiguration in interface ConfigSubscriber

refreshSubscriberConfiguration

public void refreshSubscriberConfiguration(java.lang.String parameterName)
Re-reads the configuration for the specified parameter if the parameter is applicable to the resource monitor client listener. In this case, the only configuration parameter for this listener is the port number, and that cannot change without restarting the SLAMD server. Therefore, this method does nothing.

Specified by:
refreshSubscriberConfiguration in interface ConfigSubscriber
Parameters:
parameterName - The name of the parameter for which to reread the configuration.