| @@ -0,0 +1,87 @@ | ||
| /* | ||
| * 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.SocketTransportResourceDefinition.Attribute.*; | ||
|
|
||
| import java.net.InetSocketAddress; | ||
| import java.util.Arrays; | ||
| 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.SocketBinding; | ||
| import org.jboss.dmr.ModelNode; | ||
| import org.jboss.msc.service.ServiceBuilder; | ||
| import org.jgroups.protocols.BasicTCP; | ||
| import org.wildfly.clustering.service.ServiceConfigurator; | ||
| import org.wildfly.clustering.service.ServiceSupplierDependency; | ||
| import org.wildfly.clustering.service.SimpleSupplierDependency; | ||
| import org.wildfly.clustering.service.SupplierDependency; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class SocketTransportConfigurationServiceConfigurator<TP extends BasicTCP> extends TransportConfigurationServiceConfigurator<TP> { | ||
|
|
||
| private volatile SupplierDependency<SocketBinding> clientBinding; | ||
|
|
||
| public SocketTransportConfigurationServiceConfigurator(PathAddress address) { | ||
| super(address); | ||
| } | ||
|
|
||
| @Override | ||
| public <B> ServiceBuilder<B> register(ServiceBuilder<B> builder) { | ||
| return super.register(this.clientBinding.register(builder)); | ||
| } | ||
|
|
||
| @Override | ||
| public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { | ||
| String bindingName = CLIENT_SOCKET_BINDING.resolveModelAttribute(context, model).asStringOrNull(); | ||
| this.clientBinding = (bindingName != null) ? new ServiceSupplierDependency<>(CommonUnaryRequirement.SOCKET_BINDING.getServiceName(context, bindingName)) : new SimpleSupplierDependency<>(null); | ||
| return super.configure(context, model); | ||
| } | ||
|
|
||
| @Override | ||
| public Map<String, SocketBinding> getSocketBindings() { | ||
| Map<String, SocketBinding> bindings = super.getSocketBindings(); | ||
| SocketBinding clientBinding = this.clientBinding.get(); | ||
| for (String serviceName : Arrays.asList("jgroups.tcp.sock", "jgroups.nio.client")) { | ||
| bindings.put(serviceName, clientBinding); | ||
| } | ||
| return bindings; | ||
| } | ||
|
|
||
| @Override | ||
| public void accept(TP protocol) { | ||
| SocketBinding clientBinding = this.clientBinding.get(); | ||
| if (clientBinding != null) { | ||
| InetSocketAddress socketAddress = clientBinding.getSocketAddress(); | ||
| this.setValue(protocol, "client_bind_addr", socketAddress.getAddress()); | ||
| this.setValue(protocol, "client_bind_port", socketAddress.getPort()); | ||
| } | ||
| super.accept(protocol); | ||
| } | ||
| } |
| @@ -0,0 +1,90 @@ | ||
| /* | ||
| * 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 java.util.function.UnaryOperator; | ||
|
|
||
| import org.jboss.as.clustering.controller.CapabilityReference; | ||
| import org.jboss.as.clustering.controller.CommonUnaryRequirement; | ||
| import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory; | ||
| import org.jboss.as.clustering.controller.SimpleResourceDescriptorConfigurator; | ||
| 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.registry.AttributeAccess; | ||
| import org.jboss.as.controller.transform.description.DiscardAttributeChecker; | ||
| import org.jboss.as.controller.transform.description.RejectAttributeChecker; | ||
| import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; | ||
| import org.jboss.dmr.ModelType; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class SocketTransportResourceDefinition extends TransportResourceDefinition { | ||
|
|
||
| enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { | ||
| CLIENT_SOCKET_BINDING("client-socket-binding", ModelType.STRING) { | ||
| @Override | ||
| public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { | ||
| return builder | ||
| .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.SOCKET_BINDING_REF) | ||
| .setCapabilityReference(new CapabilityReference(Capability.TRANSPORT, CommonUnaryRequirement.SOCKET_BINDING)); | ||
| } | ||
| }, | ||
| ; | ||
| private final AttributeDefinition definition; | ||
|
|
||
| Attribute(String name, ModelType type) { | ||
| this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) | ||
| .setAllowExpression(false) | ||
| .setRequired(false) | ||
| .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) | ||
| ).build(); | ||
| } | ||
|
|
||
| @Override | ||
| public AttributeDefinition getDefinition() { | ||
| return this.definition; | ||
| } | ||
|
|
||
| @Override | ||
| public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { | ||
| return builder; | ||
| } | ||
| } | ||
|
|
||
| static void addTransformations(ModelVersion version, ResourceTransformationDescriptionBuilder builder) { | ||
| if (JGroupsModel.VERSION_7_0_0.requiresTransformation(version)) { | ||
| builder.getAttributeBuilder() | ||
| .setDiscard(DiscardAttributeChecker.UNDEFINED, Attribute.CLIENT_SOCKET_BINDING.getDefinition()) | ||
| .addRejectCheck(RejectAttributeChecker.DEFINED, Attribute.CLIENT_SOCKET_BINDING.getDefinition()); | ||
| } | ||
|
|
||
| TransportResourceDefinition.addTransformations(version, builder); | ||
| } | ||
|
|
||
| SocketTransportResourceDefinition(String name, ResourceServiceConfiguratorFactory serviceConfiguratorFactory, ResourceServiceConfiguratorFactory parentServiceConfiguratorFactory) { | ||
| super(pathElement(name), new SimpleResourceDescriptorConfigurator<>(Attribute.class), serviceConfiguratorFactory, parentServiceConfiguratorFactory); | ||
| } | ||
| } |
| @@ -0,0 +1,84 @@ | ||
| <!-- | ||
| ~ 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. | ||
| --> | ||
|
|
||
| <subsystem xmlns="urn:jboss:domain:jgroups:7.0"> | ||
| <channels default="ee"> | ||
| <channel name="ee" stack="maximal" cluster="${test.expr:mycluster}"> | ||
| <fork name="web"> | ||
| <protocol type="CENTRAL_LOCK" statistics-enabled="true"> | ||
| <property name="num_backups">1</property> | ||
| </protocol> | ||
| </fork> | ||
| </channel> | ||
| <channel name="bridge" stack="minimal"/> | ||
| </channels> | ||
| <stacks> | ||
| <stack name="minimal" statistics-enabled="true"> | ||
| <transport type="UDP" socket-binding="some-binding" statistics-enabled="false"/> | ||
| </stack> | ||
| <stack name="maximal"> | ||
| <transport type="TCP" | ||
| module="org.jgroups" | ||
| socket-binding="some-binding" | ||
| diagnostics-socket-binding="jgroups-diagnostics" | ||
| shared="${test.expr:false}" | ||
| machine="${test.expr:machine1}" | ||
| rack="${test.expr:rack1}" | ||
| site="${test.expr:site1}"> | ||
| <property name="enable_bundling">${test.expr:true}</property> | ||
| <default-thread-pool min-threads="11" | ||
| max-threads="12" | ||
| keepalive-time="13"/> | ||
| </transport> | ||
| <socket-protocol type="MPING" module="org.jgroups" socket-binding="jgroups-mping"> | ||
| <property name="name">${test.expr:value}</property> | ||
| </socket-protocol> | ||
| <jdbc-protocol type="JDBC_PING" data-source="ExampleDS"/> | ||
| <socket-discovery-protocol type="TCPPING" socket-bindings="node1 node2"/> | ||
| <protocol type="MERGE3"/> | ||
| <socket-protocol type="FD_SOCK" socket-binding="jgroups-tcp-fd" client-socket-binding="jgroups-client-fd"/> | ||
| <protocol type="FD"/> | ||
| <protocol type="VERIFY_SUSPECT"/> | ||
| <encrypt-protocol type="SYM_ENCRYPT" key-store="my-key-store" key-alias="alias"> | ||
| <key-credential-reference store="my-credential-store" alias="credential-alias" type="PASSWORD"/> | ||
| </encrypt-protocol> | ||
| <protocol type="pbcast.NAKACK2"/> | ||
| <protocol type="UNICAST3"/> | ||
| <protocol type="pbcast.STABLE"/> | ||
| <protocol type="pbcast.GMS"/> | ||
| <auth-protocol type="AUTH"> | ||
| <cipher-token algorithm="RSA" key-store="my-key-store" key-alias="alias"> | ||
| <shared-secret-reference clear-text="changeme"/> | ||
| <key-credential-reference store="my-credential-store" alias="credential-alias" type="PASSWORD"/> | ||
| </cipher-token> | ||
| </auth-protocol> | ||
| <protocol type="UFC"/> | ||
| <protocol type="MFC"/> | ||
| <protocol type="FRAG2"/> | ||
| <protocol type="RSVP"/> | ||
| <relay site="LON"> | ||
| <remote-site name="SFO" channel="bridge"/> | ||
| <remote-site name="NYC" channel="bridge"/> | ||
| </relay> | ||
| </stack> | ||
| </stacks> | ||
| </subsystem> |