summaryrefslogtreecommitdiff
path: root/same/src/main/java/com/orbekk/paxos
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-04-25 12:10:57 +0200
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-04-25 12:10:57 +0200
commit768938fa1e2bfaa5a246e28badefc7d8fe7cadd3 (patch)
tree29e17a0603922c087db4c24804ba22db290e8eaa /same/src/main/java/com/orbekk/paxos
parenta8b921e07bf4ad1936e01628049a9c6fd7349312 (diff)
Add debug messages in Paxos service.
– Remove old PaxosService.
Diffstat (limited to 'same/src/main/java/com/orbekk/paxos')
-rw-r--r--same/src/main/java/com/orbekk/paxos/MasterProposer.java8
-rw-r--r--same/src/main/java/com/orbekk/paxos/PaxosService.java12
-rw-r--r--same/src/main/java/com/orbekk/paxos/PaxosServiceImpl.java12
3 files changed, 14 insertions, 18 deletions
diff --git a/same/src/main/java/com/orbekk/paxos/MasterProposer.java b/same/src/main/java/com/orbekk/paxos/MasterProposer.java
index e2723a3..eaca410 100644
--- a/same/src/main/java/com/orbekk/paxos/MasterProposer.java
+++ b/same/src/main/java/com/orbekk/paxos/MasterProposer.java
@@ -81,6 +81,8 @@ public class MasterProposer extends Thread {
public int getResult() throws InterruptedException {
done.await();
+ logger.info("ResponseHandler: {} / {} successes.",
+ numPromises.get(), numRequests);
return result.get();
}
}
@@ -117,6 +119,8 @@ public class MasterProposer extends Thread {
.setProposalNumber(proposalNumber)
.build();
paxos.acceptRequest(rpc, request, handler);
+ rpc.await();
+ logger.info("Rpc result from paxos.acceptRequest: " + rpc.errorText());
}
return handler.getResult();
}
@@ -139,6 +143,7 @@ public class MasterProposer extends Thread {
Integer proposeRetry(int proposalNumber, Runnable retryAction)
throws InterruptedException {
+ logger.info("Paxos services: {}.", paxosLocations);
assert proposalNumber > 0;
int nextProposal = proposalNumber;
int result = nextProposal - 1;
@@ -148,7 +153,8 @@ public class MasterProposer extends Thread {
if (result == nextProposal) {
result = internalAcceptRequest(nextProposal);
}
- logger.info("Proposed value {}, result {}", nextProposal, result);
+ logger.info("Proposed value {}, result {}.",
+ nextProposal, result);
if (result < 0) {
nextProposal = -result + 1;
if (retryAction != null) {
diff --git a/same/src/main/java/com/orbekk/paxos/PaxosService.java b/same/src/main/java/com/orbekk/paxos/PaxosService.java
deleted file mode 100644
index a6f6b08..0000000
--- a/same/src/main/java/com/orbekk/paxos/PaxosService.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.orbekk.paxos;
-
-public interface PaxosService {
-
- /**
- * @return N == proposalNumber if a promise is made.
- * -M if another promise already was made, where M is the promise
- * highest proposal number.
- */
- int propose(String clientUrl, int proposalNumber) throws Exception;
- int acceptRequest(String clientUrl, int proposalNumber) throws Exception;
-}
diff --git a/same/src/main/java/com/orbekk/paxos/PaxosServiceImpl.java b/same/src/main/java/com/orbekk/paxos/PaxosServiceImpl.java
index 6b9dd14..40e6320 100644
--- a/same/src/main/java/com/orbekk/paxos/PaxosServiceImpl.java
+++ b/same/src/main/java/com/orbekk/paxos/PaxosServiceImpl.java
@@ -12,7 +12,7 @@ import com.orbekk.same.Services.PaxosResponse;
/**
* This class better be thread-safe.
*/
-public class PaxosServiceImpl implements PaxosService {
+public class PaxosServiceImpl {
private Logger logger = LoggerFactory.getLogger(getClass());
private int highestPromise = 0;
private int highestAcceptedValue = 0;
@@ -23,6 +23,8 @@ public class PaxosServiceImpl implements PaxosService {
@Override
public void propose(RpcController controller, PaxosRequest request,
RpcCallback<PaxosResponse> done) {
+ logger.info("propose({}). Highest promise: {}, Highest accepted: {}",
+ new Object[]{request, highestPromise, highestAcceptedValue});
String clientUrl = request.getClient().getLocation();
int proposalNumber = request.getProposalNumber();
int response =
@@ -36,6 +38,8 @@ public class PaxosServiceImpl implements PaxosService {
@Override
public void acceptRequest(RpcController controller,
PaxosRequest request, RpcCallback<PaxosResponse> done) {
+ logger.info("acceptRequest({}). Highest promise: {}, Highest accepted: {}",
+ new Object[]{request, highestPromise, highestAcceptedValue});
String clientUrl = request.getClient().getLocation();
int proposalNumber = request.getProposalNumber();
int response =
@@ -56,8 +60,7 @@ public class PaxosServiceImpl implements PaxosService {
return service;
}
- @Override
- public synchronized int propose(String clientUrl,
+ private synchronized int propose(String clientUrl,
int proposalNumber) {
if (proposalNumber > highestPromise) {
logger.info(tag + "propose({}, {}) = accepted",
@@ -73,8 +76,7 @@ public class PaxosServiceImpl implements PaxosService {
}
}
- @Override
- public synchronized int acceptRequest(String clientUrl,
+ private synchronized int acceptRequest(String clientUrl,
int proposalNumber) {
if (proposalNumber == highestPromise) {
logger.info(tag + "acceptRequest({}, {}) = accepted",