TopDelegate.java
1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.dianping.cat.consumer.top;
import java.util.Date;
import java.util.Map;
import com.dianping.cat.consumer.top.model.transform.DefaultNativeBuilder;
import com.dianping.cat.consumer.top.model.transform.DefaultNativeParser;
import com.dianping.cat.consumer.top.model.entity.TopReport;
import com.dianping.cat.consumer.top.model.transform.DefaultSaxParser;
import com.dianping.cat.report.ReportDelegate;
public class TopDelegate implements ReportDelegate<TopReport> {
@Override
public void afterLoad(Map<String, TopReport> reports) {
}
@Override
public void beforeSave(Map<String, TopReport> reports) {
}
@Override
public byte[] buildBinary(TopReport report) {
return DefaultNativeBuilder.build(report);
}
@Override
public String buildXml(TopReport report) {
return report.toString();
}
@Override
public boolean createHourlyTask(TopReport report) {
return true;
}
@Override
public String getDomain(TopReport report) {
return report.getDomain();
}
@Override
public TopReport makeReport(String domain, long startTime, long duration) {
TopReport report = new TopReport(domain);
report.setStartTime(new Date(startTime));
report.setEndTime(new Date(startTime + duration - 1));
return report;
}
@Override
public TopReport mergeReport(TopReport old, TopReport other) {
TopReportMerger merger = new TopReportMerger(old);
other.accept(merger);
return old;
}
@Override
public TopReport parseBinary(byte[] bytes) {
return DefaultNativeParser.parse(bytes);
}
@Override
public TopReport parseXml(String xml) throws Exception {
TopReport report = DefaultSaxParser.parse(xml);
return report;
}
}