Rice Pastry API

rice.pastry.socket
Class SocketChannelReader

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

public class SocketChannelReader
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  Environment environment
          DESCRIBE THE FIELD
protected  Logger logger
          DESCRIBE THE FIELD
protected  SourceRoute path
          DESCRIBE THE FIELD
 int SELECTOR_DESERIALIZATION_MAX_SIZE
          DESCRIBE THE FIELD
 
Constructor Summary
SocketChannelReader(Environment env, SourceRoute path)
          Constructor for SocketChannelReader.
SocketChannelReader(PastryNode spn, SourceRoute path)
          Constructor which creates this SocketChannelReader and the WirePastryNode.
 
Method Summary
 java.lang.Object read(java.nio.channels.SocketChannel sc)
          Method which is to be called when there is data available on the specified SocketChannel.
protected  void record(java.lang.Object obj, int size, SourceRoute path)
          DESCRIBE THE METHOD
 void reset()
          Resets this input stream so that it is ready to read another object off of the queue.
protected  void setPath(SourceRoute path)
          Sets this reader's path
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECTOR_DESERIALIZATION_MAX_SIZE

public int SELECTOR_DESERIALIZATION_MAX_SIZE
DESCRIBE THE FIELD


path

protected SourceRoute path
DESCRIBE THE FIELD


environment

protected Environment environment
DESCRIBE THE FIELD


logger

protected Logger logger
DESCRIBE THE FIELD

Constructor Detail

SocketChannelReader

public SocketChannelReader(PastryNode spn,
                           SourceRoute path)
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.
path - DESCRIBE THE PARAMETER

SocketChannelReader

public SocketChannelReader(Environment env,
                           SourceRoute path)
Constructor for SocketChannelReader.

Parameters:
env - DESCRIBE THE PARAMETER
path - DESCRIBE THE PARAMETER
Method Detail

setPath

protected void setPath(SourceRoute path)
Sets this reader's path

Parameters:
path - The path this reader is using

read

public java.lang.Object 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 if the object is done being read, it is parsed.

Parameters:
sc - The channel to read from.
Returns:
The object read off the stream, or null if no object has been completely read yet
Throws:
java.io.IOException - DESCRIBE THE EXCEPTION

record

protected void record(java.lang.Object obj,
                      int size,
                      SourceRoute path)
DESCRIBE THE METHOD

Parameters:
obj - DESCRIBE THE PARAMETER
size - DESCRIBE THE PARAMETER
path - DESCRIBE THE PARAMETER

reset

public void reset()
Resets this input stream so that it is ready to read another object off of the queue.


Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection