<commit_before>package com.dianping.cat.system.config;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.unidal.dal.jdbc.DalNotFoundException;
import org.unidal.helper.Files;
import org.unidal.lookup.annotation.Inject;

import com.dianping.cat.Cat;
import com.dianping.cat.core.config.Config;
import com.dianping.cat.core.config.ConfigDao;
import com.dianping.cat.core.config.ConfigEntity;
import com.dianping.cat.home.router.entity.DefaultServer;
import com.dianping.cat.home.router.entity.Domain;
import com.dianping.cat.home.router.entity.RouterConfig;
import com.dianping.cat.home.router.entity.Server;
import com.dianping.cat.home.router.transform.DefaultSaxParser;

public class RouterConfigManager implements Initializable, LogEnabled {

	@Inject
	private ConfigDao m_configDao;

	private int m_configId;

	private RouterConfig m_routerConfig;

	private Logger m_logger;

	private static final String CONFIG_NAME = "routerConfig";

	@Override
	public void enableLogging(Logger logger) {
		m_logger = logger;
	}

	public RouterConfig getRouterConfig() {
		return m_routerConfig;
	}

	public Server queryBackUpServer() {
		return new Server().setId(m_routerConfig.getBackupServer()).setPort(m_routerConfig.getBackupServerPort());
	}

	public List<Server> queryServersByDomain(String domain) {
		Domain domainConfig = m_routerConfig.findDomain(domain);
		List<Server> result = new ArrayList<Server>();

		if (domainConfig == null) {
			Map<Server, Integer> map = new HashMap<Server, Integer>();
			List<Server> servers = queryEnableServers();
			int length = servers.size();
			int index = domain.hashCode() * length;

			for (int i = 0; i < 2; i++) {
				map.put(servers.get((index + 1) % length), 0);
			}
			map.put(queryBackUpServer(), 0);

			result = new ArrayList<Server>(map.keySet());
		} else {
			for (Server server : domainConfig.getServers()) {
				result.add(server);
			}<commit_msg>fix the default config<commit_after>package com.dianping.cat.system.config;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.unidal.dal.jdbc.DalNotFoundException;
import org.unidal.helper.Files;
import org.unidal.lookup.annotation.Inject;

import com.dianping.cat.Cat;
import com.dianping.cat.core.config.Config;
import com.dianping.cat.core.config.ConfigDao;
import com.dianping.cat.core.config.ConfigEntity;
import com.dianping.cat.home.router.entity.DefaultServer;
import com.dianping.cat.home.router.entity.Domain;
import com.dianping.cat.home.router.entity.RouterConfig;
import com.dianping.cat.home.router.entity.Server;
import com.dianping.cat.home.router.transform.DefaultSaxParser;

public class RouterConfigManager implements Initializable, LogEnabled {

	@Inject
	private ConfigDao m_configDao;

	private int m_configId;

	private RouterConfig m_routerConfig;

	private Logger m_logger;

	private static final String CONFIG_NAME = "routerConfig";

	@Override
	public void enableLogging(Logger logger) {
		m_logger = logger;
	}

	public RouterConfig getRouterConfig() {
		return m_routerConfig;
	}

	public Server queryBackUpServer() {
		return new Server().setId(m_routerConfig.getBackupServer()).setPort(m_routerConfig.getBackupServerPort());
	}

	public List<Server> queryServersByDomain(String domain) {
		Domain domainConfig = m_routerConfig.findDomain(domain);
		List<Server> result = new ArrayList<Server>();

		if (domainConfig == null) {
			Map<Server, Integer> map = new HashMap<Server, Integer>();
			List<Server> servers = queryEnableServers();
			int length = servers.size();
			int index = domain.hashCode();

			for (int i = 0; i < 2; i++) {
				map.put(servers.get((index + i) % length), 0);
			}
			map.put(queryBackUpServer(), 0);

			result = new ArrayList<Server>(map.keySet());
		} else {
			for (Server server : domainConfig.getServers()) {
				result.add(server);
			}
{'fraction_non_alphanumeric': 0.11744815148782688, 'fraction_numerical': 0.0020288548241659153, 'mean_word_length': 5.231741573033708, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2500240', 'n_tokens_mistral': 1500, 'n_tokens_neox': 1415, 'n_words': 276}