org.objectweb.cjdbc.controller.virtualdatabase
Class DistributedVirtualDatabase

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase
      extended byorg.objectweb.cjdbc.controller.virtualdatabase.DistributedVirtualDatabase
All Implemented Interfaces:
org.jgroups.MembershipListener, org.jgroups.MessageListener, org.jgroups.blocks.RequestHandler, java.io.Serializable, VirtualDatabaseMBean

public class DistributedVirtualDatabase
extends VirtualDatabase
implements org.jgroups.blocks.RequestHandler, org.jgroups.MessageListener, org.jgroups.MembershipListener

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

Field Summary
private  org.jgroups.JChannel channel
           
private  org.jgroups.blocks.MessageDispatcher dispatcher
           
 
Fields inherited from class org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase
authenticationManager, backends, currentNbOfThreads, groupName, logger, maxNbOfConnections, maxNbOfThreads, maxThreadIdleTime, metadata, minNbOfThreads, name, poolConnectionThreads, requestLogger, requestManager, rwLock
 
Constructor Summary
DistributedVirtualDatabase(java.lang.String name, java.lang.String groupName, int maxConnections, boolean pool, int minThreads, int maxThreads, long maxThreadIdleTime)
          Creates a new DistributedVirtualDatabase instance.
 
Method Summary
 void block()
           
 boolean equals(java.lang.Object other)
          Two virtual databases are equal if they have the same name, login and password.
 int execWriteRequest(AbstractWriteRequest request)
          Performs a write request and returns the number of rows affected.
 java.sql.ResultSet execWriteRequestWithKeys(AbstractWriteRequest request)
          Performs a write request and returns the auto generated keys.
 java.lang.String getInformation()
          Get information about this virtual database
 byte[] getState()
           
 java.lang.Object handle(org.jgroups.Message msg)
           
 boolean isDistributed()
          Is this virtual database distributed ?
 void joinGroup(java.lang.String groupName)
          Makes this virtual database join a virtual database group.
 void receive(org.jgroups.Message msg)
           
 void setRequestManager(RequestManager requestManager)
          Sets a new distributed request manager for this database.
 void setState(byte[] state)
           
 void suspect(org.jgroups.Address suspectedMember)
           
 void viewAccepted(org.jgroups.View newView)
           
 void writeNotify(AbstractWriteRequest request)
          Notifies the cache that this write request has been issued, so that cache coherency can be maintained.
 
Methods inherited from class org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase
acquireReadLockBackendLists, addBackend, addCurrentNbOfThread, addIdleThread, begin, checkAdminAuthentication, checkUserAuthentication, commit, disableAllBackend, disableAllBackendForCheckpoint, disableBackend, disableBackendForCheckpoint, enableAllBackend, enableAllBackend, enableBackend, enableBackendFromCheckpoint, execReadRequest, execReadStoredProcedure, execWriteStoredProcedure, getActiveThreads, getAllBackendNames, getAuthenticationManager, getBackendInformation, getBackends, getCurrentNbOfThreads, getDatabaseName, getDatabaseSchemaFromActiveBackends, getGroupName, getIdleThreads, getMaxNbOfConnections, getMaxNbOfThreads, getMaxThreadIdleTime, getMetaData, getMinNbOfThreads, getName, getPendingConnections, getRequestManager, getVirtualDatabaseName, getXmlInformation, isPoolConnectionThreads, releaseReadLockBackendLists, removeBackend, removeCurrentNbOfThread, removeIdleThread, rollback, setAuthenticationManager, setDatabaseSchema, setGroupName, setMaxNbOfConnections, setMaxNbOfThreads, setMaxThreadIdleTime, setMinNbOfThreads, setPoolConnectionThreads, shutdown, viewAllBackendNames
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

channel

private org.jgroups.JChannel channel

dispatcher

private org.jgroups.blocks.MessageDispatcher dispatcher
Constructor Detail

DistributedVirtualDatabase

public DistributedVirtualDatabase(java.lang.String name,
                                  java.lang.String groupName,
                                  int maxConnections,
                                  boolean pool,
                                  int minThreads,
                                  int maxThreads,
                                  long maxThreadIdleTime)
                           throws CJDBCException
Creates a new DistributedVirtualDatabase instance.

Parameters:
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.
Throws:
CJDBCException - in case of group communication-related error
Method Detail

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(java.lang.String groupName)
               throws java.lang.Exception
Makes this virtual database join a virtual database group. Those groups are mapped to JavaGroups groups.

Parameters:
groupName - name of the virtual database group
Throws:
java.lang.Exception - if an error occurs

handle

public java.lang.Object handle(org.jgroups.Message msg)
Specified by:
handle in interface org.jgroups.blocks.RequestHandler
See Also:
RequestHandler.handle(org.jgroups.Message)

getState

public byte[] getState()
Specified by:
getState in interface org.jgroups.MessageListener
See Also:
MessageListener.getState()

receive

public void receive(org.jgroups.Message msg)
Specified by:
receive in interface org.jgroups.MessageListener
See Also:
MessageListener.receive(org.jgroups.Message)

setState

public void setState(byte[] state)
Specified by:
setState in interface org.jgroups.MessageListener
See Also:
MessageListener.setState(byte[])

block

public void block()
Specified by:
block in interface org.jgroups.MembershipListener
See Also:
MembershipListener.block()

suspect

public void suspect(org.jgroups.Address suspectedMember)
Specified by:
suspect in interface org.jgroups.MembershipListener
See Also:
MembershipListener.suspect(org.jgroups.Address)

viewAccepted

public void viewAccepted(org.jgroups.View newView)
Specified by:
viewAccepted in interface org.jgroups.MembershipListener
See Also:
MembershipListener.viewAccepted(org.jgroups.View)

execWriteRequest

public int execWriteRequest(AbstractWriteRequest request)
                     throws java.sql.SQLException
Description copied from class: VirtualDatabase
Performs a write request and returns the number of rows affected.

Overrides:
execWriteRequest in class VirtualDatabase
Parameters:
request - the request to execute
Returns:
number of rows affected
Throws:
java.sql.SQLException - if the request fails
See Also:
VirtualDatabase.execWriteRequest(org.objectweb.cjdbc.sql.AbstractWriteRequest)

execWriteRequestWithKeys

public java.sql.ResultSet execWriteRequestWithKeys(AbstractWriteRequest request)
                                            throws java.sql.SQLException
Description copied from class: VirtualDatabase
Performs a write request and returns the auto generated keys.

Overrides:
execWriteRequestWithKeys in class VirtualDatabase
Parameters:
request - the request to execute
Returns:
auto generated keys
Throws:
java.sql.SQLException - if the request fails
See Also:
VirtualDatabase.execWriteRequestWithKeys(org.objectweb.cjdbc.sql.AbstractWriteRequest)

writeNotify

public void writeNotify(AbstractWriteRequest request)
                 throws java.sql.SQLException
Notifies the cache that this write request has been issued, so that cache coherency can be maintained. If the cache is distributed, this method is reponsible for broadcasting this information to other caches.

Parameters:
request - an AbstractRequest value
Throws:
java.sql.SQLException - if an error occurs

isDistributed

public boolean isDistributed()
Is this virtual database distributed ?

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

getInformation

public java.lang.String getInformation()
Get information about this virtual database

Overrides:
getInformation in class VirtualDatabase
Returns:
String containing information


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