Rice Pastry API

rice.p2p.replication
Class ReplicationImpl

java.lang.Object
  extended by rice.p2p.replication.ReplicationImpl
All Implemented Interfaces:
Application, Replication

public class ReplicationImpl
extends java.lang.Object
implements Replication, Application

Version:
$Id: ReplicationImpl.java 3613 2007-02-15 14:45:14Z jstewart $
Author:
Alan Mislove

Nested Class Summary
protected  class ReplicationImpl.BloomFilterExecutable
          Internal class which is an executable for creating a bloom filter
 
Field Summary
protected  ReplicationClient client
          This replication's client
protected  Endpoint endpoint
          this application's endpoint
protected  IdFactory factory
          The factory for create IdSets and IdRanges
protected  NodeHandle handle
          the local node handle
protected  java.lang.String instance
          The instance name of the replication
 int MAINTENANCE_INTERVAL
          The amount of time to wait between replications
 int MAX_KEYS_IN_MESSAGE
          The maximum number of keys to return in one message
protected  ReplicationPolicy policy
          This replication's policy, which allows for application-specific replication
protected  int replicationFactor
          The replication factor for this replication
 
Constructor Summary
ReplicationImpl(Node node, ReplicationClient client, int replicationFactor, java.lang.String instance)
          Constructor
ReplicationImpl(Node node, ReplicationClient client, int replicationFactor, java.lang.String instance, ReplicationPolicy policy)
          Constructor
 
Method Summary
 void deliver(Id id, Message message)
          This method is called on the application at the destination node for the given id.
 boolean forward(RouteMessage message)
          This method is invoked on applications when the underlying node is about to forward the given message with the provided target to the specified next hop.
protected  IdRange getTotalRange()
          Returns the range for which the local node is an i root, where i can range between 0 and replicationFactor can return null if the range can't be determined
static IdSet merge(IdFactory factory, IdSet a, IdSet b)
          Internal method which takes returns set A + set B, or all of the members of set A and set B.
 void replicate()
          This internal method sends out the request messages to all of the nodes which hold keys this node may be interested in
 void update(NodeHandle handle, boolean joined)
          This method is invoked to inform the application that the given node has either joined or left the neighbor set of the local node, as the set would be returned by the neighborSet call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAINTENANCE_INTERVAL

public final int MAINTENANCE_INTERVAL
The amount of time to wait between replications


MAX_KEYS_IN_MESSAGE

public final int MAX_KEYS_IN_MESSAGE
The maximum number of keys to return in one message


endpoint

protected Endpoint endpoint
this application's endpoint


handle

protected NodeHandle handle
the local node handle


factory

protected IdFactory factory
The factory for create IdSets and IdRanges


client

protected ReplicationClient client
This replication's client


policy

protected ReplicationPolicy policy
This replication's policy, which allows for application-specific replication


replicationFactor

protected int replicationFactor
The replication factor for this replication


instance

protected java.lang.String instance
The instance name of the replication

Constructor Detail

ReplicationImpl

public ReplicationImpl(Node node,
                       ReplicationClient client,
                       int replicationFactor,
                       java.lang.String instance)
Constructor

Parameters:
node - The node below this Replication implementation
client - The client for this Replication
replicationFactor - The replication factor for this instance
instance - The unique instance name of this Replication

ReplicationImpl

public ReplicationImpl(Node node,
                       ReplicationClient client,
                       int replicationFactor,
                       java.lang.String instance,
                       ReplicationPolicy policy)
Constructor

Parameters:
node - The node below this Replication implementation
client - The client for this Replication
replicationFactor - The replication factor for this instance
instance - The unique instance name of this Replication
Method Detail

merge

public static IdSet merge(IdFactory factory,
                          IdSet a,
                          IdSet b)
Internal method which takes returns set A + set B, or all of the members of set A and set B.

Parameters:
a - The first set
b - The second set
Returns:
The merge, a+b

getTotalRange

protected IdRange getTotalRange()
Returns the range for which the local node is an i root, where i can range between 0 and replicationFactor can return null if the range can't be determined

Returns:
The *total* range

replicate

public void replicate()
This internal method sends out the request messages to all of the nodes which hold keys this node may be interested in

Specified by:
replicate in interface Replication

forward

public boolean forward(RouteMessage message)
This method is invoked on applications when the underlying node is about to forward the given message with the provided target to the specified next hop. Applications can change the contents of the message, specify a different nextHop (through re-routing), or completely terminate the message.

Specified by:
forward in interface Application
Parameters:
message - The message being sent, containing an internal message along with a destination key and nodeHandle next hop.
Returns:
Whether or not to forward the message further

deliver

public void deliver(Id id,
                    Message message)
This method is called on the application at the destination node for the given id.

Specified by:
deliver in interface Application
Parameters:
id - The destination id of the message
message - The message being sent

update

public void update(NodeHandle handle,
                   boolean joined)
This method is invoked to inform the application that the given node has either joined or left the neighbor set of the local node, as the set would be returned by the neighborSet call.

Specified by:
update in interface Application
Parameters:
handle - The handle that has joined/left
joined - Whether the node has joined or left

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection