Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

RAIDb2ec_WRR.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Emmanuel Cecchet.
00022  * Contributor(s): Julie Marguerite.
00023  */
00024 
00025 package org.objectweb.cjdbc.controller.loadbalancer.raidb2;
00026 
00027 import java.sql.SQLException;
00028 import java.util.HashMap;
00029 
00030 import org.objectweb.cjdbc.common.sql.NotImplementedException;
00031 import org.objectweb.cjdbc.common.sql.SelectRequest;
00032 import org.objectweb.cjdbc.common.sql.StoredProcedure;
00033 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags;
00034 import org.objectweb.cjdbc.controller.cache.metadata.MetadataCache;
00035 import org.objectweb.cjdbc.controller.loadbalancer.WeightedBalancer;
00036 import org.objectweb.cjdbc.controller.loadbalancer.policies.WaitForCompletionPolicy;
00037 import org.objectweb.cjdbc.controller.loadbalancer.policies.createtable.CreateTablePolicy;
00038 import org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy;
00039 import org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet;
00040 import org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase;
00041 
00042 /**
00043  * RAIDb-2 Weighted Round Robin load balancer with error checking.
00044  * <p>
00045  * This load balancer tolerates byzantine failures of databases. The read
00046  * requests coming from the request manager are sent to multiple backend nodes
00047  * and the results are compared. Write requests are broadcasted to all backends.
00048  * 
00049  * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
00050  * @author <a href="mailto:Julie.Marguerite@inria.fr">Julie Marguerite </a>
00051  * @version 1.0
00052  */
00053 public class RAIDb2ec_WRR extends RAIDb2ec
00054 {
00055   /*
00056    * How the code is organized ? 1. Member variables 2. Constructor(s) 3.
00057    * Request handling 4. Debug/Monitoring
00058    */
00059 
00060   private HashMap backends;
00061 
00062   /*
00063    * Constructors
00064    */
00065 
00066   /**
00067    * Creates a new RAIDb-2 weighted round robin with error checking request load
00068    * balancer.
00069    * 
00070    * @param vdb The virtual database this load balancer belongs to.
00071    * @param waitForCompletionPolicy How many backends must complete before
00072    *          returning the result?
00073    * @param createTablePolicy The policy defining how 'create table' statements
00074    *          should be handled
00075    * @param errorCheckingPolicy Policy to apply for error checking.
00076    * @param nbOfConcurrentReads Number of concurrent reads allowed
00077    * @exception Exception if an error occurs
00078    */
00079   public RAIDb2ec_WRR(VirtualDatabase vdb,
00080       WaitForCompletionPolicy waitForCompletionPolicy,
00081       CreateTablePolicy createTablePolicy,
00082       ErrorCheckingPolicy errorCheckingPolicy, int nbOfConcurrentReads)
00083       throws Exception
00084   {
00085     super(vdb, waitForCompletionPolicy, createTablePolicy, errorCheckingPolicy,
00086         nbOfConcurrentReads);
00087   }
00088 
00089   /*
00090    * Request Handling
00091    */
00092 
00093   /**
00094    * Performs a read request. It is up to the implementation to choose to which
00095    * backend node(s) this request should be sent.
00096    * 
00097    * @param request an <code>SelectRequest</code>
00098    * @param metadataCache cached metadata to use to construct the result set
00099    * @return the corresponding <code>java.sql.ResultSet</code>
00100    * @exception SQLException if an error occurs
00101    * @see org.objectweb.cjdbc.controller.loadbalancer.raidb2.RAIDb2#execReadRequest(SelectRequest,
00102    *      MetadataCache)
00103    */
00104   public ControllerResultSet execReadRequest(SelectRequest request,
00105       MetadataCache metadataCache) throws SQLException
00106   {
00107     throw new NotImplementedException(this.getClass().getName()
00108         + ":execReadRequest");
00109   }
00110 
00111   /**
00112    * Not implemented.
00113    * 
00114    * @see org.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer#execReadOnlyReadStoredProcedure(StoredProcedure,
00115    *      MetadataCache)
00116    */
00117   public ControllerResultSet execReadOnlyReadStoredProcedure(
00118       StoredProcedure proc, MetadataCache metadataCache) throws SQLException
00119   {
00120     throw new NotImplementedException(this.getClass().getName()
00121         + ":execReadStoredProcedure");
00122   }
00123 
00124   /*
00125    * Backends management
00126    */
00127 
00128   /**
00129    * @see org.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer#setWeight(String,
00130    *      int)
00131    */
00132   public void setWeight(String name, int w) throws SQLException
00133   {
00134     throw new SQLException("Weight is not supported with this load balancer");
00135   }
00136 
00137   /*
00138    * Debug/Monitoring
00139    */
00140 
00141   /**
00142    * Gets information about the request load balancer.
00143    * 
00144    * @return <code>String</code> containing information
00145    */
00146   public String getInformation()
00147   {
00148     if (backends == null)
00149       return "RAIDb-2 Error Checking with Weighted Round Robin Request load balancer: "
00150           + "!!!Warning!!! No backend nodes found\n";
00151     else
00152       return "RAIDb-2 Error Checking with Weighted Round Robin Request load balancer balancing over "
00153           + backends.size() + " nodes\n";
00154   }
00155 
00156   /**
00157    * @see RAIDb2#getRaidb2Xml()
00158    */
00159   public String getRaidb2Xml()
00160   {
00161     return WeightedBalancer.getRaidbXml(backends,
00162         DatabasesXmlTags.ELT_RAIDb_2ec_WeightedRoundRobin);
00163   }
00164 }

Generated on Mon Apr 11 22:01:34 2005 for C-JDBC by  doxygen 1.3.9.1