summaryrefslogtreecommitdiff
path: root/same
diff options
context:
space:
mode:
Diffstat (limited to 'same')
-rw-r--r--same/src/main/java/com/orbekk/same/Client.java4
-rw-r--r--same/src/main/java/com/orbekk/same/http/StateServlet.java8
2 files changed, 7 insertions, 5 deletions
diff --git a/same/src/main/java/com/orbekk/same/Client.java b/same/src/main/java/com/orbekk/same/Client.java
index b97ab91..2d77434 100644
--- a/same/src/main/java/com/orbekk/same/Client.java
+++ b/same/src/main/java/com/orbekk/same/Client.java
@@ -28,9 +28,9 @@ public class Client implements DiscoveryListener {
return new State(state);
}
- public void set(String name, String data) throws UpdateConflict {
+ public void set(String name, String data, long revision)
+ throws UpdateConflict {
String masterUrl = state.getDataOf(".masterUrl");
- long revision = state.getRevision(name) + 1;
MasterService master = connections.getMaster(masterUrl);
try {
boolean success = master.updateStateRequest(name, data,
diff --git a/same/src/main/java/com/orbekk/same/http/StateServlet.java b/same/src/main/java/com/orbekk/same/http/StateServlet.java
index fdb2eb9..31e8bcb 100644
--- a/same/src/main/java/com/orbekk/same/http/StateServlet.java
+++ b/same/src/main/java/com/orbekk/same/http/StateServlet.java
@@ -33,10 +33,12 @@ public class StateServlet extends HttpServlet {
}
try {
- client.set(request.getParameter("key"), request.getParameter("value"));
+ String key = request.getParameter("key");
+ String value = request.getParameter("value");
+ long revision = client.getState().getRevision(key);
+ client.set(key, value, revision);
response.getWriter().println("Updated component: " +
- request.getParameter("key") + "=" +
- request.getParameter("value"));
+ key + "=" + value);
} catch (UpdateConflict e) {
response.getWriter().println("Update conflict: " +
throwableToString(e));