Rice Pastry API

rice.p2p.replication.manager
Class ReplicationManagerImpl

java.lang.Object
  extended by rice.p2p.replication.manager.ReplicationManagerImpl
All Implemented Interfaces:
Application, ReplicationManager, ReplicationClient

public class ReplicationManagerImpl
extends java.lang.Object
implements ReplicationManager, ReplicationClient, Application

Version:
$Id: ReplicationManagerImpl.java 3524 2007-01-09 14:09:27Z jeffh $
Author:
Alan Mislove

Nested Class Summary
protected  class ReplicationManagerImpl.ReplicationManagerDeleter
          Inner class which keeps track of the keys which we are currently deleting
protected  class ReplicationManagerImpl.ReplicationManagerHelper
          Inner class which keeps track of the state we're in- waiting, sleeping, or with nothing to do.
 
Field Summary
protected  ReplicationManagerClient client
          The client of this manager
protected  ReplicationManagerImpl.ReplicationManagerDeleter deleter
          The deleter, for managing ids to delete
protected  Endpoint endpoint
          The endpoint used for sending reminder messages
protected  Environment environment
           
protected  IdFactory factory
          The id factory used for manipulating ids
 int FETCH_DELAY
          The amount of time to wait between fetch calls to the client
protected  ReplicationManagerImpl.ReplicationManagerHelper helper
          The helper for the replication manager
protected  java.lang.String instance
           
protected  Logger logger
           
 int NUM_DELETE_AT_ONCE
          The number of ids to delete at a given time - others will be deleted later
protected  ReplicationImpl replication
          The replication used by the manager
 int TIMEOUT_DELAY
          The amount of time to wait before giving up on a client fetch
 
Constructor Summary
ReplicationManagerImpl(Node node, ReplicationManagerClient client, int replicationFactor, java.lang.String instance)
          Constructor
ReplicationManagerImpl(Node node, ReplicationManagerClient client, int replicationFactor, java.lang.String instance, ReplicationPolicy policy)
          Constructor
 
Method Summary
protected  IdSet clone(IdSet keySet)
          Internal method which clones an IdSet, so that iterators work as expected
 void deliver(Id id, Message message)
          This method is called on the application at the destination node for the given id.
 void fetch(IdSet keySet, NodeHandle hint)
          This upcall is invoked to notify the application that is should fetch the cooresponding keys in this set, since the node is now responsible for these keys also.
 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.
 Replication getReplication()
          Utility method which returns the underlying replication object.
protected  void informClient(Id id, NodeHandle hint)
          Internal method which informs the client of the next id to fetch
 IdSet scan(IdRange range)
          This upcall should return the set of keys that the application currently stores in this range.
protected  void scheduleNext()
          Internal method which schedules the next reminder message (if it is necessary), or simply resets the active flag if there's nothing to be fetched.
 void setRange(IdRange range)
          This upcall is to notify the application of the range of keys for which it is responsible.
 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

FETCH_DELAY

public final int FETCH_DELAY
The amount of time to wait between fetch calls to the client


TIMEOUT_DELAY

public final int TIMEOUT_DELAY
The amount of time to wait before giving up on a client fetch


NUM_DELETE_AT_ONCE

public final int NUM_DELETE_AT_ONCE
The number of ids to delete at a given time - others will be deleted later


factory

protected IdFactory factory
The id factory used for manipulating ids


endpoint

protected Endpoint endpoint
The endpoint used for sending reminder messages


replication

protected ReplicationImpl replication
The replication used by the manager


client

protected ReplicationManagerClient client
The client of this manager


helper

protected ReplicationManagerImpl.ReplicationManagerHelper helper
The helper for the replication manager


deleter

protected ReplicationManagerImpl.ReplicationManagerDeleter deleter
The deleter, for managing ids to delete


instance

protected java.lang.String instance

environment

protected Environment environment

logger

protected Logger logger
Constructor Detail

ReplicationManagerImpl

public ReplicationManagerImpl(Node node,
                              ReplicationManagerClient 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

ReplicationManagerImpl

public ReplicationManagerImpl(Node node,
                              ReplicationManagerClient 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
policy - The replication policy to use
Method Detail

clone

protected IdSet clone(IdSet keySet)
Internal method which clones an IdSet, so that iterators work as expected

Parameters:
keySet - The set to clone
Returns:
The cloned set

informClient

protected void informClient(Id id,
                            NodeHandle hint)
Internal method which informs the client of the next id to fetch

Parameters:
id - The id which the client should fetch
hint - The hint where the id may be

scheduleNext

protected void scheduleNext()
Internal method which schedules the next reminder message (if it is necessary), or simply resets the active flag if there's nothing to be fetched.


fetch

public void fetch(IdSet keySet,
                  NodeHandle hint)
This upcall is invoked to notify the application that is should fetch the cooresponding keys in this set, since the node is now responsible for these keys also.

Specified by:
fetch in interface ReplicationClient
Parameters:
keySet - set containing the keys that needs to be fetched
hint - A hint as to where to find the ids in the key set. This is where the local node heard about the keys from.

setRange

public void setRange(IdRange range)
This upcall is to notify the application of the range of keys for which it is responsible. The application might choose to react to call by calling a scan(complement of this range) to the persistance manager and get the keys for which it is not responsible and call delete on the persistance manager for those objects.

Specified by:
setRange in interface ReplicationClient
Parameters:
range - the range of keys for which the local node is currently responsible

scan

public IdSet scan(IdRange range)
This upcall should return the set of keys that the application currently stores in this range. Should return a empty IdSet (not null), in the case that no keys belong to this range. In this case, it returns the list of keys the client has, along with the keys which we have yet to tell the client to fetch.

Specified by:
scan in interface ReplicationClient
Parameters:
range - the requested range

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

getReplication

public Replication getReplication()
Utility method which returns the underlying replication object. Should only be used for testing - messing with this causes undefined behavior.

Specified by:
getReplication in interface ReplicationManager
Returns:
The underlying replication object

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection