org.objectweb.cjdbc.driver.connectpolicy
Class AbstractControllerConnectPolicy

java.lang.Object
  extended byorg.objectweb.cjdbc.driver.connectpolicy.AbstractControllerConnectPolicy
Direct Known Subclasses:
OrderedConnectPolicy, PreferredListConnectPolicy, RandomConnectPolicy, RoundRobinConnectPolicy, SingleConnectPolicy

public abstract class AbstractControllerConnectPolicy
extends java.lang.Object

This class defines an AbstractControllerConnectPolicy used by the driver to choose a controller to connect to.

Version:
1.0
Author:
Emmanuel Cecchet

Field Summary
protected  ControllerInfo[] controllerList
           
private  ControllerPingThread controllerPingThread
           
protected  int debugLevel
           
private  long retryIntervalInMs
           
protected  java.util.HashSet suspectedControllers
           
 
Constructor Summary
AbstractControllerConnectPolicy(ControllerInfo[] controllerList, long retryIntervalInMs, int debugLevel)
          Creates a new AbstractControllerConnectPolicy object
 
Method Summary
protected  void finalize()
          Terminate the controller ping thread if any and cleanup the suspected controller list.
abstract  ControllerInfo getController()
          Get a controller using the implementation specific policy
 ControllerInfo[] getControllerList()
          Returns the controllerList value.
 java.util.HashSet getSuspectedControllers()
          Returns the suspectedControllers value.
 boolean isSuspectedOfFailure(ControllerInfo controllerInfo)
          Returns true if the specified controller is suspected of failure.
 void removeControllerFromSuspectList(ControllerInfo controller)
          Remove the specified controller from the list of suspect controllers
 void setControllerList(ControllerInfo[] controllerList)
          Sets the controllerList value.
 void suspectControllerOfFailure(ControllerInfo controllerInfo)
          Add the controller to the list of suspects.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

controllerList

protected ControllerInfo[] controllerList

suspectedControllers

protected java.util.HashSet suspectedControllers

retryIntervalInMs

private long retryIntervalInMs

controllerPingThread

private ControllerPingThread controllerPingThread

debugLevel

protected int debugLevel
Constructor Detail

AbstractControllerConnectPolicy

public AbstractControllerConnectPolicy(ControllerInfo[] controllerList,
                                       long retryIntervalInMs,
                                       int debugLevel)
Creates a new AbstractControllerConnectPolicy object

Parameters:
controllerList - the controller list on which the policy applies
retryIntervalInMs - Interval in milliseconds before retrying to re-connect to a controller that has failed
debugLevel - the debug level to use
See Also:
CjdbcUrl.DEBUG_LEVEL_OFF
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Terminate the controller ping thread if any and cleanup the suspected controller list.

Throws:
java.lang.Throwable
See Also:
Object.finalize()

getController

public abstract ControllerInfo getController()
                                      throws NoMoreControllerException
Get a controller using the implementation specific policy

Returns:
ControllerInfo of the selected controller
Throws:
NoMoreControllerException - if no controller in the controller list is reachable

getControllerList

public ControllerInfo[] getControllerList()
Returns the controllerList value.

Returns:
Returns the controllerList.

getSuspectedControllers

public java.util.HashSet getSuspectedControllers()
Returns the suspectedControllers value.

Returns:
Returns the suspectedControllers.

isSuspectedOfFailure

public boolean isSuspectedOfFailure(ControllerInfo controllerInfo)
Returns true if the specified controller is suspected of failure.

Parameters:
controllerInfo - the controller to check
Returns:
true if the controller is in the suspect list

setControllerList

public void setControllerList(ControllerInfo[] controllerList)
Sets the controllerList value.

Parameters:
controllerList - The controllerList to set.

suspectControllerOfFailure

public void suspectControllerOfFailure(ControllerInfo controllerInfo)
Add the controller to the list of suspects.

Parameters:
controllerInfo - the controller suspected of failure

removeControllerFromSuspectList

public void removeControllerFromSuspectList(ControllerInfo controller)
Remove the specified controller from the list of suspect controllers

Parameters:
controller - the controller to remove from the list


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.