Search in sources :

Example 51 with OperationStepHandler

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

the class BroadcastGroupAdd method execute.

@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    CommonAttributes.renameChannelToCluster(operation);
    if (!isLegacyCall) {
        ModelNode op = operation.clone();
        PathAddress target = context.getCurrentAddress().getParent();
        OperationStepHandler addHandler;
        if (operation.hasDefined(JGROUPS_CLUSTER.getName())) {
            target = target.append(CommonAttributes.JGROUPS_BROADCAST_GROUP, context.getCurrentAddressValue());
            addHandler = JGroupsBroadcastGroupAdd.LEGACY_INSTANCE;
        } else {
            target = target.append(CommonAttributes.SOCKET_BROADCAST_GROUP, context.getCurrentAddressValue());
            addHandler = SocketBroadcastGroupAdd.LEGACY_INSTANCE;
        }
        op.get(OP_ADDR).set(target.toModelNode());
        context.addStep(op, addHandler, OperationContext.Stage.MODEL, true);
    }
    super.execute(context, operation);
}
Also used : OperationStepHandler(org.jboss.as.controller.OperationStepHandler) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 52 with OperationStepHandler

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

the class GroupingHandlerAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    ServiceRegistry registry = context.getServiceRegistry(true);
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    ServiceController<?> service = registry.getService(serviceName);
    if (service != null) {
        final ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
        if (server.getGroupingHandler() != null) {
            throw new OperationFailedException(MessagingLogger.ROOT_LOGGER.childResourceAlreadyExists(CommonAttributes.GROUPING_HANDLER));
        }
        // the groupingHandler is added as a child of the server resource. Requires a reload to restart the server with the grouping-handler
        if (context.isNormalServer()) {
            context.addStep(new OperationStepHandler() {

                @Override
                public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
                    context.reloadRequired();
                    context.completeStep(OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER);
                }
            }, OperationContext.Stage.RUNTIME);
        }
    }
// else the initial subsystem install is not complete and the grouping handler will be added in ServerAdd
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ServiceName(org.jboss.msc.service.ServiceName) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) OperationFailedException(org.jboss.as.controller.OperationFailedException) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode)

Example 53 with OperationStepHandler

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

the class BroadcastGroupRemove method execute.

@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    if (!isLegacyCall) {
        ModelNode op = operation.clone();
        PathAddress target = context.getCurrentAddress().getParent();
        OperationStepHandler removeHandler;
        try {
            context.readResourceFromRoot(target.append(CommonAttributes.JGROUPS_BROADCAST_GROUP, context.getCurrentAddressValue()), false);
            target = target.append(CommonAttributes.JGROUPS_BROADCAST_GROUP, context.getCurrentAddressValue());
            removeHandler = JGroupsBroadcastGroupRemove.LEGACY_INSTANCE;
        } catch (Resource.NoSuchResourceException ex) {
            target = target.append(CommonAttributes.SOCKET_BROADCAST_GROUP, context.getCurrentAddressValue());
            removeHandler = SocketBroadcastGroupRemove.LEGACY_INSTANCE;
        }
        op.get(OP_ADDR).set(target.toModelNode());
        context.addStep(op, removeHandler, OperationContext.Stage.MODEL, true);
    }
    super.execute(context, operation);
}
Also used : OperationStepHandler(org.jboss.as.controller.OperationStepHandler) PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode)

Example 54 with OperationStepHandler

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

the class DiscoveryGroupAdd method execute.

@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    CommonAttributes.renameChannelToCluster(operation);
    if (!isLegacyCall) {
        ModelNode op = operation.clone();
        PathAddress target = context.getCurrentAddress().getParent();
        OperationStepHandler addHandler;
        if (operation.hasDefined(JGROUPS_CLUSTER.getName())) {
            target = target.append(CommonAttributes.JGROUPS_DISCOVERY_GROUP, context.getCurrentAddressValue());
            addHandler = JGroupsDiscoveryGroupAdd.LEGACY_INSTANCE;
        } else {
            target = target.append(CommonAttributes.SOCKET_DISCOVERY_GROUP, context.getCurrentAddressValue());
            addHandler = SocketDiscoveryGroupAdd.LEGACY_INSTANCE;
        }
        op.get(OP_ADDR).set(target.toModelNode());
        context.addStep(op, addHandler, OperationContext.Stage.MODEL, true);
    }
    super.execute(context, operation);
}
Also used : OperationStepHandler(org.jboss.as.controller.OperationStepHandler) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 55 with OperationStepHandler

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

the class JGroupsBroadcastGroupAdd method populateModel.

@Override
protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    super.populateModel(context, operation, resource);
    final ModelNode connectorRefs = resource.getModel().require(CONNECTOR_REFS.getName());
    if (connectorRefs.isDefined()) {
        context.addStep(new OperationStepHandler() {

            @Override
            public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
                BroadcastGroupWriteAttributeHandler.JGROUP_INSTANCE.validateConnectors(context, operation, connectorRefs);
            }
        }, 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)

Aggregations

OperationStepHandler (org.jboss.as.controller.OperationStepHandler)76 ModelNode (org.jboss.dmr.ModelNode)57 OperationContext (org.jboss.as.controller.OperationContext)45 OperationFailedException (org.jboss.as.controller.OperationFailedException)40 PathAddress (org.jboss.as.controller.PathAddress)31 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)23 Resource (org.jboss.as.controller.registry.Resource)19 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)17 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)14 PathElement (org.jboss.as.controller.PathElement)9 ServiceController (org.jboss.msc.service.ServiceController)8 ServiceName (org.jboss.msc.service.ServiceName)8 Map (java.util.Map)7 ImmutableManagementResourceRegistration (org.jboss.as.controller.registry.ImmutableManagementResourceRegistration)7 ArrayList (java.util.ArrayList)6 List (java.util.List)5 ObjectTypeAttributeDefinition (org.jboss.as.controller.ObjectTypeAttributeDefinition)5 PropertiesAttributeDefinition (org.jboss.as.controller.PropertiesAttributeDefinition)5 SimpleOperationDefinitionBuilder (org.jboss.as.controller.SimpleOperationDefinitionBuilder)5 ManagementResourceRegistration (org.jboss.as.clustering.controller.ManagementResourceRegistration)4