提交 a215653a 编写于 作者: Y yong.you

modify the cat metric graph builder

上级 092985fb
......@@ -43,7 +43,8 @@ public class DefaultBaselineService implements BaselineService {
if (baseline == null) {
try {
baseline = m_baselineDao.findByReportNameKeyTime(reportPeriod, reportName, key, BaselineEntity.READSET_FULL);
baseline = m_baselineDao
.findByReportNameKeyTime(reportPeriod, reportName, key, BaselineEntity.READSET_FULL);
m_baselineMap.put(baselineKey, baseline);
} catch (DalNotFoundException e) {
Cat.logEvent("BaselineNotFound", baselineKey);
......@@ -67,14 +68,13 @@ public class DefaultBaselineService implements BaselineService {
double[] result = new double[60];
Date today = TaskHelper.todayZero(reportPeriod);
int hour = (int) ((reportPeriod.getTime() - today.getTime()) / TimeUtil.ONE_HOUR);
double[] dayResult = queryDailyBaseline(reportName, key, today);
if (dayResult == null)
return null;
for (int i = 0; i < 60; i++) {
result[i] = dayResult[hour * 60 + i];
}
if (dayResult != null) {
for (int i = 0; i < 60; i++) {
result[i] = dayResult[hour * 60 + i];
}
}
return result;
}
......
......@@ -25,7 +25,7 @@ public class CachedMetricReportServiceImpl implements CachedMetricReportService
@Inject
private ModelService<MetricReport> m_service;
private final Map<String, MetricReport> m_metricReportMap = new LinkedHashMap<String, MetricReport>() {
private final Map<String, MetricReport> m_metricReports = new LinkedHashMap<String, MetricReport>() {
private static final long serialVersionUID = 1L;
......@@ -37,13 +37,13 @@ public class CachedMetricReportServiceImpl implements CachedMetricReportService
private MetricReport getReportFromDB(String product, long date) {
String key = product + date;
MetricReport result = m_metricReportMap.get(key);
MetricReport result = m_metricReports.get(key);
if (result == null) {
Date start = new Date(date);
Date end = new Date(date + TimeUtil.ONE_HOUR);
try {
result = m_reportService.queryMetricReport(product, start, end);
m_metricReportMap.put(key, result);
m_metricReports.put(key, result);
} catch (Exception e) {
Cat.logError(e);
}
......@@ -61,6 +61,7 @@ public class CachedMetricReportServiceImpl implements CachedMetricReportService
if (m_service.isEligable(request)) {
ModelResponse<MetricReport> response = m_service.invoke(request);
MetricReport report = response.getModel();
return report;
} else {
throw new RuntimeException("Internal error: no eligable metric service registered for " + request + "!");
......
......@@ -51,12 +51,13 @@ public class MetricDataFetcherImpl implements MetricDataFetcher {
return values;
}
private void putKey(Map<String, double[]> datas, Map<String, double[]> values, String sumKey) {
double[] value = datas.get(sumKey);
private void putKey(Map<String, double[]> datas, Map<String, double[]> values, String key) {
double[] value = datas.get(key);
if(value ==null){
value = new double[60];
}
values.put(sumKey, value);
values.put(key, value);
}
public class MetricDataBuilder extends BaseVisitor {
......
......@@ -10,7 +10,6 @@ public class MetricReportMerger extends DefaultMerger {
public MetricReportMerger(MetricReport metricReport) {
super(metricReport);
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册