|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.omg.PortableServer.Servant
ParkNPark.interfaces.ClientManagerPOA
ParkNPark.middletier.ClientManagerImpl
public class ClientManagerImpl
Server object that will manage communication between the client and the database.
Field Summary | |
---|---|
protected PreparedStatement |
checkDuplicate
Statements used for duplicate message detection |
protected String |
clientHostname
Client's hostname |
protected int |
clientID
Client's ID used for fault-tolerance |
protected Connection |
conn
Connection to the database |
protected DatabaseManager |
databaseManager
Our database manager instance |
protected static int |
INTEGER_SIZE
Size of an intger variable |
protected byte[] |
integerPadding
Byte array used to pad integer variables |
protected int |
level
Level that client is in |
protected Logger |
logger
Our Logger instance |
protected int |
lot
Lot that client is in |
protected static int |
MAX_ATTEMPTS
Maximum number of attempts when trying to execute commends on database |
protected PaddedVoid |
paddedVoid
PaddedVoid instance for padded void returns |
protected static boolean |
PRINT_LEVELS_STATUS
|
protected static boolean |
PRINT_LOTS_STATUS
Flags used to print out the status of lots and levels |
protected int |
replySize
Size of replies |
protected int |
seq
Client's current operation sequence number used for fault-tolerance |
protected PreparedStatement |
updateSequence
|
Constructor Summary | |
---|---|
ClientManagerImpl(DatabaseManager databaseManager,
int clientID,
String clientHostname,
Logger logger,
int replySize)
Create a client manager for an existing client that will hold information specific to the client. |
|
ClientManagerImpl(DatabaseManager databaseManager,
String clientHostname,
Logger logger,
int replySize)
Create a client manager for a new client that will hold information specific to the client. |
Method Summary | |
---|---|
protected boolean |
alreadyCompleted(int seq)
Checks if the current client request has already been completed. |
void |
closeClientManager()
Closes the client manager and frees server resources associated with it, including the client manager's activation in the server's CORBA portable object adapter |
PaddedIntegerSeq |
enterLot(int seq,
int lot)
Moves the client's car into the lot with the given lot number and returns an array of level numbers that have available spaces |
PaddedVoid |
exitLot(int seq)
Removes the client's car from the lot that it is currently in |
PaddedInteger |
getClientID()
Returns the client's ID, which can be used in the client manager factory's getExistingClientManager() method |
PaddedInteger |
getCurrentLevel()
Returns the car's current level number |
PaddedIntegerSeq |
getLots()
Returns an array of valid lot numbers in the system, sorted by the lot number in ascending order |
PaddedInteger |
getMaxLevel()
Returns the top level number of the car's current parking lot |
PaddedInteger |
getMinLevel()
Returns the bottom level number of the car's current parking lot |
PaddedIntegerSeq |
getOtherLotAvailability(int lot)
Returns an array of other lots that have availability, sorted by lot distance such that closer lots are listed first |
PaddedInteger |
moveDownLevel(int seq)
Moves the car from its present level to the level beneath it |
PaddedInteger |
moveUpLevel(int seq)
Moves the car from its present level to the level above it |
protected PaddedInteger |
padInteger(int value)
Pad the integer in order to make it comply with the reply size of the analysis |
protected PaddedIntegerSeq |
padIntegerArray(int[] value)
Pad the integer array in order to make it comply with the reply size of the analysis |
protected PaddedVoid |
padVoid()
Pad the void in order to make it comply with the reply size of the analysis |
protected void |
printLevelsStatus(String message,
int seq)
Print the status of all the levels in the current lot |
protected void |
printLotsStatus(String message,
int seq)
Print the status of all the lots |
protected void |
setupDatabaseConn()
Set up the database connection |
protected void |
setupProbes(String clientHostname,
Logger logger,
int replySize)
Setup probes for real-time analysis |
protected void |
updateClientData(int seq,
int lot,
int level)
Updates the client table, which is used for duplicate detection. |
Methods inherited from class ParkNPark.interfaces.ClientManagerPOA |
---|
_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 |
---|
protected static final int MAX_ATTEMPTS
protected static int INTEGER_SIZE
protected byte[] integerPadding
protected PaddedVoid paddedVoid
protected static final boolean PRINT_LOTS_STATUS
protected static final boolean PRINT_LEVELS_STATUS
protected DatabaseManager databaseManager
protected int clientID
protected int seq
protected int lot
protected int level
protected Connection conn
protected PreparedStatement checkDuplicate
protected PreparedStatement updateSequence
protected String clientHostname
protected int replySize
protected Logger logger
Constructor Detail |
---|
public ClientManagerImpl(DatabaseManager databaseManager, int clientID, String clientHostname, Logger logger, int replySize) throws ServiceUnavailableException, InvalidClientException
databaseManager
- The database manager to use in this client managerclientID
- The ID of the client to restore this ClientManager instance fromclientHostname
- The hostname of the clientlogger
- The Logger object to log performance data toreplySize
- The size of the method return values to use for the current test
ServiceUnavailableException
- Thrown when a database exception prevented the client
manager from being created successfully
InvalidClientException
- Thrown when the given client ID does not exist in
the databasepublic ClientManagerImpl(DatabaseManager databaseManager, String clientHostname, Logger logger, int replySize) throws ServiceUnavailableException
databaseManager
- The database manager to use in this client managerclientHostname
- The hostname of the clientlogger
- The Logger object to log performance data toreplySize
- The size of the method return values to use for the current test
ServiceUnavailableException
- Thrown when a database exception prevented the client
manager from being created successfullyMethod Detail |
---|
protected void setupDatabaseConn() throws ServiceUnavailableException
ServiceUnavailableException
- Thrown if a problem came up while connecting to the database server
or setting it up after connectingprotected void setupProbes(String clientHostname, Logger logger, int replySize)
clientHostname
- numClients
- interRequestTime
- replySize
- serverHostname
- public void closeClientManager() throws ServiceUnavailableException
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the system from closing the client manager. The client manager remains
open if this exception gets thrownpublic PaddedIntegerSeq enterLot(int seq, int lot) throws AlreadyInLotException, LotNotFoundException, LotFullException, ServiceUnavailableException
seq
- The latest sequence number of the clientlot
- The lot number to enter
AlreadyInLotException
- Thrown when the client's car is already in a lot
LotNotFoundException
- Thrown if the given lot number is not known to the system
LotFullException
- Thrown if the given lot is full
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the car from entering the lotpublic PaddedVoid exitLot(int seq) throws NotInLotException, NotOnExitLevelException, ServiceUnavailableException
seq
- The latest sequence number of the client
NotInLotException
- Thrown if the car is not in a lot
NotOnExitLevelException
- Thrown if the car is in a lot but is not on a permitted
exit level
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the car from exiting the lotpublic PaddedInteger getClientID() throws ServiceUnavailableException
ServiceUnavailableException
- Thrown when the log is closed and the
server is shutting downpublic PaddedInteger getCurrentLevel() throws NotInLotException, ServiceUnavailableException
NotInLotException
- Thrown if the car is not in a lot
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the system from returning the car's current levelpublic PaddedIntegerSeq getLots() throws ServiceUnavailableException
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the system from discovering the its defined lotspublic PaddedInteger getMaxLevel() throws NotInLotException, ServiceUnavailableException
NotInLotException
- Thrown if the car is not in a lot
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the system from returning the current lot's highest levelpublic PaddedInteger getMinLevel() throws NotInLotException, ServiceUnavailableException
NotInLotException
- Thrown if the car is not in a lot
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the system from returning the current lot's lowest levelpublic PaddedIntegerSeq getOtherLotAvailability(int lot) throws LotNotFoundException, ServiceUnavailableException
lot
- The lot to get lot distances from
LotNotFoundException
- Thrown if the given lot number is not known to the system
ServiceUnavailableException
- Thrown if the database cannot be contacted or if
some other reason prevents the system from discovering the availability of other lotspublic PaddedInteger moveDownLevel(int seq) throws NotInLotException, AtBottomLevelException, ServiceUnavailableException
seq
- The latest sequence number of the client
NotInLotException
- Thrown if the car is not in a lot
AtTopLevelException
- Thrown if the car is already on the lowest level
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some other reason prevents the car from moving to the lower level
AtBottomLevelException
public PaddedInteger moveUpLevel(int seq) throws NotInLotException, AtTopLevelException, ServiceUnavailableException
seq
- The latest sequence number of the client
NotInLotException
- Thrown if the car is not in a lot
AtTopLevelException
- Thrown if the car is already on the highest level
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the car from moving to the next highest levelprotected boolean alreadyCompleted(int seq) throws ServiceUnavailableException
seq
-
ServiceUnavailableException
protected void updateClientData(int seq, int lot, int level) throws ServiceUnavailableException
seq
- lot
- level
-
ServiceUnavailableException
protected void printLotsStatus(String message, int seq)
message
- The message to display with the statusseq
- The client request sequence numberprotected void printLevelsStatus(String message, int seq)
message
- The message to display with the statusseq
- The client request sequence numberprotected PaddedIntegerSeq padIntegerArray(int[] value)
value
-
protected PaddedInteger padInteger(int value)
value
-
protected PaddedVoid padVoid()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |