Skip to content

Commit

Permalink
[WFCORE-5718] Remoting: add an ability to configure protocol used by …
Browse files Browse the repository at this point in the history
…the remoting connector
  • Loading branch information
tadamski committed Aug 30, 2023
1 parent ef0305b commit cbf9c38
Show file tree
Hide file tree
Showing 18 changed files with 149 additions and 26 deletions.
3 changes: 2 additions & 1 deletion jmx/src/test/java/org/jboss/as/jmx/JMXSubsystemTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.jboss.as.domain.management.CoreManagementResourceDefinition;
import org.jboss.as.domain.management.audit.AccessAuditResourceDefinition;
import org.jboss.as.remoting.EndpointService;
import org.jboss.as.remoting.Protocol;
import org.jboss.as.remoting.RemotingServices;
import org.jboss.as.remoting.management.ManagementRemotingServices;
import org.jboss.as.server.ServerEnvironmentResourceDescription;
Expand Down Expand Up @@ -673,7 +674,7 @@ protected void addExtraServices(final ServiceTarget target) {

RemotingServices.installConnectorServicesForSocketBinding(target, ManagementRemotingServices.MANAGEMENT_ENDPOINT,
"remote", SOCKET_BINDING_CAPABILITY.getCapabilityServiceName("remote"), OptionMap.EMPTY,
null, null, ServiceName.parse("org.wildfly.management.socket-binding-manager"));
null, null, ServiceName.parse("org.wildfly.management.socket-binding-manager"), Protocol.REMOTE.toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.jmx.model.ModelControllerMBeanHelper;
import org.jboss.as.remoting.EndpointService;
import org.jboss.as.remoting.Protocol;
import org.jboss.as.remoting.RemotingServices;
import org.jboss.as.remoting.management.ManagementRemotingServices;
import org.jboss.as.subsystem.test.AbstractSubsystemTest;
Expand Down Expand Up @@ -1682,7 +1683,7 @@ protected void addExtraServices(final ServiceTarget target) {

RemotingServices.installConnectorServicesForSocketBinding(target, ManagementRemotingServices.MANAGEMENT_ENDPOINT,
"server", SOCKET_BINDING_CAPABILITY.getCapabilityServiceName("server"), OptionMap.EMPTY,
null, null, ServiceName.parse("org.wildfly.management.socket-binding-manager"));
null, null, ServiceName.parse("org.wildfly.management.socket-binding-manager"), Protocol.REMOTE.toString());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ abstract class AbstractStreamServerService implements Service {
private final Supplier<SocketBindingManager> socketBindingManagerSupplier;
private final OptionMap connectorPropertiesOptionMap;

private final String protocol;

private volatile AcceptingChannel<StreamConnection> streamServer;
private volatile ManagedBinding managedBinding;

Expand All @@ -74,19 +76,21 @@ abstract class AbstractStreamServerService implements Service {
final Supplier<SaslAuthenticationFactory> saslAuthenticationFactorySupplier,
final Supplier<SSLContext> sslContextSupplier,
final Supplier<SocketBindingManager> socketBindingManagerSupplier,
final OptionMap connectorPropertiesOptionMap) {
final OptionMap connectorPropertiesOptionMap,
final String protocol) {
this.streamServerConsumer = streamServerConsumer;
this.endpointSupplier = endpointSupplier;
this.saslAuthenticationFactorySupplier = saslAuthenticationFactorySupplier;
this.sslContextSupplier = sslContextSupplier;
this.socketBindingManagerSupplier = socketBindingManagerSupplier;
this.connectorPropertiesOptionMap = connectorPropertiesOptionMap;
this.protocol = protocol;
}

@Override
public void start(final StartContext context) throws StartException {
try {
NetworkServerProvider networkServerProvider = endpointSupplier.get().getConnectionProviderInterface("remoting", NetworkServerProvider.class);
NetworkServerProvider networkServerProvider = endpointSupplier.get().getConnectionProviderInterface(protocol, NetworkServerProvider.class);

SSLContext sslContext = sslContextSupplier != null ? sslContextSupplier.get() : null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ void launchServices(OperationContext context, ModelNode fullModel) throws Operat

final ServiceName sbmName = context.getCapabilityServiceName(SOCKET_BINDING_MANAGER_CAPABILTIY, SocketBindingManager.class);

final String protocol = ConnectorResource.PROTOCOL.resolveModelAttribute(context, fullModel).asString();

RemotingServices.installConnectorServicesForSocketBinding(target, RemotingServices.SUBSYSTEM_ENDPOINT, connectorName,
socketBindingName, optionMap, saslAuthenticationFactoryName, sslContextName, sbmName);
socketBindingName, optionMap, saslAuthenticationFactoryName, sslContextName, sbmName, protocol);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.operations.validation.EnumValidator;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.network.ProtocolSocketBinding;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;

/**
Expand Down Expand Up @@ -96,8 +98,15 @@ public class ConnectorResource extends SimpleResourceDefinition {
.setRestartAllServices()
.build();

static final SimpleAttributeDefinition PROTOCOL = new SimpleAttributeDefinitionBuilder(CommonAttributes.PROTOCOL, ModelType.STRING)
.setDefaultValue(new ModelNode("remote"))
.setValidator(EnumValidator.create(Protocol.class))
.setRequired(false)
.setRestartAllServices()
.build();

static final AttributeDefinition[] ATTRIBUTES = {AUTHENTICATION_PROVIDER, SOCKET_BINDING, SECURITY_REALM,
SERVER_NAME, SASL_PROTOCOL, SASL_AUTHENTICATION_FACTORY, SSL_CONTEXT};
SERVER_NAME, SASL_PROTOCOL, SASL_AUTHENTICATION_FACTORY, SSL_CONTEXT, PROTOCOL};

static final ConnectorResource INSTANCE = new ConnectorResource();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ final class InjectedNetworkBindingStreamServerService extends AbstractStreamServ
final Supplier<SSLContext> sslContextSupplier,
final Supplier<SocketBindingManager> socketBindingManagerSupplier,
final Supplier<NetworkInterfaceBinding> interfaceBindingSupplier,
final OptionMap connectorPropertiesOptionMap, int port) {
final OptionMap connectorPropertiesOptionMap, int port,
final String protocol) {
super(streamServerConsumer, endpointSupplier, saslAuthenticationFactorySupplier,
sslContextSupplier, socketBindingManagerSupplier, connectorPropertiesOptionMap);
sslContextSupplier, socketBindingManagerSupplier, connectorPropertiesOptionMap, protocol);
this.interfaceBindingSupplier = interfaceBindingSupplier;
this.port = port;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ final class InjectedSocketBindingStreamServerService extends AbstractStreamServe

private final Supplier<SocketBinding> socketBindingSupplier;
private final String remotingConnectorName;
private final Protocol protocol;

InjectedSocketBindingStreamServerService(
final Consumer<AcceptingChannel<StreamConnection>> streamServerConsumer,
Expand All @@ -59,17 +60,19 @@ final class InjectedSocketBindingStreamServerService extends AbstractStreamServe
final Supplier<SocketBindingManager> socketBindingManagerSupplier,
final Supplier<SocketBinding> socketBindingSupplier,
final OptionMap connectorPropertiesOptionMap,
final String remotingConnectorName) {
final String remotingConnectorName,
final String protocol) {
super(streamServerConsumer, endpointSupplier, saslAuthenticationFactorySupplier,
sslContextSupplier, socketBindingManagerSupplier, connectorPropertiesOptionMap);
sslContextSupplier, socketBindingManagerSupplier, connectorPropertiesOptionMap, protocol);
this.socketBindingSupplier = socketBindingSupplier;
this.remotingConnectorName = remotingConnectorName;
this.protocol = Protocol.forName(protocol);
}

@Override
public void start(final StartContext context) throws StartException {
super.start(context);
RemotingConnectorBindingInfoService.install(context.getChildTarget(), remotingConnectorName, getSocketBinding(), Protocol.REMOTE);
RemotingConnectorBindingInfoService.install(context.getChildTarget(), remotingConnectorName, getSocketBinding(), protocol);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public enum Namespace {
REMOTING_2_0("urn:jboss:domain:remoting:2.0"),
REMOTING_3_0("urn:jboss:domain:remoting:3.0"),
REMOTING_4_0("urn:jboss:domain:remoting:4.0"),
REMOTING_5_0("urn:jboss:domain:remoting:5.0")
;
REMOTING_5_0("urn:jboss:domain:remoting:5.0"),
REMOTING_6_0("urn:jboss:domain:remoting:6.0");

/**
* The current namespace version.
*/
public static final Namespace CURRENT = REMOTING_5_0;
public static final Namespace CURRENT = REMOTING_6_0;

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
public enum Protocol {

REMOTE("remote"),
REMOTE_TLS("remote+tls"),
REMOTE_HTTP("remote+http"),
HTTP_REMOTING("http-remoting"),
HTTPS_REMOTING("https-remoting"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ public void initializeParsers(ExtensionParsingContext context) {
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.REMOTING_4_0.getUriString(), RemotingSubsystem40Parser::new);
// For the current version we don't use a Supplier as we want its description initialized
// TODO if any new xsd versions are added, use a Supplier for the old version

context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.REMOTING_5_0.getUriString(), new RemotingSubsystem50Parser());
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.REMOTING_6_0.getUriString(), new RemotingSubsystem60Parser());

// For servers only as a migration aid we'll install io if it is missing.
// It is invalid to do this on an HC as the HC needs to support profiles running legacy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public static void installConnectorServicesForNetworkInterfaceBinding(final Serv
final String connectorName,
final ServiceName networkInterfaceBindingName,
final int port,
final String protocol,
final OptionMap connectorPropertiesOptionMap,
final ServiceName saslAuthenticationFactory,
final ServiceName sslContext,
Expand All @@ -130,7 +131,7 @@ public static void installConnectorServicesForNetworkInterfaceBinding(final Serv
final Supplier<SocketBindingManager> sbmSupplier = socketBindingManager != null ? builder.requires(socketBindingManager) : null;
final Supplier<NetworkInterfaceBinding> ibSupplier = builder.requires(networkInterfaceBindingName);
builder.setInstance(new InjectedNetworkBindingStreamServerService(streamServerConsumer,
eSupplier, safSupplier, scSupplier, sbmSupplier, ibSupplier, connectorPropertiesOptionMap, port));
eSupplier, safSupplier, scSupplier, sbmSupplier, ibSupplier, connectorPropertiesOptionMap, port, protocol));
builder.install();
}

Expand All @@ -141,7 +142,8 @@ public static void installConnectorServicesForSocketBinding(final ServiceTarget
final OptionMap connectorPropertiesOptionMap,
final ServiceName saslAuthenticationFactory,
final ServiceName sslContext,
final ServiceName socketBindingManager) {
final ServiceName socketBindingManager,
final String protocol) {
final ServiceName serviceName = serverServiceName(connectorName);
final ServiceBuilder<?> builder = serviceTarget.addService(serviceName);
final Consumer<AcceptingChannel<StreamConnection>> streamServerConsumer = builder.provides(serviceName);
Expand All @@ -151,7 +153,7 @@ public static void installConnectorServicesForSocketBinding(final ServiceTarget
final Supplier<SocketBindingManager> sbmSupplier = builder.requires(socketBindingManager);
final Supplier<SocketBinding> sbSupplier = builder.requires(socketBindingName);
builder.setInstance(new InjectedSocketBindingStreamServerService(streamServerConsumer,
eSupplier, safSupplier, scSupplier, sbmSupplier, sbSupplier, connectorPropertiesOptionMap, connectorName));
eSupplier, safSupplier, scSupplier, sbmSupplier, sbSupplier, connectorPropertiesOptionMap, connectorName, protocol));
builder.install();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ private void writeConnector(final XMLExtendedStreamWriter writer, final ModelNod
if (node.hasDefined(SECURITY_REALM)) {
writer.writeAttribute(Attribute.SECURITY_REALM.getLocalName(), node.require(SECURITY_REALM).asString());
}
if (node.hasDefined(PROTOCOL)) {
writer.writeAttribute(Attribute.PROTOCOL.getLocalName(), node.require(PROTOCOL).asString());
}
ConnectorCommon.SERVER_NAME.marshallAsAttribute(node, writer);
ConnectorCommon.SASL_PROTOCOL.marshallAsAttribute(node, writer);
ConnectorResource.SASL_AUTHENTICATION_FACTORY.marshallAsAttribute(node, writer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class RemotingTransformers implements ExtensionTransformerRegistration {
private static final ModelVersion VERSION_3_0 = ModelVersion.create(3, 0);
private static final ModelVersion VERSION_4_0 = ModelVersion.create(4, 0); // eap 7.1

private static final ModelVersion VERSION_5_0 = ModelVersion.create(5, 0);

private static final AttributeDefinition[] endpointAttrArray = RemotingEndpointResource.ATTRIBUTES.values().toArray(new AttributeDefinition[RemotingEndpointResource.ATTRIBUTES.values().size()]);

@Override
Expand All @@ -69,20 +71,27 @@ public void registerTransformers(SubsystemTransformerRegistration registration)
// First chain: > 3.0
ChainedTransformationDescriptionBuilder chainedBuilder = TransformationDescriptionBuilder.Factory.createChainedSubystemInstance(registration.getCurrentSubsystemVersion());

// Current to 4.0.0
buildTransformers_4_0(chainedBuilder.createBuilder(registration.getCurrentSubsystemVersion(), VERSION_4_0));
//Current version to 5.0.0
buildTransformers_5_0(chainedBuilder.createBuilder(registration.getCurrentSubsystemVersion(), VERSION_5_0));

//5.0.0 to 4.0.0
buildTransformers_4_0(chainedBuilder.createBuilder(VERSION_5_0, VERSION_4_0));

// 4.0.0 to 3.0.0
buildTransformers_3_0(chainedBuilder.createBuilder(VERSION_4_0, VERSION_3_0));

chainedBuilder.buildAndRegister(registration, new ModelVersion[]{VERSION_4_0, VERSION_3_0});
chainedBuilder.buildAndRegister(registration, new ModelVersion[]{VERSION_5_0, VERSION_4_0, VERSION_3_0});

// Next, the 1.x chain
ChainedTransformationDescriptionBuilder chained1xBuilder = TransformationDescriptionBuilder.Factory.createChainedSubystemInstance(registration.getCurrentSubsystemVersion());
//Current version to 5.0.0
buildTransformers_5_0(chained1xBuilder.createBuilder(registration.getCurrentSubsystemVersion(), VERSION_5_0));
//5.0.0 to 4.0.0
//buildTransformers_4_0(chained1xBuilder.createBuilder(VERSION_5_0, VERSION_4_0));
// 4.0.0 to 1.4.0
buildTransformers_1_4(chained1xBuilder.createBuilder(registration.getCurrentSubsystemVersion(), VERSION_1_4));
buildTransformers_1_4(chained1xBuilder.createBuilder(VERSION_5_0, VERSION_1_4));

chained1xBuilder.buildAndRegister(registration, new ModelVersion[]{VERSION_1_4});
chained1xBuilder.buildAndRegister(registration, new ModelVersion[]{VERSION_5_0, VERSION_1_4});
}

private void buildTransformers_1_4(ResourceTransformationDescriptionBuilder builder) {
Expand Down Expand Up @@ -183,6 +192,14 @@ private void buildTransformers_4_0(ResourceTransformationDescriptionBuilder buil
.end();
}

private void buildTransformers_5_0(ResourceTransformationDescriptionBuilder builder) {

builder.addChildResource(ConnectorResource.PATH).getAttributeBuilder()
.setDiscard(DiscardAttributeChecker.UNDEFINED, ConnectorResource.PROTOCOL)
.addRejectCheck(RejectAttributeChecker.DEFINED, ConnectorResource.PROTOCOL)
.end();
}

/**
* Add op transformer, where, if any of the endpoint attrs are being set, the op
* is converted into a composite, with one step adding the root minus endpoint attrs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.jboss.as.controller.remote.ModelControllerOperationHandlerFactory;
import org.jboss.as.network.SocketBindingManager;
import org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization;
import org.jboss.as.remoting.Protocol;
import org.jboss.as.remoting.RemotingServices;
import org.jboss.as.remoting.logging.RemotingLogger;
import org.jboss.dmr.ModelNode;
Expand Down Expand Up @@ -102,7 +103,7 @@ public static void installDomainConnectorServices(final OperationContext context
ServiceName sbmName = context.hasOptionalCapability(sbmCap, NATIVE_MANAGEMENT_RUNTIME_CAPABILITY.getName(), null)
? context.getCapabilityServiceName(sbmCap, SocketBindingManager.class) : null;
installConnectorServicesForNetworkInterfaceBinding(serviceTarget, endpointName, MANAGEMENT_CONNECTOR,
networkInterfaceBinding, port, options, saslAuthenticationFactory, sslContext, sbmName);
networkInterfaceBinding, port, Protocol.REMOTE.toString(), options, saslAuthenticationFactory, sslContext, sbmName);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ connector.sasl-protocol=The protocol to pass into the SASL mechanisms used for a
connector.ssl-context=Reference to the SSLContext to use for this connector.
connector.security=Configuration of security for this connector.
connector.property=Properties to further configure the connector.
connector.protocol=Protocol used in the connection.

remoting.http-connector=The remoting HTTP Upgrade connectors.
http-connector=The configuration of a HTTP Upgrade based Remoting connector.
Expand Down
Loading

0 comments on commit cbf9c38

Please sign in to comment.