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 PingManager

    java.lang.Object
      rice.selector.SelectionKeyHandler
          rice.pastry.socket.PingManager

public class PingManager
extends SelectionKeyHandler

Version:
  $Id: PingManager.java,v 1.27 2005/03/11 00:58:13 jeffh Exp $
Author:
  jeffh To change the template for this generated type comment go to Window>Preferences>Java>Code Generation>Code and Comments

Nested Class Summary
`class` | `PingManager.Envelope` Internal class which holds a pending datagram

Field Summary
`static int` | `DATAGRAM_RECEIVE_BUFFER_SIZE` DESCRIBE THE FIELD
`static int` | `DATAGRAM_SEND_BUFFER_SIZE` DESCRIBE THE FIELD
`protected static byte[]` | `HEADER_PING` DESCRIBE THE FIELD
`static int` | `HEADER_SIZE` DESCRIBE THE FIELD
`protected java.util.ArrayList` | `pendingMsgs` DESCRIBE THE FIELD
`static int` | `PING_THROTTLE` DESCRIBE THE FIELD
`protected java.util.Hashtable` | `pingListeners` DESCRIBE THE FIELD

Constructor Summary
`PingManager(SocketNodeHandlePool pool, SocketSourceRouteManager manager, PastryNode spn, EpochInetSocketAddress bindAddress, EpochInetSocketAddress proxyAddress)`

Method Summary
`static byte[]` | `addHeader(SourceRoute path, java.lang.Object data, EpochInetSocketAddress localAddress)` Method which adds a header for the provided path to the given data.
`void` | `addPingResponseListener(SourceRoute path, PingResponseListener prl)` Adds a feature to the PingResponseListener attribute of the PingManager object
`static java.lang.Object` | `deserialize(byte[] array)` Method which takes in a ByteBuffer read from a datagram, and deserializes the contained object.
`void` | `enqueue(SourceRoute path, java.lang.Object msg)` DESCRIBE THE METHOD
`protected void` | `forcePing(SourceRoute path, PingResponseListener prl)` DESCRIBE THE METHOD
`long` | `getLastTimeHeardFrom(SourceRoute path)` Gets the LastTimeHeardFrom attribute of the PingManager object
`long` | `getLastTimePinged(SourceRoute path)` Gets the LastTimePinged attribute of the PingManager object
`void` | `modifyKey(java.nio.channels.SelectionKey key)` DESCRIBE THE METHOD
`protected void` | `notifyPingResponseListeners(SourceRoute path, int proximity, long lastTimePinged)` caller must synchronized(pingResponseTimes)
`void` | `ping(SourceRoute path, PingResponseListener prl)` Method which initiates a ping to the remote node.
`void` | `pingResponse(SourceRoute path, long curTime)` DESCRIBE THE METHOD
`int` | `proximity(SourceRoute path)` Method which returns the last cached proximity value for the given address.
`void` | `read(java.nio.channels.SelectionKey key)` DESCRIBE THE METHOD
`protected void` | `readHeader(java.net.InetSocketAddress address)` Method which processes an incoming message and hands it off to the appropriate handler.
`void` | `receiveMessage(java.lang.Object message, int size, java.net.InetSocketAddress from)` DESCRIBE THE METHOD
`protected void` | `resetLastTimePinged(SourceRoute path)` Resets the last pinged time, only should be called when a node is marked dead.
`void` | `resign()` Makes this node resign from the network.
`static byte[]` | `serialize(java.lang.Object message)` Method which serializes a given object into a ByteBuffer, in order to prepare it for writing.
`void` | `write(java.nio.channels.SelectionKey key)` DESCRIBE THE METHOD

Methods inherited from class rice.selector.SelectionKeyHandler
`accept, connect`

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

Field Detail

### pingListeners

    protected java.util.Hashtable pingListeners

  DESCRIBE THE FIELD

### pendingMsgs

    protected java.util.ArrayList pendingMsgs

  DESCRIBE THE FIELD

### HEADER_PING

    protected static byte[] HEADER_PING

  DESCRIBE THE FIELD

### HEADER_SIZE

    public static int HEADER_SIZE

  DESCRIBE THE FIELD

### DATAGRAM_RECEIVE_BUFFER_SIZE

    public static int DATAGRAM_RECEIVE_BUFFER_SIZE

  DESCRIBE THE FIELD

### DATAGRAM_SEND_BUFFER_SIZE

    public static int DATAGRAM_SEND_BUFFER_SIZE

  DESCRIBE THE FIELD

### PING_THROTTLE

    public static int PING_THROTTLE

  DESCRIBE THE FIELD

Constructor Detail

### PingManager

    public PingManager(SocketNodeHandlePool pool,
                       SocketSourceRouteManager manager,
                       PastryNode spn,
                       EpochInetSocketAddress bindAddress,
                       EpochInetSocketAddress proxyAddress)

Parameters:
  `manager` - DESCRIBE THE PARAMETER
  `pool` - DESCRIBE THE PARAMETER
  `spn` - DESCRIBE THE PARAMETER
  `bindAddress` - DESCRIBE THE PARAMETER
  `proxyAddress` - DESCRIBE THE PARAMETER

Method Detail

### getLastTimePinged

    public long getLastTimePinged(SourceRoute path)

  Gets the LastTimePinged attribute of the PingManager object

  Parameters:
    `path` - DESCRIBE THE PARAMETER
  Returns:
    The LastTimePinged value

### getLastTimeHeardFrom

    public long getLastTimeHeardFrom(SourceRoute path)

  Gets the LastTimeHeardFrom attribute of the PingManager object

  Parameters:
    `path` - DESCRIBE THE PARAMETER
  Returns:
    The LastTimeHeardFrom value

### resign

    public void resign()
                throws java.io.IOException

  Makes this node resign from the network. Is designed to be used for debugging and testing.

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

### resetLastTimePinged

    protected void resetLastTimePinged(SourceRoute path)

  Resets the last pinged time, only should be called when a node is marked dead.

  Parameters:
    `path` - DESCRIBE THE PARAMETER

### proximity

    public int proximity(SourceRoute path)

  Method which returns the last cached proximity value for the given address. If there is no cached value, then DEFAULT_PROXIMITY is returned.

  Parameters:
    `path` - DESCRIBE THE PARAMETER
  Returns:
    DESCRIBE THE RETURN VALUE

### addPingResponseListener

    public void addPingResponseListener(SourceRoute path,
                                        PingResponseListener prl)

  Adds a feature to the PingResponseListener attribute of the PingManager object

  Parameters:
    `prl` - The feature to be added to the PingResponseListener attribute
    `path` - The feature to be added to the PingResponseListener attribute

### enqueue

    public void enqueue(SourceRoute path,
                        java.lang.Object msg)

  DESCRIBE THE METHOD

  Parameters:
    `msg` - DESCRIBE THE PARAMETER
    `path` - DESCRIBE THE PARAMETER

### receiveMessage

    public void receiveMessage(java.lang.Object message,
                               int size,
                               java.net.InetSocketAddress from)
                        throws java.io.IOException

  DESCRIBE THE METHOD

  Parameters:
    `message` - DESCRIBE THE PARAMETER
    `size` - DESCRIBE THE PARAMETER
    `from` - DESCRIBE THE PARAMETER
  Throws:
    `java.io.IOException` - DESCRIBE THE EXCEPTION

### pingResponse

    public void pingResponse(SourceRoute path,
                             long curTime)

  DESCRIBE THE METHOD

  Parameters:
    `curTime` - DESCRIBE THE PARAMETER
    `path` - DESCRIBE THE PARAMETER

### write

    public void write(java.nio.channels.SelectionKey key)

  DESCRIBE THE METHOD

  Overrides:
    `write` in class `SelectionKeyHandler`
  Parameters:
    `key` - DESCRIBE THE PARAMETER

### modifyKey

    public void modifyKey(java.nio.channels.SelectionKey key)

  DESCRIBE THE METHOD

  Overrides:
    `modifyKey` in class `SelectionKeyHandler`
  Parameters:
    `key` - DESCRIBE THE PARAMETER

### read

    public void read(java.nio.channels.SelectionKey key)

  DESCRIBE THE METHOD

  Overrides:
    `read` in class `SelectionKeyHandler`
  Parameters:
    `key` - DESCRIBE THE PARAMETER

### ping

    public void ping(SourceRoute path,
                     PingResponseListener prl)

  Method which initiates a ping to the remote node. Once the ping is complete, the result will be available via the proximity() call.

  Parameters:
    `prl` - DESCRIBE THE PARAMETER
    `path` - DESCRIBE THE PARAMETER

### forcePing

    protected void forcePing(SourceRoute path,
                             PingResponseListener prl)

  DESCRIBE THE METHOD

  Parameters:
    `prl` - DESCRIBE THE PARAMETER
    `path` - DESCRIBE THE PARAMETER

### notifyPingResponseListeners

    protected void notifyPingResponseListeners(SourceRoute path,
                                               int proximity,
                                               long lastTimePinged)

  caller must synchronized(pingResponseTimes)

  Parameters:
    `proximity` -
    `lastTimePinged` -
    `path` - DESCRIBE THE PARAMETER

### readHeader

    protected void readHeader(java.net.InetSocketAddress address)
                       throws java.io.IOException

  Method which processes an incoming message and hands it off to the appropriate handler.

  Parameters:
    `address` - DESCRIBE THE PARAMETER
  Throws:
    `java.io.IOException` - DESCRIBE THE EXCEPTION

### serialize

    public static byte[] serialize(java.lang.Object message)
                            throws java.io.IOException

  Method which serializes a given object into a ByteBuffer, in order to prepare it for writing.

  Parameters:
    `message` - DESCRIBE THE PARAMETER
  Returns:
    A ByteBuffer containing the object
  Throws:
    `java.io.IOException` - if the object can't be serialized

### addHeader

    public static byte[] addHeader(SourceRoute path,
                                   java.lang.Object data,
                                   EpochInetSocketAddress localAddress)
                            throws java.io.IOException

  Method which adds a header for the provided path to the given data.

  Parameters:
    `path` - The feature to be added to the Header attribute
    `data` - The feature to be added to the Header attribute
    `localAddress` - The feature to be added to the Header attribute
  Returns:
    The messag with a header attached
  Throws:
    `java.io.IOException` - DESCRIBE THE EXCEPTION

### deserialize

    public static java.lang.Object deserialize(byte[] array)
                                        throws java.io.IOException

  Method which takes in a ByteBuffer read from a datagram, and deserializes the contained object.

  Parameters:
    `array` - DESCRIBE THE PARAMETER
  Returns:
    The deserialized object.
  Throws:
    `java.io.IOException` - if the buffer can't be deserialized

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.