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

org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule Class Reference

Inheritance diagram for org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 CreateTableRule (int policy)
 CreateTableRule (int policy, ArrayList backendList)
void addBackendName (String name)
ArrayList getBackendList ()
int getNumberOfNodes ()
void setNumberOfNodes (int numberOfNodes)
String getTableName ()
void setTableName (String tableName)
int getPolicy ()
void setPolicy (int policy)
boolean isDefaultRule ()
ArrayList getBackends (ArrayList backends) throws CreateTableException
abstract String getInformation ()
String getXml ()

Protected Attributes

ArrayList backendList
int nbOfNodes = 0
String tableName = null
int policy

Detailed Description

Defines the policy to adopt when creating a new table.

Author:
Emmanuel Cecchet

Jean-Bernard van Zuylen

Version:
1.0

Definition at line 40 of file CreateTableRule.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.CreateTableRule int  policy  ) 
 

Constructor for CreateTableRule.

Parameters:
policy the implemented policy

Definition at line 61 of file CreateTableRule.java.

00062   {
00063     this.policy = policy;
00064     backendList = new ArrayList();
00065   }

org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.CreateTableRule int  policy,
ArrayList  backendList
 

Creates a new CreateTableRule instance.

Parameters:
policy the implemented policy
backendList the backend list to use

Definition at line 73 of file CreateTableRule.java.

00074   {
00075     if (backendList == null)
00076       throw new IllegalArgumentException("Null backendList in CreateTableRule constructor");
00077 
00078     this.policy = policy;
00079     this.backendList = backendList;
00080   }


Member Function Documentation

void org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.addBackendName String  name  ) 
 

Add a backend name to the list of backends to wait for.

Parameters:
name backend name

Definition at line 87 of file CreateTableRule.java.

00088   {
00089     backendList.add(name);
00090   }

ArrayList org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.getBackendList  ) 
 

Returns the backendList.

Returns:
ArrayList

Definition at line 97 of file CreateTableRule.java.

00098   {
00099     return backendList;
00100   }

ArrayList org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.getBackends ArrayList  backends  )  throws CreateTableException
 

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:
CreateTableException if the rule cannot be applied

Reimplemented in org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableAll, org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRandom, and org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRoundRobin.

Definition at line 180 of file CreateTableRule.java.

References org.objectweb.cjdbc.controller.backend.DatabaseBackend.getName(), and org.objectweb.cjdbc.controller.backend.DatabaseBackend.isWriteEnabled().

Referenced by org.objectweb.cjdbc.controller.loadbalancer.raidb0.RAIDb0.execWriteRequest(), and org.objectweb.cjdbc.controller.loadbalancer.raidb0.RAIDb0.execWriteRequestWithKeys().

00181   {
00182     ArrayList clonedList;
00183 
00184     int size = backends.size();
00185 
00186     if (backendList.size() > 0)
00187     { // Keep only the backends that are affected by this rule
00188       clonedList = new ArrayList(size);
00189       for (int i = 0; i < size; i++)
00190       {
00191         DatabaseBackend db = (DatabaseBackend) backends.get(i);
00192         if (db.isWriteEnabled() && backendList.contains(db.getName()))
00193           clonedList.add(db);
00194       }
00195     }
00196     else
00197     { // Take all enabled backends
00198       clonedList = new ArrayList(size);
00199       for (int i = 0; i < size; i++)
00200       {
00201         DatabaseBackend db = (DatabaseBackend) backends.get(i);
00202         if (db.isWriteEnabled())
00203           clonedList.add(db);
00204       }
00205     }
00206     
00207     return clonedList;
00208   }

abstract String org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.getInformation  )  [pure virtual]
 

Gives information about the current policy.

Returns:
a String value

Implemented in org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableAll, org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRandom, and org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRoundRobin.

int org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.getNumberOfNodes  ) 
 

Returns the number of nodes.

Returns:
an int value

Definition at line 107 of file CreateTableRule.java.

00108   {
00109     return nbOfNodes;
00110   }

int org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.getPolicy  ) 
 

Returns the policy.

Returns:
an int value

Definition at line 147 of file CreateTableRule.java.

00148   {
00149     return policy;
00150   }

String org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.getTableName  ) 
 

Returns the table name.

Returns:
a String value

Definition at line 127 of file CreateTableRule.java.

Referenced by org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTablePolicy.addRule().

00128   {
00129     return tableName;
00130   }

String org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.getXml  ) 
 

Gives information about the current policy in xml

Returns:
a String value in xml

Definition at line 222 of file CreateTableRule.java.

00224   {
00225     StringBuffer info = new StringBuffer();
00226     info.append(
00227       "<"
00228         + DatabasesXmlTags.ELT_CreateTable
00229         + " "
00230         + DatabasesXmlTags.ATT_tableName
00231         + "=\""
00232         + tableName
00233         + "\" "
00234         + DatabasesXmlTags.ATT_policy
00235         + "=\""
00236         + CreateTablePolicy.getXmlValue(policy)
00237         + "\" "
00238         + DatabasesXmlTags.ATT_numberOfNodes
00239         + "=\""
00240         + nbOfNodes
00241         + "\">");
00242     ArrayList list = this.getBackendList();
00243     int count = list.size();
00244     for (int i = 0; i < count; i++)
00245     {
00246       info.append(
00247         "<"
00248           + DatabasesXmlTags.ELT_BackendName
00249           + " "
00250           + DatabasesXmlTags.ATT_name
00251           + "=\""
00252           + ((String) list.get(i))
00253           + "\"/>");
00254     }
00255     info.append("</" + DatabasesXmlTags.ELT_CreateTable + ">");
00256     return info.toString();
00257   }

boolean org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.isDefaultRule  ) 
 

Returns true if this rule is the default rule.

Returns:
boolean

Definition at line 167 of file CreateTableRule.java.

00168   {
00169     return this.tableName == null;
00170   }

void org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.setNumberOfNodes int  numberOfNodes  ) 
 

Sets the number of nodes.

Parameters:
numberOfNodes the number of nodes to set

Definition at line 117 of file CreateTableRule.java.

00118   {
00119     this.nbOfNodes = numberOfNodes;
00120   }

void org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.setPolicy int  policy  ) 
 

Sets the policy.

Parameters:
policy the policy to set

Definition at line 157 of file CreateTableRule.java.

00158   {
00159     this.policy = policy;
00160   }

void org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.setTableName String  tableName  ) 
 

Sets the table name.

Parameters:
tableName the table name to set

Definition at line 137 of file CreateTableRule.java.

00138   {
00139     this.tableName = tableName;
00140   }


Member Data Documentation

ArrayList org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.backendList [protected]
 

List of backend names to wait for.

Definition at line 43 of file CreateTableRule.java.

int org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.nbOfNodes = 0 [protected]
 

Number of nodes that must create the table.

Definition at line 46 of file CreateTableRule.java.

String org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTableRule.tableName = null [protected]
 

Table name pattern to which this rule apply (null means it is the default rule).

Definition at line 52 of file CreateTableRule.java.


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