Search in sources :

Example 6 with GroupAliasBuilderProvider

use of org.wildfly.clustering.spi.GroupAliasBuilderProvider in project wildfly by wildfly.

the class ForkServiceHandler method removeServices.

@Override
public void removeServices(OperationContext context, ModelNode model) throws OperationFailedException {
    PathAddress address = context.getCurrentAddress();
    String name = context.getCurrentAddressValue();
    String channel = address.getParent().getLastElement().getValue();
    for (GroupAliasBuilderProvider provider : ServiceLoader.load(GroupAliasBuilderProvider.class, GroupAliasBuilderProvider.class.getClassLoader())) {
        for (Builder<?> builder : provider.getBuilders(requirement -> CLUSTERING_CAPABILITIES.get(requirement).getServiceName(address), name, channel)) {
            context.removeService(builder.getServiceName());
        }
    }
    context.removeService(JGroupsBindingFactory.createChannelBinding(name).getBinderServiceName());
    context.removeService(JGroupsBindingFactory.createChannelFactoryBinding(name).getBinderServiceName());
    EnumSet.complementOf(EnumSet.of(FORK_CHANNEL_FACTORY)).forEach(capability -> context.removeService(capability.getServiceName(address)));
    super.removeServices(context, model);
}
Also used : GroupAliasBuilderProvider(org.wildfly.clustering.spi.GroupAliasBuilderProvider) PathAddress(org.jboss.as.controller.PathAddress)

Example 7 with GroupAliasBuilderProvider

use of org.wildfly.clustering.spi.GroupAliasBuilderProvider in project wildfly by wildfly.

the class JGroupsSubsystemServiceHandler method removeServices.

@Override
public void removeServices(OperationContext context, ModelNode model) throws OperationFailedException {
    PathAddress address = context.getCurrentAddress();
    ModelNodes.optionalString(DEFAULT_CHANNEL.resolveModelAttribute(context, model)).ifPresent(defaultChannel -> {
        for (GroupAliasBuilderProvider provider : ServiceLoader.load(GroupAliasBuilderProvider.class, GroupAliasBuilderProvider.class.getClassLoader())) {
            for (ServiceNameProvider builder : provider.getBuilders(requirement -> JGroupsSubsystemResourceDefinition.CLUSTERING_CAPABILITIES.get(requirement).getServiceName(address), null, defaultChannel)) {
                context.removeService(builder.getServiceName());
            }
        }
        if (!defaultChannel.equals(JndiNameFactory.DEFAULT_LOCAL_NAME)) {
            context.removeService(JGroupsBindingFactory.createChannelFactoryBinding(JndiNameFactory.DEFAULT_LOCAL_NAME).getBinderServiceName());
            context.removeService(JGroupsBindingFactory.createChannelBinding(JndiNameFactory.DEFAULT_LOCAL_NAME).getBinderServiceName());
        }
        CAPABILITIES.values().forEach(capability -> context.removeService(capability.getServiceName(address)));
    });
    context.removeService(ProtocolDefaultsBuilder.SERVICE_NAME);
}
Also used : GroupAliasBuilderProvider(org.wildfly.clustering.spi.GroupAliasBuilderProvider) PathAddress(org.jboss.as.controller.PathAddress) ServiceNameProvider(org.wildfly.clustering.service.ServiceNameProvider)

Example 8 with GroupAliasBuilderProvider

use of org.wildfly.clustering.spi.GroupAliasBuilderProvider in project wildfly by wildfly.

the class JGroupsSubsystemServiceHandler method installServices.

@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
    ROOT_LOGGER.activatingSubsystem(Version.printVersion());
    ServiceTarget target = context.getServiceTarget();
    PathAddress address = context.getCurrentAddress();
    // In this case, the Infinispan subsystem may have already registered default group capabilities
    if (context.getProcessType().isServer() && !context.isBooting()) {
        Resource rootResource = context.readResourceFromRoot(address.getParent());
        if (rootResource.hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "infinispan"))) {
            // Following restart, default group services will be installed by this handler, rather than the infinispan subsystem handler
            context.addStep((ctx, operation) -> {
                ctx.reloadRequired();
                ctx.completeStep(OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER);
            }, OperationContext.Stage.RUNTIME);
            return;
        }
    }
    new ProtocolDefaultsBuilder().build(target).install();
    ModelNodes.optionalString(DEFAULT_CHANNEL.resolveModelAttribute(context, model)).ifPresent(defaultChannel -> {
        CAPABILITIES.entrySet().forEach(entry -> new AliasServiceBuilder<>(entry.getValue().getServiceName(address), entry.getKey().getServiceName(context, defaultChannel), entry.getKey().getType()).build(target).install());
        if (!defaultChannel.equals(JndiNameFactory.DEFAULT_LOCAL_NAME)) {
            new BinderServiceBuilder<>(JGroupsBindingFactory.createChannelBinding(JndiNameFactory.DEFAULT_LOCAL_NAME), JGroupsRequirement.CHANNEL.getServiceName(context, defaultChannel), JGroupsRequirement.CHANNEL.getType()).build(target).install();
            new BinderServiceBuilder<>(JGroupsBindingFactory.createChannelFactoryBinding(JndiNameFactory.DEFAULT_LOCAL_NAME), JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, defaultChannel), JGroupsRequirement.CHANNEL_FACTORY.getType()).build(target).install();
        }
        for (GroupAliasBuilderProvider provider : ServiceLoader.load(GroupAliasBuilderProvider.class, GroupAliasBuilderProvider.class.getClassLoader())) {
            for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> CLUSTERING_CAPABILITIES.get(requirement).getServiceName(address), null, defaultChannel)) {
                builder.configure(context).build(target).install();
            }
        }
    });
}
Also used : BinderServiceBuilder(org.jboss.as.clustering.naming.BinderServiceBuilder) GroupAliasBuilderProvider(org.wildfly.clustering.spi.GroupAliasBuilderProvider) ServiceTarget(org.jboss.msc.service.ServiceTarget) PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource)

Example 9 with GroupAliasBuilderProvider

use of org.wildfly.clustering.spi.GroupAliasBuilderProvider in project wildfly by wildfly.

the class InfinispanSubsystemServiceHandler method installServices.

@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
    InfinispanLogger.ROOT_LOGGER.activatingSubsystem();
    PathAddress address = context.getCurrentAddress();
    ServiceTarget target = context.getServiceTarget();
    // Install local group services
    for (GroupBuilderProvider provider : ServiceLoader.load(LocalGroupBuilderProvider.class, LocalGroupBuilderProvider.class.getClassLoader())) {
        InfinispanLogger.ROOT_LOGGER.debugf("Installing %s for %s group", provider.getClass().getSimpleName(), LocalGroupBuilderProvider.LOCAL);
        for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> LOCAL_CLUSTERING_CAPABILITIES.get(requirement).getServiceName(address), LocalGroupBuilderProvider.LOCAL)) {
            builder.configure(context).build(target).install();
        }
    }
    // If JGroups subsystem is not available, install default group aliases to local group.
    if (!context.hasOptionalCapability(JGroupsRequirement.CHANNEL.getDefaultRequirement().getName(), null, null)) {
        for (GroupAliasBuilderProvider provider : ServiceLoader.load(GroupAliasBuilderProvider.class, GroupAliasBuilderProvider.class.getClassLoader())) {
            for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> CLUSTERING_CAPABILITIES.get(requirement).getServiceName(address), null, LocalGroupBuilderProvider.LOCAL)) {
                builder.configure(context).build(target).install();
            }
        }
    }
}
Also used : GroupAliasBuilderProvider(org.wildfly.clustering.spi.GroupAliasBuilderProvider) GroupBuilderProvider(org.wildfly.clustering.spi.GroupBuilderProvider) LocalGroupBuilderProvider(org.wildfly.clustering.spi.LocalGroupBuilderProvider) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) LocalGroupBuilderProvider(org.wildfly.clustering.spi.LocalGroupBuilderProvider)

Aggregations

PathAddress (org.jboss.as.controller.PathAddress)9 GroupAliasBuilderProvider (org.wildfly.clustering.spi.GroupAliasBuilderProvider)9 ServiceTarget (org.jboss.msc.service.ServiceTarget)7 ServiceNameProvider (org.wildfly.clustering.service.ServiceNameProvider)3 EnumSet (java.util.EnumSet)2 ServiceLoader (java.util.ServiceLoader)2 CapabilityServiceBuilder (org.jboss.as.clustering.controller.CapabilityServiceBuilder)2 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)2 BinderServiceBuilder (org.jboss.as.clustering.naming.BinderServiceBuilder)2 OperationContext (org.jboss.as.controller.OperationContext)2 OperationFailedException (org.jboss.as.controller.OperationFailedException)2 ModelNode (org.jboss.dmr.ModelNode)2 ServiceController (org.jboss.msc.service.ServiceController)2 LocalGroupBuilderProvider (org.wildfly.clustering.spi.LocalGroupBuilderProvider)2 JGroupsTransportResourceDefinition (org.jboss.as.clustering.infinispan.subsystem.JGroupsTransportResourceDefinition)1 CLUSTERING_CAPABILITIES (org.jboss.as.clustering.infinispan.subsystem.TransportResourceDefinition.CLUSTERING_CAPABILITIES)1 Resource (org.jboss.as.controller.registry.Resource)1 AliasServiceBuilder (org.wildfly.clustering.service.AliasServiceBuilder)1 GroupBuilderProvider (org.wildfly.clustering.spi.GroupBuilderProvider)1