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.sourceroute.manager
Class SourceRouteManagerImpl<Identifier>

    java.lang.Object
      org.mpisws.p2p.transport.sourceroute.manager.SourceRouteManagerImpl<Identifier>

All Implemented Interfaces:
  LivenessListener<SourceRoute<Identifier>>, LivenessProvider<Identifier>, LivenessTypes, ProximityListener<SourceRoute<Identifier>>, ProximityProvider<Identifier>, SourceRouteManager<Identifier>, TransportLayer<Identifier,java.nio.ByteBuffer>, TransportLayerCallback<SourceRoute<Identifier>,java.nio.ByteBuffer>, Destructable

    public class SourceRouteManagerImpl<Identifier>

extends java.lang.Object
implements SourceRouteManager<Identifier>, TransportLayerCallback<SourceRoute<Identifier>,java.nio.ByteBuffer>, LivenessListener<SourceRoute<Identifier>>, ProximityListener<SourceRoute<Identifier>>

This class adapts a SourceRoute transport layer back to an Identifier layer. It does this by selecting an appropriate source route from a SourceRouteStrategy, which generates SourceRoutes to try.

Author:
  Jeff Hoye

Nested Class Summary
`protected class` | `SourceRouteManagerImpl.AddressManager` Internal class which is tasked with maintaining the status of a single remote address.

Field Summary
`int` | `CHECK_LIVENESS_THROTTLE`
`static int` | `DEFAULT_PROXIMITY`
`int` | `NUM_SOURCE_ROUTE_ATTEMPTS`
`long` | `PING_THROTTLE`

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

Constructor Summary
`SourceRouteManagerImpl(SourceRouteFactory<Identifier> srFactory, TransportLayer<SourceRoute<Identifier>,java.nio.ByteBuffer> tl, LivenessProvider<SourceRoute<Identifier>> livenessProvider, ProximityProvider<SourceRoute<Identifier>> proxProvider, Environment env, SourceRouteStrategy<Identifier> strategy)`

Method Summary
`void` | `acceptMessages(boolean b)` Toggle accepting incoming messages.
`void` | `acceptSockets(boolean b)` Toggle accepting new sockets.
`void` | `addHardLink(SourceRouteManagerImpl.AddressManager am)`
`void` | `addLivenessListener(LivenessListener<Identifier> name)`
`void` | `addProximityListener(ProximityListener<Identifier> listener)`
`boolean` | `checkLiveness(Identifier address, java.util.Map<java.lang.String,java.lang.Object> options)` Method which FORCES a check of liveness of the remote node.
`void` | `clearState(Identifier i)` Force layer to clear the existing state related to the Identifier.
`void` | `destroy()`
`protected SourceRouteManagerImpl.AddressManager` | `getAddressManager(Identifier address)` Internal method which returns (or builds) the manager associated with an address
`int` | `getLiveness(Identifier address, java.util.Map<java.lang.String,java.lang.Object> options)` Method which returns the last cached liveness value for the given address.
`Identifier` | `getLocalIdentifier()` The local node.
`void` | `incomingSocket(P2PSocket<SourceRoute<Identifier>> s)` Notification of a new socket.
`void` | `livenessChanged(SourceRoute<Identifier> i, int val, java.util.Map<java.lang.String,java.lang.Object> options)` Called when the liveness changes.
`void` | `messageReceived(SourceRoute<Identifier> i, java.nio.ByteBuffer m, java.util.Map<java.lang.String,java.lang.Object> options)` Called when a new message is received.
`void` | `notifyProximityListeners(Identifier i, int prox, java.util.Map<java.lang.String,java.lang.Object> options)`
`SocketRequestHandle<Identifier>` | `openSocket(Identifier i, SocketCallback<Identifier> deliverSocketToMe, java.util.Map<java.lang.String,java.lang.Object> options)` Method which sends a message across the wire.
`int` | `proximity(Identifier address, java.util.Map<java.lang.String,java.lang.Object> options)` Method which returns the last cached proximity value for the given address.
`void` | `proximityChanged(SourceRoute<Identifier> i, int newProximity, java.util.Map<java.lang.String,java.lang.Object> options)`
`void` | `removeHardLink(SourceRouteManagerImpl.AddressManager am)`
`boolean` | `removeLivenessListener(LivenessListener<Identifier> name)`
`boolean` | `removeProximityListener(ProximityListener<Identifier> listener)`
`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)` Method which sends a message across the wire.
`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

### DEFAULT_PROXIMITY

    public static final int DEFAULT_PROXIMITY

See Also:
  Constant Field Values

### PING_THROTTLE

    public long PING_THROTTLE

### NUM_SOURCE_ROUTE_ATTEMPTS

    public int NUM_SOURCE_ROUTE_ATTEMPTS

### CHECK_LIVENESS_THROTTLE

    public int CHECK_LIVENESS_THROTTLE

Constructor Detail

### SourceRouteManagerImpl

    public SourceRouteManagerImpl(SourceRouteFactory<Identifier> srFactory,
                                  TransportLayer<SourceRoute<Identifier>,java.nio.ByteBuffer> tl,
                                  LivenessProvider<SourceRoute<Identifier>> livenessProvider,
                                  ProximityProvider<SourceRoute<Identifier>> proxProvider,
                                  Environment env,
                                  SourceRouteStrategy<Identifier> strategy)

Method Detail

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

  Method which sends a message across the wire.

  Specified by:
    `sendMessage` in interface `TransportLayer<Identifier,java.nio.ByteBuffer>`
  Parameters:
    `message` - The message to send
    `address` - The address to send the message to
  Returns:
    ability to cancel the message if no longer relevant

### getAddressManager

    protected SourceRouteManagerImpl.AddressManager getAddressManager(Identifier address)

  Internal method which returns (or builds) the manager associated with an address

  Parameters:
    `address` - The remote address

### 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>`
  Specified by:
    `clearState` in interface `ProximityProvider<Identifier>`

### addHardLink

    public void addHardLink(SourceRouteManagerImpl.AddressManager am)

### removeHardLink

    public void removeHardLink(SourceRouteManagerImpl.AddressManager am)

### openSocket

    public SocketRequestHandle<Identifier> openSocket(Identifier i,
                                                      SocketCallback<Identifier> deliverSocketToMe,
                                                      java.util.Map<java.lang.String,java.lang.Object> options)

  Method which sends a message across the wire.

  Specified by:
    `openSocket` in interface `TransportLayer<Identifier,java.nio.ByteBuffer>`
  Parameters:
    `message` - The message to send
    `address` - The address to send the message to
  Returns:
    an object to cancel opening the socket if it takes to long, or is no longer relevant

### checkLiveness

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

  Method which FORCES a check of liveness of the remote node. Note that this method should ONLY be called by internal Pastry maintenance algorithms - this is NOT to be used by applications. Doing so will likely cause a blowup of liveness traffic.

  Specified by:
    `checkLiveness` in interface `LivenessProvider<Identifier>`
  Parameters:
    `address` - the node to check
  Returns:
    true if node is currently alive.

### getLiveness

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

  Method which returns the last cached liveness value for the given address. If there is no cached value, then LIVENESS_ALIVE

  Specified by:
    `getLiveness` in interface `LivenessProvider<Identifier>`
  Parameters:
    `address` - The address to return the value for
  Returns:
    The liveness value

### proximity

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

  Method which returns the last cached proximity value for the given address. If there is no cached value, then DEFAULT_PROXIMITY is returned.

  Specified by:
    `proximity` in interface `ProximityProvider<Identifier>`
  Parameters:
    `address` - The address to return the value for
  Returns:
    The ping value to the remote address

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

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

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

### incomingSocket

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

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

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

### messageReceived

    public void messageReceived(SourceRoute<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<SourceRoute<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

### livenessChanged

    public void livenessChanged(SourceRoute<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<SourceRoute<Identifier>>`

### addProximityListener

    public void addProximityListener(ProximityListener<Identifier> listener)

  Specified by:
    `addProximityListener` in interface `ProximityProvider<Identifier>`

### removeProximityListener

    public boolean removeProximityListener(ProximityListener<Identifier> listener)

  Specified by:
    `removeProximityListener` in interface `ProximityProvider<Identifier>`

### proximityChanged

    public void proximityChanged(SourceRoute<Identifier> i,
                                 int newProximity,
                                 java.util.Map<java.lang.String,java.lang.Object> options)

  Specified by:
    `proximityChanged` in interface `ProximityListener<SourceRoute<Identifier>>`

### notifyProximityListeners

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

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.