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.socket
Class SocketPastryNodeFactory

    java.lang.Object
      rice.pastry.PastryNodeFactory
          rice.pastry.dist.DistPastryNodeFactory
              rice.pastry.socket.SocketPastryNodeFactory

    public class SocketPastryNodeFactory

extends DistPastryNodeFactory

Pastry node factory for Socket-linked nodes.

Version:
  $Id: SocketPastryNodeFactory.java,v 1.6 2004/03/08 19:53:57 amislove Exp $
Author:
  Alan Mislove

Field Summary
`static int` | `ALWAYS` DESCRIBE THE FIELD
`static int` | `FAIL` DESCRIBE THE FIELD
`protected int` | `findFireWallPolicy` DESCRIBE THE FIELD
`static int` | `NEVER` DESCRIBE THE FIELD
`static int` | `OVERWRITE` DESCRIBE THE FIELD
`static int` | `PREFIX_MATCH` DESCRIBE THE FIELD
`protected int` | `testFireWallPolicy` DESCRIBE THE FIELD
`static byte[]` | `TOTAL_HEADER` DESCRIBE THE FIELD
`static int` | `USE_DIFFERENT_PORT` DESCRIBE THE FIELD

Fields inherited from class rice.pastry.dist.DistPastryNodeFactory
`PROTOCOL_DEFAULT, PROTOCOL_SOCKET`

Fields inherited from class rice.pastry.PastryNodeFactory
`logger, lSetSize, pingCache, rtBase, rtMax`

Constructor Summary
`SocketPastryNodeFactory(NodeIdFactory nf, java.net.InetAddress bindAddress, int startPort, Environment env, NATHandler handler)` Constructor.
`SocketPastryNodeFactory(NodeIdFactory nf, int startPort, Environment env)` Constructor for SocketPastryNodeFactory.

Method Summary
`protected void` | `findFireWallIfNecessary()` DESCRIBE THE METHOD
`NodeHandle` | `generateNodeHandle(java.net.InetSocketAddress address)` Method which contructs a node handle (using the socket protocol) for the node at address NodeHandle.
`CancellableTask` | `generateNodeHandle(java.net.InetSocketAddress address, Continuation c)` DESCRIBE THE METHOD
`NodeHandle` | `generateNodeHandle(java.net.InetSocketAddress address, int timeout)` Way to generate a NodeHandle with a maximum timeout to receive the result.
`protected int` | `getFireWallPolicyVariable(java.lang.String key)` Gets the FireWallPolicyVariable attribute of the SocketPastryNodeFactory object
`LeafSet` | `getLeafSet(NodeHandle handle)` This method returns the remote leafset of the provided handle to the caller, in a protocol-dependent fashion.
`CancellableTask` | `getLeafSet(NodeHandle handle, Continuation c)` Gets the LeafSet attribute of the SocketPastryNodeFactory object
`int` | `getProximity(NodeHandle local, NodeHandle handle)` This method determines and returns the proximity of the current local node to the provided NodeHandle.
`protected Message` | `getResponse(java.net.InetSocketAddress address, Message message)` This method anonymously sends the given message to the remote address, blocks until a response is received, and then closes the socket and returns the response.
`protected CancellableTask` | `getResponse(java.net.InetSocketAddress address, Message message, Continuation c)` Gets the Response attribute of the SocketPastryNodeFactory object
`RouteSet[]` | `getRouteRow(NodeHandle handle, int row)` This method returns the remote route row of the provided handle to the caller, in a protocol-dependent fashion.
`CancellableTask` | `getRouteRow(NodeHandle handle, int row, Continuation c)` Gets the RouteRow attribute of the SocketPastryNodeFactory object
`SourceRoute[]` | `getRoutes(NodeHandle handle, NodeHandle local)` This method returns the routes a remote node is using
`protected boolean` | `localAddressIsProbablyNatted()`
`PastryNode` | `newNode(NodeHandle bootstrap)` Method which creates a Pastry node from the next port with a randomly generated NodeId.
`PastryNode` | `newNode(NodeHandle bootstrap, Id nodeId)` Method which creates a Pastry node from the next port with a randomly generated NodeId.
`PastryNode` | `newNode(NodeHandle bootstrap, Id nodeId, java.net.InetSocketAddress pAddress)` Method which creates a Pastry node from the next port with a randomly generated NodeId.
`PastryNode` | `newNode(NodeHandle bootstrap, Id nodeId, java.net.InetSocketAddress pAddress, boolean throwException)` DESCRIBE THE METHOD
`PastryNode` | `newNode(NodeHandle bootstrap, java.net.InetSocketAddress proxy)` Method which creates a Pastry node from the next port with a randomly generated NodeId.
`static java.net.InetSocketAddress` | `verifyConnection(int timeout, java.net.InetSocketAddress local, java.net.InetSocketAddress[] existing, Environment env, Logger logger)` Method which can be used to test the connectivity contstrains of the local node.
`static java.net.InetSocketAddress` | `verifyConnection(int timeout, int tries, java.net.InetSocketAddress local, java.net.InetSocketAddress[] existing, Environment env, Logger logger)` DESCRIBE THE METHOD

Methods inherited from class rice.pastry.dist.DistPastryNodeFactory
`getFactory, getNodeHandle, getNodeHandle, getNodeHandle, getNodeHandle, getNodeHandle, getNodeHandle`

Methods inherited from class rice.pastry.PastryNodeFactory
`getEnvironment, getNearest, proximity, sortedProximityCache`

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

Field Detail

### testFireWallPolicy

    protected int testFireWallPolicy

  DESCRIBE THE FIELD

### findFireWallPolicy

    protected int findFireWallPolicy

  DESCRIBE THE FIELD

### ALWAYS

    public static final int ALWAYS

  DESCRIBE THE FIELD

  See Also:
    Constant Field Values

### PREFIX_MATCH

    public static final int PREFIX_MATCH

  DESCRIBE THE FIELD

  See Also:
    Constant Field Values

### NEVER

    public static final int NEVER

  DESCRIBE THE FIELD

  See Also:
    Constant Field Values

### OVERWRITE

    public static final int OVERWRITE

  DESCRIBE THE FIELD

  See Also:
    Constant Field Values

### USE_DIFFERENT_PORT

    public static final int USE_DIFFERENT_PORT

  DESCRIBE THE FIELD

  See Also:
    Constant Field Values

### FAIL

    public static final int FAIL

  DESCRIBE THE FIELD

  See Also:
    Constant Field Values

### TOTAL_HEADER

    public static byte[] TOTAL_HEADER

  DESCRIBE THE FIELD

Constructor Detail

### SocketPastryNodeFactory

    public SocketPastryNodeFactory(NodeIdFactory nf,
                                   java.net.InetAddress bindAddress,
                                   int startPort,
                                   Environment env,
                                   NATHandler handler)
                            throws java.io.IOException

  Constructor. Here is order for bind address 1) bindAddress parameter 2) if bindAddress is null, then parameter: socket_bindAddress (if it exists) 3) if socket_bindAddress doesn't exist, then InetAddress.getLocalHost()

  Parameters:
    `nf` - The factory for building node ids
    `bindAddress` - which address to bind to
    `startPort` - The port to start creating nodes on
    `env` - The environment.
    `handler` - DESCRIBE THE PARAMETER
  Throws:
    `java.io.IOException` - DESCRIBE THE EXCEPTION

### SocketPastryNodeFactory

    public SocketPastryNodeFactory(NodeIdFactory nf,
                                   int startPort,
                                   Environment env)
                            throws java.io.IOException

  Constructor for SocketPastryNodeFactory.

  Parameters:
    `nf` - DESCRIBE THE PARAMETER
    `startPort` - DESCRIBE THE PARAMETER
    `env` - DESCRIBE THE PARAMETER
  Throws:
    `java.io.IOException` - DESCRIBE THE EXCEPTION

Method Detail

### getRoutes

    public SourceRoute[] getRoutes(NodeHandle handle,
                                   NodeHandle local)
                            throws java.io.IOException

  This method returns the routes a remote node is using

  Parameters:
    `handle` - The node to connect to
    `local` - DESCRIBE THE PARAMETER
  Returns:
    The leafset of the remote node
  Throws:
    `java.io.IOException` - DESCRIBE THE EXCEPTION

### getLeafSet

    public LeafSet getLeafSet(NodeHandle handle)
                       throws java.io.IOException

  This method returns the remote leafset of the provided handle to the caller, in a protocol-dependent fashion. Note that this method may block while sending the message across the wire.

  Specified by:
    `getLeafSet` in class `PastryNodeFactory`
  Parameters:
    `handle` - The node to connect to
  Returns:
    The leafset of the remote node
  Throws:
    `java.io.IOException` - DESCRIBE THE EXCEPTION

### getLeafSet

    public CancellableTask getLeafSet(NodeHandle handle,
                                      Continuation c)

  Gets the LeafSet attribute of the SocketPastryNodeFactory object

  Specified by:
    `getLeafSet` in class `PastryNodeFactory`
  Parameters:
    `handle` - DESCRIBE THE PARAMETER
    `c` - DESCRIBE THE PARAMETER
  Returns:
    The LeafSet value

### getRouteRow

    public RouteSet[] getRouteRow(NodeHandle handle,
                                  int row)
                           throws java.io.IOException

  This method returns the remote route row of the provided handle to the caller, in a protocol-dependent fashion. Note that this method may block while sending the message across the wire.

  Specified by:
    `getRouteRow` in class `PastryNodeFactory`
  Parameters:
    `handle` - The node to connect to
    `row` - The row number to retrieve
  Returns:
    The route row of the remote node
  Throws:
    `java.io.IOException` - DESCRIBE THE EXCEPTION

### getRouteRow

    public CancellableTask getRouteRow(NodeHandle handle,
                                       int row,
                                       Continuation c)

  Gets the RouteRow attribute of the SocketPastryNodeFactory object

  Specified by:
    `getRouteRow` in class `PastryNodeFactory`
  Parameters:
    `handle` - DESCRIBE THE PARAMETER
    `row` - DESCRIBE THE PARAMETER
    `c` - DESCRIBE THE PARAMETER
  Returns:
    The RouteRow value

### getProximity

    public int getProximity(NodeHandle local,
                            NodeHandle handle)

  This method determines and returns the proximity of the current local node to the provided NodeHandle. This will need to be done in a protocol- dependent fashion and may need to be done in a special way.

  Specified by:
    `getProximity` in class `PastryNodeFactory`
  Parameters:
    `local` - DESCRIBE THE PARAMETER
    `handle` - The handle to determine the proximity of
  Returns:
    The proximity of the provided handle

### getFireWallPolicyVariable

    protected int getFireWallPolicyVariable(java.lang.String key)

  Gets the FireWallPolicyVariable attribute of the SocketPastryNodeFactory object

  Parameters:
    `key` - DESCRIBE THE PARAMETER
  Returns:
    The FireWallPolicyVariable value

### getResponse

    protected Message getResponse(java.net.InetSocketAddress address,
                                  Message message)
                           throws java.io.IOException

  This method anonymously sends the given message to the remote address, blocks until a response is received, and then closes the socket and returns the response.

  Parameters:
    `address` - The address to send to
    `message` - The message to send
  Returns:
    The response
  Throws:
    `java.io.IOException` - DESCRIBE THE EXCEPTION

### getResponse

    protected CancellableTask getResponse(java.net.InetSocketAddress address,
                                          Message message,
                                          Continuation c)

  Gets the Response attribute of the SocketPastryNodeFactory object

  Parameters:
    `address` - DESCRIBE THE PARAMETER
    `message` - DESCRIBE THE PARAMETER
    `c` - DESCRIBE THE PARAMETER
  Returns:
    The Response value

### generateNodeHandle

    public NodeHandle generateNodeHandle(java.net.InetSocketAddress address,
                                         int timeout)

  Way to generate a NodeHandle with a maximum timeout to receive the result. Helper funciton for using the non-blocking version. However this method behaves as a blocking call.

  Specified by:
    `generateNodeHandle` in class `DistPastryNodeFactory`
  Parameters:
    `address` -
    `timeout` - maximum time in millis to return the result. <= 0 will use the blocking version.
  Returns:

### generateNodeHandle

    public NodeHandle generateNodeHandle(java.net.InetSocketAddress address)

  Method which contructs a node handle (using the socket protocol) for the node at address NodeHandle.

  Parameters:
    `address` - The address of the remote node.
  Returns:
    A NodeHandle cooresponding to that address

### generateNodeHandle

    public CancellableTask generateNodeHandle(java.net.InetSocketAddress address,
                                              Continuation c)

  DESCRIBE THE METHOD

  Specified by:
    `generateNodeHandle` in class `DistPastryNodeFactory`
  Parameters:
    `address` - DESCRIBE THE PARAMETER
    `c` - DESCRIBE THE PARAMETER
  Returns:
    DESCRIBE THE RETURN VALUE

### newNode

    public PastryNode newNode(NodeHandle bootstrap)

  Method which creates a Pastry node from the next port with a randomly generated NodeId.

  Specified by:
    `newNode` in class `DistPastryNodeFactory`
  Parameters:
    `bootstrap` - Node handle to bootstrap from.
  Returns:
    A node with a random ID and next port number.

### newNode

    public PastryNode newNode(NodeHandle bootstrap,
                              Id nodeId)

  Method which creates a Pastry node from the next port with a randomly generated NodeId.

  Specified by:
    `newNode` in class `DistPastryNodeFactory`
  Parameters:
    `bootstrap` - Node handle to bootstrap from.
    `nodeId` - DESCRIBE THE PARAMETER
  Returns:
    A node with a random ID and next port number.

### newNode

    public PastryNode newNode(NodeHandle bootstrap,
                              java.net.InetSocketAddress proxy)

  Method which creates a Pastry node from the next port with a randomly generated NodeId.

  Specified by:
    `newNode` in class `DistPastryNodeFactory`
  Parameters:
    `bootstrap` - Node handle to bootstrap from.
    `proxy` - DESCRIBE THE PARAMETER
  Returns:
    A node with a random ID and next port number.

### newNode

    public PastryNode newNode(NodeHandle bootstrap,
                              Id nodeId,
                              java.net.InetSocketAddress pAddress)

  Method which creates a Pastry node from the next port with a randomly generated NodeId.

  Specified by:
    `newNode` in class `DistPastryNodeFactory`
  Parameters:
    `bootstrap` - Node handle to bootstrap from.
    `nodeId` - DESCRIBE THE PARAMETER
    `pAddress` - The address to claim that this node is at - used for proxies behind NATs
  Returns:
    A node with a random ID and next port number.

### newNode

    public PastryNode newNode(NodeHandle bootstrap,
                              Id nodeId,
                              java.net.InetSocketAddress pAddress,
                              boolean throwException)
                       throws java.io.IOException

  DESCRIBE THE METHOD

  Parameters:
    `bootstrap` - DESCRIBE THE PARAMETER
    `nodeId` - DESCRIBE THE PARAMETER
    `pAddress` - DESCRIBE THE PARAMETER
    `throwException` - DESCRIBE THE PARAMETER
  Returns:
    DESCRIBE THE RETURN VALUE
  Throws:
    `java.io.IOException` - DESCRIBE THE EXCEPTION

### findFireWallIfNecessary

    protected void findFireWallIfNecessary()
                                    throws java.io.IOException

  DESCRIBE THE METHOD

  Throws:
    `java.io.IOException` - DESCRIBE THE EXCEPTION

### localAddressIsProbablyNatted

    protected boolean localAddressIsProbablyNatted()

  Returns:
    true if ip address matches firewall prefix

### verifyConnection

    public static java.net.InetSocketAddress verifyConnection(int timeout,
                                                              java.net.InetSocketAddress local,
                                                              java.net.InetSocketAddress[] existing,
                                                              Environment env,
                                                              Logger logger)
                                                       throws java.io.IOException

  Method which can be used to test the connectivity contstrains of the local node. This (optional) method is designed to be called by applications to ensure that the local node is able to connect through the network - checks can be done to check TCP/UDP connectivity, firewall setup, etc... If the method works, then nothing should be done and the method should return. If an error condition is detected, an exception should be thrown.

  Parameters:
    `timeout` - DESCRIBE THE PARAMETER
    `local` - DESCRIBE THE PARAMETER
    `existing` - DESCRIBE THE PARAMETER
    `env` - DESCRIBE THE PARAMETER
    `logger` - DESCRIBE THE PARAMETER
  Returns:
    DESCRIBE THE RETURN VALUE
  Throws:
    `java.io.IOException` - DESCRIBE THE EXCEPTION

### verifyConnection

    public static java.net.InetSocketAddress verifyConnection(int timeout,
                                                              int tries,
                                                              java.net.InetSocketAddress local,
                                                              java.net.InetSocketAddress[] existing,
                                                              Environment env,
                                                              Logger logger)
                                                       throws java.io.IOException

  DESCRIBE THE METHOD

  Parameters:
    `timeout` - DESCRIBE THE PARAMETER
    `tries` - DESCRIBE THE PARAMETER
    `local` - DESCRIBE THE PARAMETER
    `existing` - DESCRIBE THE PARAMETER
    `env` - DESCRIBE THE PARAMETER
    `logger` - DESCRIBE THE PARAMETER
  Returns:
    DESCRIBE THE RETURN VALUE
  Throws:
    `java.io.IOException` - DESCRIBE THE EXCEPTION

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.