antsim.impl
Class PeernetImpl

java.lang.Object
  |
  +--antsim.impl.PeernetImpl
All Implemented Interfaces:
Clearable, Peernet

public class PeernetImpl
extends Object
implements Peernet

This is a basic implementation of the Peernet interface. A PeernetImpl is characterized by a certain size (i.e., the number of nests composing it) and a degree (i.e., the number of links connecting it to other nests).

This Peernet implementation uses the Factory class to dynamically instantiate objects implementing Nest; the Factory instance must be opportunely instructed with an XML definition for Nest.

Version:
$Revision: 1.5 $
Author:
Alberto Montresor

Field Summary
static String PAR_DEGREE
          String name of the parameter used to determine the degree of the nodes included in this peernet.
static String PAR_JOINPROB
          String name of the parameter used to determine the probability for a node to join the peer network.
static String PAR_LEAVEPROB
          String name of the parameter used to determine the probability for a node to leave the peer network.
static String PAR_SIZE
          String name of the parameter used to determine the number of nodes included in this peernet.
 
Fields inherited from interface antsim.Peernet
NAME
 
Constructor Summary
PeernetImpl(Factory factory, String name)
          Initializes a new simulated peer networks.
 
Method Summary
 void clear()
          Restores the object to its initial state.
 int degree()
          Returns the initial degree of the simulated p2p network (number of nests)
 void executeRound()
          Executes a round in each of the nodes constituting the peernet.
 List getNests()
          Return the nodes composing the simulated p2p network
 int size()
          Returns the initial size of the simulated p2p network (number of nests)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAR_SIZE

public static final String PAR_SIZE
String name of the parameter used to determine the number of nodes included in this peernet.

See Also:
Constant Field Values

PAR_DEGREE

public static final String PAR_DEGREE
String name of the parameter used to determine the degree of the nodes included in this peernet.

See Also:
Constant Field Values

PAR_LEAVEPROB

public static final String PAR_LEAVEPROB
String name of the parameter used to determine the probability for a node to leave the peer network.

See Also:
Constant Field Values

PAR_JOINPROB

public static final String PAR_JOINPROB
String name of the parameter used to determine the probability for a node to join the peer network.

See Also:
Constant Field Values
Constructor Detail

PeernetImpl

public PeernetImpl(Factory factory,
                   String name)
Initializes a new simulated peer networks. The initial size and degree are read from the initialization parameters.

Parameters:
factory - the factory to be used to read configuration arguments and to create other configurable objects
name - the name that is associated to this instance in the configuration file
Method Detail

clear

public void clear()
Restores the object to its initial state. New nests are instantiated when this method is called for the first time; if the initialization arguments for the Nest interface have been changed, the old nests are discarded and the new nests are created. In all other cases, the old nodes are cleared.

Specified by:
clear in interface Clearable

getNests

public List getNests()
Return the nodes composing the simulated p2p network

Specified by:
getNests in interface Peernet

size

public int size()
Returns the initial size of the simulated p2p network (number of nests)

Specified by:
size in interface Peernet
Returns:
size of the p2p network.

degree

public int degree()
Returns the initial degree of the simulated p2p network (number of nests)

Returns:
degree of the p2p network.

executeRound

public void executeRound()
Executes a round in each of the nodes constituting the peernet.

Specified by:
executeRound in interface Peernet