|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectParkNPark.client.FaultTolerantClientManager
public class FaultTolerantClientManager
Fault tolerant client manager that wraps a remote ClientManager and rolls over to a new primary server in the presence of failures. Note that this class is not multi-thread safe. Multiple threads should synchronize access or wrap this class with a thread-safe delegate.
Nested Class Summary | |
---|---|
protected class |
FaultTolerantClientManager.BackgroundThread
Background thread that performs the following actions in a loop continuously: Recover from a fault on the primary server if one was detected by either this thread or by the main thread Refresh the list of servers from the naming service Poke each server serially and, upon fault detection, remove that server from the list of servers. |
protected class |
FaultTolerantClientManager.ReturnValueOrException
Return value or an exception along with the return value or the exception object. |
Field Summary | |
---|---|
protected FaultTolerantClientManager.BackgroundThread |
backgroundThread
Our background thread that handles name service interactions, fault detections, and fault recoveries |
protected int |
clientID
The server-generated client ID |
protected static Method |
closeClientManager
|
protected static Method |
enterLot
|
protected PrintStream |
err
Original System.err object instance |
protected static Method |
exitLot
|
protected ClientManagerFactory |
factory
The last-known client manager factory instance |
protected boolean |
fault
When true, we are presently processing a fault |
protected LogEntry |
faultyCallLogEntry
A logEntry instance to log to when fault is true |
protected static Method |
getClientID
|
protected static Method |
getCurrentLevel
|
protected static Method |
getLots
|
protected static Method |
getMaxLevel
|
protected static Method |
getMinLevel
|
protected static Method |
getOtherLotAvailability
|
protected static PrintStream |
inputEater
Shared static instance of the input eater output stream wrapped in a PrintStream |
private int |
interRequestTime
Time between requests |
protected Logger |
logger
Our Logger instance |
protected static Method |
moveDownLevel
|
protected static Method |
moveUpLevel
|
protected boolean |
neverGiveUp
When true, never give up when trying to contact the server |
protected ClientManager |
primaryClientManager
The primary client manager |
protected Object |
primaryClientManagerLock
Lock for primaryClientManager, factory, faultyCallLogEntry, systemDown, and fault |
protected int |
recoveryTimeout
The wait timeout to use during fault recoveries |
protected int |
seq
The latest sequence number from the client |
protected boolean |
systemDown
When true, the system is officially down due to no registration of a primary server |
protected static String |
unexpectedException
Message for unexpected exceptions that arise during remote method calls (non-IDL and non-CORBA exceptions) |
Constructor Summary | |
---|---|
FaultTolerantClientManager(ORB orb,
Logger logger,
int interRequestTime,
boolean neverGiveUp,
int detectionTimeout,
int recoveryTimeout,
PrintStream err)
Creates a new fault-tolerant client manager that automatically fails over to new primary servers on method call failures |
Method Summary | |
---|---|
protected FaultTolerantClientManager.ReturnValueOrException |
callServer(Method method,
boolean logAndWait,
Object... arguments)
Calls the given method on the server with the given arguments and returns a ReturnValueOrException object to indicate a normal or exceptional result and contain the return value or the exception object. |
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. |
protected boolean |
connectToAnyServer(ClientManager faultyClientManager,
LogEntry logEntry)
Connects to any registered server, which is chosen randomly |
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 |
void |
hoseServerDatabaseConnection()
Hoses the server's database connection. |
protected void |
interRequestWait()
Wait for the configured inter-request wait period or, if none is configured, return immediately. |
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ClientManager primaryClientManager
protected ClientManagerFactory factory
protected boolean fault
protected boolean systemDown
protected LogEntry faultyCallLogEntry
protected Object primaryClientManagerLock
protected FaultTolerantClientManager.BackgroundThread backgroundThread
protected int seq
protected int clientID
private int interRequestTime
protected Logger logger
protected boolean neverGiveUp
protected int recoveryTimeout
protected PrintStream err
protected static final Method getClientID
protected static final Method enterLot
protected static final Method exitLot
protected static final Method getOtherLotAvailability
protected static final Method getLots
protected static final Method moveUpLevel
protected static final Method moveDownLevel
protected static final Method getCurrentLevel
protected static final Method getMaxLevel
protected static final Method getMinLevel
protected static final Method closeClientManager
protected static final String unexpectedException
protected static PrintStream inputEater
Constructor Detail |
---|
public FaultTolerantClientManager(ORB orb, Logger logger, int interRequestTime, boolean neverGiveUp, int detectionTimeout, int recoveryTimeout, PrintStream err) throws ServiceUnavailableException
orb
- The object request broker instance to uselogger
- The Logger instance to write performance data tointerRequestTime
- The time to wait between method invocationsneverGiveUp
- When true, the client will never give up its attempt to
contact the server, even if no primary is registereddetectionTimeout
- The wait timeout to use during fault detectionsrecoveryTimeout
- The wait timeout to use during fault recoveriesThe
- System.err instance to use
ServiceUnavailableException
- Thrown when a primary server could not be
located or contactedMethod Detail |
---|
protected FaultTolerantClientManager.ReturnValueOrException callServer(Method method, boolean logAndWait, Object... arguments)
method
- The method to call on our client manager on the primary serverlogAndWait
- When true, this method call will be logged and, after returning
from that call, this method will wait for the inter-request time before returningarguments
- The arguments to pass to the given method's parameters
public PaddedInteger getClientID() throws ServiceUnavailableException
getClientID
in interface ClientManagerOperations
ServiceUnavailableException
- Thrown when the log is closed and the
server is shutting downpublic PaddedIntegerSeq enterLot(int seq, int lot) throws AlreadyInLotException, LotNotFoundException, LotFullException, ServiceUnavailableException
enterLot
in interface ClientManagerOperations
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
exitLot
in interface ClientManagerOperations
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 lot
[Category: Baseline; Requirement: 7]public PaddedIntegerSeq getOtherLotAvailability(int lot) throws LotNotFoundException, ServiceUnavailableException
getOtherLotAvailability
in interface ClientManagerOperations
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 PaddedIntegerSeq getLots() throws ServiceUnavailableException
getLots
in interface ClientManagerOperations
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the system from discovering the its defined lotspublic PaddedInteger moveUpLevel(int seq) throws NotInLotException, AtTopLevelException, ServiceUnavailableException
moveUpLevel
in interface ClientManagerOperations
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 levelpublic PaddedInteger moveDownLevel(int seq) throws NotInLotException, AtBottomLevelException, ServiceUnavailableException
moveDownLevel
in interface ClientManagerOperations
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 getCurrentLevel() throws NotInLotException, ServiceUnavailableException
getCurrentLevel
in interface ClientManagerOperations
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 PaddedInteger getMaxLevel() throws NotInLotException, ServiceUnavailableException
getMaxLevel
in interface ClientManagerOperations
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
getMinLevel
in interface ClientManagerOperations
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 void closeClientManager() throws ServiceUnavailableException
closeClientManager
in interface ClientManagerOperations
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 thrownprotected void interRequestWait()
public void hoseServerDatabaseConnection()
protected boolean connectToAnyServer(ClientManager faultyClientManager, LogEntry logEntry)
faultyClientManager
- The ClientManager that was deemed to be faulty, or null
if no ClientManager is faultylogEntry
- The LogEntry object to write performance data
to when not null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |