Search in sources :

Example 1 with FieldType

use of org.jboss.as.clustering.jgroups.subsystem.ProtocolMetricsHandler.FieldType 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();
}
Also used : SimpleResourceDescriptionResolver(org.jboss.as.clustering.controller.descriptions.SimpleResourceDescriptionResolver) ResourceBuilder(org.jboss.as.controller.ResourceBuilder) Attribute(org.jboss.as.clustering.jgroups.subsystem.ProtocolMetricsHandler.Attribute) Map(java.util.Map) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) FieldType(org.jboss.as.clustering.jgroups.subsystem.ProtocolMetricsHandler.FieldType)

Example 2 with FieldType

use of org.jboss.as.clustering.jgroups.subsystem.ProtocolMetricsHandler.FieldType 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);
    }
}
Also used : Locale(java.util.Locale) Attribute(org.jboss.as.clustering.jgroups.subsystem.ProtocolMetricsHandler.Attribute) HashMap(java.util.HashMap) OverrideDescriptionProvider(org.jboss.as.controller.descriptions.OverrideDescriptionProvider) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) FieldType(org.jboss.as.clustering.jgroups.subsystem.ProtocolMetricsHandler.FieldType) ModelNode(org.jboss.dmr.ModelNode) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder)

Aggregations

Attribute (org.jboss.as.clustering.jgroups.subsystem.ProtocolMetricsHandler.Attribute)2 FieldType (org.jboss.as.clustering.jgroups.subsystem.ProtocolMetricsHandler.FieldType)2 SimpleAttributeDefinitionBuilder (org.jboss.as.controller.SimpleAttributeDefinitionBuilder)2 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 Map (java.util.Map)1 SimpleResourceDescriptionResolver (org.jboss.as.clustering.controller.descriptions.SimpleResourceDescriptionResolver)1 ResourceBuilder (org.jboss.as.controller.ResourceBuilder)1 OverrideDescriptionProvider (org.jboss.as.controller.descriptions.OverrideDescriptionProvider)1 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)1 ModelNode (org.jboss.dmr.ModelNode)1