Rice Pastry API

rice.pastry.socket
Class SocketChannelRepeater

java.lang.Object
  extended byrice.pastry.socket.SocketChannelRepeater

public class SocketChannelRepeater
extends java.lang.Object

Class which serves as an "reader" for messages sent across the wire via the Pastry socket protocol. This class builds up an object as it is being sent across the wire, and when it has recieved all of an object, it informs the WirePastryNode by using the recieveMessage(msg) method. The SocketChannelReader is designed to be reused, to read objects continiously off of one stream.

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

Field Summary
protected static int HEADER_BUFFER_SIZE
          DESCRIBE THE FIELD
protected  int REPEATER_BUFFER_SIZE
          DESCRIBE THE FIELD
 
Constructor Summary
SocketChannelRepeater(SocketPastryNode spn, SocketCollectionManager.SourceRouteManager manager)
          Constructor which creates this SocketChannelReader and the WirePastryNode.
 
Method Summary
static EpochInetSocketAddress decodeHeader(byte[] array)
          Method which can be used to decode the necessary header for the intermediate hop
static EpochInetSocketAddress decodeHeader(byte[] array, int offset)
          Method which can be used to decode the necessary header for the intermediate hop
static byte[] encodeHeader(EpochInetSocketAddress address)
          Method which can be used to constuct the necessary header for the intermediate hop
 boolean read(java.nio.channels.SocketChannel sc)
          Method which is to be called when there is data available on the specified SocketChannel.
 boolean write(java.nio.channels.SocketChannel sc)
          Method which is designed to be called when this repeater should write something out.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REPEATER_BUFFER_SIZE

protected int REPEATER_BUFFER_SIZE
DESCRIBE THE FIELD


HEADER_BUFFER_SIZE

protected static int HEADER_BUFFER_SIZE
DESCRIBE THE FIELD

Constructor Detail

SocketChannelRepeater

public SocketChannelRepeater(SocketPastryNode spn,
                             SocketCollectionManager.SourceRouteManager manager)
Constructor which creates this SocketChannelReader and the WirePastryNode. Once the reader has completely read a message, it deserializes the message and hands it off to the pastry node.

Parameters:
spn - The PastryNode the SocketChannelReader serves.
manager - DESCRIBE THE PARAMETER
Method Detail

read

public boolean read(java.nio.channels.SocketChannel sc)
             throws java.io.IOException
Method which is to be called when there is data available on the specified SocketChannel. The data is read in, and is put into the output buffer.

Parameters:
sc - The channel to read from.
Returns:
whether or not we the reading key should be turned off an the writing key on
Throws:
java.io.IOException - DESCRIBE THE EXCEPTION

write

public boolean write(java.nio.channels.SocketChannel sc)
              throws java.io.IOException
Method which is designed to be called when this repeater should write something out.

Parameters:
sc - The SocketChannel to write to
Returns:
true if this output stream is done, false otherwise
Throws:
java.io.IOException - DESCRIBE THE EXCEPTION

encodeHeader

public static byte[] encodeHeader(EpochInetSocketAddress address)
Method which can be used to constuct the necessary header for the intermediate hop

Parameters:
address - The final address of the source route
Returns:
The entire header

decodeHeader

public static EpochInetSocketAddress decodeHeader(byte[] array)
                                           throws java.io.IOException
Method which can be used to decode the necessary header for the intermediate hop

Parameters:
array - The encoded header
Returns:
The address
Throws:
java.io.IOException - DESCRIBE THE EXCEPTION

decodeHeader

public static EpochInetSocketAddress decodeHeader(byte[] array,
                                                  int offset)
                                           throws java.io.IOException
Method which can be used to decode the necessary header for the intermediate hop

Parameters:
array - The encoded header
offset - DESCRIBE THE PARAMETER
Returns:
The address
Throws:
java.io.IOException - DESCRIBE THE EXCEPTION

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection