|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpeersim.core.Network
public class Network
This class forms the basic framework of all simulations. This is a static singleton which is based on the assumption that we will simulate only one overlay network at a time. This allows us to reduce memory usage in many cases by allowing all the components to directly reach the fields of this class without having to store a reference.
The network is a set of nodes implemented via an array list for the
sake of efficiency.
Each node has an array of protocols. The protocols within a node can
interact directly as defined by their implementation, and can be imagined as
processes running in a common local environment (i.e. the node).
This class is called a "network" because, although it is only a set of nodes,
in most simulations there is at least one Linkable
protocol that
defines connections between nodes. In fact, such a Linkable
protocol
layer can be accessed through a Graph
view
using OverlayGraph
.
Parameter Summary | |
---|---|
network.node
This config property defines the node class to be used. |
|
network.initialCapacity
This config property defines the initial capacity of the overlay network. |
|
network.size
This config property defines the initial size of the overlay network. |
Field Summary | |
---|---|
static Node |
prototype
The prototype node which is used to populate the simulation via cloning. |
Method Summary | |
---|---|
static void |
add(Node n)
The node will be appended to the end of the list. |
static Node |
get(int index)
Returns node with the given index. |
static int |
getCapacity()
Returns the maximal number of nodes that can be stored without reallocating the underlying array to increase capacity. |
static Node |
remove()
The node at the end of the list is removed. |
static Node |
remove(int i)
The node with the given index is removed. |
static void |
reset()
Reads configuration parameters, constructs the prototype node, and populates the network by cloning the prototype. |
static void |
setCapacity(int newSize)
Sets the capacity of the internal array storing the nodes. |
static void |
shuffle()
Shuffles the node array. |
static int |
size()
Number of nodes currently in the network |
static void |
sort(java.util.Comparator<? super Node> c)
Sorts the node array. |
static void |
swap(int i,
int j)
Swaps the two nodes at the given indexes. |
static void |
test()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Parameter Detail |
---|
network.node
GeneralNode
will be used.
network.initialCapacity
getCapacity()
network.size
Field Detail |
---|
public static Node prototype
Control
components can be
applied to perform any further initialization.
Method Detail |
---|
public static void reset()
public static int size()
public static void setCapacity(int newSize)
remove()
.
public static int getCapacity()
public static void add(Node n)
public static Node get(int index)
size()
.
public static Node remove()
Fallible.DEAD
.
public static Node remove(int i)
Fallible.DEAD
.
Look out: the index of the other nodes will not change (the right hand side of the list is not shifted to the left) except that of the last node. Only the last node is moved to the given position and will get index i.
public static void swap(int i, int j)
public static void shuffle()
public static void sort(java.util.Comparator<? super Node> c)
c
- The comparator to be used for sorting the nodes. If null, the
natural order of the nodes is used.public static void test()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |