org.objectweb.carol.cmi.ha
Class JGReplicator

java.lang.Object
  extended byorg.objectweb.carol.cmi.ha.JGReplicator
All Implemented Interfaces:
ReplicationManager, org.jgroups.blocks.RequestHandler

public class JGReplicator
extends java.lang.Object
implements ReplicationManager, org.jgroups.blocks.RequestHandler

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
JGReplicator(javax.naming.Context ctx)
           
 
Method Summary
 void addModifiedBean(RequestId reqId, ObjectId bid, byte[] state)
          Adds a modified EJB to the changes made inside a request.
 void clear()
          Closes and stops all the elements used (channel, dispatcher...)
 java.lang.Object handle(org.jgroups.Message msg)
           
 void replicate(RequestId reqId, java.lang.Object response)
          Replicates the response and the EJB changes kept on the requestChanges structure for a concrete reqId
 void replicateRemove(RequestId requestId)
          Replicates a remove method invocation over an EJB for a concrete custerOID
 ResponseInfo restoreBeanChanges(RequestId requestId, java.lang.Object beanSwitch)
          Applies the changes kept in BeanChanges.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JGReplicator

public JGReplicator(javax.naming.Context ctx)
Method Detail

addModifiedBean

public void addModifiedBean(RequestId reqId,
                            ObjectId bid,
                            byte[] state)
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:
bid - the ObjectId of the changed bean
state - the serialized state of the changed bean
reqId - the request id from the client

replicate

public void replicate(RequestId reqId,
                      java.lang.Object response)
               throws ReplicationException
Replicates the response and the EJB changes kept on the requestChanges structure for a concrete reqId

Specified by:
replicate in interface ReplicationManager
Parameters:
reqId - identifies the request changes to replicate hold in requestChanges structure
response - the response to return to the client
Throws:
ReplicationException

replicateRemove

public void replicateRemove(RequestId requestId)
                     throws ReplicationException
Replicates a remove method invocation over an EJB for a concrete custerOID

Specified by:
replicateRemove in interface ReplicationManager
Parameters:
requestId - identifies the custerOID to remove in the backups
Throws:
ReplicationException

restoreBeanChanges

public ResponseInfo restoreBeanChanges(RequestId requestId,
                                       java.lang.Object beanSwitch)
Applies the changes kept in BeanChanges. Changes will be applied to the concrete concrete custerOID speficied.

Specified by:
restoreBeanChanges in interface ReplicationManager
Parameters:
requestId - the request id to access the state of the bean
beanSwitch - the sfsw that contains the instance where restore the state
Returns:
the last response held in HA service for that request, if exists

clear

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

Specified by:
clear in interface ReplicationManager

handle

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