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 @@ -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 @@ -96,6 +96,13 @@ 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 Expand Up @@ -138,6 +145,28 @@ 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
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 +182,37 @@ 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)
.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 @@ -145,7 +145,8 @@ protected List<ServiceName> installServices(OperationContext context, HttpInterf
final Supplier<SSLContext> scSupplier = sslContext != null ? builder.requiresCapability(SSL_CONTEXT_CAPABILITY, SSLContext.class, sslContext) : null;
final UndertowHttpManagementService service = new UndertowHttpManagementService(hmConsumer, lrSupplier, mcSupplier, null, null, null, ibSupplier, sibSupplier,
rpSupplier, xwSupplier, eSupplier, hafSupplier, scSupplier, port, securePort, commonPolicy.getAllowedOrigins(), consoleMode,
Functions.constantSupplier(environment.getProductConfig().getConsoleSlot()), commonPolicy.getConstantHeaders(), caSupplier);
Functions.constantSupplier(environment.getProductConfig().getConsoleSlot()), commonPolicy.getConstantHeaders(), caSupplier,
commonPolicy.getBacklog(), commonPolicy.getNoRequestTimeoutMs(), commonPolicy.getConnectionHighWater(), commonPolicy.getConnectionLowWater());
builder.setInstance(service);
builder.setInitialMode(onDemand ? ServiceController.Mode.ON_DEMAND : ServiceController.Mode.ACTIVE).install();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ host.core.management.http-interface.sasl-protocol=The name of the protocol to be
host.core.management.http-interface.sasl-protocol.deprecated=Only for use with the legacy security realms.
host.core.management.http-interface.server-name=The name of the server used in the initial Remoting exchange and within the SASL mechanisms.
host.core.management.http-interface.server-name.deprecated=Only for use with the legacy security realms.
host.core.management.http-interface.backlog=The maximum number of pending connections on the socket.
host.core.management.http-interface.no-request-timeout=The maximum time in milliseconds a connection can be idle without a HTTP request before it is closed.
host.core.management.http-interface.connection-high-water=The maximum number of connections that can be open at any one time.
host.core.management.http-interface.connection-low-water=The number of connections that the open count must reduce to before the connection-high-water level is reset.

# Ignored resource
ignored-resources=Names of direct child resources of the domain root resource requests for which this Host Controller should ignore. Only relevant on a secondary Host Controller. Configuring such "ignored resources" may help allow a Host Controller from an earlier release to function as a secondary to a Domain Controller running a later release, by letting the secondary ignore portions of the configuration its version of the software cannot understand. This strategy can only be successful if the servers managed by the secondary Host Controller do not reference any of the ignored configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ public class UndertowHttpManagementService implements Service<HttpManagement> {
private final Supplier<ConsoleAvailability> consoleAvailabilitySupplier;
private final Supplier<SecurityDomain> virtualSecurityDomainSupplier;
private final Supplier<HttpServerAuthenticationMechanismFactory> virtualMechanismFactorySupplier;
// Resource Constraints
private final Integer backlog;
private final Integer noRequestTimeout;
private final Integer connectionHighWater;
private final Integer connectionLowWater;

private ManagementHttpServer serverManagement;
private SocketBindingManager socketBindingManager;
Expand Down Expand Up @@ -192,6 +197,9 @@ public boolean hasConsole() {
}
};

// These constructors are getting large and unwieldly, but where we use builders we end up triggering more classes to be loaded
// as well as more objects on the heap for a resource that generally comes up once at server start.

public UndertowHttpManagementService(final Consumer<HttpManagement> httpManagementConsumer,
final Supplier<ListenerRegistry> listenerRegistrySupplier,
final Supplier<ModelController> modelControllerSupplier,
Expand All @@ -211,11 +219,16 @@ public UndertowHttpManagementService(final Consumer<HttpManagement> httpManageme
final ConsoleMode consoleMode,
final Supplier<String> consoleSlot,
final Map<String, List<Header>> constantHeaders,
final Supplier<ConsoleAvailability> consoleAvailabilitySupplier) {
final Supplier<ConsoleAvailability> consoleAvailabilitySupplier,
final Integer backlog,
final Integer noRequestTimeout,
final Integer connectionHighWater,
final Integer connectionLowWater) {
this(httpManagementConsumer, listenerRegistrySupplier, modelControllerSupplier, socketBindingSupplier,
secureSocketBindingSupplier, socketBindingManagerSupplier, interfaceBindingSupplier, secureInterfaceBindingSupplier,
requestProcessorSupplier, workerSupplier, executorSupplier, httpAuthFactorySupplier, sslContextSupplier, port, securePort,
allowedOrigins, consoleMode, consoleSlot, constantHeaders, consoleAvailabilitySupplier, null, null);
allowedOrigins, consoleMode, consoleSlot, constantHeaders, consoleAvailabilitySupplier, null, null,
backlog, noRequestTimeout, connectionHighWater, connectionLowWater);
}

public UndertowHttpManagementService(final Consumer<HttpManagement> httpManagementConsumer,
Expand All @@ -239,7 +252,11 @@ public UndertowHttpManagementService(final Consumer<HttpManagement> httpManageme
final Map<String, List<Header>> constantHeaders,
final Supplier<ConsoleAvailability> consoleAvailabilitySupplier,
final Supplier<SecurityDomain> virtualSecurityDomainSupplier,
final Supplier<HttpServerAuthenticationMechanismFactory> virtualMechanismFactorySupplier) {
final Supplier<HttpServerAuthenticationMechanismFactory> virtualMechanismFactorySupplier,
final Integer backlog,
final Integer noRequestTimeout,
final Integer connectionHighWater,
final Integer connectionLowWater) {
this.httpManagementConsumer = httpManagementConsumer;
this.listenerRegistrySupplier = listenerRegistrySupplier;
this.modelControllerSupplier = modelControllerSupplier;
Expand All @@ -262,6 +279,10 @@ public UndertowHttpManagementService(final Consumer<HttpManagement> httpManageme
this.consoleAvailabilitySupplier = consoleAvailabilitySupplier;
this.virtualSecurityDomainSupplier = virtualSecurityDomainSupplier;
this.virtualMechanismFactorySupplier = virtualMechanismFactorySupplier;
this.backlog = backlog;
this.noRequestTimeout = noRequestTimeout;
this.connectionHighWater = connectionHighWater;
this.connectionLowWater = connectionLowWater;
}

/**
Expand Down Expand Up @@ -345,10 +366,14 @@ public synchronized void start(final StartContext context) throws StartException
}
}

final Integer backlog = Integer.getInteger(BACKLOG_PROPERTY, 50);
final Integer connectionHighWater = Integer.getInteger(CONNECTION_HIGH_WATER_PROPERTY, 100);
final Integer connectionLowWater = Integer.getInteger(CONNECTION_LOW_WATER_PROPERTY, 75);
final Integer noRequestTimeout = Integer.getInteger(NO_REQUEST_TIMEOUT_PROPERTY, 60000);
/*
* System properties take priority for those that already use them, by using the incoming value the defaults now
* come from the resource definition.
*/
final Integer backlog = Integer.getInteger(BACKLOG_PROPERTY, this.backlog);
final Integer connectionHighWater = Integer.getInteger(CONNECTION_HIGH_WATER_PROPERTY, this.connectionHighWater);
final Integer connectionLowWater = Integer.getInteger(CONNECTION_LOW_WATER_PROPERTY, this.connectionLowWater);
final Integer noRequestTimeout = Integer.getInteger(NO_REQUEST_TIMEOUT_PROPERTY, this.noRequestTimeout);

try {
ManagementHttpServer.Builder serverManagementBuilder = ManagementHttpServer.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ public String get() {
final Supplier<SSLContext> scSupplier = sslContext != null ? builder.requiresCapability(SSL_CONTEXT_CAPABILITY, SSLContext.class, sslContext) : null;
final UndertowHttpManagementService undertowService = new UndertowHttpManagementService(hmConsumer, lrSupplier, mcSupplier, sbSupplier, ssbSupplier, sbmSupplier,
null, null, rpSupplier, xwSupplier, eSupplier, hafSupplier, scSupplier, null, null, commonPolicy.getAllowedOrigins(), consoleMode,
consoleSlot, commonPolicy.getConstantHeaders(), caSupplier, virtualSecurityDomainSupplier, virtualMechanismFactorySupplier);
consoleSlot, commonPolicy.getConstantHeaders(), caSupplier, virtualSecurityDomainSupplier, virtualMechanismFactorySupplier,
commonPolicy.getBacklog(), commonPolicy.getNoRequestTimeoutMs(), commonPolicy.getConnectionHighWater(), commonPolicy.getConnectionLowWater());
builder.setInstance(undertowService);
builder.install();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ core.management.http-interface.http-upgrade-enabled.deprecated=Instead use http-
core.management.http-interface.http-upgrade=HTTP Upgrade specific configuration
core.management.http-interface.http-upgrade.enabled=Flag that indicates HTTP Upgrade is enabled, which allows HTTP requests to be upgraded to native remoting connections
core.management.http-interface.http-upgrade.sasl-authentication-factory=The server side SASL authentication policy to use to secure the interface where the connection is after a HTTP upgrade.
core.management.http-interface.backlog=The maximum number of pending connections on the socket.
core.management.http-interface.no-request-timeout=The maximum time in milliseconds a connection can be idle without a HTTP request before it is closed.
core.management.http-interface.connection-high-water=The maximum number of connections that can be open at any one time.
core.management.http-interface.connection-low-water=The number of connections that the open count must reduce to before the connection-high-water level is reset.
core.service-container=The central container that manages all services in a running standalone server or in a host controller in a management domain.
core.module-loading=The modular classloading system.
core.module-loading.module-roots=A list of filesystem locations under which the module loading system looks for modules, arranged in order of precedence.
Expand Down
Loading