Skip to content

Commit

Permalink
[WFLY-5384] Validate Artemis Parameters
Browse files Browse the repository at this point in the history
* map WildFly hyphen-separated names to Artemis CamelCase names for
  acceptor/connectors parameters
* change http-upgrade-endpoint to be a required attribute for http-connector resource

JIRA: https://issues.jboss.org/browse/WFLY-5384
  • Loading branch information
jmesnil committed Sep 23, 2015
1 parent cf3727c commit 5b470a7
Show file tree
Hide file tree
Showing 11 changed files with 218 additions and 37 deletions.
Expand Up @@ -417,7 +417,11 @@ private void transformResources(final ModelNode legacyModelDescription, final Ma
String name = address.getLastElement().getValue();
ModelNode value = newAddOp.get(VALUE);
ModelNode parentAddOp = newAddOperations.get(address.getParent());
parentAddOp.get("params").add(new Property(name, value));
if (name.equals("http-upgrade-endpoint") && address.getParent().getLastElement().getKey().equals("http-connector")) {
parentAddOp.get("endpoint").set(value);
} else {
parentAddOp.get("params").add(new Property(name, value));
}
continue;
}
break;
Expand Down
Expand Up @@ -73,6 +73,7 @@
<connectors>
<http-connector name="http" socket-binding="http">
<param key="batch-delay" value="${batch.delay:50}"/>
<param key="http-upgrade-endpoint" value="http"/>
</http-connector>
<netty-connector name="netty" socket-binding="messaging" />
<netty-connector name="netty-throughput" socket-binding="messaging-throughput">
Expand Down
Expand Up @@ -32,6 +32,7 @@
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;

/**
* HTTP connector resource definition
Expand All @@ -54,9 +55,15 @@ public void marshallAsAttribute(AttributeDefinition attribute, ModelNode resourc
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.SOCKET_BINDING_REF)
.build();

// for remote acceptor, the socket-binding is required
public static final SimpleAttributeDefinition ENDPOINT = create("endpoint", ModelType.STRING)
.setAllowNull(false)
.setAllowExpression(false) // references another resource
.build();

static final HTTPConnectorDefinition INSTANCE = new HTTPConnectorDefinition();

public HTTPConnectorDefinition() {
super(false, CommonAttributes.HTTP_CONNECTOR, SOCKET_BINDING, PARAMS);
super(false, CommonAttributes.HTTP_CONNECTOR, SOCKET_BINDING, ENDPOINT, PARAMS);
}
}
Expand Up @@ -117,7 +117,7 @@ public void start(StartContext context) throws StartException {
public boolean handleUpgrade(HttpServerExchange exchange) throws IOException {

if (super.handleUpgrade(exchange)) {
final String endpoint = exchange.getRequestHeaders().getFirst(HTTP_UPGRADE_ENDPOINT_PROP_NAME);
final String endpoint = exchange.getRequestHeaders().getFirst(getHttpUpgradeEndpointKey());
if (endpoint == null) {
return true;
} else {
Expand Down Expand Up @@ -169,6 +169,11 @@ protected String getSecAcceptHeader() {
return SEC_ACTIVEMQ_REMOTING_ACCEPT;
}

protected String getHttpUpgradeEndpointKey() {
return HTTP_UPGRADE_ENDPOINT_PROP_NAME;
}


/**
* Service to handle HTTP upgrade for legacy (HornetQ) clients.
*
Expand Down Expand Up @@ -197,6 +202,11 @@ protected String getProtocol() {
return HORNETQ_REMOTING;
}

@Override
protected String getHttpUpgradeEndpointKey() {
return "http-upgrade-endpoint";
}

@Override
protected String getSecKeyHeader() {
return SEC_HORNETQ_REMOTING_KEY;
Expand Down
Expand Up @@ -294,6 +294,7 @@ public class MessagingSubsystemParser_1_0 implements XMLStreamConstants, XMLElem
builder(HTTPConnectorDefinition.INSTANCE)
.addAttributes(
HTTPConnectorDefinition.SOCKET_BINDING,
HTTPConnectorDefinition.ENDPOINT,
CommonAttributes.PARAMS))
.addChild(
builder(RemoteTransportDefinition.CONNECTOR_INSTANCE)
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -174,6 +174,7 @@ connector-service.remove=Operation removing a connector service
connector-service=TODO
connector.add.params=A set of key-value pairs understood by the connector factory-class and used to configure it.
connector.add=Operation adding a connector
connector.endpoint=The http-acceptor that serves as the endpoint of this http-connector.
connector.factory-class=Class name of the factory class that can instantiate the connector.
connector.params=A key-value pair understood by the connector factory-class and used to configure it.
connector.remove=Operation removing a connector
Expand Down
Expand Up @@ -260,6 +260,7 @@
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="socket-binding" type="xs:string" use="required" />
<xs:attribute name="endpoint" type="xs:string" use="required" />
</xs:complexType>
</xs:element>

Expand Down
Expand Up @@ -17,14 +17,11 @@
<?ADDRESS-SETTINGS?>

<http-connector name="http-connector"
socket-binding="http">
<param name="http-upgrade-endpoint"
value="http-acceptor"/>
</http-connector>
socket-binding="http"
endpoint="http-acceptor" />
<http-connector name="http-connector-throughput"
socket-binding="http">
<param name="http-upgrade-endpoint"
value="http-acceptor-throughput"/>
socket-binding="http"
endpoint="http-acceptor-throughput">
<param name="batch-delay"
value="50"/>
</http-connector>
Expand Down
Expand Up @@ -122,7 +122,8 @@
slow-consumer-threshold="${slow.consumer.threshold:456}"/>

<http-connector name="http"
socket-binding="http">
socket-binding="http"
endpoint="http">
<param name="batch-delay" value="${batch.delay:50}"/>
</http-connector>
<remote-connector name="netty"
Expand Down Expand Up @@ -157,7 +158,7 @@
server-id="${my.server-id:0}"/>
<acceptor name="myacceptor"
factory-class="org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory">
<param name="batch-delay" value="${batch.delay:50}"/>
<param name="batchDelay" value="${batch.delay:50}"/>
</acceptor>

<broadcast-group name="groupT"
Expand Down
Expand Up @@ -334,11 +334,8 @@
<role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>
</security-setting>
<address-setting name="#" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10"/>
<http-connector name="http-connector" socket-binding="http">
<param name="http-upgrade-endpoint" value="http-acceptor"/>
</http-connector>
<http-connector name="http-connector-throughput" socket-binding="http">
<param name="http-upgrade-endpoint" value="http-acceptor-throughput"/>
<http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor" />
<http-connector name="http-connector-throughput" socket-binding="http" endpoint="http-acceptor-throughput">
<param name="batch-delay" value="50"/>
</http-connector>
<in-vm-connector name="in-vm" server-id="0"/>
Expand Down Expand Up @@ -598,11 +595,8 @@
<role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>
</security-setting>
<address-setting name="#" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10"/>
<http-connector name="http-connector" socket-binding="http">
<param name="http-upgrade-endpoint" value="http-acceptor"/>
</http-connector>
<http-connector name="http-connector-throughput" socket-binding="http">
<param name="http-upgrade-endpoint" value="http-acceptor-throughput"/>
<http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor" />
<http-connector name="http-connector-throughput" socket-binding="http" endpoint="http-acceptor-throughput">
<param name="batch-delay" value="50"/>
</http-connector>
<in-vm-connector name="in-vm" server-id="0"/>
Expand Down

0 comments on commit 5b470a7

Please sign in to comment.