Search in sources :

Example 1 with GroupBuilderProvider

use of org.wildfly.clustering.spi.GroupBuilderProvider 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)

Example 2 with GroupBuilderProvider

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

the class ChannelServiceHandler method installServices.

@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
    PathAddress address = context.getCurrentAddress();
    String name = context.getCurrentAddressValue();
    String stack = STACK.resolveModelAttribute(context, model).asString();
    ServiceTarget target = context.getServiceTarget();
    new ChannelClusterBuilder(JCHANNEL_CLUSTER.getServiceName(address), name).configure(context, model).build(target).install();
    new ChannelBuilder(JCHANNEL.getServiceName(address), name).statisticsEnabled(STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean()).configure(context, model).build(target).install();
    new AliasServiceBuilder<>(JCHANNEL_FACTORY.getServiceName(address), JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, stack), JGroupsRequirement.CHANNEL_FACTORY.getType()).build(target).install();
    new ForkChannelFactoryBuilder(FORK_CHANNEL_FACTORY.getServiceName(address), name).configure(context, model).build(target).install();
    new ModuleBuilder(JCHANNEL_MODULE.getServiceName(address), MODULE).configure(context, model).build(target).install();
    new BinderServiceBuilder<>(JGroupsBindingFactory.createChannelBinding(name), JGroupsRequirement.CHANNEL.getServiceName(context, name), JGroupsRequirement.CHANNEL.getType()).build(target).install();
    new BinderServiceBuilder<>(JGroupsBindingFactory.createChannelFactoryBinding(name), JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, name), JGroupsRequirement.CHANNEL_FACTORY.getType()).build(target).install();
    // Install group services for channel
    for (GroupBuilderProvider provider : ServiceLoader.load(DistributedGroupBuilderProvider.class, DistributedGroupBuilderProvider.class.getClassLoader())) {
        for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> CLUSTERING_CAPABILITIES.get(requirement).getServiceName(address), name)) {
            JGroupsLogger.ROOT_LOGGER.debugf("Installing %s for channel %s", builder.getServiceName(), name);
            builder.configure(context).build(target).install();
        }
    }
}
Also used : BinderServiceBuilder(org.jboss.as.clustering.naming.BinderServiceBuilder) GroupBuilderProvider(org.wildfly.clustering.spi.GroupBuilderProvider) DistributedGroupBuilderProvider(org.wildfly.clustering.spi.DistributedGroupBuilderProvider) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) ModuleBuilder(org.jboss.as.clustering.controller.ModuleBuilder) DistributedGroupBuilderProvider(org.wildfly.clustering.spi.DistributedGroupBuilderProvider) AliasServiceBuilder(org.wildfly.clustering.service.AliasServiceBuilder)

Example 3 with GroupBuilderProvider

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

the class ChannelServiceHandler method removeServices.

@Override
public void removeServices(OperationContext context, ModelNode model) throws OperationFailedException {
    PathAddress address = context.getCurrentAddress();
    String name = context.getCurrentAddressValue();
    EnumSet.allOf(Capability.class).forEach(capability -> context.removeService(capability.getServiceName(address)));
    context.removeService(JGroupsBindingFactory.createChannelBinding(name).getBinderServiceName());
    context.removeService(JGroupsBindingFactory.createChannelFactoryBinding(name).getBinderServiceName());
    for (GroupBuilderProvider provider : ServiceLoader.load(DistributedGroupBuilderProvider.class, DistributedGroupBuilderProvider.class.getClassLoader())) {
        for (ServiceNameProvider builder : provider.getBuilders(requirement -> CLUSTERING_CAPABILITIES.get(requirement).getServiceName(address), name)) {
            JGroupsLogger.ROOT_LOGGER.debugf("Removing %s for channel %s", builder.getServiceName(), name);
            context.removeService(builder.getServiceName());
        }
    }
}
Also used : Capability(org.jboss.as.clustering.jgroups.subsystem.ChannelResourceDefinition.Capability) GroupBuilderProvider(org.wildfly.clustering.spi.GroupBuilderProvider) DistributedGroupBuilderProvider(org.wildfly.clustering.spi.DistributedGroupBuilderProvider) PathAddress(org.jboss.as.controller.PathAddress) DistributedGroupBuilderProvider(org.wildfly.clustering.spi.DistributedGroupBuilderProvider) ServiceNameProvider(org.wildfly.clustering.service.ServiceNameProvider)

Example 4 with GroupBuilderProvider

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

the class EJB3RemoteServiceAdd method installRuntimeServices.

void installRuntimeServices(final OperationContext context, final ModelNode model) throws OperationFailedException {
    final String clientMappingsClusterName = EJB3RemoteResourceDefinition.CLIENT_MAPPINGS_CLUSTER_NAME.resolveModelAttribute(context, model).asString();
    final String connectorName = EJB3RemoteResourceDefinition.CONNECTOR_REF.resolveModelAttribute(context, model).asString();
    final ServiceName remotingServerInfoServiceName = RemotingConnectorBindingInfoService.serviceName(connectorName);
    final String threadPoolName = EJB3RemoteResourceDefinition.THREAD_POOL_NAME.resolveModelAttribute(context, model).asString();
    final boolean executeInWorker = EJB3RemoteResourceDefinition.EXECUTE_IN_WORKER.resolveModelAttribute(context, model).asBoolean();
    final ServiceTarget target = context.getServiceTarget();
    // Install the client-mapping service for the remoting connector
    new EJBRemotingConnectorClientMappingsEntryProviderService(clientMappingsClusterName, remotingServerInfoServiceName).configure(context).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
    new RegistryInstallerService(clientMappingsClusterName).configure(context).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
    // Handle case where no infinispan subsystem exists or does not define an ejb cache-container
    Resource rootResource = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS);
    PathElement infinispanPath = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "infinispan");
    if (!rootResource.hasChild(infinispanPath) || !rootResource.getChild(infinispanPath).hasChild(PathElement.pathElement("cache-container", clientMappingsClusterName))) {
        // Install services that would normally be installed by this container/cache
        CapabilityServiceSupport support = context.getCapabilityServiceSupport();
        for (GroupBuilderProvider provider : ServiceLoader.load(LocalGroupBuilderProvider.class, LocalGroupBuilderProvider.class.getClassLoader())) {
            for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> requirement.getServiceName(support, clientMappingsClusterName), clientMappingsClusterName)) {
                builder.configure(support).build(target).install();
            }
        }
        for (CacheBuilderProvider provider : ServiceLoader.load(LocalCacheBuilderProvider.class, LocalCacheBuilderProvider.class.getClassLoader())) {
            for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> requirement.getServiceName(support, clientMappingsClusterName, null), clientMappingsClusterName, null)) {
                builder.configure(support).build(target).install();
            }
        }
    }
    final OptionMap channelCreationOptions = this.getChannelCreationOptions(context);
    // Install the EJB remoting connector service which will listen for client connections on the remoting channel
    // TODO: Externalize (expose via management API if needed) the version and the marshalling strategy
    final EJBRemoteConnectorService ejbRemoteConnectorService = new EJBRemoteConnectorService(channelCreationOptions);
    ServiceBuilder<EJBRemoteConnectorService> builder = target.addService(EJBRemoteConnectorService.SERVICE_NAME, ejbRemoteConnectorService);
    builder.addDependency(RemotingServices.SUBSYSTEM_ENDPOINT, Endpoint.class, ejbRemoteConnectorService.getEndpointInjector()).addDependency(remotingServerInfoServiceName, RemotingConnectorBindingInfoService.RemotingConnectorInfo.class, ejbRemoteConnectorService.getRemotingConnectorInfoInjectedValue()).addDependency(AssociationService.SERVICE_NAME, AssociationService.class, ejbRemoteConnectorService.getAssociationServiceInjector()).addDependency(TxnServices.JBOSS_TXN_REMOTE_TRANSACTION_SERVICE, RemotingTransactionService.class, ejbRemoteConnectorService.getRemotingTransactionServiceInjector()).addDependency(ControlledProcessStateService.SERVICE_NAME, ControlledProcessStateService.class, ejbRemoteConnectorService.getControlledProcessStateServiceInjector()).setInitialMode(ServiceController.Mode.ACTIVE);
    if (!executeInWorker) {
        builder.addDependency(EJB3SubsystemModel.BASE_THREAD_POOL_SERVICE_NAME.append(threadPoolName), ExecutorService.class, ejbRemoteConnectorService.getExecutorService());
    }
    builder.install();
}
Also used : LocalCacheBuilderProvider(org.wildfly.clustering.spi.LocalCacheBuilderProvider) CacheBuilderProvider(org.wildfly.clustering.spi.CacheBuilderProvider) ControlledProcessStateService(org.jboss.as.controller.ControlledProcessStateService) EJBRemotingConnectorClientMappingsEntryProviderService(org.jboss.as.ejb3.remote.EJBRemotingConnectorClientMappingsEntryProviderService) ServiceTarget(org.jboss.msc.service.ServiceTarget) RegistryInstallerService(org.jboss.as.ejb3.remote.RegistryInstallerService) RemotingConnectorBindingInfoService(org.jboss.as.remoting.RemotingConnectorBindingInfoService) Resource(org.jboss.as.controller.registry.Resource) AssociationService(org.jboss.as.ejb3.remote.AssociationService) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) PathElement(org.jboss.as.controller.PathElement) Endpoint(org.jboss.remoting3.Endpoint) ServiceName(org.jboss.msc.service.ServiceName) EJBRemoteConnectorService(org.jboss.as.ejb3.remote.EJBRemoteConnectorService) GroupBuilderProvider(org.wildfly.clustering.spi.GroupBuilderProvider) LocalGroupBuilderProvider(org.wildfly.clustering.spi.LocalGroupBuilderProvider) OptionMap(org.xnio.OptionMap) LocalCacheBuilderProvider(org.wildfly.clustering.spi.LocalCacheBuilderProvider) LocalGroupBuilderProvider(org.wildfly.clustering.spi.LocalGroupBuilderProvider)

Aggregations

GroupBuilderProvider (org.wildfly.clustering.spi.GroupBuilderProvider)4 PathAddress (org.jboss.as.controller.PathAddress)3 ServiceTarget (org.jboss.msc.service.ServiceTarget)3 DistributedGroupBuilderProvider (org.wildfly.clustering.spi.DistributedGroupBuilderProvider)2 LocalGroupBuilderProvider (org.wildfly.clustering.spi.LocalGroupBuilderProvider)2 ModuleBuilder (org.jboss.as.clustering.controller.ModuleBuilder)1 Capability (org.jboss.as.clustering.jgroups.subsystem.ChannelResourceDefinition.Capability)1 BinderServiceBuilder (org.jboss.as.clustering.naming.BinderServiceBuilder)1 ControlledProcessStateService (org.jboss.as.controller.ControlledProcessStateService)1 PathElement (org.jboss.as.controller.PathElement)1 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)1 Resource (org.jboss.as.controller.registry.Resource)1 AssociationService (org.jboss.as.ejb3.remote.AssociationService)1 EJBRemoteConnectorService (org.jboss.as.ejb3.remote.EJBRemoteConnectorService)1 EJBRemotingConnectorClientMappingsEntryProviderService (org.jboss.as.ejb3.remote.EJBRemotingConnectorClientMappingsEntryProviderService)1 RegistryInstallerService (org.jboss.as.ejb3.remote.RegistryInstallerService)1 RemotingConnectorBindingInfoService (org.jboss.as.remoting.RemotingConnectorBindingInfoService)1 ServiceName (org.jboss.msc.service.ServiceName)1 Endpoint (org.jboss.remoting3.Endpoint)1 AliasServiceBuilder (org.wildfly.clustering.service.AliasServiceBuilder)1