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.modeshape.rhq.plugin.util.PluginConstants.ComponentType;
34 import org.modeshape.rhq.plugin.util.PluginConstants.ComponentType.Connector;
35 import org.modeshape.rhq.plugin.util.PluginConstants.ComponentType.Engine;
36 import org.modeshape.rhq.plugin.util.PluginConstants.ComponentType.Repository;
37 import org.rhq.core.domain.configuration.Configuration;
38 import org.rhq.core.domain.measurement.AvailabilityType;
39 import org.rhq.core.domain.measurement.MeasurementDataTrait;
40 import org.rhq.core.domain.measurement.MeasurementReport;
41 import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
42 import org.rhq.core.pluginapi.inventory.CreateResourceReport;
43 import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
44 import org.rhq.core.pluginapi.inventory.CreateResourceReport;
45 import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
46
47 public class RepositoryComponent extends Facet {
48
49
50
51
52
53
54 @Override
55 String getComponentType() {
56 return ComponentType.Repository.NAME;
57 }
58
59
60
61
62
63
64 @Override
65 protected void setOperationArguments(String name,
66 Configuration configuration, Map<String, Object> valueMap) {
67
68 if (name.equals(Engine.Operations.SHUTDOWN)) {
69
70 } else if (name.equals(Engine.Operations.RESTART)) {
71
72 }
73 }
74
75
76
77
78
79
80 @Override
81 public void getValues(MeasurementReport report,
82 Set<MeasurementScheduleRequest> requests) throws Exception {
83
84 ModeShapeManagementView view = new ModeShapeManagementView();
85
86 Map<String, Object> valueMap = new HashMap<String, Object>();
87 valueMap.put(Repository.Operations.Parameters.REPOSITORY_NAME,
88 this.resourceContext.getResourceKey());
89
90 for (MeasurementScheduleRequest request : requests) {
91 String name = request.getName();
92 LOG.debug("Measurement name = " + name);
93
94 Object metricReturnObject = view.getMetric(getConnection(),
95 getComponentType(), this.getComponentIdentifier(), name,
96 valueMap);
97
98 try {
99 if (request
100 .getName()
101 .equals(
102 PluginConstants.ComponentType.Repository.Metrics.ACTIVESESSIONS)) {
103 report.addData(new MeasurementDataTrait(request,
104 (String) metricReturnObject));
105 }
106 } catch (Exception e) {
107 LOG.error("Failed to obtain measurement [" + name
108 + "]. Cause: " + e);
109
110 }
111 }
112 }
113
114
115
116
117
118
119 @Override
120 public CreateResourceReport createResource(CreateResourceReport arg0) {
121 return null;
122 }
123
124
125
126
127
128
129 @Override
130 public ProfileServiceConnection getConnection() {
131 return ((EngineComponent) this.resourceContext
132 .getParentResourceComponent()).getConnection();
133 }
134
135
136
137
138
139
140 @Override
141 public EmsConnection getEmsConnection() {
142 return null;
143 }
144
145 }