summaryrefslogtreecommitdiff
path: root/same/src/main/java/com/orbekk
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-04-11 15:05:35 +0200
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-04-11 15:05:35 +0200
commita60af7c40268f65cef9d301b311db30f46a2ecf3 (patch)
tree97b6f1bedb875adc8f0a15a591847f5fd1b4ec06 /same/src/main/java/com/orbekk
parent64139964ffb1ac9fb21d936b3d4865fc9a616b40 (diff)
Same hosts a protobuf server.
Diffstat (limited to 'same/src/main/java/com/orbekk')
-rw-r--r--same/src/main/java/com/orbekk/same/Master.java4
-rw-r--r--same/src/main/java/com/orbekk/same/SameController.java14
2 files changed, 16 insertions, 2 deletions
diff --git a/same/src/main/java/com/orbekk/same/Master.java b/same/src/main/java/com/orbekk/same/Master.java
index 86b1e06..4610540 100644
--- a/same/src/main/java/com/orbekk/same/Master.java
+++ b/same/src/main/java/com/orbekk/same/Master.java
@@ -161,6 +161,10 @@ public class Master {
updateStateRequestThread.interrupt();
}
+ public Services.Master getNewService() {
+ return newMasterImpl;
+ }
+
public MasterService getService() {
return serviceImpl;
}
diff --git a/same/src/main/java/com/orbekk/same/SameController.java b/same/src/main/java/com/orbekk/same/SameController.java
index 522a0a1..78eed7a 100644
--- a/same/src/main/java/com/orbekk/same/SameController.java
+++ b/same/src/main/java/com/orbekk/same/SameController.java
@@ -7,6 +7,7 @@ import com.google.protobuf.RpcCallback;
import com.orbekk.paxos.PaxosService;
import com.orbekk.paxos.PaxosServiceImpl;
import com.orbekk.protobuf.Rpc;
+import com.orbekk.protobuf.SimpleProtobufServer;
import com.orbekk.same.config.Configuration;
import com.orbekk.same.http.JettyServerBuilder;
import com.orbekk.same.http.ServerContainer;
@@ -15,6 +16,7 @@ import com.orbekk.same.http.StateServlet;
public class SameController {
private Logger logger = LoggerFactory.getLogger(getClass());
private ServerContainer server;
+ private SimpleProtobufServer pServer;
private MasterServiceProxy masterService;
private Master master;
private Client client;
@@ -36,6 +38,7 @@ public class SameController {
master = Master.create(connections, serviceBroadcaster,
masterUrl, configuration.get("networkName"));
master.resumeFrom(lastKnownState, masterId);
+ pServer.registerService(master.getNewService());
master.start();
masterService.setService(master.getService());
}
@@ -71,9 +74,12 @@ public class SameController {
.withService(master, MasterService.class)
.withService(paxos, PaxosService.class)
.build();
+
+ SimpleProtobufServer pServer = SimpleProtobufServer.create(port + 1337);
+
SameController controller = new SameController(
configuration, connections, server, master, client,
- paxos, broadcaster);
+ paxos, broadcaster, pServer);
return controller;
}
@@ -84,7 +90,8 @@ public class SameController {
MasterServiceProxy master,
Client client,
PaxosServiceImpl paxos,
- Broadcaster serviceBroadcaster) {
+ Broadcaster serviceBroadcaster,
+ SimpleProtobufServer pServer) {
this.configuration = configuration;
this.connections = connections;
this.server = server;
@@ -92,10 +99,12 @@ public class SameController {
this.client = client;
this.paxos = paxos;
this.serviceBroadcaster = serviceBroadcaster;
+ this.pServer = pServer;
}
public void start() throws Exception {
server.start();
+ pServer.start();
client.setMasterController(masterController);
client.start();
}
@@ -107,6 +116,7 @@ public class SameController {
master.interrupt();
}
server.stop();
+ pServer.interrupt();
} catch (Exception e) {
logger.error("Failed to stop webserver", e);
}