Skip to content

Commit

Permalink
Merge pull request #15080 from TomasHofman/JBEAP-23054
Browse files Browse the repository at this point in the history
WFLY-15897 Messaging BroadcastGroupDefinition & DiscoveryGroupDefinition fixes
  • Loading branch information
bstansberry committed Jan 14, 2022
2 parents 534cdc9 + 635a232 commit fcbc144
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 11 deletions.
Expand Up @@ -879,4 +879,7 @@ public interface MessagingLogger extends BasicLogger {
@Message(id = 104, value = "Legacy security is no longer supported.")
IllegalStateException legacySecurityUnsupported();

@Message(id = 105, value = "The %s %s is configured to use socket-binding %s, but this socket binding doesn't have the multicast-address or a multicast-port attributes configured.")
OperationFailedException socketBindingMulticastNotSet(String resourceType, String resourceName, String socketBindingName);

}
Expand Up @@ -67,7 +67,7 @@
*/
public class BroadcastGroupDefinition extends ShallowResourceDefinition {
public static final PrimitiveListAttributeDefinition CONNECTOR_REFS = new StringListAttributeDefinition.Builder(CONNECTORS)
.setRequired(false)
.setRequired(true)
.setElementValidator(new StringLengthValidator(1))
.setAttributeParser(AttributeParser.STRING_LIST)
.setAttributeMarshaller(AttributeMarshaller.STRING_LIST)
Expand Down
Expand Up @@ -49,7 +49,7 @@ public class BroadcastGroupWriteAttributeHandler extends ReloadRequiredWriteAttr

public static final BroadcastGroupWriteAttributeHandler INSTANCE = new BroadcastGroupWriteAttributeHandler(BROADCAST_GROUP_PATH, BroadcastGroupDefinition.ATTRIBUTES);
public static final BroadcastGroupWriteAttributeHandler JGROUP_INSTANCE = new BroadcastGroupWriteAttributeHandler(JGROUPS_BROADCAST_GROUP_PATH, JGroupsBroadcastGroupDefinition.ATTRIBUTES);
public static final BroadcastGroupWriteAttributeHandler SOCKET_INSTANCE = new BroadcastGroupWriteAttributeHandler(SOCKET_BROADCAST_GROUP_PATH, JGroupsBroadcastGroupDefinition.ATTRIBUTES);
public static final BroadcastGroupWriteAttributeHandler SOCKET_INSTANCE = new BroadcastGroupWriteAttributeHandler(SOCKET_BROADCAST_GROUP_PATH, SocketBroadcastGroupDefinition.ATTRIBUTES);

private final PathElement path;

Expand Down
Expand Up @@ -138,6 +138,9 @@ static BroadcastGroupConfiguration createBroadcastGroupConfiguration(final Opera
static BroadcastGroupConfiguration createBroadcastGroupConfiguration(final String name, final BroadcastGroupConfiguration config, final SocketBinding socketBinding) throws Exception {

final String localAddress = socketBinding.getAddress().getHostAddress();
if (socketBinding.getMulticastAddress() == null) {
throw MessagingLogger.ROOT_LOGGER.socketBindingMulticastNotSet("socket-broadcast-group", name, socketBinding.getName());
}
final String groupAddress = socketBinding.getMulticastAddress().getHostAddress();
final int localPort = socketBinding.getPort();
final int groupPort = socketBinding.getMulticastPort();
Expand Down
Expand Up @@ -45,6 +45,7 @@
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;

/**
* Handler for adding a discovery group using socket bindings.
Expand Down Expand Up @@ -122,6 +123,9 @@ static DiscoveryGroupConfiguration createDiscoveryGroupConfiguration(final Opera
public static DiscoveryGroupConfiguration createDiscoveryGroupConfiguration(final String name, final DiscoveryGroupConfiguration config, final SocketBinding socketBinding) throws Exception {

final String localAddress = socketBinding.getAddress().getHostAddress();
if (socketBinding.getMulticastAddress() == null) {
throw MessagingLogger.ROOT_LOGGER.socketBindingMulticastNotSet("socket-discovery-group", name, socketBinding.getName());
}
final String groupAddress = socketBinding.getMulticastAddress().getHostAddress();
final int groupPort = socketBinding.getMulticastPort();
final long refreshTimeout = config.getRefreshTimeout();
Expand Down
Expand Up @@ -23,25 +23,35 @@
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.dmr.ModelNode;
import org.jboss.logging.Logger;

/**
*
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class TranslatedWriteAttributeHandler implements OperationStepHandler {

private final OperationAddressConverter converter;
private static final Logger LOG = Logger.getLogger(TranslatedWriteAttributeHandler.class);

public TranslatedWriteAttributeHandler(OperationAddressConverter converter) {
private final ShallowResourceDefinition converter;

public TranslatedWriteAttributeHandler(ShallowResourceDefinition converter) {
this.converter = converter;
}

@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
PathAddress targetAddress = converter.convert(context, operation);
ModelNode op = operation.clone();
op.get(OP_ADDR).set(targetAddress.toModelNode());
OperationStepHandler writeAttributeHandler = context.getRootResourceRegistration().getAttributeAccess(targetAddress, op.get(ModelDescriptionConstants.NAME).asString()).getWriteHandler();
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
PathAddress targetAddress = converter.convert(context, operation);
ModelNode op = operation.clone();
op.get(OP_ADDR).set(targetAddress.toModelNode());
String attributeName = op.get(ModelDescriptionConstants.NAME).asString();
if (!converter.getIgnoredAttributes(context, op).contains(attributeName)) {
OperationStepHandler writeAttributeHandler = context.getRootResourceRegistration()
.getAttributeAccess(targetAddress, attributeName).getWriteHandler();
context.addStep(op, writeAttributeHandler, context.getCurrentStage(), true);
} else {
LOG.debugf("Ignoring write operation on resource %s, attribute %s. The attribute is ignored.",
targetAddress.toString(), attributeName);
}
}
}
}

0 comments on commit fcbc144

Please sign in to comment.