org.objectweb.cjdbc.controller.virtualdatabase
Class DistributedVirtualDatabase

java.lang.Object
  extended byjavax.management.StandardMBean
      extended byorg.objectweb.cjdbc.controller.jmx.AbstractStandardMBean
          extended byorg.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase
              extended byorg.objectweb.cjdbc.controller.virtualdatabase.DistributedVirtualDatabase
All Implemented Interfaces:
javax.management.DynamicMBean, org.objectweb.tribe.messages.MessageListener, org.objectweb.tribe.adapters.MulticastRequestListener, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, java.io.Serializable, VirtualDatabaseMBean, XmlComponent

public class DistributedVirtualDatabase
extends VirtualDatabase
implements org.objectweb.tribe.messages.MessageListener, org.objectweb.tribe.adapters.MulticastRequestListener

A DistributedVirtualDatabase is a virtual database hosted by several controllers. Communication between the controllers is achieved with reliable multicast provided by Javagroups.

Version:
1.0
Author:
Emmanuel Cecchet
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.management.StandardMBean
 
Field Summary
private  java.util.ArrayList allMemberButUs
           
private  java.util.HashMap backendRecoveryPolicy
          backendName ->BackendRecoveryPolicy
private  java.util.Hashtable backendsPerController
          JGroups Address ->ArrayList of DatabaseBackend
private  org.objectweb.tribe.channel.ReliableGroupChannelWithGms channel
          JGroups channel
private  java.util.Hashtable controllersMap
          Controller name mapping: jgroup Addr --> controller Name
private  org.objectweb.tribe.common.Group currentGroup
           
private  java.lang.String groupName
          Group name
private  org.objectweb.tribe.adapters.MulticastRequestAdapter multicastRequestAdapter
          MessageDispatcher to communicate with the group
 
Fields inherited from class org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase
authenticationManager, backends, CHECK_BACKEND_DISABLE, CHECK_BACKEND_ENABLE, controller, currentNbOfThreads, logger, maxNbOfConnections, maxNbOfThreads, maxThreadIdleTime, metadata, minNbOfThreads, name, NO_CHECK_BACKEND, poolConnectionThreads, requestLogger, requestManager, rwLock
 
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_DB, XML_VERSION
 
Constructor Summary
DistributedVirtualDatabase(Controller controller, java.lang.String name, java.lang.String groupName, int maxConnections, boolean pool, int minThreads, int maxThreads, long maxThreadIdleTime, int sqlShortFormLength, AbstractBlobFilter blobFilter)
          Creates a new DistributedVirtualDatabase instance.
 
Method Summary
 void addBackend(DatabaseBackend db)
          Add a backend to this virtual database.
 void addBackendRecoveryPolicy(BackendRecoveryPolicy policy)
          Add a BackendRecoveryPolicy
private  void broadcastBackendInformation(java.util.ArrayList dest)
          Broadcast backend information among controllers.
private  boolean checkConfigurationCompatibility(java.util.ArrayList dest)
          Send the configuration of this controller to remote controller.
 BackendInfo createBackendInfo(DatabaseBackend backend, boolean useXml)
          Create backend information object from a DatabaseBackend object This will get only static information
 boolean equals(java.lang.Object other)
          Two virtual databases are equal if they have the same name, login and password.
protected  void finalize()
          Disconnect the channel and close it.
 java.util.ArrayList getAllMemberButUs()
          Returns the list of all members in the group except us.
 java.util.HashMap getBackendRecoveryPolicy()
          Get the backend distribution policies
 java.util.ArrayList getBackendsInfo(java.util.ArrayList backendsObject)
          We have to convert the backends list from an array of DatabaseBackend object to an ArrayList of BackendInfo objects.
 void getBackendStatus()
          Get the status of all remote controllers
 org.objectweb.tribe.channel.ReliableGroupChannelWithGms getChannel()
          Get the JGroups' channel used for group communications
 java.lang.String getControllerName()
          Returns the controllerName value.
 org.objectweb.tribe.common.Group getCurrentGroup()
          Returns the currentGroup value.
protected  java.lang.String getDistributionXml()
          Get the XML dump of the Distribution element if any.
 java.lang.String getGroupName()
          Returns the group name this virtual database belongs to.
 org.objectweb.tribe.adapters.MulticastRequestAdapter getMulticastRequestAdapter()
          Return the group communication multicast request adapter.
 java.io.Serializable handleMessageMultiThreaded(java.io.Serializable msg, org.objectweb.tribe.common.Member sender, java.lang.Object handleMessageSingleThreadedResult)
           
 java.lang.Object handleMessageSingleThreaded(java.io.Serializable msg, org.objectweb.tribe.common.Member sender)
          This method handle the scheduling part of the queries to be sure that the query is scheduled in total order before letting other queries to execute.
 boolean isCompatibleBackend(BackendInfo backend)
          Check if the given backend definition is compatible with the backend definitions of this distributed virtual database.
 boolean isDistributed()
          Is this virtual database distributed ?
private  boolean isLocalSender(org.objectweb.tribe.common.Member sender)
          Returns true if the given member is ourselves.
 void joinGroup()
          Makes this virtual database join a virtual database group.
 void quitChannel()
          Quit the jgroups channel
 void receive(java.io.Serializable msg)
           
 void removeBackend(java.lang.String backend)
          Remove a backend from the virtual database list.
 void setAuthenticationManager(AuthenticationManager authenticationManager)
          (non-Javadoc)
 void setGroupName(java.lang.String groupName)
          Sets the group name used by the controllers hosting this virtual database.
 void setRequestManager(RequestManager requestManager)
          Sets a new distributed request manager for this database.
 void transferBackend(java.lang.String backend, java.lang.String controllerDestination)
          Transfer the backend to the destinated controller.
 void viewAccepted(org.objectweb.tribe.common.Group newGroup)
           
 java.lang.String[] viewControllerList()
          Return the list of controllers defining this virtual database.
 java.util.Hashtable viewGroupBackends()
          Returns a mapping of controller jmx names with their backends Note the method is only useful in distributed environment
 
Methods inherited from class org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase
abort, acquireReadLockBackendLists, addBackend, addCurrentNbOfThread, addIdleThread, backupBackendWithCheckpoint, begin, callBackupManager, checkAdminAuthentication, checkUserAuthentication, cleanMonitoringData, commit, disableAllBackend, disableAllBackendForCheckpoint, disableBackend, disableBackendForCheckpoint, enableAllBackend, enableAllBackend, enableAllBackendsFromRecovery, enableBackend, enableBackendFromCheckpoint, enableBackendFromCheckpoint, enableBackendFromLastCheckpoint, execReadRequest, execReadStoredProcedure, execWriteRequest, execWriteRequestWithKeys, execWriteStoredProcedure, getActiveThreads, getAllBackendNames, getAndCheckBackend, getAssociatedString, getAuthenticationManager, getBackendInformation, getBackends, getBackendSchema, getBackendState, getBlobFilter, getCurrentNbOfThreads, getDatabaseName, getDatabaseProductName, getDatabaseSchemaFromActiveBackendsAndRefreshDatabaseProductNames, getIdleThreads, getMaxNbOfConnections, getMaxNbOfThreads, getMaxThreadIdleTime, getMetaData, getMinNbOfThreads, getName, getPendingConnections, getRequestManager, getSQLMonitor, getSQLShortFormLength, getVirtualDatabaseName, getXml, hasRecoveryLog, isPoolConnectionThreads, releaseReadLockBackendLists, removeBackend, removeCheckpoint, removeCurrentNbOfThread, removeIdleThread, replicateBackend, restoreBackendFromBackupCheckpoint, retrieveBackendsData, rollback, setBackendLastKnownCheckpoint, setBlobFilter, setDatabaseSchema, setMaxNbOfConnections, setMaxNbOfThreads, setMaxThreadIdleTime, setMinNbOfThreads, setMonitoringToActive, setPoolConnectionThreads, setSQLMonitor, shutdown, shutdown, storeBackendsInfo, viewAllBackendNames, viewAllClientNames, viewBackendInformation, viewCheckpointNames, viewOwningController
 
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, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

groupName

private java.lang.String groupName
Group name


controllersMap

private java.util.Hashtable controllersMap
Controller name mapping: jgroup Addr --> controller Name


backendRecoveryPolicy

private java.util.HashMap backendRecoveryPolicy
backendName ->BackendRecoveryPolicy


backendsPerController

private java.util.Hashtable backendsPerController
JGroups Address ->ArrayList of DatabaseBackend


channel

private org.objectweb.tribe.channel.ReliableGroupChannelWithGms channel
JGroups channel


multicastRequestAdapter

private org.objectweb.tribe.adapters.MulticastRequestAdapter multicastRequestAdapter
MessageDispatcher to communicate with the group


currentGroup

private org.objectweb.tribe.common.Group currentGroup

allMemberButUs

private java.util.ArrayList allMemberButUs
Constructor Detail

DistributedVirtualDatabase

public DistributedVirtualDatabase(Controller controller,
                                  java.lang.String name,
                                  java.lang.String groupName,
                                  int maxConnections,
                                  boolean pool,
                                  int minThreads,
                                  int maxThreads,
                                  long maxThreadIdleTime,
                                  int sqlShortFormLength,
                                  AbstractBlobFilter blobFilter)
                           throws javax.management.NotCompliantMBeanException,
                                  JmxException
Creates a new DistributedVirtualDatabase instance.

Parameters:
controller - the controller we belong to
name - the virtual database name
groupName - the virtual database group name
maxConnections - maximum number of concurrent connections.
pool - should we use a pool of threads for handling connections?
minThreads - minimum number of threads in the pool
maxThreads - maximum number of threads in the pool
maxThreadIdleTime - maximum time a thread can remain idle before being removed from the pool.
sqlShortFormLength - maximum number of characters of an SQL statement to diplay in traces or exceptions
blobFilter - encoding method for blobs
Throws:
javax.management.NotCompliantMBeanException - in case the bean does not comply with jmx
JmxException - the bean could not be registeed
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Disconnect the channel and close it.

Throws:
java.lang.Throwable
See Also:
Object.finalize()

addBackend

public void addBackend(DatabaseBackend db)
                throws VirtualDatabaseException
Description copied from class: VirtualDatabase
Add a backend to this virtual database.

Overrides:
addBackend in class VirtualDatabase
Parameters:
db - the database backend to add
Throws:
VirtualDatabaseException - if an error occurs
See Also:
VirtualDatabase.addBackend(org.objectweb.cjdbc.controller.backend.DatabaseBackend)

quitChannel

public void quitChannel()
                 throws org.objectweb.tribe.exceptions.ChannelException,
                        org.objectweb.tribe.exceptions.NotConnectedException
Quit the jgroups channel

Throws:
org.objectweb.tribe.exceptions.NotConnectedException - if the channel is not connected
org.objectweb.tribe.exceptions.ChannelException - if an error occured while closing the channel

getControllerName

public java.lang.String getControllerName()
Returns the controllerName value.

Returns:
Returns the controllerName.

getGroupName

public java.lang.String getGroupName()
Returns the group name this virtual database belongs to.

Returns:
a String value. Returns null if this virtual database is standalone

setGroupName

public void setGroupName(java.lang.String groupName)
Sets the group name used by the controllers hosting this virtual database.

Parameters:
groupName - the group name to set

addBackendRecoveryPolicy

public void addBackendRecoveryPolicy(BackendRecoveryPolicy policy)
Add a BackendRecoveryPolicy

Parameters:
policy - the policy to add

setRequestManager

public void setRequestManager(RequestManager requestManager)
Sets a new distributed request manager for this database.

Overrides:
setRequestManager in class VirtualDatabase
Parameters:
requestManager - the new request manager.

joinGroup

public void joinGroup()
               throws java.lang.Exception
Makes this virtual database join a virtual database group. Those groups are mapped to JavaGroups groups.

Throws:
java.lang.Exception - if an error occurs

getChannel

public org.objectweb.tribe.channel.ReliableGroupChannelWithGms getChannel()
Get the JGroups' channel used for group communications

Returns:
a JChannel

getMulticastRequestAdapter

public org.objectweb.tribe.adapters.MulticastRequestAdapter getMulticastRequestAdapter()
Return the group communication multicast request adapter.

Returns:
the group communication multicast request adapter

getCurrentGroup

public org.objectweb.tribe.common.Group getCurrentGroup()
Returns the currentGroup value.

Returns:
Returns the currentGroup.

getAllMemberButUs

public java.util.ArrayList getAllMemberButUs()
Returns the list of all members in the group except us.

Returns:
Returns the allMemberButUs.

checkConfigurationCompatibility

private boolean checkConfigurationCompatibility(java.util.ArrayList dest)
Send the configuration of this controller to remote controller. All remote controllers must agree on the compatibility of the local controller configuration with their own configuration. Compatibility checking include Authentication Manager, Scheduler and Load Balancer settings.

Parameters:
dest - List of Address to send the message to
Returns:
true if the local config is compatible with the group, false otherwise.

broadcastBackendInformation

private void broadcastBackendInformation(java.util.ArrayList dest)
                                  throws org.objectweb.tribe.exceptions.TimeoutException,
                                         org.objectweb.tribe.exceptions.ChannelException,
                                         org.objectweb.tribe.exceptions.NotConnectedException
Broadcast backend information among controllers.

Parameters:
dest - List of Address to send the message to
Throws:
org.objectweb.tribe.exceptions.NotConnectedException - if the channel is not connected
org.objectweb.tribe.exceptions.ChannelException - if the channel reported an error
org.objectweb.tribe.exceptions.TimeoutException - if a timeout occured

isCompatibleBackend

public boolean isCompatibleBackend(BackendInfo backend)
                            throws VirtualDatabaseException
Check if the given backend definition is compatible with the backend definitions of this distributed virtual database. Not that if the given backend does not exist in the current configuration, it is considered as compatible. Incompatibility results from 2 backends with the same JDBC URL.

Parameters:
backend - the backend to check
Returns:
true if the backend is compatible with the local definition
Throws:
VirtualDatabaseException - if locking the local backend list fails

receive

public void receive(java.io.Serializable msg)
Specified by:
receive in interface org.objectweb.tribe.messages.MessageListener
See Also:
MessageListener.receive(java.io.Serializable)

handleMessageSingleThreaded

public java.lang.Object handleMessageSingleThreaded(java.io.Serializable msg,
                                                    org.objectweb.tribe.common.Member sender)
This method handle the scheduling part of the queries to be sure that the query is scheduled in total order before letting other queries to execute.

Specified by:
handleMessageSingleThreaded in interface org.objectweb.tribe.adapters.MulticastRequestListener
See Also:
MulticastRequestListener.handleMessageSingleThreaded(java.io.Serializable, org.objectweb.tribe.common.Member)

handleMessageMultiThreaded

public java.io.Serializable handleMessageMultiThreaded(java.io.Serializable msg,
                                                       org.objectweb.tribe.common.Member sender,
                                                       java.lang.Object handleMessageSingleThreadedResult)
Specified by:
handleMessageMultiThreaded in interface org.objectweb.tribe.adapters.MulticastRequestListener
See Also:
MulticastRequestListener.handleMessageMultiThreaded(Serializable, Member, Object)

isLocalSender

private boolean isLocalSender(org.objectweb.tribe.common.Member sender)
Returns true if the given member is ourselves.

Parameters:
sender - the sender
Returns:
true if we are the sender, false otherwise

getBackendStatus

public void getBackendStatus()
                      throws org.objectweb.tribe.exceptions.TimeoutException,
                             org.objectweb.tribe.exceptions.ChannelException,
                             org.objectweb.tribe.exceptions.NotConnectedException
Get the status of all remote controllers

Throws:
org.objectweb.tribe.exceptions.NotConnectedException - if the channel is not connected
org.objectweb.tribe.exceptions.ChannelException - if the channel reported an error
org.objectweb.tribe.exceptions.TimeoutException - if a timeout occured

viewAccepted

public void viewAccepted(org.objectweb.tribe.common.Group newGroup)
See Also:
MembershipListener.viewAccepted(org.jgroups.View)

getBackendRecoveryPolicy

public java.util.HashMap getBackendRecoveryPolicy()
Get the backend distribution policies

Returns:
an ArrayList of BackendRecoveryPolicy objects

isDistributed

public boolean isDistributed()
Is this virtual database distributed ?

Specified by:
isDistributed in interface VirtualDatabaseMBean
Overrides:
isDistributed in class VirtualDatabase
Returns:
true

equals

public boolean equals(java.lang.Object other)
Two virtual databases are equal if they have the same name, login and password.

Overrides:
equals in class VirtualDatabase
Parameters:
other - an object
Returns:
a boolean value

getDistributionXml

protected java.lang.String getDistributionXml()
Get the XML dump of the Distribution element if any.

Overrides:
getDistributionXml in class VirtualDatabase
Returns:
XML dump of the Distribution element

viewControllerList

public java.lang.String[] viewControllerList()
Description copied from interface: VirtualDatabaseMBean
Return the list of controllers defining this virtual database. If the database is not distributed this returns the same as viewOwningController otherwise returns an array of controller configuring this DistributedVirtualDatabase

Specified by:
viewControllerList in interface VirtualDatabaseMBean
Overrides:
viewControllerList in class VirtualDatabase
See Also:
VirtualDatabaseMBean.viewControllerList()

setAuthenticationManager

public void setAuthenticationManager(AuthenticationManager authenticationManager)
(non-Javadoc)

Overrides:
setAuthenticationManager in class VirtualDatabase
Parameters:
authenticationManager - the AuthenticationManager to set
See Also:
VirtualDatabase.setAuthenticationManager(org.objectweb.cjdbc.controller.authentication.AuthenticationManager)

viewGroupBackends

public java.util.Hashtable viewGroupBackends()
                                      throws VirtualDatabaseException
Description copied from interface: VirtualDatabaseMBean
Returns a mapping of controller jmx names with their backends Note the method is only useful in distributed environment

Specified by:
viewGroupBackends in interface VirtualDatabaseMBean
Overrides:
viewGroupBackends in class VirtualDatabase
Throws:
VirtualDatabaseException
See Also:
VirtualDatabaseMBean.viewGroupBackends()

getBackendsInfo

public java.util.ArrayList getBackendsInfo(java.util.ArrayList backendsObject)
We have to convert the backends list from an array of DatabaseBackend object to an ArrayList of BackendInfo objects. The DatabaseBackend objects cannot be serialized because they are used as MBean and notification emitters, so we want to extract the info out of them.

Parameters:
backendsObject - the list of DatabaseBackend object
Returns:
a list of BackendInfo objects
See Also:
BackendInfo

createBackendInfo

public BackendInfo createBackendInfo(DatabaseBackend backend,
                                     boolean useXml)
Create backend information object from a DatabaseBackend object This will get only static information

Parameters:
backend - the DatabaseBackend object to get info from
useXml - should we use xml for extensive backend description
Returns:
BackendInfo

removeBackend

public void removeBackend(java.lang.String backend)
                   throws VirtualDatabaseException
Description copied from interface: VirtualDatabaseMBean
Remove a backend from the virtual database list. Do not check whether it is enabled or not, and do not perform backup operation

Specified by:
removeBackend in interface VirtualDatabaseMBean
Overrides:
removeBackend in class VirtualDatabase
Throws:
VirtualDatabaseException
See Also:
VirtualDatabaseMBean.removeBackend(java.lang.String)

transferBackend

public void transferBackend(java.lang.String backend,
                            java.lang.String controllerDestination)
                     throws VirtualDatabaseException
Description copied from interface: VirtualDatabaseMBean
Transfer the backend to the destinated controller. Note that this does nothing in a non-distributed environment

Specified by:
transferBackend in interface VirtualDatabaseMBean
Overrides:
transferBackend in class VirtualDatabase
Throws:
VirtualDatabaseException
See Also:
VirtualDatabaseMBean.transferBackend(java.lang.String, java.lang.String)


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