diff options
Diffstat (limited to 'same')
-rw-r--r-- | same/src/main/java/com/orbekk/same/Client.java | 2 | ||||
-rw-r--r-- | same/src/main/java/com/orbekk/same/Master.java | 4 | ||||
-rw-r--r-- | same/src/test/java/com/orbekk/same/FunctionalTest.java | 6 |
3 files changed, 9 insertions, 3 deletions
diff --git a/same/src/main/java/com/orbekk/same/Client.java b/same/src/main/java/com/orbekk/same/Client.java index 2bfee27..4d5965b 100644 --- a/same/src/main/java/com/orbekk/same/Client.java +++ b/same/src/main/java/com/orbekk/same/Client.java @@ -21,7 +21,7 @@ public class Client implements DiscoveryListener { private ConnectionManager connections; State state; private String myUrl; - private String masterUrl; + String masterUrl; private int masterId = -1; private List<StateChangedListener> stateListeners = diff --git a/same/src/main/java/com/orbekk/same/Master.java b/same/src/main/java/com/orbekk/same/Master.java index ba87c12..88177d6 100644 --- a/same/src/main/java/com/orbekk/same/Master.java +++ b/same/src/main/java/com/orbekk/same/Master.java @@ -121,6 +121,10 @@ public class Master { client.setState(c.getName(), c.getData(), c.getRevision()); } + client.masterTakeover( + state.getDataOf(".masterUrl"), + state.getDataOf(".networkName"), + 0); } catch (Exception e) { logger.info("Client {} failed to receive state update.", url); removeParticipant(url); diff --git a/same/src/test/java/com/orbekk/same/FunctionalTest.java b/same/src/test/java/com/orbekk/same/FunctionalTest.java index dfb7d3b..63afafb 100644 --- a/same/src/test/java/com/orbekk/same/FunctionalTest.java +++ b/same/src/test/java/com/orbekk/same/FunctionalTest.java @@ -28,8 +28,8 @@ public class FunctionalTest { TestBroadcaster broadcaster = new TestBroadcaster(); @Before public void setUp() { - master = new Master(new State("TestMaster"), connections, - broadcaster); + master = Master.create(connections, + broadcaster, masterUrl, "TestMaster"); connections.masterMap.put(masterUrl, master.getService()); client1 = newClient("TestClient1", "http://client1/ClientService.json"); @@ -83,6 +83,7 @@ public class FunctionalTest { } for (Client c : clients) { assertThat(c.getConnectionState(), is(ConnectionState.STABLE)); + assertThat(c.masterUrl, is(masterUrl)); } } @@ -92,6 +93,7 @@ public class FunctionalTest { Variable<String> x2 = vf2.createString("x"); x1.set("TestValue1"); performWork(); + x1.update(); x2.update(); assertThat(x1.get(), is("TestValue1")); assertThat(x2.get(), is("TestValue1")); |