提交 f875ff10 编写于 作者: W wangyapu

optimize router code

上级 ba7da59e
......@@ -93,7 +93,8 @@ public class Handler implements PageHandler<Context> {
return buildServerStr(servers);
}
private double buildSampleInfo(String domain, double defaultValue) {
private double buildSampleInfo(String domain) {
double defaultValue = 1.0;
com.dianping.cat.sample.entity.Domain domainConfig = m_sampleConfigManager.getConfig().findDomain(domain);
if (domainConfig != null) {
......@@ -178,7 +179,7 @@ public class Handler implements PageHandler<Context> {
kvs.put("block", String.valueOf(m_configManager.shouldBlock(ip)));
kvs.put("routers", buildRouterInfo(ip, domain, report));
kvs.put("sample", String.valueOf(buildSampleInfo(domain, 1.0)));
kvs.put("sample", String.valueOf(buildSampleInfo(domain)));
kvs.put("startTransactionTypes", m_filterManager.getAtomicStartTypes());
kvs.put("matchTransactionTypes", m_filterManager.getAtomicMatchTypes());
......
......@@ -228,7 +228,7 @@ public class RouterConfigAdjustor {
private Map<Server, Long> processGroupMachines(Map<String, Machine> machines) {
Map<Server, Long> results = new HashMap<Server, Long>();
long total = calculateTotal(machines);
Long minGap = total / 100;
long minGap = total / 100;
long avg = total / machines.size();
for (Machine machine : machines.values()) {
......
......@@ -301,9 +301,8 @@ public class RouterConfigManager implements Initializable, LogEnabled {
synchronized (this) {
if (modifyTime > m_modifyTime) {
String content = config.getContent();
RouterConfig routerConfig = DefaultSaxParser.parse(content);
m_routerConfig = routerConfig;
m_routerConfig = DefaultSaxParser.parse(content);
m_modifyTime = modifyTime;
refreshNetInfo();
}
......@@ -340,25 +339,25 @@ public class RouterConfigManager implements Initializable, LogEnabled {
long time = period.getTime();
try {
DailyReport report = m_dailyReportDao
.findByDomainNamePeriod(Constants.CAT, RouterConfigBuilder.ID, period, DailyReportEntity.READSET_FULL);
DailyReport report = m_dailyReportDao.findByDomainNamePeriod(Constants.CAT, RouterConfigBuilder.ID, period,
DailyReportEntity.READSET_FULL);
long modifyTime = report.getCreationDate().getTime();
Pair<RouterConfig, Long> pair = m_routerConfigs.get(time);
if (pair == null || modifyTime > pair.getValue()) {
try {
DailyReportContent reportContent = m_dailyReportContentDao
.findByPK(report.getId(), DailyReportContentEntity.READSET_FULL);
DailyReportContent reportContent = m_dailyReportContentDao.findByPK(report.getId(),
DailyReportContentEntity.READSET_FULL);
RouterConfig routerConfig = DefaultNativeParser.parse(reportContent.getContent());
m_routerConfigs.put(time, new Pair<RouterConfig, Long>(routerConfig, modifyTime));
Cat.logEvent("ReloadConfig", "router");
} catch (DalNotFoundException ignored) {
}
}
} catch (DalNotFoundException ignored) {
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册