Search in sources :

Example 1 with ServiceValueExecutorRegistry

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

the class CacheContainerResourceDefinition method register.

@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
    ManagementResourceRegistration registration = parent.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class).addAttributes(ListAttribute.class).addIgnoredAttributes(ExecutorAttribute.class).addIgnoredAttributes(EnumSet.complementOf(EnumSet.of(DeprecatedAttribute.MODULE))).addAttributeTranslation(DeprecatedAttribute.MODULE, new ListAttributeTranslation(ListAttribute.MODULES)).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(EnumSet.complementOf(EnumSet.of(ThreadPoolResourceDefinition.CLIENT))).addRequiredChildren(ScheduledThreadPoolResourceDefinition.class).addRequiredSingletonChildren(NoTransportResourceDefinition.PATH).setResourceTransformation(CacheContainerResource::new);
    ServiceValueExecutorRegistry<EmbeddedCacheManager> managerExecutors = new ServiceValueExecutorRegistry<>();
    ServiceValueExecutorRegistry<Cache<?, ?>> cacheExecutors = new ServiceValueExecutorRegistry<>();
    ResourceServiceHandler handler = new CacheContainerServiceHandler(managerExecutors, cacheExecutors);
    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(), ListAttribute.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(), ListAttribute.ALIASES, value);
            context.addStep(operation, ListOperations.LIST_REMOVE_HANDLER, context.getCurrentStage());
        }
    };
    registration.registerOperationHandler(ALIAS_REMOVE, removeAliasHandler);
    if (registration.isRuntimeOnlyRegistrationValid()) {
        new MetricHandler<>(new CacheContainerMetricExecutor(managerExecutors), CacheContainerMetric.class).register(registration);
        new CacheRuntimeResourceDefinition(cacheExecutors).register(registration);
    }
    new JGroupsTransportResourceDefinition().register(registration);
    new NoTransportResourceDefinition().register(registration);
    for (ThreadPoolResourceDefinition pool : EnumSet.complementOf(EnumSet.of(ThreadPoolResourceDefinition.CLIENT))) {
        pool.register(registration);
    }
    for (ScheduledThreadPoolResourceDefinition pool : EnumSet.allOf(ScheduledThreadPoolResourceDefinition.class)) {
        pool.register(registration);
    }
    new LocalCacheResourceDefinition(cacheExecutors).register(registration);
    new InvalidationCacheResourceDefinition(cacheExecutors).register(registration);
    new ReplicatedCacheResourceDefinition(cacheExecutors).register(registration);
    new DistributedCacheResourceDefinition(cacheExecutors).register(registration);
    new ScatteredCacheResourceDefinition(cacheExecutors).register(registration);
    return registration;
}
Also used : 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) UnaryOperator(java.util.function.UnaryOperator) Cache(org.infinispan.Cache) CapabilityReference(org.jboss.as.clustering.controller.CapabilityReference) AttributeAccess(org.jboss.as.controller.registry.AttributeAccess) OperationContext(org.jboss.as.controller.OperationContext) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) InfinispanLogger(org.jboss.as.clustering.infinispan.InfinispanLogger) InfinispanRequirement(org.wildfly.clustering.infinispan.spi.InfinispanRequirement) Map(java.util.Map) 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) UnaryRequirement(org.wildfly.clustering.service.UnaryRequirement) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement) ManagementResourceRegistration(org.jboss.as.clustering.controller.ManagementResourceRegistration) OperationDefinition(org.jboss.as.controller.OperationDefinition) EnumMap(java.util.EnumMap) InfinispanMarshallerFactory(org.wildfly.clustering.infinispan.spi.marshalling.InfinispanMarshallerFactory) EnumValidator(org.jboss.as.clustering.controller.validation.EnumValidator) ListOperations(org.jboss.as.controller.operations.global.ListOperations) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor) PathElement(org.jboss.as.controller.PathElement) ServiceValueExecutorRegistry(org.jboss.as.clustering.controller.ServiceValueExecutorRegistry) 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) ListAttributeTranslation(org.jboss.as.clustering.controller.ListAttributeTranslation) ModelNode(org.jboss.dmr.ModelNode) MetricHandler(org.jboss.as.clustering.controller.MetricHandler) CapabilityProvider(org.jboss.as.clustering.controller.CapabilityProvider) ModuleIdentifierValidatorBuilder(org.jboss.as.clustering.controller.validation.ModuleIdentifierValidatorBuilder) ModelType(org.jboss.dmr.ModelType) ListAttributeTranslation(org.jboss.as.clustering.controller.ListAttributeTranslation) ManagementResourceRegistration(org.jboss.as.clustering.controller.ManagementResourceRegistration) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) ServiceValueExecutorRegistry(org.jboss.as.clustering.controller.ServiceValueExecutorRegistry) ModelNode(org.jboss.dmr.ModelNode) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor) Cache(org.infinispan.Cache)

Example 2 with ServiceValueExecutorRegistry

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

the class RemoteCacheContainerResourceDefinition method register.

@SuppressWarnings("deprecation")
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parentRegistration) {
    ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class).addAttributes(ListAttribute.class).addIgnoredAttributes(EnumSet.complementOf(EnumSet.of(DeprecatedAttribute.MODULE))).addAttributeTranslation(DeprecatedAttribute.MODULE, new ListAttributeTranslation(ListAttribute.MODULES)).addCapabilities(Capability.class).addRequiredChildren(ConnectionPoolResourceDefinition.PATH, ThreadPoolResourceDefinition.CLIENT.getPathElement(), SecurityResourceDefinition.PATH, RemoteTransactionResourceDefinition.PATH).addRequiredSingletonChildren(NoNearCacheResourceDefinition.PATH).setResourceTransformation(RemoteCacheContainerResource::new);
    ServiceValueExecutorRegistry<RemoteCacheContainer> executors = new ServiceValueExecutorRegistry<>();
    ResourceServiceHandler handler = new RemoteCacheContainerServiceHandler(this, executors);
    new SimpleResourceRegistration(descriptor, handler).register(registration);
    new ConnectionPoolResourceDefinition().register(registration);
    new RemoteClusterResourceDefinition(this, executors).register(registration);
    new SecurityResourceDefinition().register(registration);
    new RemoteTransactionResourceDefinition().register(registration);
    new InvalidationNearCacheResourceDefinition().register(registration);
    new NoNearCacheResourceDefinition().register(registration);
    ThreadPoolResourceDefinition.CLIENT.register(registration);
    if (registration.isRuntimeOnlyRegistrationValid()) {
        new MetricHandler<>(new RemoteCacheContainerMetricExecutor(executors), RemoteCacheContainerMetric.class).register(registration);
        new RemoteCacheResourceDefinition(executors).register(registration);
    }
    return registration;
}
Also used : UnaryRequirementCapability(org.jboss.as.clustering.controller.UnaryRequirementCapability) ListAttributeTranslation(org.jboss.as.clustering.controller.ListAttributeTranslation) ManagementResourceRegistration(org.jboss.as.clustering.controller.ManagementResourceRegistration) RemoteCacheContainer(org.wildfly.clustering.infinispan.client.RemoteCacheContainer) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) ServiceValueExecutorRegistry(org.jboss.as.clustering.controller.ServiceValueExecutorRegistry) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Example 3 with ServiceValueExecutorRegistry

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

the class SingletonPolicyResourceDefinition method register.

@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
    ManagementResourceRegistration registration = parent.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class).addCapabilities(Capability.class).addRequiredSingletonChildren(SimpleElectionPolicyResourceDefinition.PATH).setResourceTransformation(SingletonPolicyResource::new);
    ServiceValueExecutorRegistry<Singleton> executors = new ServiceValueExecutorRegistry<>();
    ResourceServiceHandler handler = new SingletonPolicyServiceHandler(executors);
    new SimpleResourceRegistration(descriptor, handler).register(registration);
    new RandomElectionPolicyResourceDefinition().register(registration);
    new SimpleElectionPolicyResourceDefinition().register(registration);
    if (registration.isRuntimeOnlyRegistrationValid()) {
        new SingletonDeploymentResourceDefinition(executors).register(registration);
        new SingletonServiceResourceDefinition(executors).register(registration);
    }
    return registration;
}
Also used : ManagementResourceRegistration(org.jboss.as.clustering.controller.ManagementResourceRegistration) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) Singleton(org.wildfly.clustering.singleton.Singleton) ServiceValueExecutorRegistry(org.jboss.as.clustering.controller.ServiceValueExecutorRegistry) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Example 4 with ServiceValueExecutorRegistry

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

the class ChannelResourceDefinition method register.

@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
    ManagementResourceRegistration registration = parent.registerSubModel(this);
    ServiceValueExecutorRegistry<JChannel> executors = new ServiceValueExecutorRegistry<>();
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class).addCapabilities(Capability.class).addCapabilities(CLUSTERING_CAPABILITIES.values()).addAlias(DeprecatedAttribute.STATS_ENABLED, Attribute.STATISTICS_ENABLED).setAddOperationTransformation(new AddOperationTransformation()).addRuntimeResourceRegistration(new ChannelRuntimeResourceRegistration(executors));
    ResourceServiceHandler handler = new ChannelServiceHandler(executors);
    new SimpleResourceRegistration(descriptor, handler).register(registration);
    if (registration.isRuntimeOnlyRegistrationValid()) {
        new MetricHandler<>(new ChannelMetricExecutor(executors), ChannelMetric.class).register(registration);
    }
    new ForkResourceDefinition(executors).register(registration);
    return registration;
}
Also used : JChannel(org.jgroups.JChannel) ManagementResourceRegistration(org.jboss.as.clustering.controller.ManagementResourceRegistration) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) ServiceValueExecutorRegistry(org.jboss.as.clustering.controller.ServiceValueExecutorRegistry) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Example 5 with ServiceValueExecutorRegistry

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

the class ModClusterSubsystemResourceDefinition method register.

@SuppressWarnings("deprecation")
@Override
public void register(SubsystemRegistration parent) {
    ManagementResourceRegistration registration = parent.registerSubsystemModel(this);
    registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver());
    ServiceValueExecutorRegistry<ModClusterServiceMBean> registry = new ServiceValueExecutorRegistry<>();
    ResourceServiceHandler handler = new ModClusterSubsystemServiceHandler(registry);
    new SimpleResourceRegistration(descriptor, handler).register(registration);
    new ProxyConfigurationResourceDefinition(registry).register(registration);
    // Deprecated legacy operations which are exposed at the wrong location
    if (parent.isRuntimeOnlyRegistrationValid()) {
        new LegacyProxyHandler(registry).register(registration);
    }
}
Also used : ModClusterServiceMBean(org.jboss.modcluster.ModClusterServiceMBean) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) ManagementResourceRegistration(org.jboss.as.clustering.controller.ManagementResourceRegistration) ServiceValueExecutorRegistry(org.jboss.as.clustering.controller.ServiceValueExecutorRegistry) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Aggregations

ManagementResourceRegistration (org.jboss.as.clustering.controller.ManagementResourceRegistration)5 ResourceDescriptor (org.jboss.as.clustering.controller.ResourceDescriptor)5 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)5 ServiceValueExecutorRegistry (org.jboss.as.clustering.controller.ServiceValueExecutorRegistry)5 SimpleResourceRegistration (org.jboss.as.clustering.controller.SimpleResourceRegistration)5 ListAttributeTranslation (org.jboss.as.clustering.controller.ListAttributeTranslation)2 UnaryRequirementCapability (org.jboss.as.clustering.controller.UnaryRequirementCapability)2 EnumMap (java.util.EnumMap)1 EnumSet (java.util.EnumSet)1 Map (java.util.Map)1 UnaryOperator (java.util.function.UnaryOperator)1 Cache (org.infinispan.Cache)1 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)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 EnumValidator (org.jboss.as.clustering.controller.validation.EnumValidator)1 ModuleIdentifierValidatorBuilder (org.jboss.as.clustering.controller.validation.ModuleIdentifierValidatorBuilder)1