DownloadMBean.java
1 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
package com.geccocrawler.gecco.monitor;
import java.util.Set;
import org.weakref.jmx.Managed;
import com.alibaba.fastjson.JSON;
import com.geccocrawler.gecco.annotation.MBean;
/**
* downloader相关的统计信息的mbean
*
* @author huchengyi
*
*/
@MBean("downloader")
public class DownloadMBean {
private String statistics;
private String host;
@Managed
public String getHost() {
return host;
}
@Managed
public void setHost(String host) {
this.host = host;
}
@Managed
public void hosts() {
Set<String> hosts = DownloadMonitor.getHosts();
setHost(JSON.toJSONString(hosts));
}
@Managed
public String getStatistics() {
return statistics;
}
@Managed
public void setStatistics(String statistics) {
this.statistics = statistics;
}
@Managed
public void statistics(String host) {
DownloadStatistics ds = DownloadMonitor.getStatistics(host);
setStatistics(JSON.toJSONString(ds));
setHost(JSON.toJSONString(host));
}
}