Search in sources :

Example 1 with ChannelFactory

use of org.wildfly.clustering.jgroups.spi.ChannelFactory in project wildfly by wildfly.

the class ProtocolResourceRegistrationHandler method findProtocol.

@Override
public Protocol findProtocol(OperationContext context) throws ClassNotFoundException, ModuleLoadException {
    PathAddress address = context.getCurrentAddress();
    String channelName = address.getParent().getLastElement().getValue();
    String protocolName = address.getLastElement().getValue();
    ServiceRegistry registry = context.getServiceRegistry(false);
    ServiceController<?> controller = registry.getService(JGroupsRequirement.CHANNEL.getServiceName(context, channelName));
    if (controller != null) {
        Channel channel = (Channel) controller.getValue();
        if (channel != null) {
            controller = registry.getService(JGroupsRequirement.CHANNEL_SOURCE.getServiceName(context, channelName));
            ChannelFactory factory = (ChannelFactory) controller.getValue();
            if (factory != null) {
                ProtocolStackConfiguration configuration = factory.getProtocolStackConfiguration();
                ProtocolConfiguration<? extends TP> transport = configuration.getTransport();
                if (transport.getName().equals(protocolName)) {
                    Class<? extends Protocol> protocolClass = transport.createProtocol().getClass();
                    return channel.getProtocolStack().findProtocol(protocolClass);
                }
                for (ProtocolConfiguration<? extends Protocol> protocol : configuration.getProtocols()) {
                    if (protocol.getName().equals(protocolName)) {
                        Class<? extends Protocol> protocolClass = protocol.createProtocol().getClass();
                        return channel.getProtocolStack().findProtocol(protocolClass);
                    }
                }
            }
        }
    }
    return null;
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) Channel(org.jgroups.Channel) ProtocolStackConfiguration(org.wildfly.clustering.jgroups.spi.ProtocolStackConfiguration) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ChannelFactory(org.wildfly.clustering.jgroups.spi.ChannelFactory)

Example 2 with ChannelFactory

use of org.wildfly.clustering.jgroups.spi.ChannelFactory in project wildfly by wildfly.

the class ForkProtocolResourceRegistrationHandler method findProtocol.

@Override
public Protocol findProtocol(OperationContext context) throws ClassNotFoundException, ModuleLoadException {
    PathAddress address = context.getCurrentAddress();
    String channelName = address.getElement(address.size() - 3).getValue();
    String forkName = address.getElement(address.size() - 2).getValue();
    String protocolName = address.getElement(address.size() - 1).getValue();
    ServiceRegistry registry = context.getServiceRegistry(false);
    ServiceController<?> controller = registry.getService(JGroupsRequirement.CHANNEL.getServiceName(context, channelName));
    if (controller != null) {
        Channel channel = (Channel) controller.getValue();
        if (channel != null) {
            FORK fork = (FORK) channel.getProtocolStack().findProtocol(FORK.class);
            if (fork != null) {
                controller = registry.getService(JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, channelName));
                if (controller != null) {
                    ChannelFactory factory = (ChannelFactory) controller.getValue();
                    if (factory != null) {
                        ProtocolStackConfiguration configuration = factory.getProtocolStackConfiguration();
                        ProtocolConfiguration<? extends TP> transport = configuration.getTransport();
                        if (transport.getName().equals(protocolName)) {
                            Class<? extends Protocol> protocolClass = transport.createProtocol().getClass();
                            return channel.getProtocolStack().findProtocol(protocolClass);
                        }
                        for (ProtocolConfiguration<? extends Protocol> protocol : configuration.getProtocols()) {
                            if (protocol.getName().equals(protocolName)) {
                                Class<? extends Protocol> protocolClass = protocol.createProtocol().getClass();
                                return fork.get(forkName).getProtocolStack().findProtocol(protocolClass);
                            }
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : FORK(org.jgroups.protocols.FORK) PathAddress(org.jboss.as.controller.PathAddress) Channel(org.jgroups.Channel) ProtocolStackConfiguration(org.wildfly.clustering.jgroups.spi.ProtocolStackConfiguration) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ChannelFactory(org.wildfly.clustering.jgroups.spi.ChannelFactory)

Example 3 with ChannelFactory

use of org.wildfly.clustering.jgroups.spi.ChannelFactory in project wildfly by wildfly.

the class ForkResourceDefinition method register.

@Override
public void register(ManagementResourceRegistration parentRegistration) {
    ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addCapabilities(Capability.class).addCapabilities(CLUSTERING_CAPABILITIES.values());
    ResourceServiceBuilderFactory<ChannelFactory> builderFactory = address -> new ForkChannelFactoryBuilder(Capability.FORK_CHANNEL_FACTORY.getServiceName(address), address.getParent().getLastElement().getValue());
    ResourceServiceHandler handler = new ForkServiceHandler(builderFactory);
    new SimpleResourceRegistration(descriptor, handler).register(registration);
    new ProtocolRegistration(builderFactory, new ForkProtocolResourceRegistrationHandler()).register(registration);
}
Also used : UnaryRequirement(org.wildfly.clustering.service.UnaryRequirement) EnumMap(java.util.EnumMap) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) JGroupsRequirement(org.wildfly.clustering.jgroups.spi.JGroupsRequirement) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor) PathElement(org.jboss.as.controller.PathElement) ResourceServiceBuilderFactory(org.jboss.as.clustering.controller.ResourceServiceBuilderFactory) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) ClusteringRequirement(org.wildfly.clustering.spi.ClusteringRequirement) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) UnaryRequirementCapability(org.jboss.as.clustering.controller.UnaryRequirementCapability) Map(java.util.Map) ChannelFactory(org.wildfly.clustering.jgroups.spi.ChannelFactory) ChildResourceDefinition(org.jboss.as.clustering.controller.ChildResourceDefinition) CapabilityProvider(org.jboss.as.clustering.controller.CapabilityProvider) EnumSet(java.util.EnumSet) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) UnaryRequirementCapability(org.jboss.as.clustering.controller.UnaryRequirementCapability) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) ChannelFactory(org.wildfly.clustering.jgroups.spi.ChannelFactory) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Example 4 with ChannelFactory

use of org.wildfly.clustering.jgroups.spi.ChannelFactory in project wildfly by wildfly.

the class DistributedWorkManagerService method start.

@Override
public void start(StartContext context) throws StartException {
    ROOT_LOGGER.debugf("Starting JCA DistributedWorkManager: ", value.getName());
    ChannelFactory factory = this.jGroupsChannelFactory.getValue();
    JGroupsTransport transport = new ForkChannelTransport(factory);
    try {
        transport.setChannel(factory.createChannel(this.value.getName()));
        transport.setClusterName(this.value.getName());
        this.value.setTransport(transport);
    } catch (Exception e) {
        ROOT_LOGGER.trace("failed to start JGroups channel", e);
        throw ROOT_LOGGER.failedToStartJGroupsChannel(this.value.getName(), this.value.getName());
    }
    BlockingExecutor longRunning = (BlockingExecutor) executorLong.getOptionalValue();
    if (longRunning != null) {
        this.value.setLongRunningThreadPool(longRunning);
        this.value.setShortRunningThreadPool((BlockingExecutor) executorShort.getValue());
    } else {
        this.value.setLongRunningThreadPool((BlockingExecutor) executorShort.getValue());
        this.value.setShortRunningThreadPool((BlockingExecutor) executorShort.getValue());
    }
    this.value.setXATerminator(new XATerminatorImpl(xaTerminator.getValue()));
    WorkManagerCoordinator.getInstance().registerWorkManager(value);
    try {
        transport.startup();
    } catch (Throwable throwable) {
        ROOT_LOGGER.trace("failed to start DWM transport:", throwable);
        throw ROOT_LOGGER.failedToStartDWMTransport(this.value.getName());
    }
    if (this.value.isElytronEnabled()) {
        this.value.setSecurityIntegration(new ElytronSecurityIntegration());
    } else {
        this.value.setSecurityIntegration(new PicketBoxSecurityIntegration());
    }
    ROOT_LOGGER.debugf("Started JCA DistributedWorkManager: ", value.getName());
}
Also used : JGroupsTransport(org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport) PicketBoxSecurityIntegration(org.jboss.jca.core.security.picketbox.PicketBoxSecurityIntegration) ForkChannelTransport(org.jboss.as.connector.services.workmanager.transport.ForkChannelTransport) ElytronSecurityIntegration(org.jboss.as.connector.security.ElytronSecurityIntegration) ChannelFactory(org.wildfly.clustering.jgroups.spi.ChannelFactory) XATerminatorImpl(org.jboss.jca.core.tx.jbossts.XATerminatorImpl) StartException(org.jboss.msc.service.StartException) BlockingExecutor(org.jboss.threads.BlockingExecutor)

Example 5 with ChannelFactory

use of org.wildfly.clustering.jgroups.spi.ChannelFactory in project wildfly by wildfly.

the class JGroupsTransportBuilder method getValue.

@Override
public TransportConfiguration getValue() {
    ChannelFactory factory = this.factory.getValue();
    ProtocolStackConfiguration stack = factory.getProtocolStackConfiguration();
    org.wildfly.clustering.jgroups.spi.TransportConfiguration.Topology topology = stack.getTransport().getTopology();
    TransportConfigurationBuilder builder = new GlobalConfigurationBuilder().transport().clusterName(this.containerName).distributedSyncTimeout(this.lockTimeout).transport(new ChannelFactoryTransport(factory));
    if (topology != null) {
        builder.siteId(topology.getSite()).rackId(topology.getRack()).machineId(topology.getMachine());
    }
    return builder.create();
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) TransportConfigurationBuilder(org.infinispan.configuration.global.TransportConfigurationBuilder) ProtocolStackConfiguration(org.wildfly.clustering.jgroups.spi.ProtocolStackConfiguration) TransportConfiguration(org.infinispan.configuration.global.TransportConfiguration) ChannelFactory(org.wildfly.clustering.jgroups.spi.ChannelFactory) ChannelFactoryTransport(org.jboss.as.clustering.infinispan.ChannelFactoryTransport)

Aggregations

ChannelFactory (org.wildfly.clustering.jgroups.spi.ChannelFactory)8 PathAddress (org.jboss.as.controller.PathAddress)3 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)3 Channel (org.jgroups.Channel)3 ProtocolStackConfiguration (org.wildfly.clustering.jgroups.spi.ProtocolStackConfiguration)3 Map (java.util.Map)2 StartException (org.jboss.msc.service.StartException)2 InetSocketAddress (java.net.InetSocketAddress)1 ArrayList (java.util.ArrayList)1 EnumMap (java.util.EnumMap)1 EnumSet (java.util.EnumSet)1 HashMap (java.util.HashMap)1 DataSource (javax.sql.DataSource)1 BroadcastGroupConfiguration (org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)1 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)1 Interceptor (org.apache.activemq.artemis.api.core.Interceptor)1 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)1 DatabaseStorageConfiguration (org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration)1 JournalType (org.apache.activemq.artemis.core.server.JournalType)1 ActiveMQServerImpl (org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl)1