01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2002-2004 French National Institute For Research In Computer
04: * Science And Control (INRIA).
05: * Contact: sequoia@continuent.org
06: *
07: * Licensed under the Apache License, Version 2.0 (the "License");
08: * you may not use this file except in compliance with the License.
09: * You may obtain a copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS,
15: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: * See the License for the specific language governing permissions and
17: * limitations under the License.
18: *
19: * Initial developer(s): Emmanuel Cecchet.
20: * Contributor(s): ______________________.
21: */package org.continuent.sequoia.controller.loadbalancer.raidb1;
22:
23: import java.util.ArrayList;
24:
25: import org.continuent.sequoia.common.log.Trace;
26: import org.continuent.sequoia.common.xml.DatabasesXmlTags;
27: import org.continuent.sequoia.controller.loadbalancer.policies.WaitForCompletionPolicy;
28: import org.continuent.sequoia.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy;
29: import org.continuent.sequoia.controller.virtualdatabase.VirtualDatabase;
30:
31: /**
32: * RAIDb-1 load balancer.
33: * <p>
34: * This class is an abstract call because the read requests coming from the
35: * request manager are NOT treated here but in the subclasses. Transaction
36: * management and write requests are broadcasted to all backends.
37: *
38: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
39: * @version 1.0
40: */
41: public abstract class RAIDb1ec extends RAIDb1 {
42: /*
43: * How the code is organized ? 1. Member variables 2. Constructor(s) 3.
44: * Request handling 4. Transaction handling 5. Backend management
45: */
46:
47: protected ArrayList backendReadThreads;
48: protected int nbOfConcurrentReads;
49: protected ErrorCheckingPolicy errorCheckingPolicy;
50:
51: protected static Trace logger = Trace
52: .getLogger("org.continuent.sequoia.controller.loadbalancer.RAIDb1ec");
53:
54: /*
55: * Constructors
56: */
57:
58: /**
59: * Creates a new RAIDb-1 Round Robin request load balancer. A new backend
60: * worker thread is created for each backend.
61: *
62: * @param vdb the virtual database this load balancer belongs to
63: * @param waitForCompletionPolicy how many backends must complete before
64: * returning the result?
65: * @param errorCheckingPolicy policy to apply for error checking.
66: * @param nbOfConcurrentReads number of concurrent reads allowed
67: * @exception Exception if an error occurs
68: */
69: public RAIDb1ec(VirtualDatabase vdb,
70: WaitForCompletionPolicy waitForCompletionPolicy,
71: ErrorCheckingPolicy errorCheckingPolicy,
72: int nbOfConcurrentReads) throws Exception {
73: super (vdb, waitForCompletionPolicy);
74: backendReadThreads = new ArrayList();
75: this .errorCheckingPolicy = errorCheckingPolicy;
76: this .nbOfConcurrentReads = nbOfConcurrentReads;
77: }
78:
79: /*
80: * Backends management
81: */
82:
83: /**
84: * @see org.continuent.sequoia.controller.loadbalancer.AbstractLoadBalancer#getXmlImpl
85: */
86: public String getXmlImpl() {
87: StringBuffer info = new StringBuffer();
88: info.append("<" + DatabasesXmlTags.ELT_RAIDb_1ec + " "
89: + DatabasesXmlTags.ATT_nbOfConcurrentReads + "=\""
90: + this .nbOfConcurrentReads + "\">");
91: this .getRaidb1Xml();
92: if (waitForCompletionPolicy != null)
93: info.append(waitForCompletionPolicy.getXml());
94: info.append("</" + DatabasesXmlTags.ELT_RAIDb_1ec + ">");
95: return info.toString();
96: }
97: }
|