Permalink
Comparing changes
Open a pull request
- 4 commits
- 18 files changed
- 0 commit comments
- 2 contributors
Unified
Split
Showing
with
303 additions
and 44 deletions.
- +11 −0 ...a/org/jboss/as/clustering/jgroups/subsystem/AbstractProtocolConfigurationServiceConfigurator.java
- +3 −2 ...ering/jgroups/extension/src/main/java/org/jboss/as/clustering/jgroups/subsystem/JGroupsModel.java
- +1 −10 .../extension/src/main/java/org/jboss/as/clustering/jgroups/subsystem/JGroupsSubsystemXMLReader.java
- +3 −1 .../extension/src/main/java/org/jboss/as/clustering/jgroups/subsystem/JGroupsSubsystemXMLWriter.java
- +3 −1 ...boss/as/clustering/jgroups/subsystem/MulticastSocketProtocolConfigurationServiceConfigurator.java
- +92 −0 ...va/org/jboss/as/clustering/jgroups/subsystem/OptionalSocketBindingProtocolResourceDefinition.java
- +14 −0 ...roups/extension/src/main/java/org/jboss/as/clustering/jgroups/subsystem/ProtocolRegistration.java
- +1 −5 ...boss/as/clustering/jgroups/subsystem/SocketDiscoveryProtocolConfigurationServiceConfigurator.java
- +97 −0 ...ava/org/jboss/as/clustering/jgroups/subsystem/SocketProtocolConfigurationServiceConfigurator.java
- +5 −5 ...ain/java/org/jboss/as/clustering/jgroups/subsystem/TransportConfigurationServiceConfigurator.java
- +42 −11 clustering/jgroups/extension/src/main/java/org/jboss/as/clustering/jgroups/subsystem/XMLElement.java
- +4 −2 clustering/jgroups/extension/src/main/resources/subsystem-templates/jgroups.xml
- +1 −1 .../extension/src/test/resources/org/jboss/as/clustering/jgroups/subsystem/subsystem-jgroups-5_0.xml
- +1 −1 .../extension/src/test/resources/org/jboss/as/clustering/jgroups/subsystem/subsystem-jgroups-6_0.xml
- +1 −1 ...rc/test/resources/org/jboss/as/clustering/jgroups/subsystem/subsystem-jgroups-transform-6_0_0.xml
- +10 −0 galleon-pack/src/main/resources/feature_groups/domain-jgroups-sockets.xml
- +10 −0 galleon-pack/src/main/resources/feature_groups/jgroups-sockets.xml
- +4 −4 galleon-pack/src/main/resources/feature_groups/jgroups.xml
| @@ -26,6 +26,7 @@ | ||
| import static org.jboss.as.clustering.jgroups.subsystem.AbstractProtocolResourceDefinition.Attribute.PROPERTIES; | ||
| import static org.jboss.as.clustering.jgroups.subsystem.AbstractProtocolResourceDefinition.Attribute.STATISTICS_ENABLED; | ||
|
|
||
| import java.security.PrivilegedAction; | ||
| import java.security.PrivilegedExceptionAction; | ||
| import java.util.Collections; | ||
| import java.util.HashMap; | ||
| @@ -130,4 +131,14 @@ public final P createProtocol(ProtocolStackConfiguration stackConfiguration) { | ||
| throw new IllegalArgumentException(e); | ||
| } | ||
| } | ||
|
|
||
| void setValue(P protocol, String propertyName, Object propertyValue) { | ||
| PrivilegedAction<P> action = new PrivilegedAction<P>() { | ||
| @Override | ||
| public P run() { | ||
| return protocol.setValue(propertyName, propertyValue); | ||
| } | ||
| }; | ||
| WildFlySecurityManager.doUnchecked(action); | ||
| } | ||
| } | ||
| @@ -36,9 +36,10 @@ | ||
| VERSION_4_0_0(4, 0, 0), // WildFly 10, EAP 7.0 | ||
| VERSION_4_1_0(4, 1, 0), // WildFly 10.1 | ||
| VERSION_5_0_0(5, 0, 0), // WildFly 11, EAP 7.1 | ||
| VERSION_6_0_0(6, 0, 0), // WildFly 12-15, EAP 7.2 | ||
| VERSION_6_0_0(6, 0, 0), // WildFly 12-16, EAP 7.2 | ||
| VERSION_7_0_0(7, 0, 0), // WildFly 17 | ||
| ; | ||
| static final JGroupsModel CURRENT = VERSION_6_0_0; | ||
| static final JGroupsModel CURRENT = VERSION_7_0_0; | ||
|
|
||
| private final ModelVersion version; | ||
|
|
||
| @@ -32,7 +32,6 @@ | ||
| import javax.xml.stream.XMLStreamException; | ||
|
|
||
| import org.jboss.as.clustering.controller.Attribute; | ||
| import org.jboss.as.clustering.controller.Operations; | ||
| import org.jboss.as.controller.AttributeDefinition; | ||
| import org.jboss.as.controller.AttributeParser; | ||
| import org.jboss.as.controller.PathAddress; | ||
| @@ -635,15 +634,7 @@ private void parseProtocolAttribute(XMLExtendedStreamReader reader, int index, M | ||
| break; | ||
| } | ||
| case SOCKET_BINDING: { | ||
| String protocol = Operations.getPathAddress(operation).getLastElement().getValue(); | ||
| Attribute socketBindingAttribute = GenericProtocolResourceDefinition.DeprecatedAttribute.SOCKET_BINDING; | ||
| for (ProtocolRegistration.MulticastProtocol multicastProtocol : EnumSet.allOf(ProtocolRegistration.MulticastProtocol.class)) { | ||
| if (protocol.equals(multicastProtocol.name())) { | ||
| socketBindingAttribute = SocketBindingProtocolResourceDefinition.Attribute.SOCKET_BINDING; | ||
| break; | ||
| } | ||
| } | ||
| readAttribute(reader, index, operation, socketBindingAttribute); | ||
| readAttribute(reader, index, operation, GenericProtocolResourceDefinition.DeprecatedAttribute.SOCKET_BINDING); | ||
| break; | ||
| } | ||
| case DATA_SOURCE: { | ||
| @@ -117,7 +117,7 @@ private static void writeTransport(XMLExtendedStreamWriter writer, Property prop | ||
| } | ||
|
|
||
| private static void writeProtocol(XMLExtendedStreamWriter writer, Property property) throws XMLStreamException { | ||
| writer.writeStartElement(XMLElement.forProtocolName(property.getName()).getLocalName()); | ||
| writer.writeStartElement(XMLElement.forProtocolName(property).getLocalName()); | ||
| writeProtocolAttributes(writer, property); | ||
| writeElement(writer, property.getValue(), AbstractProtocolResourceDefinition.Attribute.PROPERTIES); | ||
| writer.writeEndElement(); | ||
| @@ -135,6 +135,8 @@ private static void writeProtocolAttributes(XMLExtendedStreamWriter writer, Prop | ||
| String protocol = property.getName(); | ||
| if (containsName(ProtocolRegistration.MulticastProtocol.class, protocol)) { | ||
| writeAttributes(writer, property.getValue(), SocketBindingProtocolResourceDefinition.Attribute.class); | ||
| } else if (containsName(ProtocolRegistration.SocketProtocol.class, protocol)) { | ||
| writeAttributes(writer, property.getValue(), OptionalSocketBindingProtocolResourceDefinition.Attribute.class); | ||
| } else if (containsName(ProtocolRegistration.JdbcProtocol.class, protocol)) { | ||
| writeAttributes(writer, property.getValue(), JDBCProtocolResourceDefinition.Attribute.class); | ||
| } else if (containsName(ProtocolRegistration.EncryptProtocol.class, protocol)) { | ||
| @@ -22,6 +22,8 @@ | ||
|
|
||
| package org.jboss.as.clustering.jgroups.subsystem; | ||
|
|
||
| import static org.jboss.as.clustering.jgroups.subsystem.SocketBindingProtocolResourceDefinition.Attribute.SOCKET_BINDING; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.Map; | ||
|
|
||
| @@ -56,7 +58,7 @@ public MulticastSocketProtocolConfigurationServiceConfigurator(PathAddress addre | ||
|
|
||
| @Override | ||
| public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { | ||
| String bindingName = SocketBindingProtocolResourceDefinition.Attribute.SOCKET_BINDING.resolveModelAttribute(context, model).asString(); | ||
| String bindingName = SOCKET_BINDING.resolveModelAttribute(context, model).asString(); | ||
| this.binding = new ServiceSupplierDependency<>(CommonUnaryRequirement.SOCKET_BINDING.getServiceName(context, bindingName)); | ||
| return super.configure(context, model); | ||
| } | ||
| @@ -0,0 +1,92 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2017, Red Hat, Inc., and individual contributors | ||
| * as indicated by the @author tags. See the copyright.txt file in the | ||
| * distribution for a full listing of individual contributors. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
|
|
||
| package org.jboss.as.clustering.jgroups.subsystem; | ||
|
|
||
| import java.util.function.UnaryOperator; | ||
|
|
||
| import org.jboss.as.clustering.controller.CapabilityReference; | ||
| import org.jboss.as.clustering.controller.CommonUnaryRequirement; | ||
| import org.jboss.as.clustering.controller.ResourceDescriptor; | ||
| import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory; | ||
| import org.jboss.as.controller.AttributeDefinition; | ||
| import org.jboss.as.controller.ModelVersion; | ||
| import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; | ||
| import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition; | ||
| import org.jboss.as.controller.descriptions.ModelDescriptionConstants; | ||
| import org.jboss.as.controller.registry.AttributeAccess; | ||
| import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; | ||
| import org.jboss.dmr.ModelType; | ||
|
|
||
| /** | ||
| * Resource definition override for protocols that have an optional socket-binding. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class OptionalSocketBindingProtocolResourceDefinition extends ProtocolResourceDefinition { | ||
|
|
||
| enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { | ||
| SOCKET_BINDING(ModelDescriptionConstants.SOCKET_BINDING, ModelType.STRING) { | ||
| @Override | ||
| public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { | ||
| return builder.setAccessConstraints(SensitiveTargetAccessConstraintDefinition.SOCKET_BINDING_REF) | ||
| .setCapabilityReference(new CapabilityReference(Capability.PROTOCOL, CommonUnaryRequirement.SOCKET_BINDING)) | ||
| ; | ||
| } | ||
| }, | ||
| ; | ||
| private final AttributeDefinition definition; | ||
|
|
||
| Attribute(String name, ModelType type) { | ||
| this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) | ||
| .setRequired(false) | ||
| .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) | ||
| ).build(); | ||
| } | ||
|
|
||
| @Override | ||
| public AttributeDefinition getDefinition() { | ||
| return this.definition; | ||
| } | ||
| } | ||
|
|
||
| static void addTransformations(ModelVersion version, ResourceTransformationDescriptionBuilder builder) { | ||
|
|
||
| ProtocolResourceDefinition.addTransformations(version, builder); | ||
| } | ||
|
|
||
| private static class ResourceDescriptorConfigurator implements UnaryOperator<ResourceDescriptor> { | ||
| private final UnaryOperator<ResourceDescriptor> configurator; | ||
|
|
||
| ResourceDescriptorConfigurator(UnaryOperator<ResourceDescriptor> configurator) { | ||
| this.configurator = configurator; | ||
| } | ||
|
|
||
| @Override | ||
| public ResourceDescriptor apply(ResourceDescriptor descriptor) { | ||
| return this.configurator.apply(descriptor).addAttributes(Attribute.class); | ||
| } | ||
| } | ||
|
|
||
| OptionalSocketBindingProtocolResourceDefinition(String name, UnaryOperator<ResourceDescriptor> configurator, ResourceServiceConfiguratorFactory serviceConfiguratorFactory, ResourceServiceConfiguratorFactory parentServiceConfiguratorFactory) { | ||
| super(pathElement(name), new ResourceDescriptorConfigurator(configurator), serviceConfiguratorFactory, parentServiceConfiguratorFactory); | ||
| } | ||
| } |
| @@ -84,6 +84,10 @@ | ||
| MPING; | ||
| } | ||
|
|
||
| enum SocketProtocol { | ||
| FD_SOCK; | ||
| } | ||
|
|
||
| enum LegacyProtocol { | ||
| MERGE2(MERGE3.class, JGroupsModel.VERSION_6_0_0), | ||
| NAKACK("pbcast.NAKACK", NAKACK2.class, JGroupsModel.VERSION_6_0_0), | ||
| @@ -107,6 +111,13 @@ | ||
| static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) { | ||
| ProtocolResourceDefinition.addTransformations(version, parent.addChildResource(ProtocolResourceDefinition.WILDCARD_PATH)); | ||
|
|
||
| for (SocketProtocol protocol : EnumSet.allOf(SocketProtocol.class)) { | ||
| PathElement path = ProtocolResourceDefinition.pathElement(protocol.name()); | ||
| if (!JGroupsModel.VERSION_7_0_0.requiresTransformation(version)) { | ||
| OptionalSocketBindingProtocolResourceDefinition.addTransformations(version, parent.addChildResource(path)); | ||
| } | ||
| } | ||
|
|
||
| for (MulticastProtocol protocol : EnumSet.allOf(MulticastProtocol.class)) { | ||
| PathElement path = ProtocolResourceDefinition.pathElement(protocol.name()); | ||
| if (!JGroupsModel.VERSION_5_0_0.requiresTransformation(version)) { | ||
| @@ -182,6 +193,9 @@ public void register(ManagementResourceRegistration registration) { | ||
| new GenericProtocolResourceDefinition(this.configurator, this.parentServiceConfiguratorFactory).register(registration); | ||
|
|
||
| // Override definitions for protocol types | ||
| for (SocketProtocol protocol : EnumSet.allOf(SocketProtocol.class)) { | ||
| new OptionalSocketBindingProtocolResourceDefinition(protocol.name(), this.configurator, SocketProtocolConfigurationServiceConfigurator::new, this.parentServiceConfiguratorFactory).register(registration); | ||
| } | ||
| for (MulticastProtocol protocol : EnumSet.allOf(MulticastProtocol.class)) { | ||
| new SocketBindingProtocolResourceDefinition(protocol.name(), this.configurator, MulticastSocketProtocolConfigurationServiceConfigurator::new, this.parentServiceConfiguratorFactory).register(registration); | ||
| } | ||
| @@ -26,7 +26,6 @@ | ||
|
|
||
| import java.net.InetSocketAddress; | ||
| import java.net.UnknownHostException; | ||
| import java.security.PrivilegedAction; | ||
| import java.util.ArrayList; | ||
| import java.util.LinkedList; | ||
| import java.util.List; | ||
| @@ -43,12 +42,10 @@ | ||
| import org.jboss.dmr.ModelNode; | ||
| import org.jboss.msc.service.ServiceBuilder; | ||
| import org.jgroups.protocols.Discovery; | ||
| import org.jgroups.stack.Protocol; | ||
| import org.wildfly.clustering.service.Dependency; | ||
| import org.wildfly.clustering.service.ServiceConfigurator; | ||
| import org.wildfly.clustering.service.ServiceSupplierDependency; | ||
| import org.wildfly.clustering.service.SupplierDependency; | ||
| import org.wildfly.security.manager.WildFlySecurityManager; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| @@ -93,8 +90,7 @@ public void accept(P protocol) { | ||
| } | ||
| } | ||
| // In the absence of some common interface, we need to use reflection | ||
| PrivilegedAction<Protocol> action = () -> protocol.setValue("initial_hosts", initialHosts); | ||
| WildFlySecurityManager.doUnchecked(action); | ||
| this.setValue(protocol, "initial_hosts", initialHosts); | ||
| } | ||
| } | ||
| } | ||
| @@ -0,0 +1,97 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, Red Hat, Inc., and individual contributors | ||
| * as indicated by the @author tags. See the copyright.txt file in the | ||
| * distribution for a full listing of individual contributors. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
|
|
||
| package org.jboss.as.clustering.jgroups.subsystem; | ||
|
|
||
| import static org.jboss.as.clustering.jgroups.subsystem.OptionalSocketBindingProtocolResourceDefinition.Attribute.SOCKET_BINDING; | ||
|
|
||
| import java.net.InetAddress; | ||
| import java.net.UnknownHostException; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import org.jboss.as.clustering.controller.CommonUnaryRequirement; | ||
| import org.jboss.as.controller.OperationContext; | ||
| import org.jboss.as.controller.OperationFailedException; | ||
| import org.jboss.as.controller.PathAddress; | ||
| import org.jboss.as.network.ClientMapping; | ||
| import org.jboss.as.network.SocketBinding; | ||
| import org.jboss.dmr.ModelNode; | ||
| import org.jboss.msc.service.ServiceBuilder; | ||
| import org.jgroups.protocols.FD_SOCK; | ||
| import org.wildfly.clustering.service.ServiceConfigurator; | ||
| import org.wildfly.clustering.service.ServiceSupplierDependency; | ||
| import org.wildfly.clustering.service.SimpleSupplierDependency; | ||
| import org.wildfly.clustering.service.SupplierDependency; | ||
|
|
||
| /** | ||
| * Configures a service that provides a FD_SOCK protocol. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class SocketProtocolConfigurationServiceConfigurator extends ProtocolConfigurationServiceConfigurator<FD_SOCK> { | ||
|
|
||
| private volatile SupplierDependency<SocketBinding> binding; | ||
|
|
||
| public SocketProtocolConfigurationServiceConfigurator(PathAddress address) { | ||
| super(address); | ||
| } | ||
|
|
||
| @Override | ||
| public <T> ServiceBuilder<T> register(ServiceBuilder<T> builder) { | ||
| return super.register(this.binding.register(builder)); | ||
| } | ||
|
|
||
| @Override | ||
| public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { | ||
| String bindingName = SOCKET_BINDING.resolveModelAttribute(context, model).asString(null); | ||
| this.binding = (bindingName != null) ? new ServiceSupplierDependency<>(CommonUnaryRequirement.SOCKET_BINDING.getServiceName(context, bindingName)) : new SimpleSupplierDependency<>(null); | ||
| return super.configure(context, model); | ||
| } | ||
|
|
||
| @Override | ||
| public Map<String, SocketBinding> getSocketBindings() { | ||
| return Collections.singletonMap("jgroups.fd_sock.srv_sock", this.binding.get()); | ||
| } | ||
|
|
||
| @Override | ||
| public void accept(FD_SOCK protocol) { | ||
| // If binding is undefined, protocol will use bind address of transport and a random ephemeral port | ||
| SocketBinding binding = this.binding.get(); | ||
| if (binding != null) { | ||
| protocol.setValue("bind_addr", binding.getAddress()); | ||
| protocol.setValue("start_port", binding.getPort()); | ||
|
|
||
| List<ClientMapping> clientMappings = binding.getClientMappings(); | ||
| if (!clientMappings.isEmpty()) { | ||
| // JGroups cannot select a client mapping based on the source address, so just use the first one | ||
| ClientMapping mapping = clientMappings.get(0); | ||
| try { | ||
| this.setValue(protocol, "external_addr", InetAddress.getByName(mapping.getDestinationAddress())); | ||
| this.setValue(protocol, "external_port", mapping.getDestinationPort()); | ||
| } catch (UnknownHostException e) { | ||
| throw new IllegalArgumentException(e); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
| @@ -145,8 +145,8 @@ public void accept(T protocol) { | ||
| // JGroups cannot select a client mapping based on the source address, so just use the first one | ||
| ClientMapping mapping = clientMappings.get(0); | ||
| try { | ||
| protocol.setValue("external_addr", InetAddress.getByName(mapping.getDestinationAddress())); | ||
| protocol.setValue("external_port", mapping.getDestinationPort()); | ||
| this.setValue(protocol, "external_addr", InetAddress.getByName(mapping.getDestinationAddress())); | ||
| this.setValue(protocol, "external_port", mapping.getDestinationPort()); | ||
| } catch (UnknownHostException e) { | ||
| throw new IllegalArgumentException(e); | ||
| } | ||
| @@ -164,11 +164,11 @@ public void accept(T protocol) { | ||
| ; | ||
| protocol.setInternalThreadPool(factory.apply(protocol.getInternalThreadPoolThreadFactory())); | ||
|
|
||
| protocol.setValue("enable_diagnostics", this.diagnosticsSocketBinding != null); | ||
| this.setValue(protocol, "enable_diagnostics", this.diagnosticsSocketBinding != null); | ||
| if (this.diagnosticsSocketBinding != null) { | ||
| InetSocketAddress address = this.diagnosticsSocketBinding.get().getSocketAddress(); | ||
| protocol.setValue("diagnostics_addr", address.getAddress()); | ||
| protocol.setValue("diagnostics_port", address.getPort()); | ||
| this.setValue(protocol, "diagnostics_addr", address.getAddress()); | ||
| this.setValue(protocol, "diagnostics_port", address.getPort()); | ||
| } | ||
| } | ||
|
|
||
Oops, something went wrong.