summaryrefslogtreecommitdiff
path: root/same/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'same/src/main')
-rw-r--r--same/src/main/java/com/orbekk/same/Client.java12
-rw-r--r--same/src/main/java/com/orbekk/same/SameController.java1
2 files changed, 12 insertions, 1 deletions
diff --git a/same/src/main/java/com/orbekk/same/Client.java b/same/src/main/java/com/orbekk/same/Client.java
index 4d5965b..d4ec19e 100644
--- a/same/src/main/java/com/orbekk/same/Client.java
+++ b/same/src/main/java/com/orbekk/same/Client.java
@@ -23,6 +23,7 @@ public class Client implements DiscoveryListener {
private String myUrl;
String masterUrl;
private int masterId = -1;
+ private MasterController masterController = null;
private List<StateChangedListener> stateListeners =
new ArrayList<StateChangedListener>();
@@ -160,6 +161,10 @@ public class Client implements DiscoveryListener {
return connectionState;
}
+ public void setMasterController(MasterController masterController) {
+ this.masterController = masterController;
+ }
+
public void joinNetwork(String masterUrl) {
logger.info("joinNetwork({})", masterUrl);
connectionState = ConnectionState.UNSTABLE;
@@ -233,10 +238,15 @@ public class Client implements DiscoveryListener {
return paxosUrls;
}
- private void startMasterElection() {
+ public void startMasterElection() {
+ if (masterController == null) {
+ logger.warn("Could not become master: No master controller.");
+ return;
+ }
List<String> paxosUrls = getPaxosUrls();
MasterProposer proposer = new MasterProposer(getUrl(), paxosUrls,
connections);
// TODO: Run election.
+ masterController.enableMaster(state);
}
}
diff --git a/same/src/main/java/com/orbekk/same/SameController.java b/same/src/main/java/com/orbekk/same/SameController.java
index c4bdfe7..a9b389c 100644
--- a/same/src/main/java/com/orbekk/same/SameController.java
+++ b/same/src/main/java/com/orbekk/same/SameController.java
@@ -130,6 +130,7 @@ public class SameController {
public void start() throws Exception {
server.start();
+ client.setMasterController(masterController);
client.start();
if (discoveryService != null) {
discoveryService.start();