From ae8791a096626b0196c63e4d9cb68f7a18ad86b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjetil=20=C3=98rbekk?= Date: Tue, 24 Apr 2012 12:41:25 +0200 Subject: Switch to protobuf based Paxos in functional test. --- same/src/main/java/com/orbekk/same/Client.java | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'same/src/main/java/com/orbekk/same') diff --git a/same/src/main/java/com/orbekk/same/Client.java b/same/src/main/java/com/orbekk/same/Client.java index 1833410..f9bd2a9 100644 --- a/same/src/main/java/com/orbekk/same/Client.java +++ b/same/src/main/java/com/orbekk/same/Client.java @@ -151,15 +151,15 @@ public class Client { @Override public void masterDown(RpcController controller, MasterState request, RpcCallback done) { + logger.warn("Master down({})", request); if (request.getMasterId() < masterInfo.getMasterId()) { logger.info("Master {} is down, but current master is {}. Ignoring.", request.getMasterId(), masterInfo.getMasterId()); return; } - logger.warn("Master down."); connectionState = ConnectionState.UNSTABLE; - tryBecomeMaster(request.getMasterId()); done.run(Empty.getDefaultInstance()); + tryBecomeMaster(request); } }; @@ -292,22 +292,9 @@ public class Client { return newServiceImpl; } - private List getPaxosUrlsNoMaster() { - List paxosUrls = new ArrayList(); - for (String participant : state.getList(".participants")) { - String masterPaxos = state.getDataOf(".masterUrl") - .replace("MasterService", "PaxosService"); - String paxos = participant.replace("ClientService", "PaxosService"); - if (!paxos.equals(masterPaxos)) { - paxosUrls.add(participant.replace("ClientService", "PaxosService")); - } - } - logger.info("Paxos urls: {}", paxosUrls); - return paxosUrls; - } - - private void tryBecomeMaster(int failedMasterId) { - List paxosUrls = getPaxosUrlsNoMaster(); + private void tryBecomeMaster(MasterState failedMaster) { + List paxosUrls = state.getList(State.PARTICIPANTS); + paxosUrls.remove(failedMaster.getMasterLocation()); MasterProposer proposer = new MasterProposer(getClientState(), paxosUrls, connections); if (masterController == null) { @@ -323,7 +310,7 @@ public class Client { } }; synchronized (this) { - if (failedMasterId < masterInfo.getMasterId()) { + if (failedMaster.getMasterId() < masterInfo.getMasterId()) { logger.info("Master election aborted. Master already chosen."); return; } @@ -335,6 +322,7 @@ public class Client { result = currentMasterProposal.get(); } catch (InterruptedException e) { } catch (ExecutionException e) { + logger.error("Error electing master: ", e); } catch (CancellationException e) { } if (!currentMasterProposal.isCancelled() && result != null) { -- cgit v1.2.3