net.sf.neem.impl
Class Overlay

java.lang.Object
  extended by net.sf.neem.impl.Overlay
All Implemented Interfaces:
ConnectionListener, DataListener

public class Overlay
extends java.lang.Object
implements ConnectionListener, DataListener

Implementation of overlay management. This class combines a number of random walks upon initial join with periodic shuffling.


Field Summary
 int joins
           
 int purged
           
 int shuffleIn
           
 int shuffleOut
           
 
Constructor Summary
Overlay(java.util.Random rand, java.net.InetSocketAddress id, java.util.UUID myId, Transport net, short joinport, short idport, short shuffleport)
          Creates a new instance of Overlay
 
Method Summary
 void close(Connection info)
          Notification of a connection being closed.
 Connection[] connections()
          Get all connections that have been validated.
 int getFanout()
           
 java.util.UUID getId()
          Get globally unique ID in the overlay.
 java.net.InetSocketAddress getLocalSocketAddress()
           
 java.net.InetSocketAddress[] getPeerAddresses()
          Get all peer addresses.
 java.util.UUID[] getPeers()
          Get all connected peers.
 int getShufflePeriod()
           
 void open(Connection info)
          Notification of a new connection.
 void receive(java.nio.ByteBuffer[] msg, Connection info, short port)
          Receive a message from from a connection.
 void resetCounters()
           
 void setFanout(int fanout)
           
 void setShufflePeriod(int shufflePeriod)
           
 void tradePeers(Connection target, Connection arrow)
          Connect two other peers by informing one of the other.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

joins

public int joins

purged

public int purged

shuffleIn

public int shuffleIn

shuffleOut

public int shuffleOut
Constructor Detail

Overlay

public Overlay(java.util.Random rand,
               java.net.InetSocketAddress id,
               java.util.UUID myId,
               Transport net,
               short joinport,
               short idport,
               short shuffleport)
Creates a new instance of Overlay

Method Detail

receive

public void receive(java.nio.ByteBuffer[] msg,
                    Connection info,
                    short port)
Description copied from interface: DataListener
Receive a message from from a connection. The caller is is prepared to handle a BufferUnderFlowException and will close the connection. Implementations are thus advised to start by unmarshalling the message. If it has been truncated or is invalied, the resulting exception will thus do the right thing

Specified by:
receive in interface DataListener
Parameters:
msg - The incoming message.
info - The source connection.
port - Destination port.

open

public void open(Connection info)
Description copied from interface: ConnectionListener
Notification of a new connection.

Specified by:
open in interface ConnectionListener
Parameters:
info - The connection to the new peer.

close

public void close(Connection info)
Description copied from interface: ConnectionListener
Notification of a connection being closed.

Specified by:
close in interface ConnectionListener
Parameters:
info - The recently closed connection.

tradePeers

public void tradePeers(Connection target,
                       Connection arrow)
Connect two other peers by informing one of the other.

Parameters:
target - The connection peer.
arrow - The accepting peer.

connections

public Connection[] connections()
Get all connections that have been validated.


getPeers

public java.util.UUID[] getPeers()
Get all connected peers.


getPeerAddresses

public java.net.InetSocketAddress[] getPeerAddresses()
Get all peer addresses.


getId

public java.util.UUID getId()
Get globally unique ID in the overlay.


getLocalSocketAddress

public java.net.InetSocketAddress getLocalSocketAddress()

getFanout

public int getFanout()

setFanout

public void setFanout(int fanout)

getShufflePeriod

public int getShufflePeriod()

setShufflePeriod

public void setShufflePeriod(int shufflePeriod)

resetCounters

public void resetCounters()


Copyright © 2005 University of Minho, Portugal. All Rights Reserved.