}
}
@Override
public MatrixReport queryHourlyReport(String domain, Date start, Date end) {
MatrixReportMerger merger = new MatrixReportMerger(new MatrixReport(domain));
long startTime = start.getTime();
long endTime = end.getTime();
String name = MatrixAnalyzer.ID;
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) {// for old xml storage
MatrixReport reportModel = com.dianping.cat.consumer.matrix.model.transform.DefaultSaxParser
.parse(xml);
reportModel.accept(merger);
} else {// for new binary storage, binary is same to report id
MatrixReport reportModel = queryFromHourlyBinary(report.getId(), domain);
reportModel.accept(merger);
}
} catch (DalNotFoundException e) {
//ignore
} catch (Exception e) {
Cat.logError(e);
}
}
}
}
MatrixReport matrixReport = merger.getMatrixReport();
matrixReport.setStartTime(start);
matrixReport.setEndTime(new Date(end.getTime() - 1));
Set<String> domains = queryAllDomainNames(start, end, MatrixAnalyzer.ID);
matrixReport.getDomainNames().addAll(domains);
return matrixReport;
}