public long getQuorumVersion(int quorum) {
        Map<Long, Integer> versionCnt = new HashMap<>();
        try (CloseableLock ignored = CloseableLock.lock(this.rwLock.readLock())) {
            for (Replica replica : replicas) {
                if (replica.getState() == ReplicaState.NORMAL && !replica.isBad()) {
                    versionCnt.put(replica.getVersion(), 1 + versionCnt.getOrDefault(replica.getVersion(), 0));
                }
            }
        }
        for (Map.Entry<Long, Integer> entry : versionCnt.entrySet()) {
            if (entry.getValue() >= quorum) {
                return entry.getKey();
            }
        }

        return -1L;
    }
@Test
    public void testGetQuorumVersion() {
        List<Replica> replicas = Lists.newArrayList(new Replica(10001, 20001, ReplicaState.NORMAL, 10, -1),
                new Replica(10002, 20002, ReplicaState.NORMAL, 10, -1),
                new Replica(10003, 20003, ReplicaState.NORMAL, 9, -1));
        LocalTablet tablet = new LocalTablet(10004, replicas);

        Assert.assertEquals(-1L, tablet.getQuorumVersion(3));
        Assert.assertEquals(10L, tablet.getQuorumVersion(2));

        Replica replica = tablet.getReplicaByBackendId(20001L);
        replica.setBad(true);
        Assert.assertEquals(-1L, tablet.getQuorumVersion(2));
        replica.setBad(false);

        replica.setState(ReplicaState.DECOMMISSION);
        Assert.assertEquals(-1L, tablet.getQuorumVersion(2));
        replica.setState(ReplicaState.NORMAL);
    }