mantis-control-plane/mantis-control-plane-server/src/main/java/io/mantisrx/master/zk/ZookeeperLeaderElector.java [122:141]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    private void announceLeader() {
        try {
            logger.info("Announcing leader");
            byte[] masterDescription = jsonMapper.writeValueAsBytes(leadershipManager.getDescription());

            // There is no need to lock anything because we ensure only leader will write to the leader path
            curator
                .setData()
                .inBackground((client, event) -> {
                    if (event.getResultCode() == OK.intValue()) {
                        leadershipManager.becomeLeader();
                    } else {
                        logger.warn("Failed to elect leader from path {} with event {}", leaderPath, event);
                    }
                }).forPath(leaderPath, masterDescription);
        } catch (Exception e) {
            throw new RuntimeException("Failed to announce leader: "+e.getMessage(), e);
        }

    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



mantis-control-plane/mantis-control-plane-server/src/main/java/io/mantisrx/master/zk/LeaderElector.java [120:139]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    private void announceLeader() {
        try {
            logger.info("Announcing leader");
            byte[] masterDescription = jsonMapper.writeValueAsBytes(leadershipManager.getDescription());

            // There is no need to lock anything because we ensure only leader will write to the leader path
            curator
                .setData()
                .inBackground((client, event) -> {
                    if (event.getResultCode() == OK.intValue()) {
                        leadershipManager.becomeLeader();
                    } else {
                        logger.warn("Failed to elect leader from path {} with event {}", leaderPath, event);
                    }
                }).forPath(leaderPath, masterDescription);
        } catch (Exception e) {
            throw new RuntimeException("Failed to announce leader: "+e.getMessage(), e);
        }

    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



