org.objectweb.cjdbc.driver.connectpolicy
Class OrderedConnectPolicy

java.lang.Object
  extended byorg.objectweb.cjdbc.driver.connectpolicy.AbstractControllerConnectPolicy
      extended byorg.objectweb.cjdbc.driver.connectpolicy.OrderedConnectPolicy

public class OrderedConnectPolicy
extends AbstractControllerConnectPolicy

This class defines an OrderedConnectPolicy used when the C-JDBC URL has the following form: jdbc:cjdbc://node1,node2,node3/myDB?preferredController=ordered

This always direct to the first available controller in the list following the order of the list. With this example, we first try node1, and if not available then try to node2 and finally if none are available try node3.

Version:
1.0
Author:
Emmanuel Cecchet

Field Summary
private  java.util.ArrayList availableControllerList
           
 
Fields inherited from class org.objectweb.cjdbc.driver.connectpolicy.AbstractControllerConnectPolicy
controllerList, debugLevel, suspectedControllers
 
Constructor Summary
OrderedConnectPolicy(ControllerInfo[] controllerList, long retryIntervalInMs, int debugLevel)
          Creates a new OrderedConnectPolicy object
 
Method Summary
 ControllerInfo getController()
          Get a controller using the implementation specific policy
 void removeControllerFromSuspectList(ControllerInfo controller)
          Remove the specified controller from the list of suspect controllers
 void suspectControllerOfFailure(ControllerInfo controllerInfo)
          Add the controller to the list of suspects.
 
Methods inherited from class org.objectweb.cjdbc.driver.connectpolicy.AbstractControllerConnectPolicy
finalize, getControllerList, getSuspectedControllers, isSuspectedOfFailure, setControllerList
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

availableControllerList

private java.util.ArrayList availableControllerList
Constructor Detail

OrderedConnectPolicy

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

Parameters:
controllerList - list of controller from C-JDBC url
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

removeControllerFromSuspectList

public void removeControllerFromSuspectList(ControllerInfo controller)
Description copied from class: AbstractControllerConnectPolicy
Remove the specified controller from the list of suspect controllers

Overrides:
removeControllerFromSuspectList in class AbstractControllerConnectPolicy
Parameters:
controller - the controller to remove from the list
See Also:
AbstractControllerConnectPolicy.removeControllerFromSuspectList(org.objectweb.cjdbc.driver.ControllerInfo)

suspectControllerOfFailure

public void suspectControllerOfFailure(ControllerInfo controllerInfo)
Description copied from class: AbstractControllerConnectPolicy
Add the controller to the list of suspects.

Overrides:
suspectControllerOfFailure in class AbstractControllerConnectPolicy
Parameters:
controllerInfo - the controller suspected of failure
See Also:
AbstractControllerConnectPolicy.suspectControllerOfFailure(org.objectweb.cjdbc.driver.ControllerInfo)

getController

public ControllerInfo getController()
                             throws NoMoreControllerException
Description copied from class: AbstractControllerConnectPolicy
Get a controller using the implementation specific policy

Specified by:
getController in class AbstractControllerConnectPolicy
Returns:
ControllerInfo of the selected controller
Throws:
NoMoreControllerException - if no controller in the controller list is reachable
See Also:
AbstractControllerConnectPolicy.getController()


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