Rice Pastry API

org.mpisws.p2p.transport.peerreview.replay.playback
Class ReplaySocket<Identifier>

java.lang.Object
  extended by org.mpisws.p2p.transport.peerreview.replay.playback.ReplaySocket<Identifier>
All Implemented Interfaces:
P2PSocket<Identifier>, SocketRequestHandle<Identifier>, Cancellable

public class ReplaySocket<Identifier>
extends java.lang.Object
implements P2PSocket<Identifier>, SocketRequestHandle<Identifier>


Field Summary
protected  Identifier identifier
           
protected  int socketId
           
protected  ReplayVerifier<Identifier> verifier
           
 
Constructor Summary
ReplaySocket(Identifier identifier, int socketId, ReplayVerifier<Identifier> verifier, java.util.Map<java.lang.String,java.lang.Object> options)
          TODO: Make extensible by putting into a factory.
 
Method Summary
 boolean cancel()
           
 void close()
          Closes this socket.
 Identifier getIdentifier()
          The identification of the node at the other end of the socket.
 java.util.Map<java.lang.String,java.lang.Object> getOptions()
          Details on the connectivity of the socket (encrypted, source-routed etc)
 void notifyIO(boolean canRead, boolean canWrite)
           
 long read(java.nio.ByteBuffer dst)
          Reads a sequence of bytes from this channel into a subsequence of the given buffer.
 void receiveException(java.io.IOException ioe)
           
 void register(boolean wantToRead, boolean wantToWrite, P2PSocketReceiver<Identifier> receiver)
          Must be called every time a Read/Write occurs to continue operation.
 void setDeliverSocketToMe(SocketCallback<Identifier> deliverSocketToMe)
           
 void shutdownOutput()
          Disables the output stream for this socket.
 void socketOpened()
           
 long write(java.nio.ByteBuffer src)
          Writes a sequence of bytes to this channel from a subsequence of the given buffers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

identifier

protected Identifier identifier

socketId

protected int socketId

verifier

protected ReplayVerifier<Identifier> verifier
Constructor Detail

ReplaySocket

public ReplaySocket(Identifier identifier,
                    int socketId,
                    ReplayVerifier<Identifier> verifier,
                    java.util.Map<java.lang.String,java.lang.Object> options)
TODO: Make extensible by putting into a factory.

Parameters:
identifier -
socketId -
verifier -
Method Detail

getIdentifier

public Identifier getIdentifier()
Description copied from interface: P2PSocket
The identification of the node at the other end of the socket.

Specified by:
getIdentifier in interface P2PSocket<Identifier>
Specified by:
getIdentifier in interface SocketRequestHandle<Identifier>
Returns:
The identification of the node at the other end of the socket.

getOptions

public java.util.Map<java.lang.String,java.lang.Object> getOptions()
Description copied from interface: P2PSocket
Details on the connectivity of the socket (encrypted, source-routed etc)

Specified by:
getOptions in interface P2PSocket<Identifier>
Specified by:
getOptions in interface SocketRequestHandle<Identifier>
Returns:
a read-only list of options on this socket

read

public long read(java.nio.ByteBuffer dst)
          throws java.io.IOException
Description copied from interface: P2PSocket
Reads a sequence of bytes from this channel into a subsequence of the given buffer.

Specified by:
read in interface P2PSocket<Identifier>
Returns:
Throws:
java.io.IOException

write

public long write(java.nio.ByteBuffer src)
           throws java.io.IOException
Description copied from interface: P2PSocket
Writes a sequence of bytes to this channel from a subsequence of the given buffers.

Specified by:
write in interface P2PSocket<Identifier>
Throws:
java.io.IOException

register

public void register(boolean wantToRead,
                     boolean wantToWrite,
                     P2PSocketReceiver<Identifier> receiver)
Description copied from interface: P2PSocket
Must be called every time a Read/Write occurs to continue operation. Can cancel this task by calling with null.

Specified by:
register in interface P2PSocket<Identifier>
Parameters:
wantToRead - if you want to read from this socket
wantToWrite - if you want to write to this socket
receiver - will have receiveSelectResult() called on it note that you must call select() each time receiveSelectResult() is called. This is so your application can properly handle flow control

notifyIO

public void notifyIO(boolean canRead,
                     boolean canWrite)
              throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
Description copied from interface: P2PSocket
Closes this socket.

Specified by:
close in interface P2PSocket<Identifier>

setDeliverSocketToMe

public void setDeliverSocketToMe(SocketCallback<Identifier> deliverSocketToMe)

socketOpened

public void socketOpened()

shutdownOutput

public void shutdownOutput()
Description copied from interface: P2PSocket
Disables the output stream for this socket. Used to properly close down a socket used for bi-directional communication that can be initated by either side.

Specified by:
shutdownOutput in interface P2PSocket<Identifier>

receiveException

public void receiveException(java.io.IOException ioe)

cancel

public boolean cancel()
Specified by:
cancel in interface Cancellable
Returns:
true if it was cancelled, false if it was already complete, or cancelled.

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection