Rice Pastry API

rice.pastry.wire
Class DatagramManager

java.lang.Object
  |
  +--rice.pastry.wire.DatagramManager
All Implemented Interfaces:
SelectionKeyHandler

public class DatagramManager
extends java.lang.Object
implements SelectionKeyHandler

This class is an implementation of a UDP-based Pastry protocol. All messages are sent across the network as datagrams. It uses a TransmissionManager in order to ensure (ordered) delivery.

Version:
$Id: DatagramManager.java,v 1.14 2003/07/22 03:32:48 amislove Exp $
Author:
Alan Mislove

Field Summary
static int DATAGRAM_RECEIVE_BUFFER_SIZE
           
static int DATAGRAM_SEND_BUFFER_SIZE
           
 
Constructor Summary
DatagramManager(rice.pastry.wire.WirePastryNode pastryNode, rice.pastry.wire.SelectorManager manager, int port)
          Constructor.
 
Method Summary
 void accept(java.nio.channels.SelectionKey key)
          Specified by the SelectionKeyHandler - should NEVER be called (since datagrams are never accepted).
 void connect(java.nio.channels.SelectionKey key)
          Specified by the SelectionKeyHandler - should NEVER be called (since datagrams are never connected).
static java.lang.Object deserialize(java.nio.ByteBuffer buffer)
          Method which takes in a ByteBuffer read from a datagram, and deserializes the contained object.
 void read(java.nio.channels.SelectionKey key)
          Specified by the SelectionKeyHandler interface - is called when there is a datagram ready to be read.
 void resetAckNumber(rice.pastry.NodeId node)
          Designed to be called by a node handle when a socket is open in order to reset the seqence number of UDP.
static java.nio.ByteBuffer serialize(java.lang.Object o)
          Method which serializes a given object into a ByteBuffer, in order to prepare it for writing.
 void wakeup()
          Called by the SelectorManager whenever it is awoken.
 void write(rice.pastry.NodeId destination, java.net.InetSocketAddress address, java.lang.Object o)
          Method designed for node handles to use when they wish to write to their remote node.
 void write(java.nio.channels.SelectionKey key)
          Specified by the SelectionKeyHandler interface - is called when there is space in the DatagramChannel's buffer to write some data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATAGRAM_RECEIVE_BUFFER_SIZE

public static int DATAGRAM_RECEIVE_BUFFER_SIZE

DATAGRAM_SEND_BUFFER_SIZE

public static int DATAGRAM_SEND_BUFFER_SIZE
Constructor Detail

DatagramManager

public DatagramManager(rice.pastry.wire.WirePastryNode pastryNode,
                       rice.pastry.wire.SelectorManager manager,
                       int port)
Constructor.

Parameters:
port - The port number this Datagram Manager should run on
Method Detail

resetAckNumber

public void resetAckNumber(rice.pastry.NodeId node)
Designed to be called by a node handle when a socket is open in order to reset the seqence number of UDP.

Parameters:
node - The NodeId to reset.

write

public void write(rice.pastry.NodeId destination,
                  java.net.InetSocketAddress address,
                  java.lang.Object o)
Method designed for node handles to use when they wish to write to their remote node. This method enqueues their message, and will eventually send the message to the remote node.

Parameters:
address - The remote address to send the message to.
o - The object that should be sent.

read

public void read(java.nio.channels.SelectionKey key)
Specified by the SelectionKeyHandler interface - is called when there is a datagram ready to be read.

Specified by:
read in interface SelectionKeyHandler
Parameters:
key - The SelectionKey which is readable.

write

public void write(java.nio.channels.SelectionKey key)
Specified by the SelectionKeyHandler interface - is called when there is space in the DatagramChannel's buffer to write some data.

Specified by:
write in interface SelectionKeyHandler
Parameters:
key - The key which is writable

wakeup

public void wakeup()
Called by the SelectorManager whenever it is awoken. This allows the TransmissionManager to check and make sure that if we are waiting to write, we are registered as being interested in writing.

Specified by:
wakeup in interface SelectionKeyHandler

serialize

public static java.nio.ByteBuffer serialize(java.lang.Object o)
                                     throws java.io.IOException
Method which serializes a given object into a ByteBuffer, in order to prepare it for writing.

Parameters:
o - The object to serialize
Returns:
A ByteBuffer containing the object
java.io.IOException

deserialize

public static java.lang.Object deserialize(java.nio.ByteBuffer buffer)
                                    throws java.io.IOException
Method which takes in a ByteBuffer read from a datagram, and deserializes the contained object.

Parameters:
buffer - The buffer read from the datagram.
Returns:
The deserialized object.
java.io.IOException

accept

public void accept(java.nio.channels.SelectionKey key)
Specified by the SelectionKeyHandler - should NEVER be called (since datagrams are never accepted).

Specified by:
accept in interface SelectionKeyHandler
Parameters:
key - The key that is acceptable.

connect

public void connect(java.nio.channels.SelectionKey key)
Specified by the SelectionKeyHandler - should NEVER be called (since datagrams are never connected).

Specified by:
connect in interface SelectionKeyHandler
Parameters:
key - The key that is connectable.

Rice Pastry API

Copyright © 2001 - Rice Pastry.


Imprint-Dataprotection