-
Notifications
You must be signed in to change notification settings - Fork 1
/
Site1Server.java
89 lines (70 loc) · 2.01 KB
/
Site1Server.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class Site1Server implements ThreePCInterface {
static boolean reqflag = false;
static int responseIs = 0, decisionIs = 0, ackflag = 0, transflag = 0;
static int []leaderVals;
static int x = 3;
public Site1Server() {}
public void setTransFlag(int value) {
//System.out.println("Trans Flag is set");
Site1Server.transflag = value;
}
public void setLeaderVote(int id, int value) {
Site1Server.leaderVals[id] = value;
}
public int getLeaderVote(int id) {
return Site1Server.leaderVals[id];
}
public int getTransFlag() {
return Site1Server.transflag;
}
public void setReqFlag(boolean flag) {
Site1Server.reqflag = flag;
}
public boolean getReqFlag() {
return Site1Server.reqflag;
}
public void setResponse(int response) {
Site1Server.responseIs = response;
}
public int getResponse() {
return Site1Server.responseIs;
}
public void setDecision(int decision) {
Site1Server.decisionIs = decision;
}
public int getDecision() {
return Site1Server.decisionIs;
}
public void setVariable(int y) {
Site1Server.x = y;
}
public void incVariable() {
Site1Server.x++;
}
public void setAck(int value) {
Site1Server.ackflag = value;
}
public int getAck() {
return Site1Server.ackflag;
}
public static void main(String args[]) {
try {
Site1Server obj = new Site1Server();
ThreePCInterface stub = (ThreePCInterface) UnicastRemoteObject.exportObject(obj, 0);
// Bind the remote object's stub in the registry
Registry registry = LocateRegistry.getRegistry();
registry.bind("Site1Server", stub);
String tnodes = (args.length < 1) ? "2" : args[0]; // Total Sites
int total = Integer.parseInt(tnodes);
leaderVals = new int[total];
System.out.println("Site 1 Started !");
} catch (Exception e) {
System.err.println("Server exception: " + e.toString());
e.printStackTrace();
}
}
}