Search in sources :

Example 41 with OperationStepHandler

use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.

the class IdentityStoreRemoveStepHandler method updateModel.

@Override
protected void updateModel(OperationContext context, ModelNode operation) throws OperationFailedException {
    checkIfLastIdentityStore(context);
    super.updateModel(context, operation);
    context.addStep(new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            PathAddress address = context.getCurrentAddress();
            String configurationName = address.getElement(address.size() - 2).getValue();
            String partitionManagerName = address.getElement(address.size() - 3).getValue();
            String identityStoreName = address.getLastElement().getValue();
            context.removeService(PartitionManagerService.createIdentityStoreServiceName(partitionManagerName, configurationName, identityStoreName));
            context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER);
        }
    }, OperationContext.Stage.RUNTIME);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) PathAddress(org.jboss.as.controller.PathAddress) OperationFailedException(org.jboss.as.controller.OperationFailedException) ModelNode(org.jboss.dmr.ModelNode)

Example 42 with OperationStepHandler

use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.

the class TransactionSubsystemRootResourceDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    // Register all attributes except of the mutual ones
    Set<AttributeDefinition> attributesWithoutMutuals = new HashSet<>(Arrays.asList(attributes));
    attributesWithoutMutuals.remove(USE_JOURNAL_STORE);
    attributesWithoutMutuals.remove(USE_JDBC_STORE);
    attributesWithoutMutuals.remove(STATISTICS_ENABLED);
    attributesWithoutMutuals.remove(DEFAULT_TIMEOUT);
    // Remove these as it also needs special write handler
    attributesWithoutMutuals.remove(JDBC_STORE_DATASOURCE);
    attributesWithoutMutuals.remove(PROCESS_ID_UUID);
    attributesWithoutMutuals.remove(PROCESS_ID_SOCKET_BINDING);
    attributesWithoutMutuals.remove(PROCESS_ID_SOCKET_MAX_PORTS);
    OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(attributesWithoutMutuals);
    for (final AttributeDefinition def : attributesWithoutMutuals) {
        resourceRegistration.registerReadWriteAttribute(def, null, writeHandler);
    }
    // Register mutual object store attributes
    OperationStepHandler mutualWriteHandler = new ObjectStoreMutualWriteHandler(USE_JOURNAL_STORE, USE_JDBC_STORE);
    resourceRegistration.registerReadWriteAttribute(USE_JOURNAL_STORE, null, mutualWriteHandler);
    resourceRegistration.registerReadWriteAttribute(USE_JDBC_STORE, null, mutualWriteHandler);
    //Register default-timeout attribute
    resourceRegistration.registerReadWriteAttribute(DEFAULT_TIMEOUT, null, new DefaultTimeoutHandler(DEFAULT_TIMEOUT));
    // Register jdbc-store-datasource attribute
    resourceRegistration.registerReadWriteAttribute(JDBC_STORE_DATASOURCE, null, new JdbcStoreDatasourceWriteHandler(JDBC_STORE_DATASOURCE));
    // Register mutual object store attributes
    OperationStepHandler mutualProcessIdWriteHandler = new ProcessIdWriteHandler(PROCESS_ID_UUID, PROCESS_ID_SOCKET_BINDING, PROCESS_ID_SOCKET_MAX_PORTS);
    resourceRegistration.registerReadWriteAttribute(PROCESS_ID_UUID, null, mutualProcessIdWriteHandler);
    resourceRegistration.registerReadWriteAttribute(PROCESS_ID_SOCKET_BINDING, null, mutualProcessIdWriteHandler);
    resourceRegistration.registerReadWriteAttribute(PROCESS_ID_SOCKET_MAX_PORTS, null, mutualProcessIdWriteHandler);
    //Register statistics-enabled attribute
    resourceRegistration.registerReadWriteAttribute(STATISTICS_ENABLED, null, new StatisticsEnabledHandler(STATISTICS_ENABLED));
    AliasedHandler esh = new AliasedHandler(STATISTICS_ENABLED.getName());
    resourceRegistration.registerReadWriteAttribute(ENABLE_STATISTICS, esh, esh);
    AliasedHandler hsh = new AliasedHandler(USE_JOURNAL_STORE.getName());
    resourceRegistration.registerReadWriteAttribute(USE_HORNETQ_STORE, hsh, hsh);
    AliasedHandler hseh = new AliasedHandler(JOURNAL_STORE_ENABLE_ASYNC_IO.getName());
    resourceRegistration.registerReadWriteAttribute(HORNETQ_STORE_ENABLE_ASYNC_IO, hseh, hseh);
    if (registerRuntimeOnly) {
        TxStatsHandler.INSTANCE.registerMetrics(resourceRegistration);
    }
}
Also used : OperationStepHandler(org.jboss.as.controller.OperationStepHandler) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler) HashSet(java.util.HashSet)

Example 43 with OperationStepHandler

use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.

the class LogStoreParticipantDeleteHandler method refreshParticipant.

void refreshParticipant(OperationContext context) {
    final ModelNode operation = Util.createEmptyOperation("refresh-log-store", context.getCurrentAddress().getParent().getParent());
    context.addStep(operation, new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            probeHandler.execute(context, operation);
        }
    }, OperationContext.Stage.MODEL);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) OperationFailedException(org.jboss.as.controller.OperationFailedException) ModelNode(org.jboss.dmr.ModelNode)

Example 44 with OperationStepHandler

use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.

the class ListenerResourceDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    // DO NOT call super, as we need non-standard handling for enabled
    Collection<AttributeDefinition> ads = getAttributes();
    // we include ENABLED in this set, but it doesn't matter we don't register rrh for it
    OperationStepHandler rrh = new ReloadRequiredWriteAttributeHandler(ads);
    OperationStepHandler enh = new EnabledAttributeHandler();
    for (AttributeDefinition ad : ads) {
        OperationStepHandler osh = ad == ENABLED ? enh : rrh;
        resourceRegistration.registerReadWriteAttribute(ad, null, osh);
    }
    for (ConnectorStat attr : ConnectorStat.values()) {
        resourceRegistration.registerMetric(attr.definition, ReadStatisticHandler.INSTANCE);
    }
}
Also used : OperationStepHandler(org.jboss.as.controller.OperationStepHandler) OptionAttributeDefinition(org.wildfly.extension.io.OptionAttributeDefinition) StringListAttributeDefinition(org.jboss.as.controller.StringListAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)

Example 45 with OperationStepHandler

use of org.jboss.as.controller.OperationStepHandler 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

OperationStepHandler (org.jboss.as.controller.OperationStepHandler)48 ModelNode (org.jboss.dmr.ModelNode)39 OperationContext (org.jboss.as.controller.OperationContext)37 OperationFailedException (org.jboss.as.controller.OperationFailedException)31 PathAddress (org.jboss.as.controller.PathAddress)18 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)12 Resource (org.jboss.as.controller.registry.Resource)11 PathElement (org.jboss.as.controller.PathElement)8 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)8 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)7 ServiceController (org.jboss.msc.service.ServiceController)7 ServiceName (org.jboss.msc.service.ServiceName)7 Map (java.util.Map)5 ArrayList (java.util.ArrayList)4 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)4 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)4 Collection (java.util.Collection)3 LinkedHashMap (java.util.LinkedHashMap)3 List (java.util.List)3 ResourceDescriptor (org.jboss.as.clustering.controller.ResourceDescriptor)3