summaryrefslogtreecommitdiff
path: root/same/src/main/java/com/orbekk/paxos
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-06 15:05:45 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-06 15:05:45 +0100
commit1d2eca2591c5747c65d52cb96f5246632f06d9d0 (patch)
treebc06817155bb2c683b25f608227dd0682d1bf009 /same/src/main/java/com/orbekk/paxos
parent0ac907ad19d62cc773f6f13f74af52bd75f0b5db (diff)
Fix RpcServlet: Use POST requests.
Diffstat (limited to 'same/src/main/java/com/orbekk/paxos')
-rw-r--r--same/src/main/java/com/orbekk/paxos/MasterProposer.java21
-rw-r--r--same/src/main/java/com/orbekk/paxos/PaxosService.java4
2 files changed, 19 insertions, 6 deletions
diff --git a/same/src/main/java/com/orbekk/paxos/MasterProposer.java b/same/src/main/java/com/orbekk/paxos/MasterProposer.java
index f216ff5..effe6df 100644
--- a/same/src/main/java/com/orbekk/paxos/MasterProposer.java
+++ b/same/src/main/java/com/orbekk/paxos/MasterProposer.java
@@ -1,6 +1,7 @@
package com.orbekk.paxos;
import com.orbekk.same.ConnectionManager;
+import static com.orbekk.same.StackTraceUtil.throwableToString;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
@@ -20,11 +21,17 @@ public class MasterProposer {
}
private int internalPropose(int proposalNumber) {
- int bestPromise = proposalNumber;
+ int bestPromise = -proposalNumber;
int promises = 0;
for (String url : paxosUrls) {
PaxosService paxos = connections.getPaxos(url);
- int result = paxos.propose(myUrl, proposalNumber);
+ int result = 0;
+ try {
+ result = paxos.propose(myUrl, proposalNumber);
+ } catch (Exception e) {
+ logger.warn("Exception from {}: {}", url,
+ throwableToString(e));
+ }
if (result == proposalNumber) {
promises += 1;
}
@@ -38,11 +45,17 @@ public class MasterProposer {
}
private int internalAcceptRequest(int proposalNumber) {
- int bestAccepted = proposalNumber;
+ int bestAccepted = -proposalNumber;
int accepts = 0;
for (String url : paxosUrls) {
PaxosService paxos = connections.getPaxos(url);
- int result = paxos.acceptRequest(myUrl, proposalNumber);
+ int result = 0;
+ try {
+ result = paxos.acceptRequest(myUrl, proposalNumber);
+ } catch (Exception e) {
+ logger.warn("Exception from {}: {}", url,
+ throwableToString(e));
+ }
if (result == proposalNumber) {
accepts += 1;
}
diff --git a/same/src/main/java/com/orbekk/paxos/PaxosService.java b/same/src/main/java/com/orbekk/paxos/PaxosService.java
index a92a794..8de02da 100644
--- a/same/src/main/java/com/orbekk/paxos/PaxosService.java
+++ b/same/src/main/java/com/orbekk/paxos/PaxosService.java
@@ -7,6 +7,6 @@ public interface PaxosService {
* -M if another promise already was made, where M is the promise
* highest proposal number.
*/
- int propose(String clientUrl, int proposalNumber);
- int acceptRequest(String clientUrl, int proposalNumber);
+ int propose(String clientUrl, int proposalNumber) throws Exception;
+ int acceptRequest(String clientUrl, int proposalNumber) throws Exception;
}