net.tomp2p.replication
Class Replication

java.lang.Object
  extended by net.tomp2p.replication.Replication
All Implemented Interfaces:
PeerMapChangeListener

public class Replication
extends Object
implements PeerMapChangeListener

This class has 3 methods that are called from outside eventes: check, peerInsert, peerRemoved.


Constructor Summary
Replication(ReplicationStorage replicationStorage, PeerAddress selfAddress, PeerMap peerMap, int replicationFactor)
          Constructor.
 
Method Summary
 void addResponsibilityListener(ResponsibilityListener responsibilityListener)
          Add responsibility listener.
 int getReplicationFactor()
           
 boolean isReplicationEnabled()
          Checks if the user enabled replication.
 void peerInserted(PeerAddress peerAddress)
          This method is called if a peer is added to the map
 void peerRemoved(PeerAddress peerAddress)
          This method is called if a peer is removed from the map
 void peerUpdated(PeerAddress peerAddress)
          This method is called if a peer is updated.
 void removeResponsibilityListener(ResponsibilityListener responsibilityListener)
          Remove a responsibility listener.
 void setReplicationFactor(int replicationFactor)
           
 void updateAndNotifyResponsibilities(Number160 locationKey)
          Update responsibilities.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Replication

public Replication(ReplicationStorage replicationStorage,
                   PeerAddress selfAddress,
                   PeerMap peerMap,
                   int replicationFactor)
Constructor.

Parameters:
replicationStorage - The interface where we shore the replication responsibilities
selfAddress - My address to know for what my peer is responsible
peerMap - The map of my neighbors
replicationFactor - The replication factor
Method Detail

setReplicationFactor

public void setReplicationFactor(int replicationFactor)
Parameters:
replicationFactor - Set the replication factor

getReplicationFactor

public int getReplicationFactor()
Returns:
The replication factor.

isReplicationEnabled

public boolean isReplicationEnabled()
Checks if the user enabled replication.

Returns:
True if replication is enabled.

addResponsibilityListener

public void addResponsibilityListener(ResponsibilityListener responsibilityListener)
Add responsibility listener. If the first listener is added, replication is considered enabled.

Parameters:
responsibilityListener - The responsibility listener.

removeResponsibilityListener

public void removeResponsibilityListener(ResponsibilityListener responsibilityListener)
Remove a responsibility listener. If all responsibility listeners are removed, replication is considered disabled.

Parameters:
responsibilityListener - The responsibility listener.

updateAndNotifyResponsibilities

public void updateAndNotifyResponsibilities(Number160 locationKey)
Update responsibilities. This happens for a put / add.

Parameters:
locationKey - The location key.

peerInserted

public void peerInserted(PeerAddress peerAddress)
Description copied from interface: PeerMapChangeListener
This method is called if a peer is added to the map

Specified by:
peerInserted in interface PeerMapChangeListener
Parameters:
peerAddress - The peer that has been added.

peerRemoved

public void peerRemoved(PeerAddress peerAddress)
Description copied from interface: PeerMapChangeListener
This method is called if a peer is removed from the map

Specified by:
peerRemoved in interface PeerMapChangeListener
Parameters:
peerAddress - The peer that has been removed and add to the cache.

peerUpdated

public void peerUpdated(PeerAddress peerAddress)
Description copied from interface: PeerMapChangeListener
This method is called if a peer is updated.

Specified by:
peerUpdated in interface PeerMapChangeListener
Parameters:
peerAddress - The peer can change its IP and some statistical data


Copyright © 2013. All Rights Reserved.