org.jboss.messaging.core.distributed.replicator
Class Replicator

java.lang.Object
  extended byorg.jboss.messaging.core.distributed.PeerSupport
      extended byorg.jboss.messaging.core.distributed.replicator.ReplicatorPeer
          extended byorg.jboss.messaging.core.distributed.replicator.Replicator
All Implemented Interfaces:
Distributed, Distributor, Peer, PeerFacade, Router, ServerFacade

public class Replicator
extends org.jboss.messaging.core.distributed.replicator.ReplicatorPeer
implements Distributed, Router

A Replicator is a distributed receiver that replicates synchronously or asynchronously a message to multiple receivers living in different address spaces. A replicator could have multiple inputs and multiple outputs. Messages sent by an input are replicated to every output.

The replication of messages is done efficiently by multicasting, but message acknowledment is handled by the replicator (so far) in a point-to-point manner. For that reason, each replicator peer must be able to synchronously reach any other peer. When it is configured to be synchronous, the replicator works pretty much like a distributed PointToMultipointRouter. The Replicator is NOT a Receiver. It returns a Set of deliveries instead of a single delivery. TODO: Refactor Replicator so it won't be forced to provide noop implementation for Distributor's methods: http://jira.jboss.org/jira/browse/JBMESSAGING-192

Version:
$Revision: 645 $ $Id: Replicator.java 645 2006-01-30 18:36:31Z ovidiu $
Author:
Ovidiu Feodorov

Field Summary
protected  boolean cancelOnMessageRejection
           
protected  AcknowledgmentCollector collector
           
protected  MessageStore ms
           
 
Fields inherited from class org.jboss.messaging.core.distributed.PeerSupport
dispatcher, joined, peerID, rpcServer, TIMEOUT, viewKeeper
 
Constructor Summary
Replicator(java.io.Serializable replicatorID, RpcDispatcher dispatcher, MessageStore ms, boolean cancelOnMessageRejection)
          Creates a replicator peer.
 
Method Summary
 boolean add(Receiver receiver)
          TODO http://jira.jboss.org/jira/browse/JBMESSAGING-192
 void clear()
          TODO http://jira.jboss.org/jira/browse/JBMESSAGING-192
 void close()
           
 boolean contains(Receiver receiver)
          TODO http://jira.jboss.org/jira/browse/JBMESSAGING-192
protected  RemotePeer createRemotePeer(RemotePeerInfo thatPeerInfo)
          Create a local representation of a remote peer.
 boolean doesCancelOnMessageRejection()
           
protected  void doJoin()
           
protected  void doLeave()
           
 java.util.Set getOutputs()
          Return a set of PeerIdentities corresponding to the replicator's outputs.
 Peer getPeer()
           
protected  RemotePeerInfo getRemotePeerInfo()
          Create a representation of myself to be returned to other peers that need this information.
 java.io.Serializable getReplicatorID()
           
 java.util.Set handle(DeliveryObserver observer, Routable routable, Transaction tx)
          Returns a Set of Deliveries, a delivery for each replicator output in the group.
 java.util.Iterator iterator()
          TODO http://jira.jboss.org/jira/browse/JBMESSAGING-192
 boolean remove(Receiver receiver)
          TODO http://jira.jboss.org/jira/browse/JBMESSAGING-192
 java.lang.String toString()
           
 
Methods inherited from class org.jboss.messaging.core.distributed.PeerSupport
exclude, getDispatcher, getGroupID, getID, getPeerIdentity, getView, hasJoined, include, join, leave, ping, ping
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.messaging.core.distributed.Distributed
join, leave
 

Field Detail

collector

protected AcknowledgmentCollector collector

ms

protected MessageStore ms

cancelOnMessageRejection

protected boolean cancelOnMessageRejection
Constructor Detail

Replicator

public Replicator(java.io.Serializable replicatorID,
                  RpcDispatcher dispatcher,
                  MessageStore ms,
                  boolean cancelOnMessageRejection)
Creates a replicator peer. The peer is not initially connected to the distributed replication group.

Parameters:
cancelOnMessageRejection - - if 'true', the replicator will cancel an on-going delivery on first asynchronous message rejection it receives from its outputs. If false, message rejections are ignored.
Method Detail

getPeer

public Peer getPeer()
Specified by:
getPeer in interface Distributed

close

public void close()
           throws DistributedException
Specified by:
close in interface Distributed
Throws:
DistributedException

handle

public java.util.Set handle(DeliveryObserver observer,
                            Routable routable,
                            Transaction tx)
Returns a Set of Deliveries, a delivery for each replicator output in the group. If there are no outputs, return an empty Set. If the replicator did not join the group yet, the message is rejected so null is returned.

Specified by:
handle in interface Router
Parameters:
tx - - not currently used

contains

public boolean contains(Receiver receiver)
TODO http://jira.jboss.org/jira/browse/JBMESSAGING-192

Specified by:
contains in interface Distributor

iterator

public java.util.Iterator iterator()
TODO http://jira.jboss.org/jira/browse/JBMESSAGING-192

Specified by:
iterator in interface Distributor
Returns:
an iterator of local receivers

add

public boolean add(Receiver receiver)
TODO http://jira.jboss.org/jira/browse/JBMESSAGING-192

Specified by:
add in interface Distributor
Returns:
true if the distributor did not already contain the specified receiver and the receiver was added to the distributor, false otherwise.

remove

public boolean remove(Receiver receiver)
TODO http://jira.jboss.org/jira/browse/JBMESSAGING-192

Specified by:
remove in interface Distributor
Returns:
true if this distributor contained the specified receiver.

clear

public void clear()
TODO http://jira.jboss.org/jira/browse/JBMESSAGING-192

Specified by:
clear in interface Distributor

getReplicatorID

public java.io.Serializable getReplicatorID()

doesCancelOnMessageRejection

public boolean doesCancelOnMessageRejection()

getOutputs

public java.util.Set getOutputs()
Return a set of PeerIdentities corresponding to the replicator's outputs. The set may be empty but never null.


toString

public java.lang.String toString()

doJoin

protected void doJoin()
               throws DistributedException
Specified by:
doJoin in class PeerSupport
Throws:
DistributedException

doLeave

protected void doLeave()
                throws DistributedException
Specified by:
doLeave in class PeerSupport
Throws:
DistributedException

getRemotePeerInfo

protected RemotePeerInfo getRemotePeerInfo()
Description copied from class: PeerSupport
Create a representation of myself to be returned to other peers that need this information.

Specified by:
getRemotePeerInfo in class PeerSupport

createRemotePeer

protected RemotePeer createRemotePeer(RemotePeerInfo thatPeerInfo)
Description copied from class: PeerSupport
Create a local representation of a remote peer.

Specified by:
createRemotePeer in class PeerSupport


Copyright © 2006 JBoss Inc. All Rights Reserved.