com.sun.slamd.server
Class StatListener

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

public class StatListener
extends java.lang.Thread
implements ConfigSubscriber

This class implements a listener that can be used to accept connections from clients for the use of reporting in-progress statistics while a job is running.


Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
StatListener(SLAMDServer slamdServer)
          Creates a new instance of this stat listener.
 
Method Summary
 void connectionLost(StatClientConnection connection)
          Indicates that the specified stat client has disconnected from the SLAMD server.
 boolean forceDisconnect(java.lang.String clientID)
          Forcefully closes the connection to the specified client and removes all references to it from the SLAMD server.
 void forceDisconnectAll()
          Forcefully disconnects all real-time stat clients from the SLAMD server and removes all references to them.
 StatClientConnection[] getConnectionList()
          Retrieves an array of the connections currently established to this stat listener.
 int getKeepAliveInterval()
          Retrieves the keepalive interval that should be used for new client connections.
 int getMaxResponseWaitTime()
          Retrieves the maximum length of time in seconds that the SLAMD server will wait for a response to a request issued to a stat client.
 java.lang.String getSubscriberName()
          Retrieves the name that the stat 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 stat listener.
 void refreshSubscriberConfiguration(java.lang.String parameterName)
          Re-reads the configuration for the specified parameter if the parameter is applicable to the stat listener.
 boolean requestDisconnect(java.lang.String clientID)
          Sends a message to the specified client indicating that it should disconnect from the SLAMD server.
 void requestDisconnectAll()
          Sends a message to all clients indicating that they should disconnect from the SLAMD server.
 boolean requireAuthentication()
          Indicates whether this listener is configured to require authentication.
 void run()
          Creates the server socket that will be used to accept new connections, then listens for new connections until the SLAMD server is shut down.
 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

StatListener

public StatListener(SLAMDServer slamdServer)
Creates a new instance of this stat listener.

Parameters:
slamdServer - The SLAMD server with which this stat listener will be 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 that will be used to accept new connections, then listens for new connections until the SLAMD server is shut down.

Specified by:
run in interface java.lang.Runnable

getConnectionList

public StatClientConnection[] getConnectionList()
Retrieves an array of the connections currently established to this stat listener.

Returns:
An array of the connections currently established to this stat listener.

requestDisconnect

public boolean requestDisconnect(java.lang.String clientID)
Sends a message to the specified client indicating that it should disconnect from the SLAMD server.

Parameters:
clientID - The client ID of the client to which the request is to be sent.
Returns:
true if a request was sent to the specified client, or false if not.

requestDisconnectAll

public void requestDisconnectAll()
Sends a message to all clients indicating that they should disconnect from the SLAMD server.


forceDisconnect

public boolean forceDisconnect(java.lang.String clientID)
Forcefully closes the connection to the specified client and removes all references to it from the SLAMD server.

Parameters:
clientID - The client ID of the client to be disconnected.
Returns:
true if the client was disconnected, or false if not.

forceDisconnectAll

public void forceDisconnectAll()
Forcefully disconnects all real-time stat clients from the SLAMD server and removes all references to them.


connectionLost

public void connectionLost(StatClientConnection connection)
Indicates that the specified stat client has disconnected from the SLAMD server.

Parameters:
connection - The connection to the stat client that has been lost.

getKeepAliveInterval

public int getKeepAliveInterval()
Retrieves the keepalive interval that should be used for new client connections.

Returns:
The keepalive interval that should be used for new client connections.

getMaxResponseWaitTime

public int getMaxResponseWaitTime()
Retrieves the maximum length of time in seconds that the SLAMD server will wait for a response to a request issued to a stat client.

Returns:
The maximum length of time in seconds that the SLAMD server will wait for a response to a request issued to a stat client.

requireAuthentication

public boolean requireAuthentication()
Indicates whether this listener is configured to require authentication.

Returns:
true if this listener is configured to require authentication, or false if not.

getSubscriberName

public java.lang.String getSubscriberName()
Retrieves the name that the stat 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 stat 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()
                                    throws SLAMDServerException
Re-reads all configuration information used by the stat listener. In this case, it doesn't do anything because nothing is dynamically reconfigurable.

Specified by:
refreshSubscriberConfiguration in interface ConfigSubscriber
Throws:
SLAMDServerException - If there is a problem reading or applying the changes.

refreshSubscriberConfiguration

public void refreshSubscriberConfiguration(java.lang.String parameterName)
                                    throws SLAMDServerException
Re-reads the configuration for the specified parameter if the parameter is applicable to the stat listener. In this case, nothing will be applicable.

Specified by:
refreshSubscriberConfiguration in interface ConfigSubscriber
Parameters:
parameterName - The name of the parameter for which to reread the configuration.
Throws:
SLAMDServerException - If there is a problem reading or applying the specified change.