-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigurator.java
More file actions
51 lines (43 loc) · 1.14 KB
/
Copy pathConfigurator.java
File metadata and controls
51 lines (43 loc) · 1.14 KB
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
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.StringTokenizer;
public class Configurator {
private String masterHostname;
private int masterPortNo;
private static Configurator myConfig;
private Configurator() throws IOException {
this.masterHostname = "";
this.masterPortNo = -1;
readConfig();
}
/**
* Singleton constructor for the master server
*
* @return
* @throws IOException
*/
public static Configurator getInstance() throws IOException {
if (myConfig == null) {
return myConfig = new Configurator();
} else {
return myConfig;
}
}
public String getMasterHostname() {
return masterHostname;
}
public int getMasterPort() {
return masterPortNo;
}
private void readConfig() throws IOException {
BufferedReader buff = new BufferedReader(new FileReader(
Global.MASTER_CONFIG_PATH));
StringTokenizer st;
// First entry in the configuration file is the master server
st = new StringTokenizer(buff.readLine(), Global.MASTER_DELIM);
this.masterHostname = st.nextToken();
this.masterPortNo = Integer.parseInt(st.nextToken());
buff.close();
}
}