ParkNPark.middletier
Class ClientManagerFactoryImpl

java.lang.Object
  extended by org.omg.PortableServer.Servant
      extended by ParkNPark.interfaces.ClientManagerFactoryPOA
          extended by ParkNPark.middletier.ClientManagerFactoryImpl
All Implemented Interfaces:
InvokeHandler, ClientManagerFactoryOperations

public class ClientManagerFactoryImpl
extends ClientManagerFactoryPOA

Creates and manages ClientManager instances for clients


Field Summary
protected  DatabaseManager databaseManager
          Our database manager instance
protected  Logger logger
          Logger instance
protected static int MAX_ATTEMPTS
          Maximum number of attempts when trying to execute commends on database
protected  PreparedStatement pokeStatement
          Our database poke prepared statement that is used during database pokes
protected  int replySize
          Size of reply
 
Constructor Summary
ClientManagerFactoryImpl(Logger logger, int replySize, String jdbcURL, String jdbcUsername, String jdbcPassword)
          Creates a new ClientManagerFactoryImpl instance
 
Method Summary
 void exitServer()
          Kills the server (we don't have graceful shutdowns in this implementation)
 void flushLogs()
          Flushes the server's log files
 ClientManager getClientManager(String clientHostname)
          Creates a new client manager instance for a new client
 ClientManager getExistingClientManager(int clientID, String clientHostname)
          Returns the existing client manager instance for an existing client.
 void hoseDatabaseConnection()
          Causes the server's database connection to become "hosed," meaning that it will fail to work after this method is called.
 void killServer()
          Kills the server
 void poke()
          Pokes the server to see if it is still alive and that it can still communicate with the database
 
Methods inherited from class ParkNPark.interfaces.ClientManagerFactoryPOA
_all_interfaces, _invoke, _this, _this
 
Methods inherited from class org.omg.PortableServer.Servant
_default_POA, _get_delegate, _get_interface_def, _is_a, _non_existent, _object_id, _orb, _poa, _set_delegate, _this_object, _this_object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_ATTEMPTS

protected static final int MAX_ATTEMPTS
Maximum number of attempts when trying to execute commends on database

See Also:
Constant Field Values

databaseManager

protected DatabaseManager databaseManager
Our database manager instance


replySize

protected int replySize
Size of reply


logger

protected Logger logger
Logger instance


pokeStatement

protected PreparedStatement pokeStatement
Our database poke prepared statement that is used during database pokes

Constructor Detail

ClientManagerFactoryImpl

public ClientManagerFactoryImpl(Logger logger,
                                int replySize,
                                String jdbcURL,
                                String jdbcUsername,
                                String jdbcPassword)
                         throws SQLException
Creates a new ClientManagerFactoryImpl instance

Parameters:
logger - The Logger to write performance data to
replySize - The size of the message replies to use
jdbcURL - The JDBC URL to use in the database connection
jdbcUsername - The username to use in the database connection
jdbcPassword - The password to use in the database connection
Throws:
SQLException - Thrown when a problem prevents a connection to the database
Method Detail

getClientManager

public ClientManager getClientManager(String clientHostname)
                               throws ServiceUnavailableException
Creates a new client manager instance for a new client

Parameters:
clientHostname - The host name of the client
Returns:
A new client manager instance for a new client
Throws:
ServiceUnavailableException - Thrown if the database cannot be contacted or if some other reason prevents the client manager from being created successfully

getExistingClientManager

public ClientManager getExistingClientManager(int clientID,
                                              String clientHostname)
                                       throws ServiceUnavailableException,
                                              InvalidClientException
Returns the existing client manager instance for an existing client. A client can call this method with its client ID and last sequence number on any server and will get its client manager instance

Parameters:
clientID - The ID of the client to get the ClientManager of
clientHostname - The host name of the client
Returns:
The existing client manager instance for an existing client
Throws:
InvalidClientException - Thrown when the given client ID is not known to the system
ServiceUnavailableException - Thrown if the database cannot be contacted or if some other reason prevents the client manager from being retrieved successfully

poke

public void poke()
          throws ServiceUnavailableException
Pokes the server to see if it is still alive and that it can still communicate with the database

Throws:
ServiceUnavailableException - Thrown when the server's database connection is not working

hoseDatabaseConnection

public void hoseDatabaseConnection()
Causes the server's database connection to become "hosed," meaning that it will fail to work after this method is called. This is used primarily for fault injection


flushLogs

public void flushLogs()
Flushes the server's log files


killServer

public void killServer()
Kills the server


exitServer

public void exitServer()
Kills the server (we don't have graceful shutdowns in this implementation)