Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## rice.pastry.standard
Class PartitionHandler

    java.lang.Object
      rice.selector.TimerTask
          rice.pastry.standard.PartitionHandler

All Implemented Interfaces:
  java.lang.Comparable, Cancellable, CancellableTask, NodeSetListener

    public class PartitionHandler

extends TimerTask
implements NodeSetListener

The PartitionHandler does two things: it collects a list of candidate nodes that may be in another partition, and it periodically tries to reach these nodes to heal a partition. I can refactor the code to expose a method that heals a partition tomorrow for you, but I'll paste the code below for the moment. The basic theory of healing a partition is to send a join request via a node that may not be in your partition. Join requests get routed to your own key. If the request comes back to you, then that node is in your partition and nothing needs to be done. If the request ends up at another node, it will discover your existence and begin integrating the two rings, just as if you were creating your local node for the first time. The way we look for candidate nodes is we choose a mix of the original bootstraps (as a last resort fallback) and nodes that we once believed were alive but are no longer in contact with. The idea is we may have declared those nodes dead due to losing connectivity to them but at some later point we again may be able to contact them. The reason that we make the PartitionHandler a periodic process is that in general you can't tell that a partition has happened.

Author:
  jstewart

Field Summary
`protected double` | `bootstrapRate`
`protected java.net.InetSocketAddress[]` | `bootstraps`
`protected Environment` | `env`
`protected SocketPastryNodeFactory` | `factory`
`protected java.util.Map` | `gone`
`protected Logger` | `logger`
`protected int` | `maxGoneAge`
`protected int` | `maxGoneSize`
`protected PastryNode` | `pastryNode`

Fields inherited from class rice.selector.TimerTask
`cancelled, fixedRate, period, selector, seq`

Constructor Summary
`PartitionHandler(PastryNode pn, SocketPastryNodeFactory factory, java.net.InetSocketAddress[] bootstraps)` Constructs a PartitionHandler.

Method Summary
`NodeHandle` | `getCandidateNode()` This method randomly returns a node that was once in the LeafSet or in the routing table but has since been removed.
`void` | `nodeSetUpdate(NodeSetEventSource nodeSetEventSource, NodeHandle handle, boolean added)`
`void` | `rejoin(NodeHandle target)` Manually kicks off a probe to a given target node.
`void` | `run()`
`void` | `start(Timer timer)` This method starts the PartitionHandler's probing of candidate nodes.

Methods inherited from class rice.selector.TimerTask
`cancel, compareTo, execute, isCancelled, scheduledExecutionTime, setNextExecutionTime, setSelectorManager`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### pastryNode

    protected PastryNode pastryNode

### bootstraps

    protected java.net.InetSocketAddress[] bootstraps

### factory

    protected SocketPastryNodeFactory factory

### logger

    protected Logger logger

### bootstrapRate

    protected double bootstrapRate

### maxGoneSize

    protected int maxGoneSize

### maxGoneAge

    protected int maxGoneAge

### gone

    protected java.util.Map gone

### env

    protected Environment env

Constructor Detail

### PartitionHandler

    public PartitionHandler(PastryNode pn,
                            SocketPastryNodeFactory factory,
                            java.net.InetSocketAddress[] bootstraps)

  Constructs a PartitionHandler. This will register the handler with the pastry node to begin collecting candidates nodes that may be in a partition, but it will not initiate probing. You must call the start() method to do that.

  Parameters:
    `pn` - the local pastry node
    `factory` - the SocketPastryNodeFactory
    `bootstraps` -

Method Detail

### getCandidateNode

    public NodeHandle getCandidateNode()

  This method randomly returns a node that was once in the LeafSet or in the routing table but has since been removed. The idea is that the node may have been removed because it suffered a network outage that left it in a partition of the ring. This method may also return a node from the current routing table if it doesn't know of sufficient nodes that have left to pick a good one.

  Returns:
    a NodeHandle that may be in another partition, or null if no nodes have left the routing table or LeafSet, and the routing table is empty.

### run

    public void run()

  Specified by:
    `run` in interface `CancellableTask`
  Specified by:
    `run` in class `TimerTask`

### nodeSetUpdate

    public void nodeSetUpdate(NodeSetEventSource nodeSetEventSource,
                              NodeHandle handle,
                              boolean added)

  Specified by:
    `nodeSetUpdate` in interface `NodeSetListener`

### start

    public void start(Timer timer)

  This method starts the PartitionHandler's probing of candidate nodes. It should be called after the handler is constructed.

  Parameters:
    `timer` - the timer used to schedule partition checks (normally from the environment)

### rejoin

    public void rejoin(NodeHandle target)

  Manually kicks off a probe to a given target node. This can be used to manually heal a partition if you know via some external mechanism that one occurred.

  Parameters:
    `target` - the node to rejoin through

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2005 - Rice Pastry.