Rice Pastry API

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

java.lang.Object
  extended by org.mpisws.p2p.transport.peerreview.Verifier<Identifier>
      extended by org.mpisws.p2p.transport.peerreview.replay.playback.ReplayLayer<Identifier>
All Implemented Interfaces:
PeerReviewEvents, TransportLayer<Identifier,java.nio.ByteBuffer>, Destructable

public class ReplayLayer<Identifier>
extends Verifier<Identifier>
implements TransportLayer<Identifier,java.nio.ByteBuffer>


Field Summary
 
Fields inherited from class org.mpisws.p2p.transport.peerreview.Verifier
hashProv, history, localHandle, logger, serializer
 
Fields inherited from interface org.mpisws.p2p.transport.peerreview.PeerReviewEvents
EVT_ACK, EVT_CHECKPOINT, EVT_INIT, EVT_MAX_SOCKET_EVT, EVT_MIN_SOCKET_EVT, EVT_RECV, EVT_SEND, EVT_SENDSIGN, EVT_SIGN, EVT_SOCKET_CAN_READ, EVT_SOCKET_CAN_RW, EVT_SOCKET_CAN_WRITE, EVT_SOCKET_CLOSE, EVT_SOCKET_CLOSED, EVT_SOCKET_EXCEPTION, EVT_SOCKET_OPEN_INCOMING, EVT_SOCKET_OPEN_OUTGOING, EVT_SOCKET_OPENED_OUTGOING, EVT_SOCKET_READ, EVT_SOCKET_SHUTDOWN_OUTPUT, EVT_SOCKET_WRITE, EX_TYPE_ClosedChannel, EX_TYPE_IO, EX_TYPE_Unknown
 
Constructor Summary
ReplayLayer(IdentifierSerializer<Identifier> serializer, HashProvider hashProv, SecureHistory history, Identifier localHandle, Environment environment)
           
 
Method Summary
 void acceptMessages(boolean b)
          Toggle accepting incoming messages.
 void acceptSockets(boolean b)
          Toggle accepting new sockets.
 void destroy()
           
static Environment generateEnvironment(java.lang.String name, long startTime, long randSeed)
           
 Identifier getLocalIdentifier()
          The local node.
protected  void incomingSocket(Identifier from, int socketId)
          Callback when a socket comes in from a remote node.
 SocketRequestHandle<Identifier> openSocket(Identifier i, SocketCallback<Identifier> deliverSocketToMe, java.util.Map<java.lang.String,java.lang.Object> options)
          Open a socket to the Identifier
protected  void receive(Identifier from, java.nio.ByteBuffer msg)
          Callback when a message has arrived.
 MessageRequestHandle<Identifier,java.nio.ByteBuffer> sendMessage(Identifier i, java.nio.ByteBuffer m, MessageCallback<Identifier,java.nio.ByteBuffer> deliverAckToMe, java.util.Map<java.lang.String,java.lang.Object> options)
          Send the message to the identifier
 void setCallback(TransportLayerCallback<Identifier,java.nio.ByteBuffer> callback)
          Set the callback for incoming sockets/messages
 void setErrorHandler(ErrorHandler<Identifier> handler)
          To be notified of problems not related to an outgoing messaage/socket.
protected  void socketException(int socketId, java.io.IOException ioe)
           
protected  void socketIO(int socketId, boolean canRead, boolean canWrite)
          Callback when a socket is ready to read/write.
protected  void socketOpened(int socketId)
           
 
Methods inherited from class org.mpisws.p2p.transport.peerreview.Verifier
close, deserializeException, fetchNextEvent, generatedSocketException, getNextEvent, getNextEventTime, isSuccess, makeProgress, openSocket, readSocket, registerEvent, registerEvent, send, shutdownOutput, verifiedOK, writeSocket
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplayLayer

public ReplayLayer(IdentifierSerializer<Identifier> serializer,
                   HashProvider hashProv,
                   SecureHistory history,
                   Identifier localHandle,
                   Environment environment)
            throws java.io.IOException
Throws:
java.io.IOException
Method Detail

openSocket

public SocketRequestHandle<Identifier> openSocket(Identifier i,
                                                  SocketCallback<Identifier> deliverSocketToMe,
                                                  java.util.Map<java.lang.String,java.lang.Object> options)
Description copied from interface: TransportLayer
Open a socket to the Identifier

Specified by:
openSocket in interface TransportLayer<Identifier,java.nio.ByteBuffer>
Parameters:
i - who to open the socket to
deliverSocketToMe - the callback when the socket is opened
options - options on how to open the socket (don't source route, encrypt etc) (may not be respected if layer cannot provide service)
Returns:
an object to cancel opening the socket if it takes to long, or is no longer relevent

sendMessage

public MessageRequestHandle<Identifier,java.nio.ByteBuffer> sendMessage(Identifier i,
                                                                        java.nio.ByteBuffer m,
                                                                        MessageCallback<Identifier,java.nio.ByteBuffer> deliverAckToMe,
                                                                        java.util.Map<java.lang.String,java.lang.Object> options)
Description copied from interface: TransportLayer
Send the message to the identifier

Specified by:
sendMessage in interface TransportLayer<Identifier,java.nio.ByteBuffer>
Parameters:
i - the destination
m - the message
deliverAckToMe - layer dependent notification when the message is sent (can indicate placed on the wire, point-to-point acknowledgement, or end-to-end acknowledgement)
options - delivery options (don't source route, encrypt etc) (may not be respected if layer cannot provide service)
Returns:
ability to cancel the message if no longer relevent

getLocalIdentifier

public Identifier getLocalIdentifier()
Description copied from interface: TransportLayer
The local node.

Specified by:
getLocalIdentifier in interface TransportLayer<Identifier,java.nio.ByteBuffer>
Returns:
The local node.

setCallback

public void setCallback(TransportLayerCallback<Identifier,java.nio.ByteBuffer> callback)
Description copied from interface: TransportLayer
Set the callback for incoming sockets/messages

Specified by:
setCallback in interface TransportLayer<Identifier,java.nio.ByteBuffer>
Parameters:
callback - the callback for incoming sockets/messages

setErrorHandler

public void setErrorHandler(ErrorHandler<Identifier> handler)
Description copied from interface: TransportLayer
To be notified of problems not related to an outgoing messaage/socket. Or to be notified if a callback isn't provided.

Specified by:
setErrorHandler in interface TransportLayer<Identifier,java.nio.ByteBuffer>
Parameters:
handler - to be notified of problems not related to a specific messaage/socket.

destroy

public void destroy()
Specified by:
destroy in interface Destructable

acceptMessages

public void acceptMessages(boolean b)
Description copied from interface: TransportLayer
Toggle accepting incoming messages. Useful in flow control if overwhelmed by incoming sockets. Default: true

Specified by:
acceptMessages in interface TransportLayer<Identifier,java.nio.ByteBuffer>

acceptSockets

public void acceptSockets(boolean b)
Description copied from interface: TransportLayer
Toggle accepting new sockets. Useful in flow control if overwhelmed by incoming sockets. Default: true

Specified by:
acceptSockets in interface TransportLayer<Identifier,java.nio.ByteBuffer>

receive

protected void receive(Identifier from,
                       java.nio.ByteBuffer msg)
                throws java.io.IOException
Description copied from class: Verifier
Callback when a message has arrived.

Specified by:
receive in class Verifier<Identifier>
Throws:
java.io.IOException

socketIO

protected void socketIO(int socketId,
                        boolean canRead,
                        boolean canWrite)
                 throws java.io.IOException
Description copied from class: Verifier
Callback when a socket is ready to read/write. Note that the simulated node should have already registered for this event, even though it is not logged. If the node is not registred for the event, it is an error.

Specified by:
socketIO in class Verifier<Identifier>
Throws:
java.io.IOException

incomingSocket

protected void incomingSocket(Identifier from,
                              int socketId)
                       throws java.io.IOException
Description copied from class: Verifier
Callback when a socket comes in from a remote node.

Specified by:
incomingSocket in class Verifier<Identifier>
Throws:
java.io.IOException

generateEnvironment

public static Environment generateEnvironment(java.lang.String name,
                                              long startTime,
                                              long randSeed)

socketOpened

protected void socketOpened(int socketId)
                     throws java.io.IOException
Specified by:
socketOpened in class Verifier<Identifier>
Throws:
java.io.IOException

socketException

protected void socketException(int socketId,
                               java.io.IOException ioe)
                        throws java.io.IOException
Specified by:
socketException in class Verifier<Identifier>
Throws:
java.io.IOException

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection