クラス org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingRandom

org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingRandomに対する継承グラフ

Inheritance graph
[凡例]
org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingRandomのコラボレーション図

Collaboration graph
[凡例]
すべてのメンバ一覧

説明

Chooses numberOfNodes nodes randomly for error checking.

作者:
Emmanuel Cecchet
バージョン:
1.0

ErrorCheckingRandom.java38 行で定義されています。

Public メソッド

 ErrorCheckingRandom (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 変数

Random random = new Random()


コンストラクタとデストラクタ

org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingRandom.ErrorCheckingRandom int  numberOfNodes  ) 
 

Creates a new ErrorCheckingRandom instance.

引数:
numberOfNodes number of nodes to use to check for errors on a query

ErrorCheckingRandom.java47 行で定義されています。

00048   {
00049     super(ErrorCheckingPolicy.RANDOM, numberOfNodes);
00050   }


メソッド

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

参照:
org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.getBackends(ArrayList)

org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicyに実装されています.

ErrorCheckingRandom.java55 行で定義されています。

参照先 org.objectweb.cjdbc.controller.backend.DatabaseBackend.isReadEnabled, と org.objectweb.cjdbc.controller.backend.DatabaseBackend.isWriteEnabled.

00057   {
00058     int size = backends.size();
00059 
00060     if (nbOfNodes == size)
00061       return backends;
00062     else if (nbOfNodes > size)
00063       throw new ErrorCheckingException(
00064         "Asking for more backends ("
00065           + nbOfNodes
00066           + ") than available ("
00067           + size
00068           + ")");
00069 
00070     ArrayList result = new ArrayList(nbOfNodes);
00071     ArrayList clonedList = new ArrayList(size);
00072     for (int i = 0; i < size; i++)
00073     { // Take all enabled backends
00074       DatabaseBackend db = (DatabaseBackend) backends.get(i);
00075       if (db.isReadEnabled() || db.isWriteEnabled())
00076         clonedList.add(db);
00077     }
00078 
00079     int clonedSize = clonedList.size();
00080 
00081     if (nbOfNodes == clonedSize)
00082       return backends;
00083     else if (nbOfNodes > clonedSize)
00084       throw new ErrorCheckingException(
00085         "Asking for more backends ("
00086           + nbOfNodes
00087           + ") than available ("
00088           + clonedSize
00089           + ")");
00090 
00091     // Pickup the nodes randomly
00092     for (int i = 0; i < nbOfNodes; i++)
00093       result.add(clonedList.remove(random.nextInt(clonedSize)));
00094 
00095     return result;
00096   }

String org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingRandom.getInformation  )  [virtual]
 

参照:
org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.getInformation()

org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicyに実装されています.

ErrorCheckingRandom.java101 行で定義されています。

00102   {
00103     return "Error checking using " + nbOfNodes + " nodes choosen randomly";
00104   }

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

Returns the number of nodes.

戻り値:
an int value
参照:
setNumberOfNodes

ErrorCheckingPolicy.java71 行で定義されています。

00072   {
00073     return nbOfNodes;
00074   }

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

Returns the policy.

戻り値:
an int value
参照:
setPolicy

ErrorCheckingPolicy.java98 行で定義されています。

00099   {
00100     return policy;
00101   }

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

Convert this error checking policy to xml

戻り値:
xml formatted string

ErrorCheckingPolicy.java137 行で定義されています。

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  )  [inherited]
 

Sets the number of nodes.

引数:
numberOfNodes the number of nodes to set
参照:
getNumberOfNodes

ErrorCheckingPolicy.java82 行で定義されています。

参照元 org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.ErrorCheckingPolicy().

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  )  [inherited]
 

Sets the policy.

引数:
policy the policy to set
参照:
getPolicy

ErrorCheckingPolicy.java109 行で定義されています。

参照元 org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.ErrorCheckingPolicy().

00110   {
00111     this.policy = policy;
00112   }


変数

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

Request is sent to all backends.

ErrorCheckingPolicy.java46 行で定義されています。

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

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

ErrorCheckingPolicy.java49 行で定義されています。

int org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy.policy [protected, inherited]
 

ErrorCheckingPolicy.java51 行で定義されています。

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

Pickup backends randomly.

ErrorCheckingPolicy.java40 行で定義されています。

Random org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingRandom.random = new Random() [private]
 

ErrorCheckingRandom.java40 行で定義されています。

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

Backends are chosen using a round-robin algorithm.

ErrorCheckingPolicy.java43 行で定義されています。


このクラスの説明は次のファイルから生成されました:
CJDBCversion1.0rc6に対してWed May 5 18:02:25 2004に生成されました。 doxygen 1.3.6