ErrorCheckingRoundRobin.java の 38 行で定義されています。
Public メソッド | |
ErrorCheckingRoundRobin (int numberOfNodes) | |
ArrayList | getBackends (ArrayList backends) throws ErrorCheckingException |
String | getInformation () |
int | getNumberOfNodes () |
void | setNumberOfNodes (int numberOfNodes) |
int | getPolicy () |
void | setPolicy (int policy) |
String | getXml () |
Static Public 変数 | |
final int | RANDOM = 0 |
final int | ROUND_ROBIN = 1 |
final int | ALL = 2 |
Protected 変数 | |
int | nbOfNodes = 0 |
int | policy |
Private 変数 | |
int | index = 0 |
|
Creates a new
ErrorCheckingRoundRobin.java の 48 行で定義されています。
00049 { 00050 super(ErrorCheckingPolicy.ROUND_ROBIN, numberOfNodes); 00051 } |
|
org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicyに実装されています. ErrorCheckingRoundRobin.java の 56 行で定義されています。 参照先 org.objectweb.cjdbc.controller.backend.DatabaseBackend.isReadEnabled, と org.objectweb.cjdbc.controller.backend.DatabaseBackend.isWriteEnabled.
00058 { 00059 int size = backends.size(); 00060 00061 if (nbOfNodes == 0) 00062 return null; 00063 else if (nbOfNodes == size) 00064 return backends; 00065 00066 ArrayList result = new ArrayList(nbOfNodes); 00067 ArrayList clonedList = new ArrayList(size); 00068 for (int i = 0; i < size; i++) 00069 { // Take all enabled backends 00070 DatabaseBackend db = (DatabaseBackend) backends.get(i); 00071 if (db.isReadEnabled() || db.isWriteEnabled()) 00072 clonedList.add(db); 00073 } 00074 00075 int clonedSize = clonedList.size(); 00076 00077 if (nbOfNodes == clonedSize) 00078 return backends; 00079 else if (nbOfNodes > clonedSize) 00080 throw new ErrorCheckingException( 00081 "Asking for more backends (" 00082 + nbOfNodes 00083 + ") than available (" 00084 + clonedSize 00085 + ")"); 00086 00087 synchronized (this) 00088 { // index must be modified in mutual exclusion 00089 for (int i = 0; i < nbOfNodes; i++) 00090 { 00091 index = (index + 1) % clonedSize; 00092 result.add(clonedList.remove(index)); 00093 } 00094 } 00095 00096 return result; 00097 } |
|
org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicyに実装されています. ErrorCheckingRoundRobin.java の 102 行で定義されています。
00103 { 00104 return "Error checking using " 00105 + nbOfNodes 00106 + " nodes choosen using a round-robin algorithm"; 00107 } |
|
Returns the number of nodes.
ErrorCheckingPolicy.java の 71 行で定義されています。
00072 { 00073 return nbOfNodes; 00074 } |
|
Returns the policy.
ErrorCheckingPolicy.java の 98 行で定義されています。
00099 { 00100 return policy; 00101 } |
|
Convert this error checking policy to xml
ErrorCheckingPolicy.java の 137 行で定義されています。
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 } |
|
Sets the number of nodes.
ErrorCheckingPolicy.java の 82 行で定義されています。
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 } |
|
Sets the policy.
ErrorCheckingPolicy.java の 109 行で定義されています。
00110 {
00111 this.policy = policy;
00112 }
|
|
Request is sent to all backends. ErrorCheckingPolicy.java の 46 行で定義されています。 |
|
Round-robin index. ErrorCheckingRoundRobin.java の 41 行で定義されています。 |
|
Number of nodes that are involved in error-checking per request. ErrorCheckingPolicy.java の 49 行で定義されています。 |
|
ErrorCheckingPolicy.java の 51 行で定義されています。 |
|
Pickup backends randomly. ErrorCheckingPolicy.java の 40 行で定義されています。 |
|
Backends are chosen using a round-robin algorithm. ErrorCheckingPolicy.java の 43 行で定義されています。 |