org.objectweb.cjdbc.controller.loadbalancer
Class AbstractLoadBalancer

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer
Direct Known Subclasses:
RAIDb0, RAIDb1, RAIDb2, SingleDB

public abstract class AbstractLoadBalancer
extends java.lang.Object

The Request Load Balancer should implement the load balancing of the requests among the backend nodes.

The requests comes from the Request Controller and are sent to the Connection Managers.

Version:
1.0
Author:
Emmanuel Cecchet, Vadim Kassin

Field Summary
protected static Trace logger
           
protected  int parsingGranularity
           
protected  int raidbLevel
           
protected  VirtualDatabase vdb
           
 
Constructor Summary
protected AbstractLoadBalancer(VirtualDatabase vdb, int raidbLevel, int parsingGranularity)
          Generic constructor that sets some member variables and checks that backends are in the disabled state
 
Method Summary
abstract  void begin(TransactionMarkerMetaData tm)
          Begin a new transaction.
abstract  void commit(TransactionMarkerMetaData tm)
          Commit a transaction.
abstract  void disableBackend(DatabaseBackend db)
          Disable a backend without further check.
abstract  void enableBackend(DatabaseBackend db)
          Enable a backend without further check.
abstract  java.sql.ResultSet execReadRequest(SelectRequest request)
          Perform a read request.
abstract  java.sql.ResultSet execReadStoredProcedure(StoredProcedure proc)
          Call a stored procedure that returns a ResultSet.
abstract  int execWriteRequest(AbstractWriteRequest request)
          Perform a write request.
abstract  java.sql.ResultSet execWriteRequestWithKeys(AbstractWriteRequest request)
          Perform a write request and return a ResultSet containing the auto generated keys.
abstract  int execWriteStoredProcedure(StoredProcedure proc)
          Call a stored procedure that performs an update.
abstract  java.lang.String getInformation()
          Get information about the Request Load Balancer
 int getParsingGranularity()
          Get the needed query parsing granularity.
 int getRAIDbLevel()
          Returns the RAIDbLevel.
abstract  java.lang.String getXmlInformation()
          Get information about the Request Load Balancer in xml
abstract  void rollback(TransactionMarkerMetaData tm)
          Rollback a transaction.
 void setParsingGranularity(int parsingGranularity)
          Set the needed query parsing granularity.
 void setRAIDbLevel(int raidbLevel)
          Sets the RAIDbLevel.
 void setWeight(java.lang.String name, int w)
          Associate a weight to a backend identified by its logical name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vdb

protected VirtualDatabase vdb

raidbLevel

protected int raidbLevel

parsingGranularity

protected int parsingGranularity

logger

protected static Trace logger
Constructor Detail

AbstractLoadBalancer

protected AbstractLoadBalancer(VirtualDatabase vdb,
                               int raidbLevel,
                               int parsingGranularity)
                        throws java.sql.SQLException
Generic constructor that sets some member variables and checks that backends are in the disabled state

Parameters:
vdb - The virtual database this load balancer belongs to
raidbLevel - The RAIDb level of this load balancer
parsingGranularity - The parsing granularity needed by this load balancer
Method Detail

getRAIDbLevel

public int getRAIDbLevel()
Returns the RAIDbLevel.

Returns:
int

setRAIDbLevel

public void setRAIDbLevel(int raidbLevel)
Sets the RAIDbLevel.

Parameters:
raidbLevel - The RAIDbLevel to set

getParsingGranularity

public int getParsingGranularity()
Get the needed query parsing granularity.

Returns:
needed query parsing granularity

setParsingGranularity

public void setParsingGranularity(int parsingGranularity)
Set the needed query parsing granularity.

Parameters:
parsingGranularity - the granularity to set

execReadRequest

public abstract java.sql.ResultSet execReadRequest(SelectRequest request)
                                            throws java.sql.SQLException
Perform a read request. It is up to the implementation to choose to which backend node(s) this request should be sent.

Parameters:
request - an SelectRequest
Returns:
the corresponding java.sql.ResultSet
Throws:
java.sql.SQLException - if an error occurs

execWriteRequest

public abstract int execWriteRequest(AbstractWriteRequest request)
                              throws java.sql.SQLException
Perform a write request. This request should usually be broadcasted to all nodes.

Parameters:
request - an AbstractWriteRequest
Returns:
number of rows affected by the request
Throws:
java.sql.SQLException - if an error occurs

execWriteRequestWithKeys

public abstract java.sql.ResultSet execWriteRequestWithKeys(AbstractWriteRequest request)
                                                     throws java.sql.SQLException
Perform a write request and return a ResultSet containing the auto generated keys.

Parameters:
request - an AbstractWriteRequest
Returns:
auto generated keys
Throws:
java.sql.SQLException - if an error occurs

execReadStoredProcedure

public abstract java.sql.ResultSet execReadStoredProcedure(StoredProcedure proc)
                                                    throws java.sql.SQLException
Call a stored procedure that returns a ResultSet.

Parameters:
proc - the stored procedure call
Returns:
a java.sql.ResultSet value
Throws:
java.sql.SQLException - if an error occurs

execWriteStoredProcedure

public abstract int execWriteStoredProcedure(StoredProcedure proc)
                                      throws java.sql.SQLException
Call a stored procedure that performs an update.

Parameters:
proc - the stored procedure call
Returns:
number of rows affected
Throws:
java.sql.SQLException - if an error occurs

begin

public abstract void begin(TransactionMarkerMetaData tm)
                    throws java.sql.SQLException
Begin a new transaction.

Parameters:
tm - The transaction marker metadata
Throws:
java.sql.SQLException - if an error occurs

commit

public abstract void commit(TransactionMarkerMetaData tm)
                     throws java.sql.SQLException
Commit a transaction.

Parameters:
tm - The transaction marker metadata
Throws:
java.sql.SQLException - if an error occurs

rollback

public abstract void rollback(TransactionMarkerMetaData tm)
                       throws java.sql.SQLException
Rollback a transaction.

Parameters:
tm - The transaction marker metadata
Throws:
java.sql.SQLException - if an error occurs

enableBackend

public abstract void enableBackend(DatabaseBackend db)
                            throws java.sql.SQLException
Enable a backend without further check. Ask the corresponding connection manager to initialize the connections if needed.

Parameters:
db - The database backend to enable
Throws:
java.sql.SQLException - if an error occurs

disableBackend

public abstract void disableBackend(DatabaseBackend db)
                             throws java.sql.SQLException
Disable a backend without further check. Ask the corresponding connection manager to finalize the connections if needed.

Parameters:
db - The database backend to disable
Throws:
java.sql.SQLException - if an error occurs

setWeight

public void setWeight(java.lang.String name,
                      int w)
               throws java.sql.SQLException
Associate a weight to a backend identified by its logical name.

Parameters:
name - the backend name
w - the weight
Throws:
java.sql.SQLException - if an error occurs

getInformation

public abstract java.lang.String getInformation()
Get information about the Request Load Balancer

Returns:
String containing information

getXmlInformation

public abstract java.lang.String getXmlInformation()
Get information about the Request Load Balancer in xml

Returns:
String containing information, xml formatted


Copyright © 2002, 2003 - ObjectWeb Consortium - All Rights Reserved.