ManualColl.java
1.95 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
package com.sitech.jmx.mbean;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.apache.log4j.Logger;
import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
import com.sitech.ismp.messageObject.PerformanceObject;
import com.sitech.jmx.manage.MBeanManager;
/**
* 手动远程采集接口
*
* @author LINXC
*/
public class ManualColl implements ManualCollMBean {
private Logger logger = Logger.getLogger(ManualColl.class);
private static MBeanServer mbs = null;
static{
mbs = MBeanManager.getInstance().getMBeanServer();
}
@SuppressWarnings("unchecked")
public List<PerformanceObject> exec(String objectName, String className,
String operationName, HashMap<String, String> paramMap) throws Exception {
List<PerformanceObject> resultList = new ArrayList<PerformanceObject>();
MBeanManager.getInstance().registCollMBean(objectName, className);
try {
Object[] params = new Object[] { paramMap };
String[] signature = new String[]{"java.util.HashMap"};
ObjectName objectname = new ObjectName(objectName);
logger.info("[MenualColl]- Executing objectName[" + objectName + "], operationName[" + operationName + "].");
Vector<TblATO_KPIDETAIL> vResult = (Vector<TblATO_KPIDETAIL>) mbs
.invoke(objectname, operationName, params, signature);
if(vResult!=null){
for(TblATO_KPIDETAIL kpidetail : vResult){
PerformanceObject obj = new PerformanceObject();
obj.setUnitId(kpidetail.UNIT_ID);
obj.setKpiId(kpidetail.KPI_ID);
obj.setKpiValue(kpidetail.KPI_VALUE);
obj.setCllTime(kpidetail.CLL_TIME);
obj.setKpiDetail("n/r");
resultList.add(obj);
}
}
} catch (Exception e) {
logger.error("[MenualColl]- Exception while executing job, objectName[" + objectName + "], operationName[" + operationName + "].", e);
throw e;
}
return resultList;
}
}