private HostPort fetcheLeaderInfoFromZk() { try { Participant leader = m_leaderLatch.getLeader(); return JSON.parseObject(leader.getId(), HostPort.class); } catch (Exception e) { log.error("Failed to fetch leader info from zk.", e); } return null; }
public String getCurrentLeader() { try { final LeaderLatch latch = leaderLatch.get(); if (latch == null) { return null; } Participant participant = latch.getLeader(); if (participant.isLeader()) { return participant.getId(); } return null; } catch (Exception e) { throw Throwables.propagate(e); } }