ctubbsii commented on a change in pull request #1037: Switch to leader latch WIP
URL: https://github.com/apache/fluo/pull/1037#discussion_r193191385
##########
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:
If we ever want to support running the Oracle in any other execution
framework, I think it's worth trying to ensure those threads are properly
managed and interrupted. But, we don't need to support that today, I suppose.
----------------------------------------------------------------
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