class DBGroup {

    public String getDBServer(DBRole role) throws QuitException {
        if (!isInitialized()) {
            logger.error("DBGroup:" + this.groupName + " has not been initialized");
            throw new QuitException("DBGroup:" + this.groupName + " has not been initialized");
        }

        if (dbGroupUpdater.isMultiMaster() && !this.masters.isEmpty()) {
            return masterSelector.select(masters);
        }

        if (role == DBRole.MASTER) {
            if (masterElected()) {
                return master;
            } else {
                throw new QuitException("DBGroup:" + this.groupName + " no available master pool");
            }
        } else {
            List<String> slavelist = this.slaves;
            if (slavelist.size() > 0) {
                return slaveSelector.select(slaves);
            } else if (masterElected()) {
                return master;
            } else {
                throw new QuitException("DBGroup:" + this.groupName + " no available slave pool");
            }
        }
    }

    public  DBGroup(String group, ZKCache zkCache, SchedulerGroup schedulerGroup,
        DALGroup dalGroup);

}