-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
37 lines (31 loc) · 1.21 KB
/
Copy pathMain.java
File metadata and controls
37 lines (31 loc) · 1.21 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
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
try {
int priority = 1;
ServerListener server;
String envPriority = System.getenv("PRIORITY");
if(envPriority.length() != 0){
try {
priority = Integer.parseInt(envPriority);
}catch(Exception ex){
Logger.logError("Invalid priority must be integer");
System.exit(-1);
}
}
//Get whether server want to join the cluster or want to create new cluster
// if true -> Join cluster
String envWantToJoin = System.getenv("JOINCLUSTER");
//if server want to join cluster than IP of node which belongs to cluster
String hostAddress = System.getenv("CLUSTER_NODE_IP");
if(envWantToJoin.equalsIgnoreCase("true")){
server = new ServerListener(hostAddress, priority);
}else{
server = new ServerListener(priority);
}
server.start();
} catch (Exception e) {
Logger.logMsg("Error when starting the server");
}
}
}