use of javax.management.AttributeList in project geode by apache.
the class JMXDataUpdater method initGatewayReceiver.
/**
* function used to get attribute values of Gateway Receiver and map them to GatewayReceiver inner
* class object
*
* @return GatewayReceiver object
*/
private Cluster.GatewayReceiver initGatewayReceiver(ObjectName mbeanName) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException, AttributeNotFoundException, MBeanException {
Cluster.GatewayReceiver gatewayReceiver = new Cluster.GatewayReceiver();
AttributeList attributeList = this.mbs.getAttributes(mbeanName, PulseConstants.GATEWAY_MBEAN_ATTRIBUTES);
for (int i = 0; i < attributeList.size(); i++) {
Attribute attribute = (Attribute) attributeList.get(i);
if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_PORT)) {
gatewayReceiver.setListeningPort(getIntegerAttribute(attribute.getValue(), attribute.getName()));
} else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_EVENTRECEIVEDDATE)) {
gatewayReceiver.setLinkThroughput(getDoubleAttribute(attribute.getValue(), attribute.getName()));
} else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_AVEARGEBATCHPROCESSINGTIME)) {
gatewayReceiver.setAvgBatchProcessingTime(getLongAttribute(attribute.getValue(), attribute.getName()));
} else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_RUNNING)) {
gatewayReceiver.setStatus(getBooleanAttribute(attribute.getValue(), attribute.getName()));
}
}
return gatewayReceiver;
}
use of javax.management.AttributeList in project jackrabbit-oak by apache.
the class OakOSGiRepositoryFactory method registerMBeanServer.
/**
* Registers the Platform MBeanServer as OSGi service. This would enable
* Aries JMX Whitboard support to then register the JMX MBean which are registered as OSGi service
* to be registered against the MBean server
*/
private static void registerMBeanServer(PojoServiceRegistry registry) {
MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
Hashtable<String, Object> mbeanProps = new Hashtable<String, Object>();
try {
ObjectName beanName = ObjectName.getInstance("JMImplementation:type=MBeanServerDelegate");
AttributeList attrs = platformMBeanServer.getAttributes(beanName, new String[] { "MBeanServerId", "SpecificationName", "SpecificationVersion", "SpecificationVendor", "ImplementationName", "ImplementationVersion", "ImplementationVendor" });
for (Object object : attrs) {
Attribute attr = (Attribute) object;
if (attr.getValue() != null) {
mbeanProps.put(attr.getName(), attr.getValue().toString());
}
}
} catch (Exception je) {
log.info("Cannot set service properties of Platform MBeanServer service, registering without", je);
}
registry.registerService(MBeanServer.class.getName(), platformMBeanServer, mbeanProps);
}
use of javax.management.AttributeList in project sling by apache.
the class HealthCheckMBean method getAttribute.
@Override
public Object getAttribute(final String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException {
// we should call getAttributes - and not vice versa to have the result
// of a single check call - and not do a check call for each attribute
final AttributeList result = this.getAttributes(new String[] { attribute });
if (result.size() == 0) {
throw new AttributeNotFoundException(attribute);
}
final Attribute attr = (Attribute) result.get(0);
return attr.getValue();
}
use of javax.management.AttributeList in project wildfly by wildfly.
the class LogStoreParticipantRefreshHandler method execute.
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
MBeanServer mbs = TransactionExtension.getMBeanServer(context);
final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
try {
final ObjectName on = LogStoreResource.getObjectName(resource);
final ModelNode model = resource.getModel().clone();
AttributeList attributes = mbs.getAttributes(on, LogStoreConstants.PARTICIPANT_JMX_NAMES);
for (javax.management.Attribute attribute : attributes.asList()) {
String modelName = LogStoreConstants.jmxNameToModelName(LogStoreConstants.MODEL_TO_JMX_PARTICIPANT_NAMES, attribute.getName());
if (modelName != null) {
ModelNode aNode = model.get(modelName);
Object value = attribute.getValue();
if (aNode != null)
aNode.set(value == null ? "" : value.toString());
}
}
// Replace the model
resource.writeModel(model);
} catch (Exception e) {
throw new OperationFailedException("JMX error: " + e.getMessage());
}
context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
}
use of javax.management.AttributeList in project wildfly by wildfly.
the class LogStoreProbeHandler method getMBeanValues.
private Map<String, String> getMBeanValues(MBeanServerConnection cnx, ObjectName on, String... attributeNames) throws InstanceNotFoundException, IOException, ReflectionException, IntrospectionException {
if (attributeNames == null) {
MBeanInfo info = cnx.getMBeanInfo(on);
MBeanAttributeInfo[] attributeArray = info.getAttributes();
int i = 0;
attributeNames = new String[attributeArray.length];
for (MBeanAttributeInfo ai : attributeArray) attributeNames[i++] = ai.getName();
}
AttributeList attributes = cnx.getAttributes(on, attributeNames);
Map<String, String> values = new HashMap<String, String>();
for (javax.management.Attribute attribute : attributes.asList()) {
Object value = attribute.getValue();
values.put(attribute.getName(), value == null ? "" : value.toString());
}
return values;
}
Aggregations