Skip to content

Commit

Permalink
WFLY-7806 Undertow mod_cluster: advertise-socket-binding should be au…
Browse files Browse the repository at this point in the history
…xiliary
  • Loading branch information
rhusar committed Dec 16, 2016
1 parent 19e65d6 commit 378f69f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
Expand Up @@ -149,7 +149,6 @@ public interface Constants {
String MANAGEMENT_SOCKET_BINDING = "management-socket-binding";
String ADVERTISE_SOCKET_BINDING = "advertise-socket-binding";
String SECURITY_KEY = "security-key";
String ADVERTISE_MULTICAST_SOCKET_BINDING = "advertise-multicast-socket-binding";
String ADVERTISE_PROTOCOL = "advertise-protocol";
String ADVERTISE_PATH = "advertise-path";
String ADVERTISE_FREQUENCY = "advertise-frequency";
Expand Down
Expand Up @@ -161,6 +161,7 @@ private static void registerTransformers_EAP_7_0_0(SubsystemRegistration subsyst
.addRejectCheck(RejectAttributeChecker.DEFINED, Constants.SSL_CONTEXT)
.setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(1)), Constants.MAX_RETRIES)
.addRejectCheck(RejectAttributeChecker.DEFINED, Constants.MAX_RETRIES)
.addRejectCheck(RejectAttributeChecker.UNDEFINED, Constants.ADVERTISE_SOCKET_BINDING)
.end();

builder.addChildResource(UndertowExtension.PATH_HANDLERS)
Expand Down
Expand Up @@ -74,7 +74,7 @@ public class ModClusterDefinition extends AbstractHandlerDefinition {

public static final AttributeDefinition ADVERTISE_SOCKET_BINDING = new SimpleAttributeDefinitionBuilder(Constants.ADVERTISE_SOCKET_BINDING, ModelType.STRING)
.setAllowExpression(true)
.setAllowNull(false)
.setRequired(false)
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.SOCKET_BINDING_REF)
.setRestartAllServices()
.build();
Expand Down
Expand Up @@ -145,27 +145,30 @@ public synchronized void start(StartContext context) throws StartException {
.build();

MCMPConfig.Builder builder = MCMPConfig.builder();
InetAddress multicastAddress = advertiseSocketBinding.getValue().getMulticastAddress();
if(multicastAddress == null) {
throw UndertowLogger.ROOT_LOGGER.advertiseSocketBindingRequiresMulticastAddress();
}
if(advertiseFrequency > 0) {
builder.enableAdvertise()
.setAdvertiseAddress(advertiseSocketBinding.getValue().getSocketAddress().getAddress().getHostAddress())
.setAdvertiseGroup(multicastAddress.getHostAddress())
.setAdvertisePort(advertiseSocketBinding.getValue().getMulticastPort())
.setAdvertiseFrequency(advertiseFrequency)
.setPath(advertisePath)
.setProtocol(advertiseProtocol)
.setSecurityKey(securityKey);
final SocketBinding advertiseBinding = advertiseSocketBinding.getOptionalValue();
if (advertiseBinding != null) {
InetAddress multicastAddress = advertiseBinding.getMulticastAddress();
if (multicastAddress == null) {
throw UndertowLogger.ROOT_LOGGER.advertiseSocketBindingRequiresMulticastAddress();
}
if (advertiseFrequency > 0) {
builder.enableAdvertise()
.setAdvertiseAddress(advertiseBinding.getSocketAddress().getAddress().getHostAddress())
.setAdvertiseGroup(multicastAddress.getHostAddress())
.setAdvertisePort(advertiseBinding.getMulticastPort())
.setAdvertiseFrequency(advertiseFrequency)
.setPath(advertisePath)
.setProtocol(advertiseProtocol)
.setSecurityKey(securityKey);
}
}
builder.setManagementHost(managementSocketBinding.getValue().getSocketAddress().getHostString());
builder.setManagementPort(managementSocketBinding.getValue().getSocketAddress().getPort());

config = builder.build();


if(advertiseFrequency > 0) {
if (advertiseBinding != null && advertiseFrequency > 0) {
try {
modCluster.advertise(config);
} catch (IOException e) {
Expand Down Expand Up @@ -260,7 +263,10 @@ static ServiceController<FilterService> install(String name, ServiceTarget servi
builder.getMap());
ServiceBuilder<FilterService> serviceBuilder = serviceTarget.addService(UndertowService.FILTER.append(name), service);
serviceBuilder.addDependency(SocketBinding.JBOSS_BINDING_NAME.append(ModClusterDefinition.MANAGEMENT_SOCKET_BINDING.resolveModelAttribute(operationContext, model).asString()), SocketBinding.class, service.managementSocketBinding);
serviceBuilder.addDependency(SocketBinding.JBOSS_BINDING_NAME.append(ModClusterDefinition.ADVERTISE_SOCKET_BINDING.resolveModelAttribute(operationContext, model).asString()), SocketBinding.class, service.advertiseSocketBinding);
final ModelNode advertiseSocketBinding = ModClusterDefinition.ADVERTISE_SOCKET_BINDING.resolveModelAttribute(operationContext, model);
if (advertiseSocketBinding.isDefined()) {
serviceBuilder.addDependency(SocketBinding.JBOSS_BINDING_NAME.append(advertiseSocketBinding.asString()), SocketBinding.class, service.advertiseSocketBinding);
}
serviceBuilder.addDependency(IOServices.WORKER.append(ModClusterDefinition.WORKER.resolveModelAttribute(operationContext, model).asString()), XnioWorker.class, service.workerInjectedValue);

if (sslContext.isDefined()) {
Expand Down
Expand Up @@ -394,8 +394,8 @@ undertow.filter.mod-cluster=A mod-cluster front end load balancer
undertow.handler.mod-cluster=A mod-cluster front end load balancer
undertow.handler.mod-cluster.add=Adds a front end mod-proxy load balancer
undertow.handler.mod-cluster.remove=Removes a mod cluster proxy handler
undertow.handler.mod-cluster.management-socket-binding=The socket binding of the mod_cluster management port. When using mod_cluster two HTTP listeners should be defined, a public one to handle requests, and one bound to the internal network to handle mod cluster commands. This socket binding should correspond to the internal listener, and should not be publicly accessible
undertow.handler.mod-cluster.advertise-socket-binding=The multicast group that is used to advertise
undertow.handler.mod-cluster.management-socket-binding=The socket binding of the mod_cluster management address and port. When using mod_cluster two HTTP listeners should be defined, a public one to handle requests, and one bound to the internal network to handle mod cluster commands. This socket binding should correspond to the internal listener, and should not be publicly accessible.
undertow.handler.mod-cluster.advertise-socket-binding=The multicast group and port that is used to advertise.
undertow.handler.mod-cluster.security-key=The security key that is used for the mod-cluster group. All members must use the same security key.
undertow.handler.mod-cluster.advertise-protocol=The protocol that is in use.
undertow.handler.mod-cluster.advertise-path=The path that mod-cluster is registered under.
Expand Down
Expand Up @@ -582,7 +582,7 @@
<xs:complexType name="modClusterType">
<xs:attribute name="name" use="required" type="xs:string"/>
<xs:attribute name="management-socket-binding" type="xs:string" use="required"/>
<xs:attribute name="advertise-socket-binding" type="xs:string" use="required"/>
<xs:attribute name="advertise-socket-binding" type="xs:string" use="optional"/>
<xs:attribute name="security-key" type="xs:string" use="optional"/>
<xs:attribute name="advertise-protocol" type="xs:string" use="optional"/>
<xs:attribute name="advertise-path" type="xs:string" use="optional"/>
Expand Down

0 comments on commit 378f69f

Please sign in to comment.