diff options
Diffstat (limited to 'same/src/main/java')
-rw-r--r-- | same/src/main/java/com/orbekk/same/Client.java | 7 | ||||
-rw-r--r-- | same/src/main/java/com/orbekk/same/Master.java | 8 | ||||
-rw-r--r-- | same/src/main/java/com/orbekk/same/SameController.java | 5 |
3 files changed, 13 insertions, 7 deletions
diff --git a/same/src/main/java/com/orbekk/same/Client.java b/same/src/main/java/com/orbekk/same/Client.java index 7d1ce56..6386928 100644 --- a/same/src/main/java/com/orbekk/same/Client.java +++ b/same/src/main/java/com/orbekk/same/Client.java @@ -28,6 +28,7 @@ public class Client { private final ConnectionManager connections; volatile State state; private volatile String myUrl; + private volatile String myLocation; volatile String masterUrl; volatile String masterLocation; private volatile int masterId = 0; @@ -206,10 +207,11 @@ public class Client { }; public Client(State state, ConnectionManager connections, - String myUrl, Broadcaster broadcaster) { + String myUrl, String myLocation, Broadcaster broadcaster) { this.state = state; this.connections = connections; this.myUrl = myUrl; + this.myLocation = myLocation; this.broadcaster = broadcaster; } @@ -229,7 +231,8 @@ public class Client { public Services.ClientState getClientState() { return Services.ClientState.newBuilder() - .setUrl(getUrl()) + .setUrl(myUrl) + .setLocation(myLocation) .build(); } diff --git a/same/src/main/java/com/orbekk/same/Master.java b/same/src/main/java/com/orbekk/same/Master.java index b2adea1..511da08 100644 --- a/same/src/main/java/com/orbekk/same/Master.java +++ b/same/src/main/java/com/orbekk/same/Master.java @@ -83,7 +83,7 @@ public class Master { } /** New participant code. */ - addParticipant(request); + addParticipant(request.getLocation()); done.run(Empty.getDefaultInstance()); } @@ -199,10 +199,10 @@ public class Master { return serviceImpl; } - private synchronized void addParticipant(ClientState client) { + private synchronized void addParticipant(String location) { List<String> participants = state.getList(State.PARTICIPANTS); - if (!participants.contains(client.getUrl())) { - participants.add(client.getUrl()); + if (!participants.contains(location)) { + participants.add(location); state.updateFromObject(State.PARTICIPANTS, participants, state.getRevision(State.PARTICIPANTS) + 1); updateStateRequestThread.add(State.PARTICIPANTS); diff --git a/same/src/main/java/com/orbekk/same/SameController.java b/same/src/main/java/com/orbekk/same/SameController.java index 900dcbc..b87e6f5 100644 --- a/same/src/main/java/com/orbekk/same/SameController.java +++ b/same/src/main/java/com/orbekk/same/SameController.java @@ -57,6 +57,8 @@ public class SameController { public static SameController create(Configuration configuration) { int port = configuration.getInt("port"); int pport = configuration.getInt("pport"); + String myLocation = configuration.get("localIp") + ":" + pport; + ConnectionManagerImpl connections = new ConnectionManagerImpl( timeout, timeout); State clientState = new State(".InvalidClientNetwork"); @@ -67,7 +69,8 @@ public class SameController { MasterServiceProxy master = new MasterServiceProxy(); Client client = new Client(clientState, connections, - clientUrl, BroadcasterImpl.getDefaultBroadcastRunner()); + clientUrl, myLocation, + BroadcasterImpl.getDefaultBroadcastRunner()); PaxosServiceImpl paxos = new PaxosServiceImpl(""); StateServlet stateServlet = new StateServlet(client.getInterface(), new VariableFactory(client.getInterface())); |