Rice Pastry API

org.mpisws.p2p.transport.peerreview.replay
Class VerifierImpl<Handle extends RawSerializable,Identifier extends RawSerializable>

java.lang.Object
  extended by org.mpisws.p2p.transport.peerreview.replay.VerifierImpl<Handle,Identifier>
All Implemented Interfaces:
PeerReviewConstants, Verifier<Handle>, StatusConstants, TransportLayer<Handle,java.nio.ByteBuffer>, Destructable

public class VerifierImpl<Handle extends RawSerializable,Identifier extends RawSerializable>
extends java.lang.Object
implements Verifier<Handle>


Field Summary
protected  SecureHistory history
           
protected  Handle localHandle
           
protected  Logger logger
           
protected  IdentityTransport<Handle,Identifier> transport
           
 
Fields inherited from interface org.mpisws.p2p.transport.peerreview.PeerReviewConstants
AUTH_CACHE_INTERVAL, CERT_MISSING, CHAL_AUDIT, CHAL_SEND, DEFAULT_AUDIT_INTERVAL_MILLIS, DEFAULT_AUTH_PUSH_INTERVAL_MILLIS, DEFAULT_CHECKPOINT_INTERVAL_MILLIS, DEFAULT_LOG_DOWNLOAD_TIMEOUT, DEFAULT_TIME_TOLERANCE_MILLIS, EVT_ACK, EVT_CHECKPOINT, EVT_CHOOSE_Q, EVT_CHOOSE_RAND, EVT_INIT, EVT_MAX_RESERVED, 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, EVT_VRF, EX_TYPE_ClosedChannel, EX_TYPE_IO, EX_TYPE_Unknown, FLAG_FULL_MESSAGES_ALL, FLAG_FULL_MESSAGES_SENDER, FLAG_INCLUDE_CHECKPOINT, INVALID, INVESTIGATION_INTERVAL_MILLIS, MAINTENANCE_INTERVAL_MILLIS, MAX_ACTIVE_AUDITS, MAX_ACTIVE_INVESTIGATIONS, MAX_ENTRIES_BETWEEN_CHECKPOINTS, MAX_STATUS_INFO, MAX_WITNESSED_NODES, MSG_ACCUSATION, MSG_ACK, MSG_AUTHPUSH, MSG_AUTHREQ, MSG_AUTHRESP, MSG_CHALLENGE, MSG_RESPONSE, MSG_USERDATA, MSG_USERDGRAM, NO_CERTIFICATE, PROGRESS_INTERVAL_MILLIS, PROOF_INCONSISTENT, PROOF_NONCONFORMANT, RESP_AUDIT, RESP_SEND, SIGNATURE_BAD, SIGNATURE_OK, STATE_SEND_AUDIT, STATE_WAIT_FOR_LOG, TI_AUTH_PUSH, TI_CHECKPOINT, TI_MAINTENANCE, TI_MAKE_PROGRESS, TI_MAX_RESERVED, TI_START_AUDITS, TI_STATUS_INFO, VALID
 
Fields inherited from interface org.mpisws.p2p.transport.peerreview.StatusConstants
STATUS_EXPOSED, STATUS_SUSPECTED, STATUS_TRUSTED
 
Constructor Summary
VerifierImpl(PeerReview<Handle,Identifier> peerreview, Environment env, SecureHistory history, Handle localHandle, long firstEntryToReplay, java.lang.Object extInfo)
           
 
Method Summary
 void acceptMessages(boolean b)
          Toggle accepting incoming messages.
 void acceptSockets(boolean b)
          Toggle accepting new sockets.
 void close(int socketId)
           
protected  java.io.IOException deserializeException(InputBuffer nextEvent)
           
 void destroy()
           
protected  void fetchNextEvent()
          Fetch the next log entry, or set the EOF flag
 void generatedSocketException(int socketId, java.io.IOException ioe)
           
 Environment getEnvironment()
           
 java.lang.Object getExtInfo()
           
 Handle getLocalIdentifier()
          The local node.
 IndexEntry getNextEvent()
           
 long getNextEventTime()
           
protected  void incomingSocket(Handle from, int socketId)
           
 boolean isSuccess()
           
 boolean makeProgress()
          This is called by the Audit protocol to make another replay step; it returns true if further calls are necessary, and false if the replay has finished.
 int openSocket(Handle target)
          Return the new socketId
 SocketRequestHandle<Handle> openSocket(Handle i, SocketCallback<Handle> deliverSocketToMe, java.util.Map<java.lang.String,java.lang.Object> options)
          Open a socket to the Identifier
 int readSocket(int socketId, java.nio.ByteBuffer dst)
          Return the bytes read.
 void registerEvent(EventCallback callback, short... eventType)
          This binds specific event types to one of the handlers
 void registerEvent(EventCallback callback, short eventType)
           
 MessageRequestHandle<Handle,java.nio.ByteBuffer> sendMessage(Handle target, java.nio.ByteBuffer message, MessageCallback<Handle,java.nio.ByteBuffer> deliverAckToMe, java.util.Map<java.lang.String,java.lang.Object> options)
          Called by the state machine when it wants to send a message
 void setApplication(PeerReviewCallback app)
           
 void setCallback(TransportLayerCallback<Handle,java.nio.ByteBuffer> callback)
          Set the callback for incoming sockets/messages
 void setErrorHandler(ErrorHandler<Handle> handler)
          To be notified of problems not related to an outgoing messaage/socket.
 void shutdownOutput(int socketId)
           
protected  void socketException(int socketId, java.io.IOException ioe)
           
protected  void socketIO(int socketId, boolean canRead, boolean canWrite)
           
protected  void socketOpened(int socketId)
           
 boolean verifiedOK()
           
 int writeSocket(int socketId, java.nio.ByteBuffer src)
          Return the bytes written.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

localHandle

protected Handle extends RawSerializable localHandle

history

protected SecureHistory history

logger

protected Logger logger

transport

protected IdentityTransport<Handle extends RawSerializable,Identifier extends RawSerializable> transport
Constructor Detail

VerifierImpl

public VerifierImpl(PeerReview<Handle,Identifier> peerreview,
                    Environment env,
                    SecureHistory history,
                    Handle localHandle,
                    long firstEntryToReplay,
                    java.lang.Object extInfo)
             throws java.io.IOException
Throws:
java.io.IOException
Method Detail

getExtInfo

public java.lang.Object getExtInfo()

fetchNextEvent

protected void fetchNextEvent()
Fetch the next log entry, or set the EOF flag


verifiedOK

public boolean verifiedOK()
Specified by:
verifiedOK in interface Verifier<Handle extends RawSerializable>

getNextEvent

public IndexEntry getNextEvent()

setApplication

public void setApplication(PeerReviewCallback app)
Specified by:
setApplication in interface Verifier<Handle extends RawSerializable>

registerEvent

public void registerEvent(EventCallback callback,
                          short... eventType)
This binds specific event types to one of the handlers


registerEvent

public void registerEvent(EventCallback callback,
                          short eventType)

makeProgress

public boolean makeProgress()
This is called by the Audit protocol to make another replay step; it returns true if further calls are necessary, and false if the replay has finished. The idea is that we can stop calling this if there is more important work to do, e.g. handle foreground requests

Specified by:
makeProgress in interface Verifier<Handle extends RawSerializable>

sendMessage

public MessageRequestHandle<Handle,java.nio.ByteBuffer> sendMessage(Handle target,
                                                                    java.nio.ByteBuffer message,
                                                                    MessageCallback<Handle,java.nio.ByteBuffer> deliverAckToMe,
                                                                    java.util.Map<java.lang.String,java.lang.Object> options)
Called by the state machine when it wants to send a message

Specified by:
sendMessage in interface TransportLayer<Handle extends RawSerializable,java.nio.ByteBuffer>
Parameters:
target - the destination
message - the message
deliverAckToMe - layer dependent notification when the message is sent (can indicate placed on the wire, point-to-point acknowledgment, 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 relevant

getNextEventTime

public long getNextEventTime()
Specified by:
getNextEventTime in interface Verifier<Handle extends RawSerializable>

isSuccess

public boolean isSuccess()
Specified by:
isSuccess in interface Verifier<Handle extends RawSerializable>

deserializeException

protected java.io.IOException deserializeException(InputBuffer nextEvent)
                                            throws java.io.IOException
Throws:
java.io.IOException

openSocket

public SocketRequestHandle<Handle> openSocket(Handle i,
                                              SocketCallback<Handle> 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<Handle extends RawSerializable,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 relevant

socketIO

protected void socketIO(int socketId,
                        boolean canRead,
                        boolean canWrite)
                 throws java.io.IOException
Throws:
java.io.IOException

incomingSocket

protected void incomingSocket(Handle from,
                              int socketId)
                       throws java.io.IOException
Throws:
java.io.IOException

socketOpened

protected void socketOpened(int socketId)
                     throws java.io.IOException
Throws:
java.io.IOException

socketException

protected void socketException(int socketId,
                               java.io.IOException ioe)
                        throws java.io.IOException
Throws:
java.io.IOException

openSocket

public int openSocket(Handle target)
               throws java.io.IOException
Return the new socketId

Parameters:
i -
Returns:
the new socketId, Integer.MIN_VALUE for an error
Throws:
java.io.IOException

readSocket

public int readSocket(int socketId,
                      java.nio.ByteBuffer dst)
               throws java.io.IOException
Return the bytes read.

Parameters:
socketId -
Returns:
number of bytes read
Throws:
java.io.IOException

generatedSocketException

public void generatedSocketException(int socketId,
                                     java.io.IOException ioe)

writeSocket

public int writeSocket(int socketId,
                       java.nio.ByteBuffer src)
                throws java.io.IOException
Return the bytes written.

Parameters:
socketId -
Returns:
number of bytes written
Throws:
java.io.IOException

close

public void close(int socketId)

shutdownOutput

public void shutdownOutput(int socketId)

getEnvironment

public Environment getEnvironment()
Specified by:
getEnvironment in interface Verifier<Handle extends RawSerializable>

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<Handle extends RawSerializable,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<Handle extends RawSerializable,java.nio.ByteBuffer>

getLocalIdentifier

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

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

setCallback

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

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

setErrorHandler

public void setErrorHandler(ErrorHandler<Handle> 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<Handle extends RawSerializable,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

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection