Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
peersimgrid release 1.0
[simgrid.git] / contrib / psg / src / psgsim / PSGDynamicNetwork.java
1 package psgsim;
2
3 import org.simgrid.msg.Host;
4 import org.simgrid.msg.HostNotFoundException;
5
6 import peersim.core.Node;
7
8 /**
9  * 
10  * This class can change the size of networks by adding and removing nodes, as
11  * {@link peersim.dynamics.DynamicNetwork} in peersim.
12  * 
13  * @author Khaled Baati 09/02/2015
14  * @version version 1.1
15  */
16 public class PSGDynamicNetwork {
17
18         /**
19          * Removes the node from the network.
20          * 
21          * @param node
22          *            the node to be removed
23          */
24         public static void remove(Node node) {
25                 // NodeHost.getHost(node).off();
26                 // Host h=NodeHost.mapHostNode.get(node);
27                 // NodeHost.mapHostNode.remove(node);
28                 PSGSimulator.size = PSGSimulator.size - 1;
29         }
30
31         /**
32          * Adds a node to the network.
33          * 
34          * @param node
35          *            the node to be added
36          * @throws HostNotFoundException 
37          */
38         public static void add(Node node) throws HostNotFoundException {
39                 Host host = PSGPlatform.hostList[(int) node.getID()];
40                 NodeHost.mapHostNode.put(node, host);
41                 if (PSGPlatform.interfED)
42                         new PSGProcessEvent(host, host.getName(), null).start();
43                 PSGSimulator.size = PSGSimulator.size + 1;
44         }
45 }