-
Notifications
You must be signed in to change notification settings - Fork 0
/
NetworkMain.java
57 lines (44 loc) · 1.44 KB
/
NetworkMain.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package rmi.netflix.network;
import java.net.MalformedURLException;
import java.rmi.*;
//import java.lang.Thread;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.*;
public class NetworkMain{
public static void main(String[] args) throws RemoteException, MalformedURLException {
//Security
int MaxNumServers = 0;
try {
if (args.length >= 1) {
MaxNumServers = Integer.parseInt(args[0]);
} else {
System.out.println("Usage: java NetworkMain <numOfProcesses>");
System.exit(1);
}
} catch(NumberFormatException nfe) {
System.out.println("Usage: java NetworkMain <numOfProcesses>\n<numOfProcesses> is a number.");
System.exit(1);
}
System.out.println("Running Network Topology Configurator\n");
try {
Network oNet = new Network(MaxNumServers);
System.out.println("Creating the Network");
Registry registry = LocateRegistry.createRegistry(1099);
//String registry = "localhost:1099";
//if (args.length >= 2) {
// registry = args[1];
//}
//String regUrl = "rmi://"+ registry +"/Network";
Naming.rebind("rmi://localhost/oNet", oNet);
//Naming.rebind(regUrl, oNet);
//Thread oNetThread = new Thread(oNet);
System.out.println("Network Sucessully created!");
oNet.run();
//oNetThread.start();
oNet.get_ElectedServer();
} catch(Exception e) {
e.printStackTrace();
}
}
}