diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-03-27 11:42:42 +0200 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-03-27 11:42:42 +0200 |
commit | cd660183bad3757d12beb9c1e9c1afa1d0e03419 (patch) | |
tree | 71225618cd14c4885385db623d18c8774281c6e7 /same/src | |
parent | 242ad944762e17fd3636beb40237c870551a653a (diff) |
Fix state bug.0.3
Make sure to copy the state when creating a new master. Using the same
state instance on the master and client is a disaster.
Diffstat (limited to 'same/src')
-rw-r--r-- | same/src/main/java/com/orbekk/same/Client.java | 5 | ||||
-rw-r--r-- | same/src/main/java/com/orbekk/same/Master.java | 2 | ||||
-rw-r--r-- | same/src/test/java/com/orbekk/same/ClientTest.java | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/same/src/main/java/com/orbekk/same/Client.java b/same/src/main/java/com/orbekk/same/Client.java index b210b6b..53d0ac8 100644 --- a/same/src/main/java/com/orbekk/same/Client.java +++ b/same/src/main/java/com/orbekk/same/Client.java @@ -103,7 +103,8 @@ public class Client { listener.stateChanged(state.getComponent(component)); } } else { - logger.warn("Ignoring update: {}", + logger.warn("Ignoring update: {) => {}", + state.getComponent(component), new State.Component(component, revision, data)); } } @@ -261,7 +262,7 @@ public class Client { } catch (CancellationException e) { } if (!currentMasterProposal.isCancelled() && result != null) { - masterController.enableMaster(state, result); + masterController.enableMaster(new State(state), result); } } diff --git a/same/src/main/java/com/orbekk/same/Master.java b/same/src/main/java/com/orbekk/same/Master.java index 529d729..6041cf1 100644 --- a/same/src/main/java/com/orbekk/same/Master.java +++ b/same/src/main/java/com/orbekk/same/Master.java @@ -13,7 +13,7 @@ public class Master { private String myUrl; State state; private Broadcaster broadcaster; - private volatile int masterId = 0; + private volatile int masterId = 1; public static Master create(ConnectionManager connections, Broadcaster broadcaster, String myUrl, String networkName) { diff --git a/same/src/test/java/com/orbekk/same/ClientTest.java b/same/src/test/java/com/orbekk/same/ClientTest.java index 0e2a278..6c617be 100644 --- a/same/src/test/java/com/orbekk/same/ClientTest.java +++ b/same/src/test/java/com/orbekk/same/ClientTest.java @@ -33,7 +33,7 @@ public class ClientTest { } @Test public void connectedUpdateWorks() throws Exception { - clientS.masterTakeover("master", null, 0); + clientS.masterTakeover("master", null, 1); ClientInterface clientI = client.getInterface(); State.Component component = new State.Component( "TestVariable", 1, "meow"); |