From a9648ab4fb3ec47ef465172a0753c2c434d3f2b4 Mon Sep 17 00:00:00 2001 From: Lin Gao Date: Fri, 17 Jan 2025 19:06:21 +0800 Subject: [PATCH] [Issue-48] Rename some attribute names to follow WildFly style --- ...AbstractVertxOptionsResourceDefinition.java | 4 ++-- .../extension/vertx/VertxConstants.java | 9 +++------ .../vertx/VertxOptionsAttributes.java | 12 ++++++------ .../vertx/VertxOptionsResourceDefinition.java | 18 +++++++++--------- .../vertx/VertxResourceDefinition.java | 4 ++-- .../vertx/LocalDescriptions.properties | 4 ++-- .../resources/schema/wildfly-vertx_1_0_0.xsd | 4 ++-- .../extension/vertx/vertx-options-full.xml | 2 +- .../VertxOptionNoReloadRequiredTestCase.java | 14 +++++++------- .../VertxOptionsManagementTestCase.java | 8 ++++---- .../test/shared/ManagementClientUtils.java | 2 +- 11 files changed, 39 insertions(+), 42 deletions(-) diff --git a/subsystem/src/main/java/org/wildfly/extension/vertx/AbstractVertxOptionsResourceDefinition.java b/subsystem/src/main/java/org/wildfly/extension/vertx/AbstractVertxOptionsResourceDefinition.java index af2ed26..7f87127 100644 --- a/subsystem/src/main/java/org/wildfly/extension/vertx/AbstractVertxOptionsResourceDefinition.java +++ b/subsystem/src/main/java/org/wildfly/extension/vertx/AbstractVertxOptionsResourceDefinition.java @@ -19,7 +19,7 @@ import static org.wildfly.extension.vertx.VertxConstants.ATTR_OPTION_NAME; import static org.wildfly.extension.vertx.VertxConstants.ELEMENT_VERTX_OPTION; import static org.wildfly.extension.vertx.VertxConstants.ELEMENT_VERTX_OPTION_ADDRESS_RESOLVER; -import static org.wildfly.extension.vertx.VertxConstants.VERTX_SERVICE; +import static org.wildfly.extension.vertx.VertxConstants.ELEMENT_VERTX; import static org.wildfly.extension.vertx.VertxResourceDefinition.VERTX_CAPABILITY_NAME; /** @@ -66,7 +66,7 @@ private static Resource readVertxRootResource(OperationContext context) { } private static boolean isVertxOptionUsedInternal(Resource vertxResource, String vertxOptionName) { - return vertxResource.getChildren(VERTX_SERVICE).stream().anyMatch(re -> re.getModel().get(ATTR_OPTION_NAME).asString().equals(vertxOptionName)); + return vertxResource.getChildren(ELEMENT_VERTX).stream().anyMatch(re -> re.getModel().get(ATTR_OPTION_NAME).asString().equals(vertxOptionName)); } static boolean isVertxOptionUsed(OperationContext context, String vertxOptionName) { diff --git a/subsystem/src/main/java/org/wildfly/extension/vertx/VertxConstants.java b/subsystem/src/main/java/org/wildfly/extension/vertx/VertxConstants.java index 860c672..e86f599 100644 --- a/subsystem/src/main/java/org/wildfly/extension/vertx/VertxConstants.java +++ b/subsystem/src/main/java/org/wildfly/extension/vertx/VertxConstants.java @@ -17,25 +17,22 @@ public interface VertxConstants { String[] TIME_UNITS = Arrays.stream(TimeUnit.values()).map(Enum::toString).collect(Collectors.toList()).toArray(new String[0]); String CDI_QUALIFIER = "vertx"; - String VERTX_SERVICE = "vertx"; String ELEMENT_VERTX = "vertx"; String ELEMENT_VERTX_OPTIONS = "vertx-options"; - String ELEMENT_VERTX_OPTIONS_FILE = "vertx-option-file"; String ELEMENT_VERTX_OPTION = "vertx-option"; String ELEMENT_VERTX_OPTION_ADDRESS_RESOLVER = "address-resolver-option"; String ATTR_OPTION_NAME = "option-name"; - String ATTR_PATH = "path"; // basic vertx-option attributes - String ATTR_EVENTLOOP_POOL_SIZE = "event-loop-pool-size"; + String ATTR_EVENT_LOOP_POOL_SIZE = "event-loop-pool-size"; String ATTR_WORKER_POOL_SIZE = "worker-pool-size"; String ATTR_INTERNAL_BLOCKING_POOL_SIZE = "internal-blocking-pool-size"; String ATTR_PREFER_NATIVE_TRANSPORT = "prefer-native-transport"; String ATTR_BLOCKED_THREAD_CHECK_INTERVAL = "blocked-thread-check-interval"; String ATTR_BLOCKED_THREAD_CHECK_INTERVAL_UNIT = "blocked-thread-check-interval-unit"; - String ATTR_MAX_EVENTLOOP_EXECUTE_TIME = "max-eventloop-execute-time"; - String ATTR_MAX_EVENTLOOP_EXECUTE_TIME_UNIT = "max-eventloop-execute-time-unit"; + String ATTR_MAX_EVENT_LOOP_EXECUTE_TIME = "max-event-loop-execute-time"; + String ATTR_MAX_EVENT_LOOP_EXECUTE_TIME_UNIT = "max-event-loop-execute-time-unit"; String ATTR_MAX_WORKER_EXECUTE_TIME = "max-worker-execute-time"; String ATTR_MAX_WORKER_EXECUTE_TIME_UNIT = "max-worker-execute-time-unit"; String ATTR_WARNING_EXECUTION_TIME = "warning-exception-time"; diff --git a/subsystem/src/main/java/org/wildfly/extension/vertx/VertxOptionsAttributes.java b/subsystem/src/main/java/org/wildfly/extension/vertx/VertxOptionsAttributes.java index f4c521e..21f9abc 100644 --- a/subsystem/src/main/java/org/wildfly/extension/vertx/VertxOptionsAttributes.java +++ b/subsystem/src/main/java/org/wildfly/extension/vertx/VertxOptionsAttributes.java @@ -19,7 +19,7 @@ */ public abstract class VertxOptionsAttributes implements VertxConstants { - public static final SimpleAttributeDefinition ATTR_EVENTLOOP_POOL_SIZE = new SimpleAttributeDefinitionBuilder(VertxConstants.ATTR_EVENTLOOP_POOL_SIZE, ModelType.INT) + public static final SimpleAttributeDefinition ATTR_EVENT_LOOP_POOL_SIZE = new SimpleAttributeDefinitionBuilder(VertxConstants.ATTR_EVENT_LOOP_POOL_SIZE, ModelType.INT) .setRequired(false) .setAllowExpression(true) .setValidator(new IntRangeValidator(1, true)) @@ -54,13 +54,13 @@ public abstract class VertxOptionsAttributes implements VertxConstants { .setAllowedValues(TIME_UNITS) .build(); - public static final SimpleAttributeDefinition ATTR_MAX_EVENTLOOP_EXECUTE_TIME = new SimpleAttributeDefinitionBuilder(VertxConstants.ATTR_MAX_EVENTLOOP_EXECUTE_TIME, ModelType.LONG) + public static final SimpleAttributeDefinition ATTR_MAX_EVENT_LOOP_EXECUTE_TIME = new SimpleAttributeDefinitionBuilder(VertxConstants.ATTR_MAX_EVENT_LOOP_EXECUTE_TIME, ModelType.LONG) .setRequired(false) .setAllowExpression(true) .setValidator(new LongRangeValidator(1, true)) .build(); - public static final SimpleAttributeDefinition ATTR_MAX_EVENTLOOP_EXECUTE_TIME_UNIT = new SimpleAttributeDefinitionBuilder(VertxConstants.ATTR_MAX_EVENTLOOP_EXECUTE_TIME_UNIT, ModelType.STRING) + public static final SimpleAttributeDefinition ATTR_MAX_EVENT_LOOP_EXECUTE_TIME_UNIT = new SimpleAttributeDefinitionBuilder(VertxConstants.ATTR_MAX_EVENT_LOOP_EXECUTE_TIME_UNIT, ModelType.STRING) .setRequired(false) .setAllowExpression(true) .setAllowedValues(TIME_UNITS) @@ -113,14 +113,14 @@ public abstract class VertxOptionsAttributes implements VertxConstants { private static final List VERTX_OPTIONS_ATTRS = new ArrayList<>(); static { - VERTX_OPTIONS_ATTRS.add(ATTR_EVENTLOOP_POOL_SIZE); + VERTX_OPTIONS_ATTRS.add(ATTR_EVENT_LOOP_POOL_SIZE); VERTX_OPTIONS_ATTRS.add(ATTR_WORKER_POOL_SIZE); VERTX_OPTIONS_ATTRS.add(ATTR_INTERNAL_BLOCKING_POOL_SIZE); VERTX_OPTIONS_ATTRS.add(ATTR_PREFER_NATIVE_TRANSPORT); VERTX_OPTIONS_ATTRS.add(ATTR_BLOCKED_THREAD_CHECK_INTERVAL); VERTX_OPTIONS_ATTRS.add(ATTR_BLOCKED_THREAD_CHECK_INTERVAL_UNIT); - VERTX_OPTIONS_ATTRS.add(ATTR_MAX_EVENTLOOP_EXECUTE_TIME); - VERTX_OPTIONS_ATTRS.add(ATTR_MAX_EVENTLOOP_EXECUTE_TIME_UNIT); + VERTX_OPTIONS_ATTRS.add(ATTR_MAX_EVENT_LOOP_EXECUTE_TIME); + VERTX_OPTIONS_ATTRS.add(ATTR_MAX_EVENT_LOOP_EXECUTE_TIME_UNIT); VERTX_OPTIONS_ATTRS.add(ATTR_MAX_WORKER_EXECUTE_TIME); VERTX_OPTIONS_ATTRS.add(ATTR_MAX_WORKER_EXECUTE_TIME_UNIT); VERTX_OPTIONS_ATTRS.add(ATTR_WARNING_EXECUTION_TIME); diff --git a/subsystem/src/main/java/org/wildfly/extension/vertx/VertxOptionsResourceDefinition.java b/subsystem/src/main/java/org/wildfly/extension/vertx/VertxOptionsResourceDefinition.java index d2c6a6b..72b0c56 100644 --- a/subsystem/src/main/java/org/wildfly/extension/vertx/VertxOptionsResourceDefinition.java +++ b/subsystem/src/main/java/org/wildfly/extension/vertx/VertxOptionsResourceDefinition.java @@ -23,13 +23,13 @@ import static org.wildfly.extension.vertx.VertxConstants.ATTR_BLOCKED_THREAD_CHECK_INTERVAL; import static org.wildfly.extension.vertx.VertxConstants.ATTR_BLOCKED_THREAD_CHECK_INTERVAL_UNIT; -import static org.wildfly.extension.vertx.VertxConstants.ATTR_EVENTLOOP_POOL_SIZE; +import static org.wildfly.extension.vertx.VertxConstants.ATTR_EVENT_LOOP_POOL_SIZE; import static org.wildfly.extension.vertx.VertxConstants.ATTR_FS_CLASS_PATH_RESOLVING_ENABLED; import static org.wildfly.extension.vertx.VertxConstants.ATTR_FS_FILE_CACHE_DIR; import static org.wildfly.extension.vertx.VertxConstants.ATTR_FS_FILE_CACHE_ENABLED; import static org.wildfly.extension.vertx.VertxConstants.ATTR_INTERNAL_BLOCKING_POOL_SIZE; -import static org.wildfly.extension.vertx.VertxConstants.ATTR_MAX_EVENTLOOP_EXECUTE_TIME; -import static org.wildfly.extension.vertx.VertxConstants.ATTR_MAX_EVENTLOOP_EXECUTE_TIME_UNIT; +import static org.wildfly.extension.vertx.VertxConstants.ATTR_MAX_EVENT_LOOP_EXECUTE_TIME; +import static org.wildfly.extension.vertx.VertxConstants.ATTR_MAX_EVENT_LOOP_EXECUTE_TIME_UNIT; import static org.wildfly.extension.vertx.VertxConstants.ATTR_MAX_WORKER_EXECUTE_TIME; import static org.wildfly.extension.vertx.VertxConstants.ATTR_MAX_WORKER_EXECUTE_TIME_UNIT; import static org.wildfly.extension.vertx.VertxConstants.ATTR_PREFER_NATIVE_TRANSPORT; @@ -85,8 +85,8 @@ protected void performRuntime(OperationContext context, ModelNode operation, Res static VertxOptions parseOptions(ModelNode operation) throws OperationFailedException { VertxOptions vertxOptions = new VertxOptions(); - if (operation.hasDefined(ATTR_EVENTLOOP_POOL_SIZE)) { - vertxOptions.setEventLoopPoolSize(VertxOptionsAttributes.ATTR_EVENTLOOP_POOL_SIZE.validateOperation(operation).asInt()); + if (operation.hasDefined(ATTR_EVENT_LOOP_POOL_SIZE)) { + vertxOptions.setEventLoopPoolSize(VertxOptionsAttributes.ATTR_EVENT_LOOP_POOL_SIZE.validateOperation(operation).asInt()); } if (operation.hasDefined(ATTR_WORKER_POOL_SIZE)) { vertxOptions.setWorkerPoolSize(VertxOptionsAttributes.ATTR_WORKER_POOL_SIZE.validateOperation(operation).asInt()); @@ -103,11 +103,11 @@ static VertxOptions parseOptions(ModelNode operation) throws OperationFailedExce if (operation.hasDefined(ATTR_BLOCKED_THREAD_CHECK_INTERVAL_UNIT)) { vertxOptions.setBlockedThreadCheckIntervalUnit(TimeUnit.valueOf(VertxOptionsAttributes.ATTR_BLOCKED_THREAD_CHECK_INTERVAL_UNIT.validateOperation(operation).asString())); } - if (operation.hasDefined(ATTR_MAX_EVENTLOOP_EXECUTE_TIME)) { - vertxOptions.setMaxEventLoopExecuteTime(VertxOptionsAttributes.ATTR_MAX_EVENTLOOP_EXECUTE_TIME.validateOperation(operation).asLong()); + if (operation.hasDefined(ATTR_MAX_EVENT_LOOP_EXECUTE_TIME)) { + vertxOptions.setMaxEventLoopExecuteTime(VertxOptionsAttributes.ATTR_MAX_EVENT_LOOP_EXECUTE_TIME.validateOperation(operation).asLong()); } - if (operation.hasDefined(ATTR_MAX_EVENTLOOP_EXECUTE_TIME_UNIT)) { - vertxOptions.setMaxEventLoopExecuteTimeUnit(TimeUnit.valueOf(VertxOptionsAttributes.ATTR_MAX_EVENTLOOP_EXECUTE_TIME_UNIT.validateOperation(operation).asString())); + if (operation.hasDefined(ATTR_MAX_EVENT_LOOP_EXECUTE_TIME_UNIT)) { + vertxOptions.setMaxEventLoopExecuteTimeUnit(TimeUnit.valueOf(VertxOptionsAttributes.ATTR_MAX_EVENT_LOOP_EXECUTE_TIME_UNIT.validateOperation(operation).asString())); } if (operation.hasDefined(ATTR_MAX_WORKER_EXECUTE_TIME)) { vertxOptions.setMaxWorkerExecuteTime(VertxOptionsAttributes.ATTR_MAX_WORKER_EXECUTE_TIME.validateOperation(operation).asLong()); diff --git a/subsystem/src/main/java/org/wildfly/extension/vertx/VertxResourceDefinition.java b/subsystem/src/main/java/org/wildfly/extension/vertx/VertxResourceDefinition.java index 8399810..69244e5 100644 --- a/subsystem/src/main/java/org/wildfly/extension/vertx/VertxResourceDefinition.java +++ b/subsystem/src/main/java/org/wildfly/extension/vertx/VertxResourceDefinition.java @@ -20,7 +20,7 @@ import static org.wildfly.extension.vertx.VertxConstants.ATTR_OPTION_NAME; import static org.wildfly.extension.vertx.VertxConstants.ELEMENT_VERTX; -import static org.wildfly.extension.vertx.VertxConstants.VERTX_SERVICE; +import static org.wildfly.extension.vertx.VertxConstants.ELEMENT_VERTX; /** * This represents a Vert.x instance, and there is only one Vert.x instance can be defined in this subsystem. @@ -35,7 +35,7 @@ public class VertxResourceDefinition extends PersistentResourceDefinition { static VertxResourceDefinition INSTANCE = new VertxResourceDefinition(); VertxResourceDefinition() { - super(new SimpleResourceDefinition.Parameters(PathElement.pathElement(VERTX_SERVICE, ELEMENT_VERTX), + super(new SimpleResourceDefinition.Parameters(PathElement.pathElement(ELEMENT_VERTX, ELEMENT_VERTX), VertxSubsystemExtension.getResourceDescriptionResolver(VertxSubsystemExtension.SUBSYSTEM_NAME)) .setAddHandler(new VertxResourceAdd()) .setRemoveHandler(ReloadRequiredRemoveStepHandler.INSTANCE) diff --git a/subsystem/src/main/resources/org/wildfly/extension/vertx/LocalDescriptions.properties b/subsystem/src/main/resources/org/wildfly/extension/vertx/LocalDescriptions.properties index 5463df4..11f7cde 100644 --- a/subsystem/src/main/resources/org/wildfly/extension/vertx/LocalDescriptions.properties +++ b/subsystem/src/main/resources/org/wildfly/extension/vertx/LocalDescriptions.properties @@ -20,8 +20,8 @@ vertx.vertx-option.internal-blocking-pool-size=The size of the internal blocking vertx.vertx-option.prefer-native-transport=If native transport is preferred or not vertx.vertx-option.blocked-thread-check-interval=The blocked thread check interval, defaults to 1000 ms vertx.vertx-option.blocked-thread-check-interval-unit=The blocked thread check interval unit, defaults to MILLISECONDS -vertx.vertx-option.max-eventloop-execute-time=The max event loop execute time, defaults to 2 seconds -vertx.vertx-option.max-eventloop-execute-time-unit=The max event loop execute time unit, defaults to NANOSECONDS +vertx.vertx-option.max-event-loop-execute-time=The max event loop execute time, defaults to 2 seconds +vertx.vertx-option.max-event-loop-execute-time-unit=The max event loop execute time unit, defaults to NANOSECONDS vertx.vertx-option.max-worker-execute-time=The max worker execute time, defaults to 60 seconds vertx.vertx-option.max-worker-execute-time-unit=The max worker execute time unit, defaults to NANOSECONDS vertx.vertx-option.warning-exception-time=The warning exception time, If a thread is blocked longer than this threshold, the warning log contains a stack trace, defaults to 5 seconds diff --git a/subsystem/src/main/resources/schema/wildfly-vertx_1_0_0.xsd b/subsystem/src/main/resources/schema/wildfly-vertx_1_0_0.xsd index b07b305..1e331c0 100644 --- a/subsystem/src/main/resources/schema/wildfly-vertx_1_0_0.xsd +++ b/subsystem/src/main/resources/schema/wildfly-vertx_1_0_0.xsd @@ -52,8 +52,8 @@ - - + + diff --git a/subsystem/src/test/resources/org/wildfly/extension/vertx/vertx-options-full.xml b/subsystem/src/test/resources/org/wildfly/extension/vertx/vertx-options-full.xml index 52e9886..d8fcc34 100644 --- a/subsystem/src/test/resources/org/wildfly/extension/vertx/vertx-options-full.xml +++ b/subsystem/src/test/resources/org/wildfly/extension/vertx/vertx-options-full.xml @@ -9,7 +9,7 @@