org.objectweb.cjdbc.controller.loadbalancer.raidb1
Class RAIDb1_LPRF

java.lang.Object
  extended byjavax.management.StandardMBean
      extended byorg.objectweb.cjdbc.controller.jmx.AbstractStandardMBean
          extended byorg.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer
              extended byorg.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1
                  extended byorg.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1_LPRF
All Implemented Interfaces:
AbstractLoadBalancerMBean, javax.management.DynamicMBean, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, XmlComponent

public class RAIDb1_LPRF
extends RAIDb1

RAIDb-1 Round Robin load balancer featuring (Least Pending Requests First load balancing algorithm).

The read requests coming from the Request Manager are sent to the node that has the least pending read requests among the nodes that can execute the request. Write requests are broadcasted to all backends.

Version:
1.0
Author:
Emmanuel Cecchet

Nested Class Summary
 
Nested classes inherited from class javax.management.StandardMBean
 
Field Summary
 
Fields inherited from class org.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1
backendBlockingThreads, backendBlockingThreadsRWLock, backendNonBlockingThreads, backendNonBlockingThreadsRWLock, logger, waitForCompletionPolicy
 
Fields inherited from class org.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer
macroHandler, parsingGranularity, raidbLevel, totalOrderQueue, vdb
 
Fields inherited from class org.objectweb.cjdbc.controller.jmx.AbstractStandardMBean
 
Fields inherited from class javax.management.StandardMBean
 
Fields inherited from interface org.objectweb.cjdbc.common.xml.XmlComponent
DOCTYPE_CONTROLLER, DOCTYPE_DB, XML_VERSION
 
Constructor Summary
RAIDb1_LPRF(VirtualDatabase vdb, WaitForCompletionPolicy waitForCompletionPolicy)
          Creates a new RAIDb-1 Round Robin request load balancer.
 
Method Summary
 ControllerResultSet execReadOnlyReadStoredProcedure(StoredProcedure proc, MetadataCache metadataCache)
          Selects the backend using a least pending request first policy.
 ControllerResultSet execReadRequest(SelectRequest request, MetadataCache metadataCache)
          Selects the backend using a least pending request first policy.
private  ControllerResultSet executeLPRF(AbstractRequest request, boolean isSelect, java.lang.String errorMsgPrefix, MetadataCache metadataCache)
          Common code to execute a SelectRequest or a StoredProcedure on a backend chosen using a LPRF algorithm.
 java.lang.String getInformation()
          Gets information about the request load balancer.
 java.lang.String getRaidb1Xml()
          Surrounding raidb1 tags can be treated by getXmlImpl above, but more detailed content have to be returned by the method getRaidb1Xml below.
 
Methods inherited from class org.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1
begin, commit, disableBackend, enableBackend, execReadStoredProcedure, executeRequestOnBackend, executeStoredProcedureOnBackend, execWriteRequest, execWriteRequestWithKeys, execWriteStoredProcedure, getNumberOfEnabledBackends, getXmlImpl, releaseSavepoint, rollback, rollback, setSavepoint, waitForAllWritesToComplete, waitForAllWritesToComplete, waitForAllWritesToComplete
 
Methods inherited from class org.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer
executeReadStoredProcedureOnBackend, executeSelectRequestOnBackend, executeUpdateRequestOnBackend, executeUpdateRequestOnBackendWithKeys, executeWriteStoredProcedureOnBackend, getAssociatedString, getConnectionAndBeginTransaction, getParsingGranularity, getRAIDbLevel, getXml, handleMacros, removeHeadFromAndNotifyTotalOrderQueue, setMacroHandler, setParsingGranularity, setRAIDbLevel, setWeight, waitForTotalOrder
 
Methods inherited from class org.objectweb.cjdbc.controller.jmx.AbstractStandardMBean
addNotificationListener, getDescription, getDescription, getDescription, getDescription, getDescription, getDescription, getNotificationInfo, getParameterName, getParameterName, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class javax.management.StandardMBean
cacheMBeanInfo, getAttribute, getAttributes, getCachedMBeanInfo, getClassName, getConstructors, getDescription, getImpact, getImplementation, getImplementationClass, getMBeanInfo, getMBeanInterface, invoke, setAttribute, setAttributes, setImplementation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RAIDb1_LPRF

public RAIDb1_LPRF(VirtualDatabase vdb,
                   WaitForCompletionPolicy waitForCompletionPolicy)
            throws java.lang.Exception
Creates a new RAIDb-1 Round Robin request load balancer.

Parameters:
vdb - the virtual database this load balancer belongs to.
waitForCompletionPolicy - how many backends must complete before returning the result?
Throws:
java.lang.Exception - if an error occurs
Method Detail

execReadRequest

public ControllerResultSet execReadRequest(SelectRequest request,
                                           MetadataCache metadataCache)
                                    throws java.sql.SQLException
Selects the backend using a least pending request first policy. The backend that has the shortest queue of currently executing queries is chosen to execute this query.

Specified by:
execReadRequest in class RAIDb1
Throws:
java.sql.SQLException
See Also:
RAIDb1.execReadRequest(SelectRequest, MetadataCache)

execReadOnlyReadStoredProcedure

public ControllerResultSet execReadOnlyReadStoredProcedure(StoredProcedure proc,
                                                           MetadataCache metadataCache)
                                                    throws java.sql.SQLException
Selects the backend using a least pending request first policy. The backend that has the shortest queue of currently executing queries is chosen to execute this stored procedure.

Specified by:
execReadOnlyReadStoredProcedure in class AbstractLoadBalancer
Parameters:
proc - the stored procedure call
metadataCache - MetadataCache (null if none)
Returns:
a ControllerResultSet value
Throws:
java.sql.SQLException - if an error occurs
See Also:
AbstractLoadBalancer.execReadOnlyReadStoredProcedure(StoredProcedure, MetadataCache)

executeLPRF

private ControllerResultSet executeLPRF(AbstractRequest request,
                                        boolean isSelect,
                                        java.lang.String errorMsgPrefix,
                                        MetadataCache metadataCache)
                                 throws java.sql.SQLException
Common code to execute a SelectRequest or a StoredProcedure on a backend chosen using a LPRF algorithm.

Parameters:
request - a SelectRequest or StoredProcedure
isSelect - true if it is a SelectRequest, false if it is a StoredProcedure
errorMsgPrefix - the error message prefix, usually "Request " or "Stored procedure " ... failed because ...
metadataCache - the metadataCache if any or null
Returns:
a ResultSet
Throws:
java.sql.SQLException - if an error occurs

getInformation

public java.lang.String getInformation()
Gets information about the request load balancer.

Specified by:
getInformation in interface AbstractLoadBalancerMBean
Specified by:
getInformation in class AbstractLoadBalancer
Returns:
String containing information

getRaidb1Xml

public java.lang.String getRaidb1Xml()
Description copied from class: RAIDb1
Surrounding raidb1 tags can be treated by getXmlImpl above, but more detailed content have to be returned by the method getRaidb1Xml below.

Specified by:
getRaidb1Xml in class RAIDb1
Returns:
content of Raidb1 xml
See Also:
RAIDb1.getRaidb1Xml()


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