Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mpisws.p2p.transport.liveness
Class LivenessTransportLayerImpl<Identifier>

    java.lang.Object
      org.mpisws.p2p.transport.liveness.LivenessTransportLayerImpl<Identifier>

All Implemented Interfaces:
  LivenessProvider<Identifier>, LivenessTransportLayer<Identifier,java.nio.ByteBuffer>, LivenessTypes, OverrideLiveness<Identifier>, Pinger<Identifier>, TransportLayer<Identifier,java.nio.ByteBuffer>, TransportLayerCallback<Identifier,java.nio.ByteBuffer>, Destructable

Direct Known Subclasses:
  AggressiveLivenessTransportLayerImpl

    public class LivenessTransportLayerImpl<Identifier>

extends java.lang.Object
implements LivenessTypes, LivenessTransportLayer<Identifier,java.nio.ByteBuffer>, TransportLayerCallback<Identifier,java.nio.ByteBuffer>, OverrideLiveness<Identifier>

Nested Class Summary
`protected class` | `LivenessTransportLayerImpl.DeadChecker` DESCRIBE THE CLASS
`class` | `LivenessTransportLayerImpl.EntityManager` Internal class which is charges with managing the remote connection via a specific route

Field Summary
`long` | `BACKOFF_INITIAL`
`int` | `BACKOFF_LIMIT`
`long` | `CHECK_DEAD_THROTTLE`
`int` | `DEFAULT_RTO` millis for the timeout The idea is that we don't want this parameter to change too fast, so this is the timeout for it to increase, you could set this to infinity, but that may be bad because it doesn't account for intermediate link failures
`protected Environment` | `environment`
`static byte` | `HDR_NORMAL` Pass the msg to the callback if it is NORMAL
`static byte` | `HDR_PING`
`static byte` | `HDR_PONG`
`protected Logger` | `logger`
`int` | `NUM_PING_TRIES`
`int` | `PING_DELAY`
`float` | `PING_JITTER`
`protected java.util.Random` | `random`
`protected TimeSource` | `time`
`protected Timer` | `timer`
`protected TransportLayer<Identifier,java.nio.ByteBuffer>` | `tl`

Constructor Summary
`LivenessTransportLayerImpl(TransportLayer<Identifier,java.nio.ByteBuffer> tl, Environment env, ErrorHandler<Identifier> errorHandler, int checkDeadThrottle)`

Method Summary
`void` | `acceptMessages(boolean b)` Toggle accepting incoming messages.
`void` | `acceptSockets(boolean b)` Toggle accepting new sockets.
`void` | `addLivenessListener(LivenessListener<Identifier> name)`
`void` | `addPingListener(PingListener<Identifier> name)`
`boolean` | `cancelLivenessCheck(Identifier i, java.util.Map<java.lang.String,java.lang.Object> options)` True if there was a pending liveness check.
`boolean` | `cancelLivenessCheck(LivenessTransportLayerImpl.EntityManager manager, java.util.Map<java.lang.String,java.lang.Object> options)`
`boolean` | `checkLiveness(Identifier i, java.util.Map<java.lang.String,java.lang.Object> options)` Returns whether a new notification will occur.
`void` | `clearState(Identifier i)` Force layer to clear the existing state related to the Identifier.
`void` | `connectionExceptionMeansFaulty(boolean b)` Set this to true if you want a ConnectionException to mark the connection as faulty.
`LivenessTransportLayerImpl.EntityManager` | `deleteManager(Identifier i)`
`void` | `destroy()`
`int` | `getLiveness(Identifier i, java.util.Map<java.lang.String,java.lang.Object> options)`
`Identifier` | `getLocalIdentifier()` The local node.
`P2PSocket<Identifier>` | `getLSocket(P2PSocket<Identifier> s, LivenessTransportLayerImpl.EntityManager manager)`
`LivenessTransportLayerImpl.EntityManager` | `getManager(Identifier i)`
`void` | `incomingSocket(P2PSocket<Identifier> s)` Notification of a new socket.
`void` | `messageReceived(Identifier i, java.nio.ByteBuffer m, java.util.Map<java.lang.String,java.lang.Object> options)` Called when a new message is received.
`SocketRequestHandle<Identifier>` | `openSocket(Identifier i, SocketCallback<Identifier> deliverSocketToMe, java.util.Map<java.lang.String,java.lang.Object> options)` Open a socket to the Identifier
`boolean` | `ping(Identifier i, java.util.Map<java.lang.String,java.lang.Object> options)` Send the ping.
`void` | `pong(Identifier i, long senderTime, java.util.Map<java.lang.String,java.lang.Object> options)` Send the pong();
`boolean` | `removeLivenessListener(LivenessListener<Identifier> name)`
`boolean` | `removePingListener(PingListener<Identifier> name)`
`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.
`void` | `setLiveness(Identifier i, int liveness, java.util.Map<java.lang.String,java.lang.Object> options)`
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### PING_DELAY

    public final int PING_DELAY

### PING_JITTER

    public final float PING_JITTER

### NUM_PING_TRIES

    public final int NUM_PING_TRIES

### BACKOFF_INITIAL

    public final long BACKOFF_INITIAL

### BACKOFF_LIMIT

    public final int BACKOFF_LIMIT

### CHECK_DEAD_THROTTLE

    public long CHECK_DEAD_THROTTLE

### DEFAULT_RTO

    public int DEFAULT_RTO

  millis for the timeout The idea is that we don't want this parameter to change too fast, so this is the timeout for it to increase, you could set this to infinity, but that may be bad because it doesn't account for intermediate link failures

### tl

    protected TransportLayer<Identifier,java.nio.ByteBuffer> tl

### logger

    protected Logger logger

### environment

    protected Environment environment

### time

    protected TimeSource time

### timer

    protected Timer timer

### random

    protected java.util.Random random

### HDR_NORMAL

    public static final byte HDR_NORMAL

  Pass the msg to the callback if it is NORMAL

  See Also:
    Constant Field Values

### HDR_PING

    public static final byte HDR_PING

See Also:
  Constant Field Values

### HDR_PONG

    public static final byte HDR_PONG

See Also:
  Constant Field Values

Constructor Detail

### LivenessTransportLayerImpl

    public LivenessTransportLayerImpl(TransportLayer<Identifier,java.nio.ByteBuffer> tl,
                                      Environment env,
                                      ErrorHandler<Identifier> errorHandler,
                                      int checkDeadThrottle)

Method Detail

### clearState

    public void clearState(Identifier i)

  Description copied from interface: `LivenessProvider`
  Force layer to clear the existing state related to the Identifier. Usually if there is reason to believe a node has returned.

  Specified by:
    `clearState` in interface `LivenessProvider<Identifier>`

### checkLiveness

    public boolean checkLiveness(Identifier i,
                                 java.util.Map<java.lang.String,java.lang.Object> options)

  Description copied from interface: `LivenessProvider`
  Returns whether a new notification will occur. Will return false if a liveness check has recently completed. Will return true if a new liveness check starts, or an existing one is in progress.

  Specified by:
    `checkLiveness` in interface `LivenessProvider<Identifier>`
  Parameters:
    `i` - the node to check
  Returns:
    true if there will be an update (either a ping, or a change in liveness) false if there won't be an update due to bandwidth concerns

### getLSocket

    public P2PSocket<Identifier> getLSocket(P2PSocket<Identifier> s,
                                            LivenessTransportLayerImpl.EntityManager manager)

### getManager

    public LivenessTransportLayerImpl.EntityManager getManager(Identifier i)

### deleteManager

    public LivenessTransportLayerImpl.EntityManager deleteManager(Identifier i)

### getLiveness

    public int getLiveness(Identifier i,
                           java.util.Map<java.lang.String,java.lang.Object> options)

  Specified by:
    `getLiveness` in interface `LivenessProvider<Identifier>`

### 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>`

### 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.

### connectionExceptionMeansFaulty

    public void connectionExceptionMeansFaulty(boolean b)

  Set this to true if you want a ConnectionException to mark the connection as faulty. Default = true;

### 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 relevant

### 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 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

### messageReceived

    public void messageReceived(Identifier i,
                                java.nio.ByteBuffer m,
                                java.util.Map<java.lang.String,java.lang.Object> options)
                         throws java.io.IOException

  Description copied from interface: `TransportLayerCallback`
  Called when a new message is received.

  Specified by:
    `messageReceived` in interface `TransportLayerCallback<Identifier,java.nio.ByteBuffer>`
  Parameters:
    `i` - The node it is coming from
    `m` - the message
    `options` - describe how the message arrived (udp/tcp, encrypted etc)
  Throws:
    `java.io.IOException` - if there is a problem decoding the message

### cancelLivenessCheck

    public boolean cancelLivenessCheck(Identifier i,
                                       java.util.Map<java.lang.String,java.lang.Object> options)

  True if there was a pending liveness check.

  Parameters:
    `i` -
    `options` -
  Returns:

### cancelLivenessCheck

    public boolean cancelLivenessCheck(LivenessTransportLayerImpl.EntityManager manager,
                                       java.util.Map<java.lang.String,java.lang.Object> options)

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### ping

    public boolean ping(Identifier i,
                        java.util.Map<java.lang.String,java.lang.Object> options)

  Send the ping.

  Specified by:
    `ping` in interface `Pinger<Identifier>`
  Parameters:
    `i` -
    `options` - transport layer dependent way to send the ping (udp/tcp etc)
  Returns:
    true If the ping will occur. (Maybe it won't due to bandwidth concerns.)

### pong

    public void pong(Identifier i,
                     long senderTime,
                     java.util.Map<java.lang.String,java.lang.Object> options)

  Send the pong();

  Parameters:
    `i` -
    `senderTime` -

### 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`

### incomingSocket

    public void incomingSocket(P2PSocket<Identifier> s)
                        throws java.io.IOException

  Description copied from interface: `TransportLayerCallback`
  Notification of a new socket.

  Specified by:
    `incomingSocket` in interface `TransportLayerCallback<Identifier,java.nio.ByteBuffer>`
  Parameters:
    `s` - the incoming socket
  Throws:
    `java.io.IOException`

### addLivenessListener

    public void addLivenessListener(LivenessListener<Identifier> name)

  Specified by:
    `addLivenessListener` in interface `LivenessProvider<Identifier>`

### removeLivenessListener

    public boolean removeLivenessListener(LivenessListener<Identifier> name)

  Specified by:
    `removeLivenessListener` in interface `LivenessProvider<Identifier>`

### addPingListener

    public void addPingListener(PingListener<Identifier> name)

  Specified by:
    `addPingListener` in interface `Pinger<Identifier>`

### removePingListener

    public boolean removePingListener(PingListener<Identifier> name)

  Specified by:
    `removePingListener` in interface `Pinger<Identifier>`

### setLiveness

    public void setLiveness(Identifier i,
                            int liveness,
                            java.util.Map<java.lang.String,java.lang.Object> options)

  Specified by:
    `setLiveness` in interface `OverrideLiveness<Identifier>`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2005 - Rice Pastry.