@@ -35,6 +35,10 @@ public static void main(String[] args) throws RemoteException, MalformedURLExcep
35
35
}
36
36
System .setProperty (("java.rmi.server.hostname" ), "127.0.0.1" );
37
37
38
+
39
+
40
+
41
+
38
42
List <ProcessInterface > processList = new ArrayList <ProcessInterface >();
39
43
for (int i = 1 ; i < NUMBER_OF_COMPONENT + 1 ; i ++) {
40
44
//Creation of process
@@ -44,31 +48,22 @@ public static void main(String[] args) throws RemoteException, MalformedURLExcep
44
48
processList .add ((ProcessInterface ) Naming .lookup ("rmi://localhost:1101/" + (i )));
45
49
}
46
50
47
- // //Setting up network of process
48
- // Naming.rebind("rmi://localhost:1101/p1", new Component(1));
49
- // //Naming.rebind("rmi://localhost:1100/p2", new Process("p2"));
50
- // //Naming.rebind("rmi://localhost:1100/p3", new Process("p3"));
51
- //
52
- // List<ProcessInterface> processList = new ArrayList<ProcessInterface>();
53
- // processList.add((ProcessInterface) Naming.lookup("rmi://localhost:1101/p1"));
54
- // processList.add((ProcessInterface) Naming.lookup("rmi://localhost:1102/p2"));
55
- // processList.add((ProcessInterface) Naming.lookup("rmi://localhost:1103/p3"));
51
+ //Acknolege each process of the existance of other process
56
52
for (ProcessInterface p : processList ) {
57
53
p .setNeighbor (processList );
58
- //System.out.println("Hi i'm process: " + p.getID());
59
54
}
60
55
61
- // //Start comunication
62
- // processList.get(0).broadcast("Ciao");
63
- // processList.get(0).broadcast("Ciao2");
64
- // processList.get(0).broadcast("Ciao3");
65
- //Thread.sleep(3000);
66
- //List<String> deliveredMessage = processList.get(0).getDeliveredMessage();
67
- // for (String message : deliveredMessage) {
68
- // System.out.println("I recevive: " + message);
69
- // }
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
70
64
Random rand = new Random ();
71
65
66
+ //Broadcast a message
72
67
new Thread (new Runnable () {
73
68
public void run () {
74
69
try {
@@ -81,7 +76,10 @@ public void run() {
81
76
}).start ();
82
77
83
78
79
+
80
+
84
81
82
+ //Run a status collection procedure
85
83
new Thread (new Runnable () {
86
84
public void run () {
87
85
try {
@@ -96,6 +94,10 @@ public void run() {
96
94
}
97
95
}
98
96
}).start ();
97
+
98
+
99
+
100
+
99
101
100
102
System .out .println (" main end " );
101
103
//System.exit(0);
0 commit comments