KickJava   Java API By Example, From Geeks To Geeks.

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

50 public class RAIDb1ec_RR extends RAIDb1ec
51 {
52   /*
53    * How the code is organized ? 1. Member variables 2. Constructor(s) 3.
54    * Request handling 4. Debug/Monitoring
55    */

56
57   // private int index; // index in the backend vector the Round-Robin
58
/*
59    * Constructors
60    */

61
62   /**
63    * Creates a new RAIDb-1 Round Robin with error checking request load
64    * balancer.
65    *
66    * @param vdb the virtual database this load balancer belongs to.
67    * @param waitForCompletionPolicy how many backends must complete before
68    * returning the result?
69    * @param errorCheckingPolicy policy to apply for error checking.
70    * @param nbOfConcurrentReads Number of concurrent reads allowed
71    * @exception Exception if an error occurs
72    */

73   public RAIDb1ec_RR(VirtualDatabase vdb,
74       WaitForCompletionPolicy waitForCompletionPolicy,
75       ErrorCheckingPolicy errorCheckingPolicy, int nbOfConcurrentReads)
76       throws Exception JavaDoc
77   {
78     super(vdb, waitForCompletionPolicy, errorCheckingPolicy,
79         nbOfConcurrentReads);
80     // index = -1;
81
}
82
83   /*
84    * Request Handling
85    */

86
87   /**
88    * Not implemented.
89    *
90    * @see org.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1#execReadRequest(SelectRequest, MetadataCache)
91    */

92   public ControllerResultSet execReadRequest(SelectRequest request, MetadataCache metadataCache)
93       throws SQLException JavaDoc
94   {
95     throw new NotImplementedException(this.getClass().getName()
96         + ":execReadRequest");
97   }
98
99   /**
100    * Not implemented.
101    *
102    * @see org.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer#execReadOnlyReadStoredProcedure(StoredProcedure, MetadataCache)
103    */

104   public ControllerResultSet execReadOnlyReadStoredProcedure(StoredProcedure proc, MetadataCache metadataCache)
105       throws SQLException JavaDoc
106   {
107     throw new NotImplementedException(this.getClass().getName()
108         + ":execReadStoredProcedure");
109   }
110
111   /*
112    * Debug/Monitoring
113    */

114
115   /**
116    * Gets information about the request load balancer.
117    *
118    * @return <code>String</code> containing information
119    */

120   public String JavaDoc getInformation()
121   {
122     // We don't lock since we don't need a top accurate value
123
int size = vdb.getBackends().size();
124
125     if (size == 0)
126       return "RAIDb-1 Error Checking with Round-Robin Request load balancer: !!!Warning!!! No backend nodes found\n";
127     else
128       return "RAIDb-1 Error Checking with Round-Robin Request load balancer ("
129           + size + " backends)\n";
130   }
131
132   /**
133    * @see org.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1#getRaidb1Xml
134    */

135   public String JavaDoc getRaidb1Xml()
136   {
137     return "<" + DatabasesXmlTags.ELT_RAIDb_1ec_RoundRobin + "/>";
138   }
139
140 }
Popular Tags