1 24 25 package org.objectweb.cjdbc.controller.loadbalancer.raidb1; 26 27 import java.sql.SQLException ; 28 import java.util.HashMap ; 29 30 import org.objectweb.cjdbc.common.exceptions.NotImplementedException; 31 import org.objectweb.cjdbc.common.i18n.Translate; 32 import org.objectweb.cjdbc.common.sql.SelectRequest; 33 import org.objectweb.cjdbc.common.sql.StoredProcedure; 34 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags; 35 import org.objectweb.cjdbc.controller.cache.metadata.MetadataCache; 36 import org.objectweb.cjdbc.controller.loadbalancer.WeightedBalancer; 37 import org.objectweb.cjdbc.controller.loadbalancer.policies.WaitForCompletionPolicy; 38 import org.objectweb.cjdbc.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy; 39 import org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet; 40 import org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase; 41 42 53 public class RAIDb1ec_WRR extends RAIDb1ec 54 { 55 59 60 private HashMap weights; 62 63 66 67 78 public RAIDb1ec_WRR(VirtualDatabase vdb, 79 WaitForCompletionPolicy waitForCompletionPolicy, 80 ErrorCheckingPolicy errorCheckingPolicy, int nbOfConcurrentReads) 81 throws Exception 82 { 83 super(vdb, waitForCompletionPolicy, errorCheckingPolicy, 84 nbOfConcurrentReads); 85 } 87 88 91 92 97 public ControllerResultSet execReadRequest(SelectRequest request, MetadataCache metadataCache) 98 throws SQLException 99 { 100 throw new NotImplementedException(this.getClass().getName() 101 + ":execReadRequest"); 102 } 103 104 109 public ControllerResultSet execReadOnlyReadStoredProcedure(StoredProcedure proc, MetadataCache metadataCache) 110 throws SQLException 111 { 112 throw new NotImplementedException(this.getClass().getName() 113 + ":execReadStoredProcedure"); 114 } 115 116 119 120 124 public void setWeight(String name, int w) throws SQLException 125 { 126 if (logger.isDebugEnabled()) 127 logger.debug(Translate.get("loadbalancer.weight.set", new String []{ 128 String.valueOf(w), name})); 129 130 weights.put(name, new Integer (w)); 131 } 132 133 136 137 142 public String getInformation() 143 { 144 int size = vdb.getBackends().size(); 146 147 if (size == 0) 148 return "RAIDb-1 Error Checking with Weighted Round-Robin Request load balancer: " 149 + "!!!Warning!!! No backend nodes found\n"; 150 else 151 return "RAIDb-1 Error Checking with Weighted Round-Robin Request load balancer (" 152 + size + " backends)\n"; 153 } 154 155 158 public String getRaidb1Xml() 159 { 160 return WeightedBalancer.getRaidbXml(weights, 161 DatabasesXmlTags.ELT_RAIDb_1ec_WeightedRoundRobin); 162 } 163 } | Popular Tags |