Search in sources :

Example 1 with ProtocolStackConfiguration

use of org.wildfly.clustering.jgroups.spi.ProtocolStackConfiguration 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 ProtocolStackConfiguration

use of org.wildfly.clustering.jgroups.spi.ProtocolStackConfiguration 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 ProtocolStackConfiguration

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

Example 4 with ProtocolStackConfiguration

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

the class JGroupsTransportServiceConfigurator method get.

@Override
public TransportConfiguration get() {
    ChannelFactory factory = this.factory.get();
    Properties properties = new Properties();
    properties.put(JGroupsTransport.CHANNEL_CONFIGURATOR, new ChannelConfigurator(factory, this.containerName));
    ProtocolStackConfiguration stack = factory.getProtocolStackConfiguration();
    org.wildfly.clustering.jgroups.spi.TransportConfiguration.Topology topology = stack.getTransport().getTopology();
    TransportConfigurationBuilder builder = new GlobalConfigurationBuilder().transport().clusterName(this.cluster.get()).distributedSyncTimeout(this.lockTimeout).transport(new JGroupsTransport()).withProperties(properties);
    if (topology != null) {
        builder.siteId(topology.getSite()).rackId(topology.getRack()).machineId(topology.getMachine());
    }
    return builder.create();
}
Also used : ChannelConfigurator(org.jboss.as.clustering.infinispan.ChannelConfigurator) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) JGroupsTransport(org.infinispan.remoting.transport.jgroups.JGroupsTransport) 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) Properties(java.util.Properties)

Aggregations

ChannelFactory (org.wildfly.clustering.jgroups.spi.ChannelFactory)4 ProtocolStackConfiguration (org.wildfly.clustering.jgroups.spi.ProtocolStackConfiguration)4 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)2 TransportConfiguration (org.infinispan.configuration.global.TransportConfiguration)2 TransportConfigurationBuilder (org.infinispan.configuration.global.TransportConfigurationBuilder)2 PathAddress (org.jboss.as.controller.PathAddress)2 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)2 Channel (org.jgroups.Channel)2 Properties (java.util.Properties)1 JGroupsTransport (org.infinispan.remoting.transport.jgroups.JGroupsTransport)1 ChannelConfigurator (org.jboss.as.clustering.infinispan.ChannelConfigurator)1 ChannelFactoryTransport (org.jboss.as.clustering.infinispan.ChannelFactoryTransport)1 FORK (org.jgroups.protocols.FORK)1