}
}
@Override
public UtilizationReport queryHourlyReport(String domain, Date start, Date end) {
UtilizationReportMerger merger = new UtilizationReportMerger(new UtilizationReport(domain));
long startTime = start.getTime();
long endTime = end.getTime();
String name = Constants.REPORT_UTILIZATION;
for (; startTime < endTime; startTime = startTime + TimeHelper.ONE_HOUR) {
List<HourlyReport> reports = null;
try {
reports = m_hourlyReportDao.findAllByDomainNamePeriod(new Date(startTime), domain, name,
HourlyReportEntity.READSET_FULL);
} catch (DalException e) {
Cat.logError(e);
}
if (reports != null) {
for (HourlyReport report : reports) {
String xml = report.getContent();
try {
if (xml != null && xml.length() > 0) {
UtilizationReport reportModel = com.dianping.cat.home.utilization.transform.DefaultSaxParser
.parse(xml);
reportModel.accept(merger);
} else {
UtilizationReport reportModel = queryFromHourlyBinary(report.getId(), domain);
reportModel.accept(merger);
}
} catch (DalNotFoundException e) {
//ignore
} catch (Exception e) {
Cat.logError(e);
}
}
}
}
UtilizationReport utilizationReport = merger.getUtilizationReport();
utilizationReport.setStartTime(start);
utilizationReport.setEndTime(new Date(end.getTime() - 1));
return utilizationReport;
}