001: /**
002: * Sequoia: Database clustering technology.
003: * Copyright (C) 2002-2004 French National Institute For Research In Computer
004: * Science And Control (INRIA).
005: * Contact: sequoia@continuent.org
006: *
007: * Licensed under the Apache License, Version 2.0 (the "License");
008: * you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS,
015: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: * See the License for the specific language governing permissions and
017: * limitations under the License.
018: *
019: * Initial developer(s): Emmanuel Cecchet.
020: * Contributor(s): Julie Marguerite.
021: */package org.continuent.sequoia.controller.loadbalancer.raidb1;
022:
023: import java.sql.SQLException;
024:
025: import org.continuent.sequoia.common.exceptions.NotImplementedException;
026: import org.continuent.sequoia.common.xml.DatabasesXmlTags;
027: import org.continuent.sequoia.controller.backend.result.ControllerResultSet;
028: import org.continuent.sequoia.controller.backend.result.ExecuteResult;
029: import org.continuent.sequoia.controller.cache.metadata.MetadataCache;
030: import org.continuent.sequoia.controller.loadbalancer.policies.WaitForCompletionPolicy;
031: import org.continuent.sequoia.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy;
032: import org.continuent.sequoia.controller.requests.SelectRequest;
033: import org.continuent.sequoia.controller.requests.StoredProcedure;
034: import org.continuent.sequoia.controller.virtualdatabase.VirtualDatabase;
035:
036: /**
037: * RAIDb-1 Round Robin load balancer with error checking.
038: * <p>
039: * This load balancer tolerates byzantine failures of databases. The read
040: * requests coming from the Request Manager are sent to multiple backend nodes
041: * and the results are compared. Write requests are broadcasted to all backends.
042: *
043: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
044: * @author <a href="mailto:Julie.Marguerite@inria.fr">Julie Marguerite </a>
045: * @version 1.0
046: */
047: public class RAIDb1ec_RR extends RAIDb1ec {
048: /*
049: * How the code is organized ? 1. Member variables 2. Constructor(s) 3.
050: * Request handling 4. Debug/Monitoring
051: */
052:
053: // private int index; // index in the backend vector the Round-Robin
054: /*
055: * Constructors
056: */
057:
058: /**
059: * Creates a new RAIDb-1 Round Robin with error checking request load
060: * balancer.
061: *
062: * @param vdb the virtual database this load balancer belongs to.
063: * @param waitForCompletionPolicy how many backends must complete before
064: * returning the result?
065: * @param errorCheckingPolicy policy to apply for error checking.
066: * @param nbOfConcurrentReads Number of concurrent reads allowed
067: * @exception Exception if an error occurs
068: */
069: public RAIDb1ec_RR(VirtualDatabase vdb,
070: WaitForCompletionPolicy waitForCompletionPolicy,
071: ErrorCheckingPolicy errorCheckingPolicy,
072: int nbOfConcurrentReads) throws Exception {
073: super (vdb, waitForCompletionPolicy, errorCheckingPolicy,
074: nbOfConcurrentReads);
075: // index = -1;
076: }
077:
078: /*
079: * Request Handling
080: */
081:
082: /**
083: * Not implemented.
084: *
085: * @see org.continuent.sequoia.controller.loadbalancer.raidb1.RAIDb1#statementExecuteQuery(SelectRequest,
086: * MetadataCache)
087: */
088: public ControllerResultSet execSingleBackendReadRequest(
089: SelectRequest request, MetadataCache metadataCache)
090: throws SQLException {
091: throw new NotImplementedException(this .getClass().getName()
092: + ":execSingleBackendReadRequest");
093: }
094:
095: /**
096: * Not implemented.
097: *
098: * @see org.continuent.sequoia.controller.loadbalancer.AbstractLoadBalancer#readOnlyCallableStatementExecuteQuery(StoredProcedure,
099: * MetadataCache)
100: */
101: public ControllerResultSet readOnlyCallableStatementExecuteQuery(
102: StoredProcedure proc, MetadataCache metadataCache)
103: throws SQLException {
104: throw new NotImplementedException(this .getClass().getName()
105: + ":readOnlyCallableStatementExecuteQuery");
106: }
107:
108: /**
109: * Not implemented.
110: *
111: * @see org.continuent.sequoia.controller.loadbalancer.AbstractLoadBalancer#readOnlyCallableStatementExecute(org.continuent.sequoia.controller.requests.StoredProcedure,
112: * org.continuent.sequoia.controller.cache.metadata.MetadataCache)
113: */
114: public ExecuteResult readOnlyCallableStatementExecute(
115: StoredProcedure proc, MetadataCache metadataCache)
116: throws SQLException {
117: throw new NotImplementedException(this .getClass().getName()
118: + ":readOnlyCallableStatementExecute");
119: }
120:
121: /*
122: * Debug/Monitoring
123: */
124:
125: /**
126: * Gets information about the request load balancer.
127: *
128: * @return <code>String</code> containing information
129: */
130: public String getInformation() {
131: // We don't lock since we don't need a top accurate value
132: int size = vdb.getBackends().size();
133:
134: if (size == 0)
135: return "RAIDb-1 Error Checking with Round-Robin Request load balancer: !!!Warning!!! No backend nodes found\n";
136: else
137: return "RAIDb-1 Error Checking with Round-Robin Request load balancer ("
138: + size + " backends)\n";
139: }
140:
141: /**
142: * @see org.continuent.sequoia.controller.loadbalancer.raidb1.RAIDb1#getRaidb1Xml
143: */
144: public String getRaidb1Xml() {
145: return "<" + DatabasesXmlTags.ELT_RAIDb_1ec_RoundRobin + "/>";
146: }
147:
148: }
|