use of org.jboss.as.clustering.jgroups.subsystem.ProtocolMetricsHandler.Attribute in project wildfly by wildfly.
the class ProtocolResourceRegistrationHandler method createProtocolResourceDefinition.
private ResourceDefinition createProtocolResourceDefinition(String protocolName, Class<? extends Protocol> protocolClass) {
SimpleResourceDescriptionResolver resolver = new SimpleResourceDescriptionResolver(protocolName, protocolClass.getSimpleName());
ResourceBuilder builder = ResourceBuilder.Factory.create(ProtocolResourceDefinition.pathElement(protocolName), resolver).setRuntime();
ProtocolMetricsHandler handler = new ProtocolMetricsHandler(this);
for (Map.Entry<String, Attribute> entry : ProtocolMetricsHandler.findProtocolAttributes(protocolClass).entrySet()) {
String name = entry.getKey();
Attribute attribute = entry.getValue();
FieldType type = FieldType.valueOf(attribute.getType());
resolver.addDescription(name, attribute.getDescription());
builder.addMetric(new SimpleAttributeDefinitionBuilder(name, type.getModelType(), true).setStorageRuntime().build(), handler);
}
return builder.build();
}
use of org.jboss.as.clustering.jgroups.subsystem.ProtocolMetricsHandler.Attribute in project wildfly by wildfly.
the class ForkProtocolResourceRegistrationHandler method execute.
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
ManagementResourceRegistration registration = context.getResourceRegistrationForUpdate();
String protocolName = context.getCurrentAddressValue();
String moduleName = ProtocolResourceDefinition.Attribute.MODULE.resolveModelAttribute(context, operation).asString();
Class<? extends Protocol> protocolClass = ProtocolResourceRegistrationHandler.findProtocolClass(context, protocolName, moduleName);
final Map<String, Attribute> attributes = ProtocolMetricsHandler.findProtocolAttributes(protocolClass);
OverrideDescriptionProvider provider = new OverrideDescriptionProvider() {
@Override
public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
Map<String, ModelNode> result = new HashMap<>();
for (Attribute attribute : attributes.values()) {
ModelNode value = new ModelNode();
value.get(ModelDescriptionConstants.DESCRIPTION).set(attribute.getDescription());
result.put(attribute.getName(), value);
}
return result;
}
@Override
public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
};
ManagementResourceRegistration protocolRegistration = registration.registerOverrideModel(protocolName, provider);
ProtocolMetricsHandler handler = new ProtocolMetricsHandler(this);
for (Attribute attribute : attributes.values()) {
String name = attribute.getName();
FieldType type = FieldType.valueOf(attribute.getType());
protocolRegistration.registerMetric(new SimpleAttributeDefinitionBuilder(name, type.getModelType()).setStorageRuntime().build(), handler);
}
}
Aggregations