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 all commits
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 @@ -66,6 +66,7 @@ public class ModelDescriptionConstants {
public static final String AUTHENTICATION_CONTEXT = "authentication-context";
public static final String AUTHORIZATION = "authorization";
public static final String AUTO_START = "auto-start";
public static final String BACKLOG = "backlog";
public static final String BASE_DN = "base-dn";
public static final String BASE_ROLE = "base-role";
public static final String BLOCKING = "blocking";
Expand Down Expand Up @@ -94,6 +95,8 @@ public class ModelDescriptionConstants {
public static final String COMPLEX_ATTRIBUTE = "complex-attribute";
public static final String COMPOSITE = "composite";
public static final String CONFIGURATION_CHANGES="configuration-changes";
public static final String CONNECTION_HIGH_WATER = "connection-high-water";
public static final String CONNECTION_LOW_WATER = "connection-low-water";
public static final String CONSTRAINT = "constraint";
public static final String CONCURRENT_GROUPS = "concurrent-groups";
public static final String CONFIGURED_APPLICATION = "configured-application";
Expand Down Expand Up @@ -325,6 +328,7 @@ public class ModelDescriptionConstants {
public static final String NETWORK = "network";
public static final String NILLABLE = "nillable";
public static final String NIL_SIGNIFICANT = "nil-significant";
public static final String NO_REQUEST_TIMEOUT = "no-request-timeout";
public static final String NORMAL = "normal";
public static final String NOT = "not";
public static final String NOTIFICATION = "notification";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3798,4 +3798,8 @@ OperationFailedRuntimeException capabilityAlreadyRegisteredInContext(String capa
@Message(id = 514, value = "Management namespace %s is not enabled by the current stability level")
XMLStreamException unstableManagementNamespace(String namespaceURI);

@LogMessage(level = INFO)
@Message(id = 515, value = "The system property '%s' is deprecated and may be removed in a future version, " +
"attribute '%s' on resource '%s' should be used instead.")
void systemPropertyDeprecated(String systemProperty, String attribute, String address);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

package org.jboss.as.controller.management;

import static org.jboss.as.controller.logging.ControllerLogger.DEPRECATED_LOGGER;
import static org.jboss.as.controller.logging.ControllerLogger.ROOT_LOGGER;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
Expand All @@ -30,6 +32,12 @@
*/
public abstract class BaseHttpInterfaceAddStepHandler extends ManagementInterfaceAddStepHandler {

private static final String PROPERTY_BASE = "org.wildfly.management.";
private static final String BACKLOG_PROPERTY = PROPERTY_BASE + "backlog";
private static final String CONNECTION_HIGH_WATER_PROPERTY = PROPERTY_BASE + "connection-high-water";
private static final String CONNECTION_LOW_WATER_PROPERTY = PROPERTY_BASE + "connection-low-water";
private static final String NO_REQUEST_TIMEOUT_PROPERTY = PROPERTY_BASE + "no-request-timeout";

protected static final String HTTP_AUTHENTICATION_FACTORY_CAPABILITY = "org.wildfly.security.http-authentication-factory";
protected static final String SASL_AUTHENTICATION_FACTORY_CAPABILITY = "org.wildfly.security.sasl-authentication-factory";
protected static final String SSL_CONTEXT_CAPABILITY = "org.wildfly.security.ssl-context";
Expand Down Expand Up @@ -96,6 +104,10 @@ public void performRuntime(OperationContext context, ModelNode operation, ModelN
}
}

final int backlog = resolveIntProperty(BACKLOG_PROPERTY, BaseHttpInterfaceResourceDefinition.BACKLOG, context, model);
final int noRequestTimeout = resolveIntProperty(NO_REQUEST_TIMEOUT_PROPERTY, BaseHttpInterfaceResourceDefinition.NO_REQUEST_TIMEOUT, context, model);
final int connectionHighWater = resolveIntProperty(CONNECTION_HIGH_WATER_PROPERTY, BaseHttpInterfaceResourceDefinition.CONNECTION_HIGH_WATER, context, model);
final int connectionLowWater = resolveIntProperty(CONNECTION_LOW_WATER_PROPERTY, BaseHttpInterfaceResourceDefinition.CONNECTION_LOW_WATER, context, model);
List<ServiceName> requiredServices = installServices(context, new HttpInterfaceCommonPolicy() {

@Override
Expand Down Expand Up @@ -138,11 +150,46 @@ public Map<String, List<Header>> getConstantHeaders() {
return constantHeaders;
}

@Override
public int getBacklog() {
return backlog;
}

@Override
public int getNoRequestTimeoutMs() {
return noRequestTimeout;
}

@Override
public int getConnectionHighWater() {
return connectionHighWater;
}

@Override
public int getConnectionLowWater() {
return connectionLowWater;
}




}, model);
addVerifyInstallationStep(context, requiredServices);
}

protected abstract List<ServiceName> installServices(OperationContext context, HttpInterfaceCommonPolicy commonPolicy, ModelNode model) throws OperationFailedException;

private static int resolveIntProperty(final String systemProperty, final AttributeDefinition attributeDefinition,
final OperationContext context, final ModelNode model) throws OperationFailedException {
if (System.getProperty(systemProperty) != null) {
if (context.enables(attributeDefinition)) {
// Log a warning if the system property is used and the attribute is enabled at the current stability level.
DEPRECATED_LOGGER.systemPropertyDeprecated(systemProperty, attributeDefinition.getName(), context.getCurrentAddress().toCLIStyleString());
}
return Integer.parseInt(System.getProperty(systemProperty));
}

// This is fine if not enabled as we still get the default returned.
return attributeDefinition.resolveModelAttribute(context, model).asInt();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@
import org.jboss.as.controller.StringListAttributeDefinition;
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.client.helpers.MeasurementUnit;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.operations.validation.ParameterValidator;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
import org.jboss.as.controller.parsing.Attribute;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.version.Stability;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;

Expand Down Expand Up @@ -181,8 +183,38 @@ public void validateParameter(String parameterName, ModelNode value) throws Oper
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.build();

public static final SimpleAttributeDefinition BACKLOG = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.BACKLOG, ModelType.INT, true)
.setAllowExpression(true)
.setDefaultValue(new ModelNode(50))
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setStability(Stability.COMMUNITY)
.build();

public static final SimpleAttributeDefinition NO_REQUEST_TIMEOUT = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.NO_REQUEST_TIMEOUT, ModelType.INT, true)
.setAllowExpression(true)
.setMeasurementUnit(MeasurementUnit.MILLISECONDS)
.setDefaultValue(new ModelNode(60000))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a setMeasurementUnit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is added, BTW @bstansberry GitHub says FAHRENHEIGHT was your contribution? 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Somebody hacked me!

Copy link
Contributor

Choose a reason for hiding this comment

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

.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setStability(Stability.COMMUNITY)
.build();

public static final SimpleAttributeDefinition CONNECTION_HIGH_WATER = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.CONNECTION_HIGH_WATER, ModelType.INT, true)
.setAllowExpression(true)
.setDefaultValue(new ModelNode(100))
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setStability(Stability.COMMUNITY)
.build();

public static final SimpleAttributeDefinition CONNECTION_LOW_WATER = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.CONNECTION_LOW_WATER, ModelType.INT, true)
.setAllowExpression(true)
.setDefaultValue(new ModelNode(75))
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setStability(Stability.COMMUNITY)
.build();

protected static final AttributeDefinition[] COMMON_ATTRIBUTES = new AttributeDefinition[] { HTTP_AUTHENTICATION_FACTORY, SSL_CONTEXT, CONSOLE_ENABLED, HTTP_UPGRADE_ENABLED,
HTTP_UPGRADE, SASL_PROTOCOL, SERVER_NAME, ALLOWED_ORIGINS, CONSTANT_HEADERS};
HTTP_UPGRADE, SASL_PROTOCOL, SERVER_NAME, ALLOWED_ORIGINS, CONSTANT_HEADERS,
BACKLOG, NO_REQUEST_TIMEOUT, CONNECTION_HIGH_WATER, CONNECTION_LOW_WATER };

/**
* @param parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,34 @@ public interface HttpInterfaceCommonPolicy {
*/
Map<String, List<Header>> getConstantHeaders();

/**
* Get the maximum number of pending connections that can be queued before the server starts to reject connections.
*
* @return the maximum number of pending connections that can be queued before the server starts to reject connections.
*/
int getBacklog();

/**
* Get the maximum time in milliseconds that a connection can be idle without receiving a HTTP request before it is closed.
*
* @return the maximum time in milliseconds that a connection can be idle without receiving a HTTP request before it is closed.
*/
int getNoRequestTimeoutMs();

/**
* Get the maximum number of connections that can be open before the interface stops accepting new connections.
*
* @return the maximum number of connections that can be open before the interface stops accepting new connections.
*/
int getConnectionHighWater();

/**
* Gets the connection count that must be reached before the server starts to accept new connections again.
*
* @return the connection count that must be reached before the server starts to accept new connections again.
*/
int getConnectionLowWater();

static class Header {
final String name;
final String value;
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 @@ -50,13 +50,13 @@ public String getLocalName() {

@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> value) throws XMLStreamException {
readerWriterDelegate.readElement(reader, namespace.getVersion(), namespace.getUri(), value);
readerWriterDelegate.readElement(reader, namespace, value);
}

@Override
public void writeContent(XMLExtendedStreamWriter streamWriter, ModelMarshallingContext value)
throws XMLStreamException {
readerWriterDelegate.writeContent(streamWriter, namespace.getVersion(), namespace.getUri(), value);
readerWriterDelegate.writeContent(streamWriter, namespace, value);
}

public static ManagementSchema create(ManagementXmlReaderWriter readerWriterDelegate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private enum Version implements Feature {
VERSION_18(18),
VERSION_19(19),
VERSION_20(20),
VERSION_20_COMMUNITY(20, Stability.COMMUNITY),
;

private final int majorVersion;
Expand All @@ -66,6 +67,10 @@ private enum Version implements Feature {
this(majorVersion, 0);
}

Version(final int majorVersion, final Stability stability) {
this(majorVersion, 0, stability);
}

Version(final int majorVersion, final int minorVersion) {
this(majorVersion, minorVersion, Stability.DEFAULT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import javax.xml.stream.XMLStreamException;

import org.jboss.as.controller.persistence.ModelMarshallingContext;
import org.jboss.as.controller.xml.VersionedNamespace;
import org.jboss.dmr.ModelNode;
import org.jboss.staxmapper.IntVersion;
import org.jboss.staxmapper.XMLExtendedStreamReader;
Expand All @@ -22,7 +23,7 @@
*/
public interface ManagementXmlReaderWriter {

void readElement(XMLExtendedStreamReader reader, IntVersion version, String namespaceUri, List<ModelNode> value) throws XMLStreamException;
void readElement(XMLExtendedStreamReader reader, VersionedNamespace<IntVersion, ManagementXmlSchema> namespace, List<ModelNode> value) throws XMLStreamException;

void writeContent(XMLExtendedStreamWriter streamWriter, IntVersion version, String namespaceUri, ModelMarshallingContext value) throws XMLStreamException;
void writeContent(XMLExtendedStreamWriter streamWriter, VersionedNamespace<IntVersion, ManagementXmlSchema> namespace, ModelMarshallingContext value) throws XMLStreamException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import javax.xml.stream.XMLStreamException;

import org.jboss.as.controller.persistence.ModelMarshallingContext;
import org.jboss.as.controller.xml.VersionedNamespace;
import org.jboss.dmr.ModelNode;
import org.jboss.staxmapper.IntVersion;
import org.jboss.staxmapper.XMLExtendedStreamReader;
Expand All @@ -30,14 +31,14 @@ private UnstableManagementReaderWriter() {
}

@Override
public void readElement(XMLExtendedStreamReader reader, final IntVersion version, final String namespaceUri, List<ModelNode> value) throws XMLStreamException {
public void readElement(XMLExtendedStreamReader reader, final VersionedNamespace<IntVersion, ManagementXmlSchema> namespace, List<ModelNode> value) throws XMLStreamException {
throw ROOT_LOGGER.unstableManagementNamespace(reader.getNamespaceURI());
}

@Override
public void writeContent(XMLExtendedStreamWriter streamWriter, final IntVersion version, final String namespaceUri, ModelMarshallingContext value)
public void writeContent(XMLExtendedStreamWriter streamWriter, final VersionedNamespace<IntVersion, ManagementXmlSchema> namespace, ModelMarshallingContext value)
throws XMLStreamException {
throw ROOT_LOGGER.unstableManagementNamespace(namespaceUri);
throw ROOT_LOGGER.unstableManagementNamespace(namespace.getUri());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,16 @@ private class KernelServicesBuilderImpl implements KernelServicesBuilder, ModelT
ExtensionRegistry extensionRegistry;
private final Map<ModelNode, Map<String, Set<String>>> attributeDescriptors = new HashMap<>();
private Map<ModelNode, Map<String, Map<String, Set<String>>>> operationParameterDescriptors = new HashMap<>();
private final Stability stability;


KernelServicesBuilderImpl(TestModelType type, Stability stability) {
this.type = type;
this.stability = stability;
this.processType = type == TestModelType.HOST || type == TestModelType.DOMAIN ? ProcessType.HOST_CONTROLLER : ProcessType.STANDALONE_SERVER;
runningModeControl = type == TestModelType.HOST ? new HostRunningModeControl(RunningMode.ADMIN_ONLY, RestartMode.HC_ONLY) : new RunningModeControl(RunningMode.ADMIN_ONLY);
extensionRegistry = ExtensionRegistry.builder(this.processType).withRunningModeControl(this.runningModeControl).withStability(stability).build();
testParser = TestParser.create(extensionRegistry, xmlMapper, type);
testParser = TestParser.create(stability, extensionRegistry, xmlMapper, type);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class TestModelControllerService extends ModelTestModelControllerService {
TestModelControllerService(ProcessType processType, RunningModeControl runningModeControl, StringConfigurationPersister persister, ModelTestOperationValidatorFilter validateOpsFilter,
TestModelType type, ModelInitializer modelInitializer, TestDelegatingResourceDefinition rootResourceDefinition, ControlledProcessState processState, ExtensionRegistry extensionRegistry,
CapabilityRegistry capabilityRegistry, RuntimeExpressionResolver expressionResolver) {
super(processType, runningModeControl, null, persister, validateOpsFilter, rootResourceDefinition, processState,
super(processType, extensionRegistry.getStability(), runningModeControl, null, persister, validateOpsFilter, rootResourceDefinition, processState,
expressionResolver, capabilityRegistry);
this.type = type;
this.runningModeControl = runningModeControl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ private static TestParser createLegacy(ExtensionRegistry registry, XMLMapper xml
return testParser;
}

private static TestParser createFrom27(ExtensionRegistry registry, XMLMapper xmlMapper, TestModelType type) {
Stability stability = Stability.DEFAULT;

private static TestParser createFrom27(Stability stability, ExtensionRegistry registry, XMLMapper xmlMapper, TestModelType type) {
ManagementSchemas schemas;
if (type == TestModelType.STANDALONE) {
schemas = new StandaloneXmlSchemas(stability, null, Executors.newCachedThreadPool(), registry);
Expand All @@ -149,14 +147,18 @@ private static TestParser createFrom27(ExtensionRegistry registry, XMLMapper xml


public static TestParser create(ExtensionRegistry registry, XMLMapper xmlMapper, TestModelType type) {
return create(Stability.DEFAULT, registry, xmlMapper, type);
}

public static TestParser create(Stability stability, ExtensionRegistry registry, XMLMapper xmlMapper, TestModelType type) {
if (getModelMajorVersion() < 27) {
try {
return createLegacy(registry, xmlMapper, type);
} catch (Exception e) {
throw new IllegalStateException("Failed to create the parser", e);
}
}
return createFrom27(registry, xmlMapper, type);
return createFrom27(stability, registry, xmlMapper, type);
}

void addModelWriteSanitizer(ModelWriteSanitizer writeSanitizer) {
Expand Down
Loading
Loading