diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-05-10 14:55:30 +0200 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-05-10 14:55:30 +0200 |
commit | 816d4613d7d2fe0366b6913f2a6124e08c21549d (patch) | |
tree | 3dda231715a55e437861411d4e4cce9eaba955a6 | |
parent | 7680d58d2ab0d5edc4fcc5214001b3880eb78e8a (diff) |
Remove lost participants during master takeover.
-rw-r--r-- | same/src/main/java/com/orbekk/same/Master.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/same/src/main/java/com/orbekk/same/Master.java b/same/src/main/java/com/orbekk/same/Master.java index 0571896..974f01c 100644 --- a/same/src/main/java/com/orbekk/same/Master.java +++ b/same/src/main/java/com/orbekk/same/Master.java @@ -172,6 +172,11 @@ public class Master { } } + private void updateParticipants() throws InterruptedException { + long newRevision = revision.incrementAndGet(); + state.updateFromObject(State.PARTICIPANTS, clients, newRevision); + } + private void sendFullState() throws InterruptedException { RpcList rpcs = new RpcList(); for (String location : clients) { @@ -211,10 +216,12 @@ public class Master { try { sendTakeovers(); getMostRecentState(); + updateParticipants(); sendFullState(); finishTakeover(); } catch (InterruptedException e) { // Abort master takeover. + logger.warn("Master takeover aborted: ", e); aborted.set(true); } } @@ -357,8 +364,9 @@ public class Master { List<String> participants = state.getList(State.PARTICIPANTS); if (!participants.contains(location)) { participants.add(location); + long newRevision = revision.incrementAndGet(); state.updateFromObject(State.PARTICIPANTS, participants, - state.getRevision(State.PARTICIPANTS) + 1); + newRevision); sendStateToClients(state.getComponent(State.PARTICIPANTS)); } @@ -369,8 +377,9 @@ public class Master { if (participants0.contains(url)) { logger.info("removeParticipant({})", url); participants0.remove(url); + long newRevision = revision.incrementAndGet(); state.updateFromObject(State.PARTICIPANTS, participants0, - state.getRevision(State.PARTICIPANTS) + 1); + newRevision); sendStateToClients(state.getComponent(State.PARTICIPANTS)); } } |