Search in sources :

Example 1 with MetricHandler

use of org.jboss.as.clustering.controller.MetricHandler in project wildfly by wildfly.

the class CacheContainerResourceDefinition method register.

@Override
public void register(ManagementResourceRegistration parentRegistration) {
    ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class).addAttributes(ExecutorAttribute.class).addAttributes(DeprecatedAttribute.class).addCapabilities(Capability.class).addCapabilities(model -> model.hasDefined(Attribute.DEFAULT_CACHE.getName()), DEFAULT_CAPABILITIES.values()).addCapabilities(model -> model.hasDefined(Attribute.DEFAULT_CACHE.getName()), DEFAULT_CLUSTERING_CAPABILITIES.values()).addRequiredChildren(ThreadPoolResourceDefinition.class).addRequiredChildren(ScheduledThreadPoolResourceDefinition.class).addRequiredSingletonChildren(NoTransportResourceDefinition.PATH);
    ResourceServiceHandler handler = new CacheContainerServiceHandler();
    new SimpleResourceRegistration(descriptor, handler).register(registration);
    // Translate legacy add-alias operation to list-add operation
    OperationStepHandler addAliasHandler = new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode legacyOperation) {
            String value = legacyOperation.get(ALIAS.getName()).asString();
            ModelNode operation = Operations.createListAddOperation(context.getCurrentAddress(), Attribute.ALIASES, value);
            context.addStep(operation, ListOperations.LIST_ADD_HANDLER, context.getCurrentStage());
        }
    };
    registration.registerOperationHandler(ALIAS_ADD, addAliasHandler);
    // Translate legacy remove-alias operation to list-remove operation
    OperationStepHandler removeAliasHandler = new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode legacyOperation) throws OperationFailedException {
            String value = legacyOperation.get(ALIAS.getName()).asString();
            ModelNode operation = Operations.createListRemoveOperation(context.getCurrentAddress(), Attribute.ALIASES, value);
            context.addStep(operation, ListOperations.LIST_REMOVE_HANDLER, context.getCurrentStage());
        }
    };
    registration.registerOperationHandler(ALIAS_REMOVE, removeAliasHandler);
    if (this.allowRuntimeOnlyRegistration) {
        new MetricHandler<>(new CacheContainerMetricExecutor(), CacheContainerMetric.class).register(registration);
    }
    new JGroupsTransportResourceDefinition().register(registration);
    new NoTransportResourceDefinition().register(registration);
    EnumSet.allOf(ThreadPoolResourceDefinition.class).forEach(p -> p.register(registration));
    EnumSet.allOf(ScheduledThreadPoolResourceDefinition.class).forEach(p -> p.register(registration));
    new LocalCacheResourceDefinition(this.pathManager, this.allowRuntimeOnlyRegistration).register(registration);
    new InvalidationCacheResourceDefinition(this.pathManager, this.allowRuntimeOnlyRegistration).register(registration);
    new ReplicatedCacheResourceDefinition(this.pathManager, this.allowRuntimeOnlyRegistration).register(registration);
    new DistributedCacheResourceDefinition(this.pathManager, this.allowRuntimeOnlyRegistration).register(registration);
}
Also used : DiscardAttributeChecker(org.jboss.as.controller.transform.description.DiscardAttributeChecker) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) Operations(org.jboss.as.clustering.controller.Operations) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) StringListAttributeDefinition(org.jboss.as.controller.StringListAttributeDefinition) CapabilityReference(org.jboss.as.clustering.controller.CapabilityReference) AttributeAccess(org.jboss.as.controller.registry.AttributeAccess) EnumValidatorBuilder(org.jboss.as.clustering.controller.validation.EnumValidatorBuilder) OperationContext(org.jboss.as.controller.OperationContext) RejectAttributeChecker(org.jboss.as.controller.transform.description.RejectAttributeChecker) OperationTransformer(org.jboss.as.clustering.controller.transform.OperationTransformer) Util(org.jboss.as.controller.operations.common.Util) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) InfinispanRequirement(org.wildfly.clustering.infinispan.spi.InfinispanRequirement) Map(java.util.Map) ModelVersion(org.jboss.as.controller.ModelVersion) ChildResourceDefinition(org.jboss.as.clustering.controller.ChildResourceDefinition) SimpleOperationDefinitionBuilder(org.jboss.as.controller.SimpleOperationDefinitionBuilder) ModelDescriptionConstants(org.jboss.as.controller.descriptions.ModelDescriptionConstants) EnumSet(java.util.EnumSet) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) CapabilityReferenceRecorder(org.jboss.as.controller.CapabilityReferenceRecorder) UnaryRequirement(org.wildfly.clustering.service.UnaryRequirement) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement) AttributeParsers(org.jboss.as.clustering.controller.AttributeParsers) OperationDefinition(org.jboss.as.controller.OperationDefinition) EnumMap(java.util.EnumMap) PathAddress(org.jboss.as.controller.PathAddress) SimpleOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleOperationTransformer) ListOperations(org.jboss.as.controller.operations.global.ListOperations) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor) PathElement(org.jboss.as.controller.PathElement) PathManager(org.jboss.as.controller.services.path.PathManager) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) UnaryRequirementCapability(org.jboss.as.clustering.controller.UnaryRequirementCapability) OperationFailedException(org.jboss.as.controller.OperationFailedException) InfinispanCacheRequirement(org.wildfly.clustering.infinispan.spi.InfinispanCacheRequirement) ModelNode(org.jboss.dmr.ModelNode) MetricHandler(org.jboss.as.clustering.controller.MetricHandler) ParameterValidatorBuilder(org.jboss.as.clustering.controller.validation.ParameterValidatorBuilder) CapabilityProvider(org.jboss.as.clustering.controller.CapabilityProvider) ModuleIdentifierValidatorBuilder(org.jboss.as.clustering.controller.validation.ModuleIdentifierValidatorBuilder) ModelType(org.jboss.dmr.ModelType) OperationContext(org.jboss.as.controller.OperationContext) UnaryRequirementCapability(org.jboss.as.clustering.controller.UnaryRequirementCapability) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) ModelNode(org.jboss.dmr.ModelNode) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Aggregations

EnumMap (java.util.EnumMap)1 EnumSet (java.util.EnumSet)1 Map (java.util.Map)1 AttributeParsers (org.jboss.as.clustering.controller.AttributeParsers)1 CapabilityProvider (org.jboss.as.clustering.controller.CapabilityProvider)1 CapabilityReference (org.jboss.as.clustering.controller.CapabilityReference)1 ChildResourceDefinition (org.jboss.as.clustering.controller.ChildResourceDefinition)1 MetricHandler (org.jboss.as.clustering.controller.MetricHandler)1 Operations (org.jboss.as.clustering.controller.Operations)1 ResourceDescriptor (org.jboss.as.clustering.controller.ResourceDescriptor)1 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)1 SimpleResourceRegistration (org.jboss.as.clustering.controller.SimpleResourceRegistration)1 UnaryRequirementCapability (org.jboss.as.clustering.controller.UnaryRequirementCapability)1 OperationTransformer (org.jboss.as.clustering.controller.transform.OperationTransformer)1 SimpleOperationTransformer (org.jboss.as.clustering.controller.transform.SimpleOperationTransformer)1 EnumValidatorBuilder (org.jboss.as.clustering.controller.validation.EnumValidatorBuilder)1 ModuleIdentifierValidatorBuilder (org.jboss.as.clustering.controller.validation.ModuleIdentifierValidatorBuilder)1 ParameterValidatorBuilder (org.jboss.as.clustering.controller.validation.ParameterValidatorBuilder)1 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)1 CapabilityReferenceRecorder (org.jboss.as.controller.CapabilityReferenceRecorder)1