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 |
Definition at line 40 of file CreateTableRule.java.
|
Constructor for CreateTableRule.
Definition at line 61 of file CreateTableRule.java. 00062 { 00063 this.policy = policy; 00064 backendList = new ArrayList(); 00065 }
|
|
Creates a new
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 }
|
|
Add a backend name to the list of backends to wait for.
Definition at line 87 of file CreateTableRule.java. 00088 { 00089 backendList.add(name); 00090 }
|
|
Returns the backendList.
Definition at line 97 of file CreateTableRule.java. 00098 {
00099 return backendList;
00100 }
|
|
Pickups backends from the given backends arraylist according to the current rule policy.
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 }
|
|
Gives information about the current policy.
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. |
|
Returns the number of nodes.
Definition at line 107 of file CreateTableRule.java. 00108 {
00109 return nbOfNodes;
00110 }
|
|
Returns the policy.
Definition at line 147 of file CreateTableRule.java. 00148 {
00149 return policy;
00150 }
|
|
Returns the table name.
Definition at line 127 of file CreateTableRule.java. Referenced by org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTablePolicy.addRule(). 00128 {
00129 return tableName;
00130 }
|
|
Gives information about the current policy 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 }
|
|
Returns
Definition at line 167 of file CreateTableRule.java. 00168 { 00169 return this.tableName == null; 00170 }
|
|
Sets the number of nodes.
Definition at line 117 of file CreateTableRule.java. 00118 {
00119 this.nbOfNodes = numberOfNodes;
00120 }
|
|
Sets the policy.
Definition at line 157 of file CreateTableRule.java. 00158 {
00159 this.policy = policy;
00160 }
|
|
Sets the table name.
Definition at line 137 of file CreateTableRule.java. 00138 {
00139 this.tableName = tableName;
00140 }
|
|
List of backend names to wait for. Definition at line 43 of file CreateTableRule.java. |
|
Number of nodes that must create the table. Definition at line 46 of file CreateTableRule.java. |
|
Table name pattern to which this rule apply (null means it is the default rule). Definition at line 52 of file CreateTableRule.java. |