summaryrefslogtreecommitdiff
path: root/same/src/main/java/com
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-17 17:11:12 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-17 17:11:12 +0100
commita2f0a58484bdfc22a8af7b16df051c1e611fc83d (patch)
tree5b3a67d53db242971fdf64e89a4ef5df985363ab /same/src/main/java/com
parent057ed9266ddfeb4fecd1531f6aa51255a4003b68 (diff)
Fix revision update.
Change State to take the *new* revision when updating.
Diffstat (limited to 'same/src/main/java/com')
-rw-r--r--same/src/main/java/com/orbekk/same/MasterServiceImpl.java6
-rw-r--r--same/src/main/java/com/orbekk/same/State.java8
2 files changed, 7 insertions, 7 deletions
diff --git a/same/src/main/java/com/orbekk/same/MasterServiceImpl.java b/same/src/main/java/com/orbekk/same/MasterServiceImpl.java
index d7a9e53..a8acc52 100644
--- a/same/src/main/java/com/orbekk/same/MasterServiceImpl.java
+++ b/same/src/main/java/com/orbekk/same/MasterServiceImpl.java
@@ -31,7 +31,7 @@ public class MasterServiceImpl implements MasterService, UrlReceiver, Runnable {
_fullStateReceivers.add(clientUrl);
synchronized(this) {
state.updateFromObject(".participants", participants,
- state.getRevision(".participants"));
+ state.getRevision(".participants") + 1);
notifyAll();
}
} else {
@@ -79,7 +79,7 @@ public class MasterServiceImpl implements MasterService, UrlReceiver, Runnable {
@Override
public synchronized boolean updateStateRequest(String component,
String newData, long revision) {
- boolean updated = state.update(component, newData, revision);
+ boolean updated = state.update(component, newData, revision + 1);
if (updated) {
notifyAll();
}
@@ -90,7 +90,7 @@ public class MasterServiceImpl implements MasterService, UrlReceiver, Runnable {
public void setUrl(String url) {
String myUrl = url + "MasterService.json";
logger.info("Master URL is " + myUrl);
- state.update(".masterUrl", myUrl, 0);
+ state.update(".masterUrl", myUrl, 1);
}
boolean _performWork() {
diff --git a/same/src/main/java/com/orbekk/same/State.java b/same/src/main/java/com/orbekk/same/State.java
index c352990..19b67e5 100644
--- a/same/src/main/java/com/orbekk/same/State.java
+++ b/same/src/main/java/com/orbekk/same/State.java
@@ -26,8 +26,8 @@ public class State {
private Set<String> updatedComponents = new TreeSet<String>();
public State(String networkName) {
- update(".networkName", networkName, 0);
- updateFromObject(".participants", new ArrayList<String>(), 0);
+ update(".networkName", networkName, 1);
+ updateFromObject(".participants", new ArrayList<String>(), 1);
}
public synchronized void clear() {
@@ -54,10 +54,10 @@ public class State {
component = state.get(componentName);
}
- if (revision >= component.getRevision()) {
+ if (revision > component.getRevision()) {
Component oldComponent = new Component(component);
component.setName(componentName);
- component.setRevision(revision + 1);
+ component.setRevision(revision);
component.setData(data);
state.put(componentName, component);
updatedComponents.add(componentName);