Code example for ListenableFuture

Methods: get

    protected Result check() {
        try { 
            ListenableFuture<Void> nopFuture = distributedStore.nop();
            nopFuture.get(TIMEOUT, TIMEOUT_TIME_UNIT);
            return Result.healthy("server is leader");
        } catch (TimeoutException e) {
            return Result.unhealthy(String.format("timed out after attempting to reach cluster for %d %s", TIMEOUT, TIMEOUT_TIME_UNIT));
        } catch (ExecutionException e) {
            if (e.getCause() instanceof NotLeaderException) {
                NotLeaderException leaderException = (NotLeaderException) e.getCause();
                String leader = leaderException.getLeader();
                if (leader != null) {
                    return Result.healthy(String.format("server not leader, but cluster has leader: %s", leader));
                } else { 
                    return Result.unhealthy("cluster does not have a leader");
            } else {