Search in sources :

Example 1 with RemoteSiteConfiguration

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

the class RemoteSiteConfigurationServiceConfigurator method build.

@Override
public ServiceBuilder<?> build(ServiceTarget target) {
    ServiceBuilder<?> builder = target.addService(this.getServiceName());
    Consumer<RemoteSiteConfiguration> configuration = new CompositeDependency(this.cluster, this.factory).register(builder).provides(this.getServiceName());
    Service service = Service.newInstance(configuration, this);
    return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
Also used : RemoteSiteConfiguration(org.wildfly.clustering.jgroups.spi.RemoteSiteConfiguration) Service(org.jboss.msc.Service) CompositeDependency(org.wildfly.clustering.service.CompositeDependency)

Example 2 with RemoteSiteConfiguration

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

the class RelayConfigurationBuilder method accept.

@Override
public void accept(RELAY2 protocol) {
    String localSite = this.siteName;
    List<RemoteSiteConfiguration> remoteSites = this.getRemoteSites();
    List<String> sites = new ArrayList<>(remoteSites.size() + 1);
    sites.add(localSite);
    // Collect bridges, eliminating duplicates
    Map<String, RelayConfig.BridgeConfig> bridges = new HashMap<>();
    for (final RemoteSiteConfiguration remoteSite : remoteSites) {
        String siteName = remoteSite.getName();
        sites.add(siteName);
        String clusterName = remoteSite.getClusterName();
        RelayConfig.BridgeConfig bridge = new RelayConfig.BridgeConfig(clusterName) {

            @Override
            public JChannel createChannel() throws Exception {
                JChannel channel = (JChannel) remoteSite.getChannelFactory().createChannel(siteName);
                // Don't use FORK in bridge stack
                channel.getProtocolStack().removeProtocol(FORK.class);
                return channel;
            }
        };
        bridges.put(clusterName, bridge);
    }
    protocol.site(localSite);
    for (String site : sites) {
        RelayConfig.SiteConfig siteConfig = new RelayConfig.SiteConfig(site);
        protocol.addSite(site, siteConfig);
        if (site.equals(localSite)) {
            for (RelayConfig.BridgeConfig bridge : bridges.values()) {
                siteConfig.addBridge(bridge);
            }
        }
    }
}
Also used : JChannel(org.jgroups.JChannel) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RelayConfig(org.jgroups.protocols.relay.config.RelayConfig) RemoteSiteConfiguration(org.wildfly.clustering.jgroups.spi.RemoteSiteConfiguration)

Example 3 with RemoteSiteConfiguration

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

the class RelayConfigurationServiceConfigurator method accept.

@Override
public void accept(RELAY2 protocol) {
    String localSite = this.siteName;
    List<RemoteSiteConfiguration> remoteSites = this.getRemoteSites();
    List<String> sites = new ArrayList<>(remoteSites.size() + 1);
    sites.add(localSite);
    // Collect bridges, eliminating duplicates
    Map<String, RelayConfig.BridgeConfig> bridges = new HashMap<>();
    for (final RemoteSiteConfiguration remoteSite : remoteSites) {
        String siteName = remoteSite.getName();
        sites.add(siteName);
        String clusterName = remoteSite.getClusterName();
        RelayConfig.BridgeConfig bridge = new RelayConfig.BridgeConfig(clusterName) {

            @Override
            public JChannel createChannel() throws Exception {
                JChannel channel = remoteSite.getChannelFactory().createChannel(siteName);
                // Don't use FORK in bridge stack
                channel.getProtocolStack().removeProtocol(FORK.class);
                return channel;
            }
        };
        bridges.put(clusterName, bridge);
    }
    protocol.site(localSite);
    for (String site : sites) {
        RelayConfig.SiteConfig siteConfig = new RelayConfig.SiteConfig(site);
        protocol.addSite(site, siteConfig);
        if (site.equals(localSite)) {
            for (RelayConfig.BridgeConfig bridge : bridges.values()) {
                siteConfig.addBridge(bridge);
            }
        }
    }
}
Also used : JChannel(org.jgroups.JChannel) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RelayConfig(org.jgroups.protocols.relay.config.RelayConfig) RemoteSiteConfiguration(org.wildfly.clustering.jgroups.spi.RemoteSiteConfiguration)

Aggregations

RemoteSiteConfiguration (org.wildfly.clustering.jgroups.spi.RemoteSiteConfiguration)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 JChannel (org.jgroups.JChannel)2 RelayConfig (org.jgroups.protocols.relay.config.RelayConfig)2 Service (org.jboss.msc.Service)1 CompositeDependency (org.wildfly.clustering.service.CompositeDependency)1