summaryrefslogtreecommitdiff
path: root/same/src/main/java/com/orbekk/paxos
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-24 11:48:19 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-24 11:48:19 +0100
commit55beb6df753604996ae61f8a099db40f0906804e (patch)
tree4f1424195a0b5d47e9b39e76b427b27926cab8dd /same/src/main/java/com/orbekk/paxos
parent5f36d81e47fd142ee7b7c172012917b11411db8d (diff)
Basic Paxos working.
Diffstat (limited to 'same/src/main/java/com/orbekk/paxos')
-rw-r--r--same/src/main/java/com/orbekk/paxos/MasterProposer.java24
1 files changed, 22 insertions, 2 deletions
diff --git a/same/src/main/java/com/orbekk/paxos/MasterProposer.java b/same/src/main/java/com/orbekk/paxos/MasterProposer.java
index 7bc4350..f216ff5 100644
--- a/same/src/main/java/com/orbekk/paxos/MasterProposer.java
+++ b/same/src/main/java/com/orbekk/paxos/MasterProposer.java
@@ -1,11 +1,13 @@
package com.orbekk.paxos;
+import com.orbekk.same.ConnectionManager;
import java.util.ArrayList;
import java.util.List;
-
-import com.orbekk.same.ConnectionManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class MasterProposer {
+ private Logger logger = LoggerFactory.getLogger(getClass());
private String myUrl;
private List<String> paxosUrls = new ArrayList<String>();
private ConnectionManager connections;
@@ -64,4 +66,22 @@ public class MasterProposer {
return false;
}
}
+
+ public boolean proposeRetry(int proposalNumber) {
+ int nextProposal = proposalNumber;
+ int result = 0;
+
+ while (result != nextProposal) {
+ result = internalPropose(nextProposal);
+ if (result == nextProposal) {
+ result = internalAcceptRequest(nextProposal);
+ }
+ logger.info("Proposed value {}, result {}", nextProposal, result);
+ if (result < 0) {
+ nextProposal = -result + 1;
+ }
+ }
+
+ return true;
+ }
}