class NvaLeaderSelectorListenerAdapter extends LeaderSelectorListenerAdapter implements AutoCloseable {

    @Override
    public void takeLeadership(CuratorFramework curatorFramework) throws Exception {
        log.info("Leadership acquired");
        try {
            log.info("Starting nvaMonitor");
            Future<Void> task = nvaMonitor.start();
            task.get();
            log.debug("task.get() returned");
        } catch (InterruptedException e) {
            log.info("takeLeadership interrupted");
            Thread.currentThread().interrupt();
        } catch (NvaMonitorException e){
            log.error("Error creating NvaMonitor", e);
            throw e;
        } catch (ExecutionException e) {
            // This should happen when there is an exception starting the nvaMonitor.  We need to
            // relinquish leadership so someone else can try.  However, if this is a configuration
            // issue, it will just bounce from leader to leader, so we need to log it.
            log.error("Error executing NvaMonitor", e);
            throw e;
        } finally {
            this.nvaMonitor.stop();
        }
    }

    public  NvaLeaderSelectorListenerAdapter(NvaDaemonConfiguration configuration,
                                            CuratorFramework client);

}