KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > controller > loadbalancer > raidb2 > RAIDb2ec_RR


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Emmanuel Cecchet.
22  * Contributor(s): Julie Marguerite.
23  */

24
25 package org.objectweb.cjdbc.controller.loadbalancer.raidb2;
26
27 import java.sql.SQLException JavaDoc;
28 import java.util.Vector JavaDoc;
29
30 import org.objectweb.cjdbc.common.exceptions.NotImplementedException;
31 import org.objectweb.cjdbc.common.sql.SelectRequest;
32 import org.objectweb.cjdbc.common.sql.StoredProcedure;
33 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags;
34 import org.objectweb.cjdbc.controller.cache.metadata.MetadataCache;
35 import org.objectweb.cjdbc.controller.loadbalancer.policies.WaitForCompletionPolicy;
36 import org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTablePolicy;
37 import org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy;
38 import org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet;
39 import org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase;
40
41 /**
42  * RAIDb-2 Round Robin load balancer with error checking
43  * <p>
44  * This load balancer tolerates byzantine failures of databases. The read
45  * requests coming from the Request Manager are sent to multiple backend nodes
46  * and the results are compared. Write requests are broadcasted to all backends.
47  *
48  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
49  * @author <a HREF="mailto:Julie.Marguerite@inria.fr">Julie Marguerite </a>
50  * @version 1.0
51  */

52 public class RAIDb2ec_RR extends RAIDb2ec
53 {
54   /*
55    * How the code is organized ? 1. Member variables 2. Constructor(s) 3.
56    * Request handling 4. Debug/Monitoring
57    */

58
59   private Vector JavaDoc backends;
60
61   /*
62    * Constructors
63    */

64
65   /**
66    * Creates a new RAIDb-2 Round Robin with error checking request load
67    * balancer.
68    *
69    * @param vdb The virtual database this load balancer belongs to.
70    * @param waitForCompletionPolicy How many backends must complete before
71    * returning the result?
72    * @param createTablePolicy The policy defining how 'create table' statements
73    * should be handled
74    * @param errorCheckingPolicy Policy to apply for error checking.
75    * @param nbOfConcurrentReads Number of concurrent reads allowed
76    * @exception Exception if an error occurs
77    */

78   public RAIDb2ec_RR(VirtualDatabase vdb,
79       WaitForCompletionPolicy waitForCompletionPolicy,
80       CreateTablePolicy createTablePolicy,
81       ErrorCheckingPolicy errorCheckingPolicy, int nbOfConcurrentReads)
82       throws Exception JavaDoc
83   {
84     super(vdb, waitForCompletionPolicy, createTablePolicy, errorCheckingPolicy,
85         nbOfConcurrentReads);
86   }
87
88   /*
89    * Request Handling
90    */

91
92   /**
93    * Performs a read request. It is up to the implementation to choose to which
94    * backend node(s) this request should be sent.
95    *
96    * @param request an <code>SelectRequest</code>
97    * @param metadataCache cached metadata to use to construct the result set
98    * @return the corresponding <code>java.sql.ResultSet</code>
99    * @exception SQLException if an error occurs
100    * @see org.objectweb.cjdbc.controller.loadbalancer.raidb2.RAIDb2#execReadRequest(SelectRequest,
101    * MetadataCache)
102    */

103   public ControllerResultSet execReadRequest(SelectRequest request,
104       MetadataCache metadataCache) throws SQLException JavaDoc
105   {
106     throw new NotImplementedException(this.getClass().getName()
107         + ":execReadRequest");
108   }
109
110   /**
111    * Not implemented.
112    *
113    * @see org.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer#execReadOnlyReadStoredProcedure(StoredProcedure,
114    * MetadataCache)
115    */

116   public ControllerResultSet execReadOnlyReadStoredProcedure(
117       StoredProcedure proc, MetadataCache metadataCache) throws SQLException JavaDoc
118   {
119     throw new NotImplementedException(this.getClass().getName()
120         + ":execReadStoredProcedure");
121   }
122
123   /*
124    * Debug/Monitoring
125    */

126
127   /**
128    * Gets information about the request load balancer.
129    *
130    * @return <code>String</code> containing information
131    */

132   public String JavaDoc getInformation()
133   {
134     if (backends == null)
135       return "RAIDb-2 Error Checking with Round Robin Request load balancer: !!!Warning!!! No backend nodes found\n";
136     else
137       return "RAIDb-2 Error Checking with Round Robin Request load balancer balancing over "
138           + backends.size() + " nodes\n";
139   }
140
141   /**
142    * @see org.objectweb.cjdbc.controller.loadbalancer.raidb2.RAIDb2#getRaidb2Xml
143    */

144   public String JavaDoc getRaidb2Xml()
145   {
146     return "<" + DatabasesXmlTags.ELT_RAIDb_2ec_RoundRobin + "/>";
147   }
148 }
Popular Tags