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.priority
Class PriorityTransportLayerImpl<Identifier>

    java.lang.Object
      org.mpisws.p2p.transport.priority.PriorityTransportLayerImpl<Identifier>

All Implemented Interfaces:
  LivenessListener<Identifier>, LivenessTypes, PriorityTransportLayer<Identifier>, TransportLayer<Identifier,java.nio.ByteBuffer>, TransportLayerCallback<Identifier,java.nio.ByteBuffer>, Destructable

    public class PriorityTransportLayerImpl<Identifier>

extends java.lang.Object
implements PriorityTransportLayer<Identifier>, LivenessListener<Identifier>, TransportLayerCallback<Identifier,java.nio.ByteBuffer>

Author:
  Jeff Hoye

Field Summary
`protected boolean` | `destroyed`
`protected java.util.Map<Identifier,org.mpisws.p2p.transport.priority.PriorityTransportLayerImpl.EntityManager>` | `entityManagers`
`protected Environment` | `environment`
`Logger` | `logger`
`int` | `MAX_MSG_SIZE`
`int` | `MAX_QUEUE_SIZE`
`static byte[]` | `PASSTHROUGH_SOCKET`
`static byte` | `PASSTHROUGH_SOCKET_B`
`static byte[]` | `PRIMARY_SOCKET`
`static byte` | `PRIMARY_SOCKET_B`
`protected SelectorManager` | `selectorManager`
`java.util.Hashtable` | `sockets`

Fields inherited from interface org.mpisws.p2p.transport.priority.PriorityTransportLayer
`DEFAULT_PRIORITY, HIGH_PRIORITY, LOW_PRIORITY, LOWEST_PRIORITY, MAX_PRIORITY, MEDIUM_HIGH_PRIORITY, MEDIUM_LOW_PRIORITY, MEDIUM_PRIORITY, OPTION_PRIORITY, STATUS_CONNECTED, STATUS_CONNECTING, STATUS_NOT_CONNECTED`

Fields inherited from interface org.mpisws.p2p.transport.liveness.LivenessTypes
`LIVENESS_ALIVE, LIVENESS_DEAD, LIVENESS_DEAD_FOREVER, LIVENESS_SUSPECTED`

Constructor Summary
`PriorityTransportLayerImpl(TransportLayer<Identifier,java.nio.ByteBuffer> tl, LivenessProvider<Identifier> livenessProvider, ProximityProvider<Identifier> proximityProvider, Environment env, int maxMsgSize, int maxQueueSize, ErrorHandler<Identifier> handler)` The maximum message size;

Method Summary
`void` | `acceptMessages(boolean b)` Toggle accepting incoming messages.
`void` | `acceptSockets(boolean b)` Toggle accepting new sockets.
`long` | `bytesPending(Identifier i)` The number of bytes to be sent to the identifier
`void` | `cancelLivenessChecker(Identifier i)`
`java.util.Map<java.lang.String,java.lang.Object>` | `connectionOptions(Identifier i)` Returns the options on the primary connection
`int` | `connectionStatus(Identifier i)` Returns if there is a primary connection to the identifier
`protected org.mpisws.p2p.transport.priority.PriorityTransportLayerImpl.EntityManager` | `deleteEntityManager(Identifier i)`
`void` | `destroy()`
`protected org.mpisws.p2p.transport.priority.PriorityTransportLayerImpl.EntityManager` | `getEntityManager(Identifier i)`
`Identifier` | `getLocalIdentifier()` The local node.
`void` | `incomingSocket(P2PSocket<Identifier> s)` We have to read the first byte and see if this is a passthrough (the layer higher than us asked to open it) socket or a primary (our layer tried to open it) socket.
`void` | `livenessChanged(Identifier i, int val, java.util.Map<java.lang.String,java.lang.Object> options)` Called when the liveness changes.
`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.
`java.util.Collection<Identifier>` | `nodesWithPendingMessages()` usually used with bytesPending() or queueLength()
`void` | `openPrimaryConnection(Identifier i, java.util.Map<java.lang.String,java.lang.Object> options)` open a primary connection
`SocketRequestHandle<Identifier>` | `openSocket(Identifier i, SocketCallback<Identifier> deliverSocketToMe, java.util.Map<java.lang.String,java.lang.Object> options)` Open a socket to the Identifier
`void` | `printMemStats(int logLevel)` Problem?: this method should perhaps take the EntityManager as an arg.
`int` | `queueLength(Identifier i)` Returns the number of messages pending to be sent
`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.

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

Field Detail

### PASSTHROUGH_SOCKET_B

    public static final byte PASSTHROUGH_SOCKET_B

See Also:
  Constant Field Values

### PRIMARY_SOCKET_B

    public static final byte PRIMARY_SOCKET_B

See Also:
  Constant Field Values

### PASSTHROUGH_SOCKET

    public static final byte[] PASSTHROUGH_SOCKET

### PRIMARY_SOCKET

    public static final byte[] PRIMARY_SOCKET

### MAX_MSG_SIZE

    public int MAX_MSG_SIZE

### MAX_QUEUE_SIZE

    public int MAX_QUEUE_SIZE

### sockets

    public java.util.Hashtable sockets

### logger

    public Logger logger

### entityManagers

    protected java.util.Map<Identifier,org.mpisws.p2p.transport.priority.PriorityTransportLayerImpl.EntityManager> entityManagers

### selectorManager

    protected SelectorManager selectorManager

### environment

    protected Environment environment

### destroyed

    protected boolean destroyed

Constructor Detail

### PriorityTransportLayerImpl

    public PriorityTransportLayerImpl(TransportLayer<Identifier,java.nio.ByteBuffer> tl,
                                      LivenessProvider<Identifier> livenessProvider,
                                      ProximityProvider<Identifier> proximityProvider,
                                      Environment env,
                                      int maxMsgSize,
                                      int maxQueueSize,
                                      ErrorHandler<Identifier> handler)

  The maximum message size;

  Parameters:
    `env` -
    `maxMsgSize` -

Method Detail

### incomingSocket

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

  We have to read the first byte and see if this is a passthrough (the layer higher than us asked to open it) socket or a primary (our layer tried to open it) socket.

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

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

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

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

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

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

### getEntityManager

    protected org.mpisws.p2p.transport.priority.PriorityTransportLayerImpl.EntityManager getEntityManager(Identifier i)

### deleteEntityManager

    protected org.mpisws.p2p.transport.priority.PriorityTransportLayerImpl.EntityManager deleteEntityManager(Identifier i)

### livenessChanged

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

  Description copied from interface: `LivenessListener`
  Called when the liveness changes.

  Specified by:
    `livenessChanged` in interface `LivenessListener<Identifier>`

### cancelLivenessChecker

    public void cancelLivenessChecker(Identifier i)

### printMemStats

    public void printMemStats(int logLevel)

  Problem?: this method should perhaps take the EntityManager as an arg.

  Parameters:
    `i` -
    `options` -

### bytesPending

    public long bytesPending(Identifier i)

  Description copied from interface: `PriorityTransportLayer`
  The number of bytes to be sent to the identifier

  Specified by:
    `bytesPending` in interface `PriorityTransportLayer<Identifier>`
  Returns:

### queueLength

    public int queueLength(Identifier i)

  Description copied from interface: `PriorityTransportLayer`
  Returns the number of messages pending to be sent

  Specified by:
    `queueLength` in interface `PriorityTransportLayer<Identifier>`
  Returns:

### nodesWithPendingMessages

    public java.util.Collection<Identifier> nodesWithPendingMessages()

  Description copied from interface: `PriorityTransportLayer`
  usually used with bytesPending() or queueLength()

  Specified by:
    `nodesWithPendingMessages` in interface `PriorityTransportLayer<Identifier>`
  Returns:
    any Identifier with messages to be sent

### connectionOptions

    public java.util.Map<java.lang.String,java.lang.Object> connectionOptions(Identifier i)

  Description copied from interface: `PriorityTransportLayer`
  Returns the options on the primary connection

  Specified by:
    `connectionOptions` in interface `PriorityTransportLayer<Identifier>`
  Returns:

### connectionStatus

    public int connectionStatus(Identifier i)

  Description copied from interface: `PriorityTransportLayer`
  Returns if there is a primary connection to the identifier

  Specified by:
    `connectionStatus` in interface `PriorityTransportLayer<Identifier>`
  Returns:
    STATUS_NOT_CONNECTED, STATUS_CONNECTING, STATUS_CONNECTED

### openPrimaryConnection

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

  Description copied from interface: `PriorityTransportLayer`
  open a primary connection

  Specified by:
    `openPrimaryConnection` in interface `PriorityTransportLayer<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.