4
4
import java .io .IOException ;
5
5
import java .rmi .AlreadyBoundException ;
6
6
import java .rmi .NotBoundException ;
7
+ import java .rmi .RemoteException ;
7
8
import java .rmi .registry .LocateRegistry ;
8
9
import java .rmi .registry .Registry ;
9
10
import java .util .ArrayList ;
@@ -31,7 +32,7 @@ public static void main(String[] args) throws AlreadyBoundException, NotBoundExc
31
32
links = new HashMap <Integer , List <Link >>();
32
33
initializeEdges ();
33
34
// "clients" files contain the name of the remote processes used
34
- BufferedReader br = new BufferedReader (new FileReader ("tests/nodes1 .txt" ));
35
+ BufferedReader br = new BufferedReader (new FileReader ("tests/nodes2 .txt" ));
35
36
String line = br .readLine ();
36
37
numProc = Integer .parseInt (line );
37
38
localProc = 0 ;
@@ -48,7 +49,16 @@ public static void main(String[] args) throws AlreadyBoundException, NotBoundExc
48
49
localIDS .add (i );
49
50
}
50
51
else {
51
- registry .bind ("//145.94.233.58:" +Constant .RMI_PORT +"/" +split_line [0 ], new Node (i , new PriorityQueue <Link >(links .get (i ))));
52
+ boolean success = false ;
53
+ while (!success ){
54
+ try {
55
+ registry .bind ("//145.94.233.58:" +Constant .RMI_PORT +"/" +split_line [0 ], new Node (i , new PriorityQueue <Link >(links .get (i ))));
56
+ success = true ;
57
+ }
10000
td>58
+ catch (RemoteException e ) {
59
+ e .printStackTrace ();
60
+ }
61
+ }
52
62
local [i ] = 0 ;
53
63
54
64
}
@@ -63,7 +73,7 @@ public static void main(String[] args) throws AlreadyBoundException, NotBoundExc
63
73
}
64
74
65
75
public static void initializeEdges () throws IOException {
66
- BufferedReader br = new BufferedReader (new FileReader ("tests/edges1 .txt" ));
76
+ BufferedReader br = new BufferedReader (new FileReader ("tests/edges2 .txt" ));
67
77
String line ;
68
78
int node1 ;
69
79
int node2 ;
@@ -118,7 +128,7 @@ public static void setRegistry() throws NotBoundException, NumberFormatException
118
128
System .out .println ("Press enter to continue" );
119
129
Scanner scan = new Scanner (System .in );
120
130
scan .nextLine ();
121
- myThreads [0 ].start ();
131
+ myThreads [0 ].start ();
122
132
myThreads [1 ].start ();
123
133
}
124
134
}
0 commit comments