Skip to content

Commit

Permalink
Merge pull request #51 from gaol/isue_48
Browse files Browse the repository at this point in the history
[Issue-48] Rename some attribute names to follow WildFly style
  • Loading branch information
gaol authored Jan 20, 2025
2 parents 146830d + a9648ab commit 38015b8
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -113,14 +113,14 @@ public abstract class VertxOptionsAttributes implements VertxConstants {

private static final List<AttributeDefinition> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions subsystem/src/main/resources/schema/wildfly-vertx_1_0_0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@

<xs:attribute name="blocked-thread-check-interval" type="xs:long" />
<xs:attribute name="blocked-thread-check-interval-unit" type="xs:string" />
<xs:attribute name="max-eventloop-execute-time" type="xs:long" />
<xs:attribute name="max-eventloop-execute-time-unit" type="xs:string" />
<xs:attribute name="max-event-loop-execute-time" type="xs:long" />
<xs:attribute name="max-event-loop-execute-time-unit" type="xs:string" />
<xs:attribute name="max-worker-execute-time" type="xs:long" />
<xs:attribute name="max-worker-execute-time-unit" type="xs:string" />
<xs:attribute name="warning-exception-time" type="xs:long" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<vertx-option name="vo" address-resolver-option="aro" event-loop-pool-size="10"
worker-pool-size="20" internal-blocking-pool-size="50" prefer-native-transport="false"
blocked-thread-check-interval="2000" blocked-thread-check-interval-unit="MILLISECONDS"
max-eventloop-execute-time="3000" max-eventloop-execute-time-unit="MILLISECONDS"
max-event-loop-execute-time="3000" max-event-loop-execute-time-unit="MILLISECONDS"
max-worker-execute-time="5" max-worker-execute-time-unit="SECONDS"
warning-exception-time="5" warning-exception-time-unit="SECONDS"
classpath-resolving-enabled="true" file-cache-enabled="true" file-cache-dir="tmp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE;
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_MAX_QUERIES;
import static org.wildfly.extension.vertx.VertxConstants.ELEMENT_VERTX_OPTION_ADDRESS_RESOLVER;
import static org.wildfly.extension.vertx.test.shared.ManagementClientUtils.addressResolverOperation;
Expand Down Expand Up @@ -64,31 +64,31 @@ public void testVertxOption() throws Exception {

// now add it back
operation = vertxOptionOperation(vertxOptionName, "add");
operation.get(ATTR_EVENTLOOP_POOL_SIZE).set(10);
operation.get(ATTR_EVENT_LOOP_POOL_SIZE).set(10);
executeOperation(managementClient, operation);
response = executeOperation(managementClient, readVertxOptionOperation(vertxOptionName));
result = response.get(RESULT);
Assert.assertNotNull(result);
Assert.assertEquals(10, result.get(ATTR_EVENTLOOP_POOL_SIZE).asInt());
Assert.assertEquals(10, result.get(ATTR_EVENT_LOOP_POOL_SIZE).asInt());

operation = vertxOptionOperation(vertxOptionName, "write-attribute");
operation.get(NAME).set(ATTR_EVENTLOOP_POOL_SIZE);
operation.get(NAME).set(ATTR_EVENT_LOOP_POOL_SIZE);
operation.get(VALUE).set(20);
executeOperation(managementClient, operation);

// it does not need to reload
Assert.assertFalse(isReloadRequired(managementClient));
response = executeOperation(managementClient, readVertxOptionOperation(vertxOptionName));
result = response.get(RESULT);
Assert.assertEquals(20, result.get(ATTR_EVENTLOOP_POOL_SIZE).asInt());
Assert.assertEquals(20, result.get(ATTR_EVENT_LOOP_POOL_SIZE).asInt());

// refer it to vertx instance
try {
setVertxOption(vertxOptionName);

// now update the option again
operation = vertxOptionOperation(vertxOptionName, "write-attribute");
operation.get(NAME).set(ATTR_EVENTLOOP_POOL_SIZE);
operation.get(NAME).set(ATTR_EVENT_LOOP_POOL_SIZE);
operation.get(VALUE).set(30);
executeOperation(managementClient, operation);

Expand All @@ -98,7 +98,7 @@ public void testVertxOption() throws Exception {
reload();
response = executeOperation(managementClient, readVertxOptionOperation(vertxOptionName));
result = response.get(RESULT);
Assert.assertEquals(30, result.get(ATTR_EVENTLOOP_POOL_SIZE).asInt());
Assert.assertEquals(30, result.get(ATTR_EVENT_LOOP_POOL_SIZE).asInt());
} finally {
unSetVertxOption();
executeOperation(managementClient, vertxOptionOperation(vertxOptionName, "remove"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public class VertxOptionsManagementTestCase implements VertxConstants {
public void testAddVertxOption() throws IOException {
final String vertxOptionName = "vo";
ModelNode operation = vertxOptionOperation(vertxOptionName, "add");
operation.get(ATTR_EVENTLOOP_POOL_SIZE).set(10);
operation.get(ATTR_EVENT_LOOP_POOL_SIZE).set(10);
operation.get(ATTR_WORKER_POOL_SIZE).set(20);
operation.get(ATTR_INTERNAL_BLOCKING_POOL_SIZE).set(50);
operation.get(ATTR_PREFER_NATIVE_TRANSPORT).set(true);
operation.get(ATTR_BLOCKED_THREAD_CHECK_INTERVAL).set(50);
operation.get(ATTR_MAX_EVENTLOOP_EXECUTE_TIME).set(60);
operation.get(ATTR_MAX_EVENT_LOOP_EXECUTE_TIME).set(60);
operation.get(ATTR_MAX_WORKER_EXECUTE_TIME).set(70);
operation.get(ATTR_WARNING_EXECUTION_TIME).set(80);
operation.get(ATTR_FS_CLASS_PATH_RESOLVING_ENABLED).set(true);
Expand All @@ -60,12 +60,12 @@ public void testAddVertxOption() throws IOException {
ModelNode response = executeOperation(managementClient, readVertxOptionOperation(vertxOptionName));
ModelNode result = response.get(RESULT);
Assert.assertNotNull(result);
Assert.assertEquals(10, result.get(ATTR_EVENTLOOP_POOL_SIZE).asInt());
Assert.assertEquals(10, result.get(ATTR_EVENT_LOOP_POOL_SIZE).asInt());
Assert.assertEquals(20, result.get(ATTR_WORKER_POOL_SIZE).asInt());
Assert.assertEquals(50, result.get(ATTR_INTERNAL_BLOCKING_POOL_SIZE).asInt());
Assert.assertTrue(result.get(ATTR_PREFER_NATIVE_TRANSPORT).asBoolean());
Assert.assertEquals(50L, result.get(ATTR_BLOCKED_THREAD_CHECK_INTERVAL).asLong());
Assert.assertEquals(60L, result.get(ATTR_MAX_EVENTLOOP_EXECUTE_TIME).asLong());
Assert.assertEquals(60L, result.get(ATTR_MAX_EVENT_LOOP_EXECUTE_TIME).asLong());
Assert.assertEquals(70L, result.get(ATTR_MAX_WORKER_EXECUTE_TIME).asLong());
Assert.assertEquals(80L, result.get(ATTR_WARNING_EXECUTION_TIME).asLong());
Assert.assertTrue(result.get(ATTR_FS_CLASS_PATH_RESOLVING_ENABLED).asBoolean());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private ManagementClientUtils() {
*/
public static ModelNode vertxAddress() {
ModelNode address = new ModelNode();
address.add(SUBSYSTEM, VertxConstants.ELEMENT_VERTX).add(VertxConstants.VERTX_SERVICE, VertxConstants.ELEMENT_VERTX);
address.add(SUBSYSTEM, VertxConstants.ELEMENT_VERTX).add(VertxConstants.ELEMENT_VERTX, VertxConstants.ELEMENT_VERTX);
address.protect();
return address;
}
Expand Down

0 comments on commit 38015b8

Please sign in to comment.