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.raidb2;
022:
023: import java.sql.SQLException;
024: import java.util.Vector;
025:
026: import org.continuent.sequoia.common.exceptions.NotImplementedException;
027: import org.continuent.sequoia.common.xml.DatabasesXmlTags;
028: import org.continuent.sequoia.controller.backend.result.ControllerResultSet;
029: import org.continuent.sequoia.controller.backend.result.ExecuteResult;
030: import org.continuent.sequoia.controller.cache.metadata.MetadataCache;
031: import org.continuent.sequoia.controller.loadbalancer.policies.WaitForCompletionPolicy;
032: import org.continuent.sequoia.controller.loadbalancer.policies.createtable.CreateTablePolicy;
033: import org.continuent.sequoia.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy;
034: import org.continuent.sequoia.controller.requests.SelectRequest;
035: import org.continuent.sequoia.controller.requests.StoredProcedure;
036: import org.continuent.sequoia.controller.virtualdatabase.VirtualDatabase;
037:
038: /**
039: * RAIDb-2 Round Robin load balancer with error checking
040: * <p>
041: * This load balancer tolerates byzantine failures of databases. The read
042: * requests coming from the Request Manager are sent to multiple backend nodes
043: * and the results are compared. Write requests are broadcasted to all backends.
044: *
045: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
046: * @author <a href="mailto:Julie.Marguerite@inria.fr">Julie Marguerite </a>
047: * @version 1.0
048: */
049: public class RAIDb2ec_RR extends RAIDb2ec {
050: /*
051: * How the code is organized ? 1. Member variables 2. Constructor(s) 3.
052: * Request handling 4. Debug/Monitoring
053: */
054:
055: private Vector backends;
056:
057: /*
058: * Constructors
059: */
060:
061: /**
062: * Creates a new RAIDb-2 Round Robin with error checking request load
063: * balancer.
064: *
065: * @param vdb The virtual database this load balancer belongs to.
066: * @param waitForCompletionPolicy How many backends must complete before
067: * returning the result?
068: * @param createTablePolicy The policy defining how 'create table' statements
069: * should be handled
070: * @param errorCheckingPolicy Policy to apply for error checking.
071: * @param nbOfConcurrentReads Number of concurrent reads allowed
072: * @exception Exception if an error occurs
073: */
074: public RAIDb2ec_RR(VirtualDatabase vdb,
075: WaitForCompletionPolicy waitForCompletionPolicy,
076: CreateTablePolicy createTablePolicy,
077: ErrorCheckingPolicy errorCheckingPolicy,
078: int nbOfConcurrentReads) throws Exception {
079: super (vdb, waitForCompletionPolicy, createTablePolicy,
080: errorCheckingPolicy, nbOfConcurrentReads);
081: }
082:
083: /*
084: * Request Handling
085: */
086:
087: /**
088: * Performs a read request. It is up to the implementation to choose to which
089: * backend node(s) this request should be sent.
090: *
091: * @param request an <code>SelectRequest</code>
092: * @param metadataCache cached metadata to use to construct the result set
093: * @return the corresponding <code>java.sql.ResultSet</code>
094: * @exception SQLException if an error occurs
095: * @see org.continuent.sequoia.controller.loadbalancer.raidb2.RAIDb2#statementExecuteQuery(SelectRequest,
096: * MetadataCache)
097: */
098: public ControllerResultSet statementExecuteQuery(
099: SelectRequest request, MetadataCache metadataCache)
100: throws SQLException {
101: throw new NotImplementedException(this .getClass().getName()
102: + ":statementExecuteQuery");
103: }
104:
105: /**
106: * Not implemented.
107: *
108: * @see org.continuent.sequoia.controller.loadbalancer.AbstractLoadBalancer#readOnlyCallableStatementExecuteQuery(StoredProcedure,
109: * MetadataCache)
110: */
111: public ControllerResultSet readOnlyCallableStatementExecuteQuery(
112: StoredProcedure proc, MetadataCache metadataCache)
113: throws SQLException {
114: throw new NotImplementedException(this .getClass().getName()
115: + ":readOnlyCallableStatementExecuteQuery");
116: }
117:
118: /**
119: * Not implemented.
120: *
121: * @see org.continuent.sequoia.controller.loadbalancer.AbstractLoadBalancer#readOnlyCallableStatementExecute(StoredProcedure,
122: * MetadataCache)
123: */
124: public ExecuteResult readOnlyCallableStatementExecute(
125: StoredProcedure proc, MetadataCache metadataCache)
126: throws SQLException {
127: throw new NotImplementedException(this .getClass().getName()
128: + ":readOnlyCallableStatementExecute");
129: }
130:
131: /*
132: * Debug/Monitoring
133: */
134:
135: /**
136: * Gets information about the request load balancer.
137: *
138: * @return <code>String</code> containing information
139: */
140: public String getInformation() {
141: if (backends == null)
142: return "RAIDb-2 Error Checking with Round Robin Request load balancer: !!!Warning!!! No backend nodes found\n";
143: else
144: return "RAIDb-2 Error Checking with Round Robin Request load balancer balancing over "
145: + backends.size() + " nodes\n";
146: }
147:
148: /**
149: * @see org.continuent.sequoia.controller.loadbalancer.raidb2.RAIDb2#getRaidb2Xml
150: */
151: public String getRaidb2Xml() {
152: return "<" + DatabasesXmlTags.ELT_RAIDb_2ec_RoundRobin + "/>";
153: }
154: }
|