Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[COMMUNITY] [WFCORE-6830] Add four new attributes to the HTTP management interface #6166

Merged
merged 12 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,10 @@ public void performRuntime(OperationContext context, ModelNode operation, ModelN
}
}

// TODO - Double check, if these are not supported we still want to fall back to their default values.
final int backlog = BaseHttpInterfaceResourceDefinition.BACKLOG.resolveModelAttribute(context, model).asInt();
final int noRequestTimeout = BaseHttpInterfaceResourceDefinition.NO_REQUEST_TIMEOUT.resolveModelAttribute(context, model).asInt();
final int connectionHighWater = BaseHttpInterfaceResourceDefinition.CONNECTION_HIGH_WATER.resolveModelAttribute(context, model).asInt();
final int connectionLowWater = BaseHttpInterfaceResourceDefinition.CONNECTION_LOW_WATER.resolveModelAttribute(context, model).asInt();
ROOT_LOGGER.debugf("Resource Constraints backlog=%d, noRequestTimeout=%d, connectionHighWater=%d, connectionLowWater=%d",
backlog, noRequestTimeout, connectionHighWater, connectionLowWater);
List<ServiceName> requiredServices = installServices(context, new HttpInterfaceCommonPolicy() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ public enum Attribute {
ATTRIBUTE("attribute"),
AUTHENTICATION_CONTEXT("authentication-context"),
AUTO_START("auto-start"),
BACKLOG("backlog"),
BASE_DN("base-dn"),
BASE_ROLE("base-role"),
BOOT_TIME("boot-time"),
CACHE_FAILURES("cache-failures"),
CODE("code"),
COMPACT("compact"),
CONNECTION("connection"),
CONNECTION_HIGH_WATER("connection-high-water"),
CONNECTION_LOW_WATER("connection-low-water"),
CONNECTOR("connector"),
CONSOLE_ENABLED("console-enabled"),
CONTENT("content"),
Expand Down Expand Up @@ -122,6 +125,7 @@ public enum Attribute {
MULTICAST_PORT("multicast-port"),
NAME("name"),
NATIVE("native"),
NO_REQUEST_TIMEOUT("no-request-timeout"),
ORGANIZATION("organization"),
PARSE_ROLES_FROM_DN("parse-group-name-from-dn"),
PASSWORD("password"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ private static ManagementHttpServer create(Builder builder) {
}
}

ROOT_LOGGER.debugf("Resource Constraints backlog=%d, noRequestTimeout=%d, connectionHighWater=%d, connectionLowWater=%d",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Resource Constraints" is pretty vague in a message from a broadly scoped thing like ROOT_LOGGER.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bstansberry although this is ROOT_LOGGER the category logged at is actually "org.jboss.as.domain.http.api.undertow" - I could change the phrasing slightly to something like "Concurrent connection limits" but I think the log category does cover that this is the Undertow HTTP API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually may go for "HTTP Management API Connection Constraints"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, I went for the second option to add some clarity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry; for some reason I thought this was in controller or server or something. Anyway, the change is an improvement.

builder.backlog, builder.noRequestTimeout, builder.connectionHighWater, builder.connectionLowWater);

final OptionMap undertowOptions;
if (builder.noRequestTimeout != null) {
undertowOptions = OptionMap.create(UndertowOptions.NO_REQUEST_TIMEOUT, builder.noRequestTimeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,15 @@ public void readElement(final XMLExtendedStreamReader reader, final VersionedNam
new HostXml_18(defaultHostControllerName, runningMode, isCachedDc, extensionRegistry, extensionXml, version, namespaceUri).readElement(reader, operationList);
break;
default:
new HostXml_20(defaultHostControllerName, runningMode, isCachedDc, extensionRegistry, extensionXml, version, namespaceUri).readElement(reader, operationList);
new HostXml_20(defaultHostControllerName, runningMode, isCachedDc, extensionRegistry, extensionXml, namespace).readElement(reader, operationList);
}
}

@Override
public void writeContent(final XMLExtendedStreamWriter writer, final VersionedNamespace<IntVersion, ManagementXmlSchema> namespace, final ModelMarshallingContext context)
throws XMLStreamException {

final IntVersion version = namespace.getVersion();
final String namespaceUri = namespace.getUri();

new HostXml_20(defaultHostControllerName, runningMode, isCachedDc, extensionRegistry, extensionXml, version, namespaceUri).writeContent(writer, context);
new HostXml_20(defaultHostControllerName, runningMode, isCachedDc, extensionRegistry, extensionXml, namespace).writeContent(writer, context);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@
import org.jboss.as.controller.parsing.Attribute;
import org.jboss.as.controller.parsing.Element;
import org.jboss.as.controller.parsing.ExtensionXml;
import org.jboss.as.controller.parsing.ManagementXmlSchema;
import org.jboss.as.controller.parsing.ParseUtils;
import org.jboss.as.controller.parsing.ProfileParsingCompletionHandler;
import org.jboss.as.controller.parsing.WriteUtils;
import org.jboss.as.controller.persistence.ModelMarshallingContext;
import org.jboss.as.controller.xml.VersionedNamespace;
import org.jboss.as.domain.management.parsing.AuditLogXml;
import org.jboss.as.domain.management.parsing.ManagementXml;
import org.jboss.as.domain.management.parsing.ManagementXmlDelegate;
Expand All @@ -101,6 +103,7 @@
import org.jboss.as.server.parsing.CommonXml;
import org.jboss.as.server.parsing.SocketBindingsXml;
import org.jboss.as.server.services.net.SocketBindingGroupResourceDefinition;
import org.jboss.as.version.Stability;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.jboss.dmr.Property;
Expand All @@ -126,18 +129,20 @@ final class HostXml_20 extends CommonXml implements ManagementXmlDelegate {
private final ExtensionXml extensionXml;
private final IntVersion version;
private final String namespace;
private final Stability stability;

HostXml_20(String defaultHostControllerName, RunningMode runningMode, boolean isCachedDC,
final ExtensionRegistry extensionRegistry, final ExtensionXml extensionXml, final IntVersion version,
final String namespaceUri) {
final ExtensionRegistry extensionRegistry, final ExtensionXml extensionXml,
final VersionedNamespace<IntVersion, ManagementXmlSchema> namespace) {
super(new SocketBindingsXml.HostSocketBindingsXml());
this.namespace = namespaceUri;
this.namespace = namespace.getUri();
this.version = namespace.getVersion();
this.auditLogDelegate = AuditLogXml.newInstance(version, true);
this.defaultHostControllerName = defaultHostControllerName;
this.runningMode = runningMode;
this.isCachedDc = isCachedDC;
this.extensionRegistry = extensionRegistry;
this.version = version;
this.stability = namespace.getStability();
this.extensionXml = extensionXml;
}

Expand Down Expand Up @@ -396,6 +401,42 @@ private void parseHttpManagementInterfaceAttributes(XMLExtendedStreamReader read
HttpManagementResourceDefinition.ALLOWED_ORIGINS.getParser().parseAndSetParameter(HttpManagementResourceDefinition.ALLOWED_ORIGINS, value, addOp, reader);
break;
}
case BACKLOG: {
// Can't pull the Stability level from the attribute definition as to move would mean a new major version of the schema.
if (stability.enables(Stability.COMMUNITY)) {
HttpManagementResourceDefinition.BACKLOG.parseAndSetParameter(value, addOp, reader);
} else {
throw unexpectedAttribute(reader, i);
}
break;
}
case NO_REQUEST_TIMEOUT: {
// Can't pull the Stability level from the attribute definition as to move would mean a new major version of the schema.
if (stability.enables(Stability.COMMUNITY)) {
HttpManagementResourceDefinition.NO_REQUEST_TIMEOUT.parseAndSetParameter(value, addOp, reader);
} else {
throw unexpectedAttribute(reader, i);
}
break;
}
case CONNECTION_HIGH_WATER: {
// Can't pull the Stability level from the attribute definition as to move would mean a new major version of the schema.
if (stability.enables(Stability.COMMUNITY)) {
HttpManagementResourceDefinition.CONNECTION_HIGH_WATER.parseAndSetParameter(value, addOp, reader);
} else {
throw unexpectedAttribute(reader, i);
}
break;
}
case CONNECTION_LOW_WATER: {
// Can't pull the Stability level from the attribute definition as to move would mean a new major version of the schema.
if (stability.enables(Stability.COMMUNITY)) {
HttpManagementResourceDefinition.CONNECTION_LOW_WATER.parseAndSetParameter(value, addOp, reader);
} else {
throw unexpectedAttribute(reader, i);
}
break;
}
default:
throw unexpectedAttribute(reader, i);
}
Expand Down Expand Up @@ -1711,9 +1752,15 @@ public boolean writeHttpManagementProtocol(XMLExtendedStreamWriter writer, Model
HttpManagementResourceDefinition.SSL_CONTEXT.marshallAsAttribute(protocol, writer);
HttpManagementResourceDefinition.CONSOLE_ENABLED.marshallAsAttribute(protocol, writer);
HttpManagementResourceDefinition.ALLOWED_ORIGINS.getMarshaller().marshallAsAttribute(
HttpManagementResourceDefinition.ALLOWED_ORIGINS, protocol, true, writer);
HttpManagementResourceDefinition.ALLOWED_ORIGINS, protocol, true, writer);
HttpManagementResourceDefinition.SASL_PROTOCOL.marshallAsAttribute(protocol, writer);
HttpManagementResourceDefinition.SERVER_NAME.marshallAsAttribute(protocol, writer);
if (stability.enables(Stability.COMMUNITY)) {
HttpManagementResourceDefinition.BACKLOG.marshallAsAttribute(protocol, writer);
HttpManagementResourceDefinition.NO_REQUEST_TIMEOUT.marshallAsAttribute(protocol, writer);
HttpManagementResourceDefinition.CONNECTION_HIGH_WATER.marshallAsAttribute(protocol, writer);
HttpManagementResourceDefinition.CONNECTION_LOW_WATER.marshallAsAttribute(protocol, writer);
}

if (HttpManagementResourceDefinition.HTTP_UPGRADE.isMarshallable(protocol)) {
writer.writeEmptyElement(Element.HTTP_UPGRADE.getLocalName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,15 @@ public void readElement(final XMLExtendedStreamReader reader, final VersionedNam
new StandaloneXml_18(extensionHandler, version, namespaceUri, deferredExtensionContext, parsingOptions).readElement(reader, operationList);
break;
default:
new StandaloneXml_20(extensionHandler, version, namespaceUri, deferredExtensionContext, parsingOptions).readElement(reader, operationList);
new StandaloneXml_20(extensionHandler, namespace, deferredExtensionContext, parsingOptions).readElement(reader, operationList);
}
}

@Override
public void writeContent(final XMLExtendedStreamWriter writer, final VersionedNamespace<IntVersion, ManagementXmlSchema> namespace, final ModelMarshallingContext context)
throws XMLStreamException {

final IntVersion version = namespace.getVersion();
final String namespaceUri = namespace.getUri();

new StandaloneXml_20(extensionHandler, version, namespaceUri, deferredExtensionContext, parsingOptions).writeContent(writer, context);
new StandaloneXml_20(extensionHandler, namespace, deferredExtensionContext, parsingOptions).writeContent(writer, context);
}

class DefaultExtensionHandler implements ExtensionHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ACCESS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.AUTHORIZATION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CONNECTION_HIGH_WATER;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CONNECTION_LOW_WATER;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CONTENT;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CORE_SERVICE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DEPLOYMENT;
Expand All @@ -22,6 +24,7 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NATIVE_INTERFACE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NATIVE_REMOTING_INTERFACE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NO_REQUEST_TIMEOUT;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ORGANIZATION;
Expand Down Expand Up @@ -62,10 +65,12 @@
import org.jboss.as.controller.parsing.Attribute;
import org.jboss.as.controller.parsing.DeferredExtensionContext;
import org.jboss.as.controller.parsing.Element;
import org.jboss.as.controller.parsing.ManagementXmlSchema;
import org.jboss.as.controller.parsing.ParseUtils;
import org.jboss.as.controller.parsing.ProfileParsingCompletionHandler;
import org.jboss.as.controller.parsing.WriteUtils;
import org.jboss.as.controller.persistence.ModelMarshallingContext;
import org.jboss.as.controller.xml.VersionedNamespace;
import org.jboss.as.domain.management.access.AccessAuthorizationResourceDefinition;
import org.jboss.as.domain.management.parsing.AccessControlXml;
import org.jboss.as.domain.management.parsing.AuditLogXml;
Expand All @@ -77,6 +82,7 @@
import org.jboss.as.server.mgmt.HttpManagementResourceDefinition;
import org.jboss.as.server.mgmt.NativeManagementResourceDefinition;
import org.jboss.as.server.services.net.SocketBindingGroupResourceDefinition;
import org.jboss.as.version.Stability;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.jboss.dmr.Property;
Expand All @@ -97,16 +103,18 @@ final class StandaloneXml_20 extends CommonXml implements ManagementXmlDelegate
private final StandaloneXml.ParsingOption[] parsingOptions;
private final IntVersion version;
private final String namespace;
private final Stability stability;
private AuditLogXml auditLogDelegate;
private ExtensionHandler extensionHandler;
private final DeferredExtensionContext deferredExtensionContext;

StandaloneXml_20(ExtensionHandler extensionHandler, IntVersion version, String namespaceUri, DeferredExtensionContext deferredExtensionContext, StandaloneXml.ParsingOption... options) {
StandaloneXml_20(ExtensionHandler extensionHandler, final VersionedNamespace<IntVersion, ManagementXmlSchema> namespace, DeferredExtensionContext deferredExtensionContext, StandaloneXml.ParsingOption... options) {
super(new SocketBindingsXml.ServerSocketBindingsXml());
this.extensionHandler = extensionHandler;
this.version = version;
this.namespace = namespaceUri;
this.accessControlXml = AccessControlXml.newInstance(namespace);
this.version = namespace.getVersion();
this.namespace = namespace.getUri();
this.stability = namespace.getStability();
this.accessControlXml = AccessControlXml.newInstance(this.namespace);
this.auditLogDelegate = AuditLogXml.newInstance(version, false);
this.deferredExtensionContext = deferredExtensionContext;
this.parsingOptions = options;
Expand Down Expand Up @@ -274,6 +282,42 @@ private void parseHttpManagementInterfaceAttributes(XMLExtendedStreamReader read
HttpManagementResourceDefinition.ALLOWED_ORIGINS.getParser().parseAndSetParameter(HttpManagementResourceDefinition.ALLOWED_ORIGINS, value, addOp, reader);
break;
}
case BACKLOG: {
// Can't pull the Stability level from the attribute definition as to move would mean a new major version of the schema.
if (stability.enables(Stability.COMMUNITY)) {
HttpManagementResourceDefinition.BACKLOG.parseAndSetParameter(value, addOp, reader);
} else {
throw unexpectedAttribute(reader, i);
}
break;
}
case NO_REQUEST_TIMEOUT: {
// Can't pull the Stability level from the attribute definition as to move would mean a new major version of the schema.
if (stability.enables(Stability.COMMUNITY)) {
HttpManagementResourceDefinition.NO_REQUEST_TIMEOUT.parseAndSetParameter(value, addOp, reader);
} else {
throw unexpectedAttribute(reader, i);
}
break;
}
case CONNECTION_HIGH_WATER: {
// Can't pull the Stability level from the attribute definition as to move would mean a new major version of the schema.
if (stability.enables(Stability.COMMUNITY)) {
HttpManagementResourceDefinition.CONNECTION_HIGH_WATER.parseAndSetParameter(value, addOp, reader);
} else {
throw unexpectedAttribute(reader, i);
}
break;
}
case CONNECTION_LOW_WATER: {
// Can't pull the Stability level from the attribute definition as to move would mean a new major version of the schema.
if (stability.enables(Stability.COMMUNITY)) {
HttpManagementResourceDefinition.CONNECTION_LOW_WATER.parseAndSetParameter(value, addOp, reader);
} else {
throw unexpectedAttribute(reader, i);
}
break;
}
default:
throw unexpectedAttribute(reader, i);
}
Expand Down Expand Up @@ -929,6 +973,12 @@ public boolean writeHttpManagementProtocol(XMLExtendedStreamWriter writer, Model
HttpManagementResourceDefinition.SASL_PROTOCOL.marshallAsAttribute(protocol, writer);
HttpManagementResourceDefinition.SERVER_NAME.marshallAsAttribute(protocol, writer);
HttpManagementResourceDefinition.CONSOLE_ENABLED.marshallAsAttribute(protocol, writer);
if (stability.enables(Stability.COMMUNITY)) {
HttpManagementResourceDefinition.BACKLOG.marshallAsAttribute(protocol, writer);
HttpManagementResourceDefinition.NO_REQUEST_TIMEOUT.marshallAsAttribute(protocol, writer);
HttpManagementResourceDefinition.CONNECTION_HIGH_WATER.marshallAsAttribute(protocol, writer);
HttpManagementResourceDefinition.CONNECTION_LOW_WATER.marshallAsAttribute(protocol, writer);
}

HttpManagementResourceDefinition.ALLOWED_ORIGINS.getMarshaller().marshallAsAttribute(
HttpManagementResourceDefinition.ALLOWED_ORIGINS, protocol, true, writer);
Expand Down