summaryrefslogtreecommitdiff
path: root/same/src/main
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-17 10:16:17 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-17 10:16:17 +0100
commit1517ec87df466d9c2b0c38ff80b7160bb67c2ba6 (patch)
treea186d160e195e3d21e0a858e9e364e8973db177c /same/src/main
parenteffce9ac69de33364f6e0dc78ced189fc32ebd38 (diff)
Change ClientInterface.set().
Take revision parameter.
Diffstat (limited to 'same/src/main')
-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));