1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.modeshape.rhq.plugin;
25
26 import java.util.HashMap;
27 import java.util.Map;
28 import java.util.Set;
29
30 import org.mc4j.ems.connection.EmsConnection;
31 import org.modeshape.rhq.plugin.util.ModeShapeManagementView;
32 import org.modeshape.rhq.plugin.util.PluginConstants;
33 import org.rhq.core.domain.measurement.MeasurementDataTrait;
34 import org.rhq.core.domain.measurement.MeasurementReport;
35 import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
36 import org.rhq.core.pluginapi.inventory.CreateResourceReport;
37 import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
38
39 public class SequencingServiceComponent extends Facet {
40
41
42
43
44
45
46 @Override
47 String getComponentType() {
48 return PluginConstants.ComponentType.SequencingService.NAME;
49 }
50
51
52
53
54
55
56
57 @Override
58 public void getValues(MeasurementReport report,
59 Set<MeasurementScheduleRequest> requests) throws Exception {
60
61 ModeShapeManagementView view = new ModeShapeManagementView();
62
63 Map<String, Object> valueMap = new HashMap<String, Object>();
64 valueMap.put(PluginConstants.ComponentType.SequencingService.NAME,
65 this.resourceContext.getResourceKey());
66
67 for (MeasurementScheduleRequest request : requests) {
68 String name = request.getName();
69 LOG.debug("Measurement name = " + name);
70
71 Object metricReturnObject = view.getMetric(getConnection(),
72 getComponentType(), this.getComponentIdentifier(), name,
73 valueMap);
74
75 try {
76 if (request
77 .getName()
78 .equals(
79 PluginConstants.ComponentType.SequencingService.Metrics.NUM_NODES_SEQUENCED)) {
80 report.addData(new MeasurementDataTrait(request, (String) metricReturnObject));
81 } else {
82 if (request
83 .getName()
84 .equals(
85 PluginConstants.ComponentType.SequencingService.Metrics.NUM_NODES_SKIPPED)) {
86 report.addData(new MeasurementDataTrait(request, (String) metricReturnObject));
87 }
88
89 }
90
91 } catch (Exception e) {
92 LOG.error("Failed to obtain measurement [" + name
93 + "]. Cause: " + e);
94
95 }
96 }
97
98 }
99
100
101
102
103
104
105 @Override
106 public CreateResourceReport createResource(CreateResourceReport arg0) {
107 return null;
108 }
109
110
111
112
113
114
115 @Override
116 public ProfileServiceConnection getConnection() {
117 return ((EngineComponent) this.resourceContext
118 .getParentResourceComponent()).getConnection();
119 }
120
121
122
123
124
125
126 @Override
127 public EmsConnection getEmsConnection() {
128 return null;
129 }
130
131 }