com.sun.slamd.clientmanager
Class ClientManager

java.lang.Object
  extended by com.sun.slamd.clientmanager.ClientManager

public class ClientManager
extends java.lang.Object

This class defines a client manager that will manage the process of starting clients independent of the SLAMD server itself.

Author:
Neil A. Wilson

Field Summary
static int MAX_BLOCK_TIME
          The maximum length of time in milliseconds that any part of this client manager should block at any one time.
static int SERVER_DOWN_CHECK_TIME
          The length of time between checks to determine whether the SLAMD server is available if it was detected that it has been taken offline.
 
Constructor Summary
ClientManager(java.lang.String serverAddress, int serverPort, boolean useSSL, boolean blindTrust, java.lang.String sslKeyStore, java.lang.String sslKeyStorePassword, java.lang.String sslTrustStore, java.lang.String sslTrustStorePassword, int maxClients, java.lang.String startCommand, ClientMessageWriter messageWriter)
          Creates a new client manager that is intended to work with the specified SLAMD server.
 
Method Summary
 void disconnect()
          Closes the connection to the SLAMD server and disconnects any clients that may be connected.
 int nextMessageID()
          Retreives the next message ID that should be used to send a message to the SLAMD server.
 void run()
          Establishes a connection to the SLAMD server and then operates in a loop waiting for requests to arrive.
 void setAutoCreateClients(int autoCreateClients)
          Specifies the number of client instances to create automatically when establishing a connection to the SLAMD server.
 void sleepBeforeReconnectAttempt()
          Allows the client manager to sleep for a period of time before it checks to see if the SLAMD server is available.
 void startClients(int numClients)
          Attempts to start the specified number of clients, presumably as a result of a start client request from the SLAMD server.
 void startClients(StartClientRequestMessage startClientRequest)
          Attempts to start the specified number of clients, presumably as a result of a start client request from the SLAMD server.
 void stopClients(StopClientRequestMessage stopClientRequest)
          Attempts to stop the specified number of clients, presumably as a result of a stop client request from the SLAMD server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_BLOCK_TIME

public static final int MAX_BLOCK_TIME
The maximum length of time in milliseconds that any part of this client manager should block at any one time.

See Also:
Constant Field Values

SERVER_DOWN_CHECK_TIME

public static final int SERVER_DOWN_CHECK_TIME
The length of time between checks to determine whether the SLAMD server is available if it was detected that it has been taken offline.

See Also:
Constant Field Values
Constructor Detail

ClientManager

public ClientManager(java.lang.String serverAddress,
                     int serverPort,
                     boolean useSSL,
                     boolean blindTrust,
                     java.lang.String sslKeyStore,
                     java.lang.String sslKeyStorePassword,
                     java.lang.String sslTrustStore,
                     java.lang.String sslTrustStorePassword,
                     int maxClients,
                     java.lang.String startCommand,
                     ClientMessageWriter messageWriter)
Creates a new client manager that is intended to work with the specified SLAMD server.

Parameters:
serverAddress - The address of the SLAMD server.
serverPort - The port number of the SLAMD server.
useSSL - Indicates whether to use SSL to communicate with the SLAMD server.
blindTrust - Indicates whether to blindly trust any SSL certificate presented by the SLAMD server.
sslKeyStore - The location of the JSSE key store.
sslKeyStorePassword - The password required to access the SSL key store.
sslTrustStore - The location of the JSSE trust store.
sslTrustStorePassword - The password required to access the SSL trust store.
maxClients - The maximum number of clients that may be created on this system.
startCommand - The command to execute to start a single client instance.
messageWriter - The message writer to use for output.
Method Detail

setAutoCreateClients

public void setAutoCreateClients(int autoCreateClients)
Specifies the number of client instances to create automatically when establishing a connection to the SLAMD server.

Parameters:
autoCreateClients - The number of client instances to create automatically when establishing a connection to the SLAMD server.

run

public void run()
Establishes a connection to the SLAMD server and then operates in a loop waiting for requests to arrive.


nextMessageID

public int nextMessageID()
Retreives the next message ID that should be used to send a message to the SLAMD server.

Returns:
The next message ID that should be used to send a message to the SLAMD server.

startClients

public void startClients(int numClients)
Attempts to start the specified number of clients, presumably as a result of a start client request from the SLAMD server. In general, this should only be called when automatically creating client instances when the client manager connects to the SLAMD server.

Parameters:
numClients - The number of instances of the client to create.

startClients

public void startClients(StartClientRequestMessage startClientRequest)
Attempts to start the specified number of clients, presumably as a result of a start client request from the SLAMD server.

Parameters:
startClientRequest - The start client request to be processed.

stopClients

public void stopClients(StopClientRequestMessage stopClientRequest)
Attempts to stop the specified number of clients, presumably as a result of a stop client request from the SLAMD server.

Parameters:
stopClientRequest - The request received from the server.

disconnect

public void disconnect()
Closes the connection to the SLAMD server and disconnects any clients that may be connected.


sleepBeforeReconnectAttempt

public void sleepBeforeReconnectAttempt()
Allows the client manager to sleep for a period of time before it checks to see if the SLAMD server is available. It will generally sleep for a time equal to SERVER_DOWN_CHECK_TIME, but it can stop sooner if the client manager is asked to shut down.