ctubbsii commented on a change in pull request #1037: Switch to leader latch WIP
URL: https://github.com/apache/fluo/pull/1037#discussion_r192926423
##########
File path:
modules/core/src/main/java/org/apache/fluo/core/oracle/OracleServer.java
##########
@@ -322,11 +326,29 @@ public synchronized void start() throws Exception {
Thread.sleep(200);
}
- leaderSelector = new LeaderSelector(curatorFramework,
ZookeeperPath.ORACLE_SERVER, this);
+ final InetSocketAddress addr = startServer();
+
String leaderId = HostUtil.getHostName() + ":" + addr.getPort();
- leaderSelector.setId(leaderId);
+ leaderLatch = new LeaderLatch(curatorFramework,
ZookeeperPath.ORACLE_SERVER, leaderId);
log.info("Leader ID = " + leaderId);
- leaderSelector.start();
+ execService = Executors.newSingleThreadExecutor(new
FluoThreadFactory("Oracle Server Worker"));
+ leaderLatch.addListener(new LeaderLatchListener() {
+ @Override
+ public void notLeader() {
+ isLeader = false;
+
+ if (started) {
+ // if we stopped the server manually, we shouldn't halt
+ Halt.halt("Oracle has lost leadership unexpectedly and is now
halting.");
Review comment:
This halt is *very* unfriendly to running Fluo services in a framework. It
makes sense only if it is only ever executed as it's own Java process... and I
don't think it's a good idea to make that assumption, since it constrains how
it should be run.
Is there an alternative to doing this which might be available?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services