Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy Class Reference

Inheritance diagram for org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 ErrorCheckingPolicy (int policy, int numberOfNodes)
int getNumberOfNodes ()
void setNumberOfNodes (int numberOfNodes)
int getPolicy ()
void setPolicy (int policy)
abstract ArrayList getBackends (ArrayList backends) throws ErrorCheckingException
abstract String getInformation ()
String getXml ()

Static Public Attributes

final int RANDOM = 0
final int ROUND_ROBIN = 1
final int ALL = 2

Protected Attributes

int nbOfNodes = 0
int policy

Detailed Description

Defines the policy to adopt for error checking.

Author:
Emmanuel Cecchet
Version:
1.0

Definition at line 37 of file ErrorCheckingPolicy.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.ErrorCheckingPolicy int  policy,
int  numberOfNodes
 

Creates a new CreateTableRule.

Parameters:
policy implemented policy
numberOfNodes number of nodes to use to check for errors on a query

Definition at line 59 of file ErrorCheckingPolicy.java.

00060   {
00061     setPolicy(policy);
00062     setNumberOfNodes(numberOfNodes);
00063   }


Member Function Documentation

abstract ArrayList org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.getBackends ArrayList  backends  )  throws ErrorCheckingException [pure virtual]
 

Pickups backends from the given backends arraylist according to the current rule policy.

Parameters:
backends backends to choose from
Returns:
Arraylist of choosen DatabaseBackend
Exceptions:
ErrorCheckingException if the rule cannot be applied

Implemented in org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingAll, org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingRandom, and org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingRoundRobin.

abstract String org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.getInformation  )  [pure virtual]
 

Gives information about the current policy.

Returns:
a String value

Implemented in org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingAll, org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingRandom, and org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingRoundRobin.

int org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.getNumberOfNodes  ) 
 

Returns the number of nodes.

Returns:
an int value
See also:
setNumberOfNodes

Definition at line 71 of file ErrorCheckingPolicy.java.

00072   {
00073     return nbOfNodes;
00074   }

int org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.getPolicy  ) 
 

Returns the policy.

Returns:
an int value
See also:
setPolicy

Definition at line 98 of file ErrorCheckingPolicy.java.

00099   {
00100     return policy;
00101   }

String org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.getXml  ) 
 

Convert this error checking policy to xml

Returns:
xml formatted string

Definition at line 137 of file ErrorCheckingPolicy.java.

00139   {
00140     StringBuffer info = new StringBuffer();
00141     info.append(
00142       "<"
00143         + DatabasesXmlTags.ELT_ErrorChecking
00144         + " />"
00145         + DatabasesXmlTags.ATT_numberOfNodes
00146         + "=\""
00147         + this.getNumberOfNodes()
00148         + "\" "
00149         + DatabasesXmlTags.ATT_policy
00150         + "=\"");
00151     switch (policy)
00152     {
00153       case RANDOM :
00154         info.append(DatabasesXmlTags.VAL_random);
00155       case ROUND_ROBIN :
00156         info.append(DatabasesXmlTags.VAL_roundRobin);
00157       case ALL :
00158         info.append(DatabasesXmlTags.VAL_all);
00159       default :
00160         }
00161     info.append("\"/>");
00162     return info.toString();
00163   }

void org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.setNumberOfNodes int  numberOfNodes  ) 
 

Sets the number of nodes.

Parameters:
numberOfNodes the number of nodes to set
See also:
getNumberOfNodes

Definition at line 82 of file ErrorCheckingPolicy.java.

00083   {
00084     if (numberOfNodes < 3)
00085       throw new IllegalArgumentException(
00086         "You must use at least 3 nodes for error checking ("
00087           + numberOfNodes
00088           + " is not acceptable)");
00089     this.nbOfNodes = numberOfNodes;
00090   }

void org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.setPolicy int  policy  ) 
 

Sets the policy.

Parameters:
policy the policy to set
See also:
getPolicy

Definition at line 109 of file ErrorCheckingPolicy.java.

00110   {
00111     this.policy = policy;
00112   }


Member Data Documentation

final int org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.ALL = 2 [static]
 

Request is sent to all backends.

Definition at line 46 of file ErrorCheckingPolicy.java.

int org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.nbOfNodes = 0 [protected]
 

Number of nodes that are involved in error-checking per request.

Definition at line 49 of file ErrorCheckingPolicy.java.

final int org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.RANDOM = 0 [static]
 

Pickup backends randomly.

Definition at line 40 of file ErrorCheckingPolicy.java.

final int org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.ROUND_ROBIN = 1 [static]
 

Backends are chosen using a round-robin algorithm.

Definition at line 43 of file ErrorCheckingPolicy.java.


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:03:59 2005 for C-JDBC by  doxygen 1.3.9.1