org.ow2.carol.cmi.ha
Class ReplicationManagerImpl

java.lang.Object
  extended by org.ow2.carol.cmi.ha.ReplicationManagerImpl
All Implemented Interfaces:
ReplicationManager, ReplicationManagerImplMBean

public class ReplicationManagerImpl
extends java.lang.Object
implements ReplicationManager, ReplicationManagerImplMBean

This class implements the main replication functionality.

Author:
Francisco Perez-Sorrosal (fpsorrosal@no-spam@fi.upm.es), Alberto Paz-Jimenez (apaz@no-spam@fi.upm.es)

Constructor Summary
ReplicationManagerImpl(int timeout, java.lang.String datasource, java.lang.String jgroupsConf, java.lang.String jgroupsGroupname)
           
 
Method Summary
 void addEntityBean(RequestId reqId, EntityBeanReference bean)
          Correlates the changes made on a modified bean with a concrete client request.
 void addModifiedBean(RequestId reqId, org.ow2.carol.cmi.ha.SessionId clusterOId, StatefulBeanReference bean)
          Adds a modified EJB to the changes made inside a request.
 void addResponse(RequestId reqId, java.lang.Object response)
          Associate a response with a requestId.
 void clear()
          Closes and stops all the elements used (channel, dispatcher...).
 double getavgSizeofReplicatedMessages()
          Get the average size of the replicated messages sent.
 java.lang.Object getBackupResponse(RequestId reqId)
          Returns the response associated with the request id.
 java.lang.String getdatasourceName()
          Get the Datasource name required to hold the EB version numbers of the horizontal replication approach.
 long getinfoTimeout()
          Get the SFSB info timeout to clean certain information stored in memory.
 java.lang.String getjgroupsConfFileName()
          Get the JGroups configuration file name.
 java.lang.String getName()
           
 long getnumberofReplicatedMessages()
          Get the number of replicated messages sent.
 java.lang.String getobjectName()
           
 double gettotSizeofReplicatedMessages()
          Get the total size of the replicated messages sent.
 boolean hasBackupResponse(RequestId requestId)
          Returns true if the request id has an associated response, false in other case.
 void processMessage(HaMessageData data)
          Processes a message data.
 void replicate(RequestId requestId)
          Replicates the EJB changes kept on the requestChanges structure for a concrete reqId.
 void replicateCommit(RequestId reqId, boolean committed)
          Replicates the commit/abort message associate with a request.
 void restoreBeanChanges(org.ow2.carol.cmi.ha.SessionId clusterOID, StatefulBeanReference bean)
          Applies the changes kept in BeanChanges.
 void setdatasourceName(java.lang.String name)
          Set the Datasource name required to hold the EB version numbers of the horizontal replication approach.
 void setinfoTimeout(long timeout)
          Set the SFSB info timeout.
 void setobjectName(javax.management.ObjectName name)
          Sets the object name of this MBean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplicationManagerImpl

public ReplicationManagerImpl(int timeout,
                              java.lang.String datasource,
                              java.lang.String jgroupsConf,
                              java.lang.String jgroupsGroupname)
                       throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

addModifiedBean

public void addModifiedBean(RequestId reqId,
                            org.ow2.carol.cmi.ha.SessionId clusterOId,
                            StatefulBeanReference bean)
Adds a modified EJB to the changes made inside a request. The EJB modifications performed under the reqId will be replicated before the response will be returned to the client outside the VM.

Specified by:
addModifiedBean in interface ReplicationManager
Parameters:
reqId - the request id from the client
clusterOId - the ObjectId of the changed bean
bean - the serialized state of the changed bean

addEntityBean

public void addEntityBean(RequestId reqId,
                          EntityBeanReference bean)
Correlates the changes made on a modified bean with a concrete client request.

Specified by:
addEntityBean in interface ReplicationManager
Parameters:
reqId - the request id from the client
bean - the bean reference

addResponse

public void addResponse(RequestId reqId,
                        java.lang.Object response)
Associate a response with a requestId.

Specified by:
addResponse in interface ReplicationManager
Parameters:
reqId - the request id
response - the response

replicate

public void replicate(RequestId requestId)
               throws ReplicationException
Replicates the EJB changes kept on the requestChanges structure for a concrete reqId.

Specified by:
replicate in interface ReplicationManager
Parameters:
requestId - identifies the request changes to replicate hold in requestChanges structure
Throws:
ReplicationException

replicateCommit

public void replicateCommit(RequestId reqId,
                            boolean committed)
                     throws ReplicationException
Description copied from interface: ReplicationManager
Replicates the commit/abort message associate with a request.

Specified by:
replicateCommit in interface ReplicationManager
Parameters:
reqId - the request id
committed - true if the transaction has committed
Throws:
ReplicationException

hasBackupResponse

public boolean hasBackupResponse(RequestId requestId)
Returns true if the request id has an associated response, false in other case.

Specified by:
hasBackupResponse in interface ReplicationManager
Parameters:
requestId - the request id
Returns:
true if the request id has an associated response, false in other case

getBackupResponse

public java.lang.Object getBackupResponse(RequestId reqId)
Returns the response associated with the request id. Returns null if there is not response associated

Specified by:
getBackupResponse in interface ReplicationManager
Parameters:
reqId -
Returns:
the associated response

restoreBeanChanges

public void restoreBeanChanges(org.ow2.carol.cmi.ha.SessionId clusterOID,
                               StatefulBeanReference bean)
Applies the changes kept in BeanChanges. Changes will be applied to the concrete concrete custerOID specified.

Specified by:
restoreBeanChanges in interface ReplicationManager
Parameters:
clusterOID -
bean -

processMessage

public void processMessage(HaMessageData data)
Processes a message data.

Specified by:
processMessage in interface ReplicationManager
Parameters:
data - the message data

clear

public void clear()
Closes and stops all the elements used (channel, dispatcher...).

Specified by:
clear in interface ReplicationManager

getName

public java.lang.String getName()
Specified by:
getName in interface ReplicationManagerImplMBean
Returns:
the name of this bean

getobjectName

public java.lang.String getobjectName()
Specified by:
getobjectName in interface ReplicationManagerImplMBean
Returns:
Object Name

setobjectName

public void setobjectName(javax.management.ObjectName name)
Sets the object name of this MBean.

Parameters:
name - the Object Name

getnumberofReplicatedMessages

public long getnumberofReplicatedMessages()
Get the number of replicated messages sent.

Specified by:
getnumberofReplicatedMessages in interface ReplicationManagerImplMBean
Returns:
the number of replicated messages

getavgSizeofReplicatedMessages

public double getavgSizeofReplicatedMessages()
Get the average size of the replicated messages sent.

Specified by:
getavgSizeofReplicatedMessages in interface ReplicationManagerImplMBean
Returns:
the number of replicated messages

gettotSizeofReplicatedMessages

public double gettotSizeofReplicatedMessages()
Get the total size of the replicated messages sent.

Specified by:
gettotSizeofReplicatedMessages in interface ReplicationManagerImplMBean
Returns:
the total size of the replicated messages

getjgroupsConfFileName

public java.lang.String getjgroupsConfFileName()
Get the JGroups configuration file name.

Specified by:
getjgroupsConfFileName in interface ReplicationManagerImplMBean
Returns:
the JGroups configuration file name

getinfoTimeout

public long getinfoTimeout()
Get the SFSB info timeout to clean certain information stored in memory.

Specified by:
getinfoTimeout in interface ReplicationManagerImplMBean
Returns:
the timeout that

setinfoTimeout

public void setinfoTimeout(long timeout)
Set the SFSB info timeout. The info stored in the node is removed when the timer expires.

Specified by:
setinfoTimeout in interface ReplicationManagerImplMBean
Parameters:
timeout - the timeout to clean the info

getdatasourceName

public java.lang.String getdatasourceName()
Get the Datasource name required to hold the EB version numbers of the horizontal replication approach.

Specified by:
getdatasourceName in interface ReplicationManagerImplMBean
Returns:
the Datasource name

setdatasourceName

public void setdatasourceName(java.lang.String name)
Set the Datasource name required to hold the EB version numbers of the horizontal replication approach.

Specified by:
setdatasourceName in interface ReplicationManagerImplMBean
Parameters:
name - the name of the datasource


Copyright © 2007 OW2 Consortium. All Rights Reserved.