class HAManager {

    public long selectSlaveId(SortedSet<Long> ids) {
        long slaveId = -1;
        if (ids.size() - 1 == ids.last()) {
            slaveId = ids.last() + 1;
        } else {
            long preId = 0;
            for (long id : ids) {
                if (id == MixAll.MASTER_ID) {
                    continue;
                }
                if (id - preId > 1) {
                    slaveId = preId + 1;
                    break;
                }
                preId++;
            }
            if (slaveId == -1) {
                slaveId = ids.last() + 1;
            }
        }
        return slaveId;
    }

    public  HAManager();
    public  HAManager(NamesrvController namesrvController);

}