From 816d4613d7d2fe0366b6913f2a6124e08c21549d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjetil=20=C3=98rbekk?= Date: Thu, 10 May 2012 14:55:30 +0200 Subject: Remove lost participants during master takeover. --- same/src/main/java/com/orbekk/same/Master.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'same/src/main/java/com') 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 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)); } } -- cgit v1.2.3