Skip to content

Commit

Permalink
[Issue-40] Adds missing attributes
Browse files Browse the repository at this point in the history
* disableTCCL in VertxOptions
* useDaemonThread in VertxOptions
* fileCacheDir in FileSystemOptions
* hostsRefreshPeriod in AddressResolverOptions
  • Loading branch information
gaol committed Nov 20, 2024
1 parent d82fa88 commit 350f21c
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ class AddressResolverResourceDefinition extends SimpleResourceDefinition impleme
.setAllowExpression(true)
.build();

public static final SimpleAttributeDefinition ATTR_HOSTS_REFRESH_PERIOD = new SimpleAttributeDefinitionBuilder(VertxConstants.ATTR_HOSTS_REFRESH_PERIOD, ModelType.INT)
.setRequired(false)
.setAllowExpression(true)
.build();

private static final List<AttributeDefinition> VERTX_ADDRESS_RESOLVER_OPTIONS_ATTRS = new ArrayList<>();
static {
VERTX_ADDRESS_RESOLVER_OPTIONS_ATTRS.add(ATTR_HOSTS_PATH);
Expand All @@ -138,6 +143,7 @@ class AddressResolverResourceDefinition extends SimpleResourceDefinition impleme
VERTX_ADDRESS_RESOLVER_OPTIONS_ATTRS.add(ATTR_N_DOTS);
VERTX_ADDRESS_RESOLVER_OPTIONS_ATTRS.add(ATTR_ROTATE_SERVERS);
VERTX_ADDRESS_RESOLVER_OPTIONS_ATTRS.add(ATTR_ROUND_ROBIN_INET_ADDRESS);
VERTX_ADDRESS_RESOLVER_OPTIONS_ATTRS.add(ATTR_HOSTS_REFRESH_PERIOD);
}

static List<AttributeDefinition> getVertxAddressResolverOptionsAttrs() {
Expand Down Expand Up @@ -256,6 +262,9 @@ private AddressResolverOptions parseAddressResolverOptions(ModelNode operation)
if (operation.hasDefined(VertxConstants.ATTR_ROUND_ROBIN_INET_ADDRESS)) {
addressResolverOptions.setRoundRobinInetAddress(ATTR_ROUND_ROBIN_INET_ADDRESS.validateOperation(operation).asBoolean());
}
if (operation.hasDefined(VertxConstants.ATTR_HOSTS_REFRESH_PERIOD)) {
addressResolverOptions.setHostsRefreshPeriod(ATTR_HOSTS_REFRESH_PERIOD.validateOperation(operation).asInt());
}
return addressResolverOptions;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ public interface VertxConstants {
String ATTR_MAX_WORKER_EXECUTE_TIME_UNIT = "max-worker-execute-time-unit";
String ATTR_WARNING_EXECUTION_TIME = "warning-exception-time";
String ATTR_WARNING_EXECUTION_TIME_UNIT = "warning-exception-time-unit";
String ATTR_DISABLE_TCCL = "disable-tccl";
String ATTR_USE_DAEMON_THREAD = "use-daemon-thread";

// file system options
String ATTR_FS_CLASS_PATH_RESOLVING_ENABLED = "classpath-resolving-enabled";
String ATTR_FS_FILE_CACHE_ENABLED = "file-cache-enabled";
String ATTR_FS_FILE_CACHE_DIR = "file-cache-dir";

// address resolver options
String ATTR_HOSTS_PATH = "hosts-path";
String ATTR_HOSTS_VALUE = "hosts-value";
String ATTR_HOSTS_REFRESH_PERIOD = "hosts-refresh-period";
String ATTR_SERVERS = "servers";
String ATTR_OPT_RES_ENABLED = "opt-resource-enabled";
String ATTR_CACHE_MIN_TTL = "cache-min-time-to-live";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ static List<AttributeDefinition> getVertxOptionsFileAttributes() {
.setAllowedValues(TIME_UNITS)
.build();

public static final SimpleAttributeDefinition ATTR_DISABLE_TCCL = new SimpleAttributeDefinitionBuilder(VertxConstants.ATTR_DISABLE_TCCL, ModelType.BOOLEAN)
.setRequired(false)
.setAllowExpression(true)
.build();

public static final SimpleAttributeDefinition ATTR_USE_DAEMON_THREAD = new SimpleAttributeDefinitionBuilder(VertxConstants.ATTR_USE_DAEMON_THREAD, ModelType.BOOLEAN)
.setRequired(false)
.setAllowExpression(true)
.build();

public static final SimpleAttributeDefinition ATTR_FS_CLASS_PATH_RESOLVING_ENABLED = new SimpleAttributeDefinitionBuilder(VertxConstants.ATTR_FS_CLASS_PATH_RESOLVING_ENABLED, ModelType.BOOLEAN)
.setRequired(false)
.setAllowExpression(true)
Expand All @@ -117,6 +127,11 @@ static List<AttributeDefinition> getVertxOptionsFileAttributes() {
.setAllowExpression(true)
.build();

public static final SimpleAttributeDefinition ATTR_FS_FILE_CACHE_DIR = new SimpleAttributeDefinitionBuilder(VertxConstants.ATTR_FS_FILE_CACHE_DIR, ModelType.STRING)
.setRequired(false)
.setAllowExpression(true)
.build();

// address-resolver-option
public static final SimpleAttributeDefinition ATTR_VERTX_OPTION_ADDRESS_RESOLVER = new SimpleAttributeDefinitionBuilder(VertxConstants.ELEMENT_VERTX_OPTION_ADDRESS_RESOLVER, ModelType.STRING)
.setRequired(false)
Expand All @@ -137,10 +152,13 @@ static List<AttributeDefinition> getVertxOptionsFileAttributes() {
VERTX_OPTIONS_ATTRS.add(ATTR_MAX_WORKER_EXECUTE_TIME_UNIT);
VERTX_OPTIONS_ATTRS.add(ATTR_WARNING_EXECUTION_TIME);
VERTX_OPTIONS_ATTRS.add(ATTR_WARNING_EXECUTION_TIME_UNIT);
VERTX_OPTIONS_ATTRS.add(ATTR_DISABLE_TCCL);
VERTX_OPTIONS_ATTRS.add(ATTR_USE_DAEMON_THREAD);

// file system options
VERTX_OPTIONS_ATTRS.add(ATTR_FS_CLASS_PATH_RESOLVING_ENABLED);
VERTX_OPTIONS_ATTRS.add(ATTR_FS_FILE_CACHE_ENABLED);
VERTX_OPTIONS_ATTRS.add(ATTR_FS_FILE_CACHE_DIR);

// address-resolver-option
VERTX_OPTIONS_ATTRS.add(ATTR_VERTX_OPTION_ADDRESS_RESOLVER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@

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_DISABLE_TCCL;
import static org.wildfly.extension.vertx.VertxConstants.ATTR_EVENTLOOP_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_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;
import static org.wildfly.extension.vertx.VertxConstants.ATTR_USE_DAEMON_THREAD;
import static org.wildfly.extension.vertx.VertxConstants.ATTR_WARNING_EXECUTION_TIME;
import static org.wildfly.extension.vertx.VertxConstants.ATTR_WARNING_EXECUTION_TIME_UNIT;
import static org.wildfly.extension.vertx.VertxConstants.ATTR_WORKER_POOL_SIZE;
Expand Down Expand Up @@ -128,6 +131,12 @@ VertxOptions parseOptions(ModelNode operation) throws OperationFailedException {
if (operation.hasDefined(ATTR_WARNING_EXECUTION_TIME_UNIT)) {
vertxOptions.setWarningExceptionTimeUnit(TimeUnit.valueOf(VertxOptionsAttributes.ATTR_WARNING_EXECUTION_TIME_UNIT.validateOperation(operation).asString()));
}
if (operation.hasDefined(ATTR_DISABLE_TCCL)) {
vertxOptions.setDisableTCCL(VertxOptionsAttributes.ATTR_DISABLE_TCCL.validateOperation(operation).asBoolean());
}
if (operation.hasDefined(ATTR_USE_DAEMON_THREAD)) {
vertxOptions.setUseDaemonThread(VertxOptionsAttributes.ATTR_USE_DAEMON_THREAD.validateOperation(operation).asBoolean());
}

// file system options
if (operation.hasDefined(ATTR_FS_CLASS_PATH_RESOLVING_ENABLED)) {
Expand All @@ -136,6 +145,9 @@ VertxOptions parseOptions(ModelNode operation) throws OperationFailedException {
if (operation.hasDefined(ATTR_FS_FILE_CACHE_ENABLED)) {
vertxOptions.getFileSystemOptions().setFileCachingEnabled(VertxOptionsAttributes.ATTR_FS_FILE_CACHE_ENABLED.validateOperation(operation).asBoolean());
}
if (operation.hasDefined(ATTR_FS_FILE_CACHE_DIR)) {
vertxOptions.getFileSystemOptions().setFileCacheDir(VertxOptionsAttributes.ATTR_FS_FILE_CACHE_DIR.validateOperation(operation).asString());
}
return vertxOptions;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ vertx.vertx-option.max-worker-execute-time=The max worker execute time, defaults
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
vertx.vertx-option.warning-exception-time-unit=The warning exception time, defaults to NANOSECONDS
vertx.vertx-option.classpath-resolving-enabled=whether classpath resolving is enabled
vertx.vertx-option.file-cache-enabled=whether file caching is enabled for class path resolving
vertx.vertx-option.disable-tccl=Whether Vert.x sets the Context classloader as the thread context classloader on actions executed on that Context.
vertx.vertx-option.use-daemon-thread=Whether we want to use daemon vertx thread
vertx.vertx-option.classpath-resolving-enabled=Whether classpath resolving is enabled
vertx.vertx-option.file-cache-enabled=Whether file caching is enabled for class path resolving
vertx.vertx-option.file-cache-dir=The file cache directory
vertx.vertx-option.address-resolver-option=The address-resolver-option name used for the AddressResolverOptions
vertx.vertx-option.show-info=Show VertxOptions information

Expand All @@ -54,3 +57,4 @@ vertx.address-resolver-option.search-domains=The lists of DNS search domains. Wh
vertx.address-resolver-option.n-dots=The ndots value used when resolving using search domains, the default value is -1 which determines the value from the OS on Linux or uses the value 1.
vertx.address-resolver-option.rotate-servers=The option to enable round-robin selection of the dns server to use. It spreads the query load among the servers and avoids all lookup to hit the first server of the list.
vertx.address-resolver-option.round-robin-inet-address=The option to enable round-robin inet address selection of the ip address to use.
vertx.address-resolver-option.hosts-refresh-period=The hosts configuration refresh period in millis
3 changes: 3 additions & 0 deletions subsystem/src/main/resources/schema/wildfly-vertx_1_0_0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@
<xs:attribute name="max-worker-execute-time-unit" type="xs:string" />
<xs:attribute name="warning-exception-time" type="xs:long" />
<xs:attribute name="warning-exception-time-unit" type="xs:string" />
<xs:attribute name="use-daemon-thread" type="xs:boolean" />

<xs:attribute name="classpath-resolving-enabled" type="xs:boolean" />
<xs:attribute name="file-cache-enabled" type="xs:boolean" />
<xs:attribute name="file-cache-dir" type="xs:string" />

<xs:attribute name="address-resolver-option" type="xs:string">
<xs:annotation>
Expand All @@ -100,6 +102,7 @@
<xs:attribute name="n-dots" type="xs:int" />
<xs:attribute name="rotate-servers" type="xs:boolean" />
<xs:attribute name="round-robin-inet-address" type="xs:boolean" />
<xs:attribute name="hosts-refresh-period" type="xs:int" />
</xs:complexType>

</xs:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@
<subsystem xmlns="urn:wildfly:vertx:preview:1.0">
<vertx option-name="vo" />
<vertx-options>
<vertx-option name="vo" address-resolver-option="aro" />
<address-resolver-option name="aro" max-queries="20"/>
<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-worker-execute-time="5" max-worker-execute-time-unit="SECONDS"
warning-exception-time="5" warning-exception-time-unit="SECONDS"
disable-tccl="false" use-daemon-thread="false"
classpath-resolving-enabled="true" file-cache-enabled="true" file-cache-dir="tmp"
/>
<address-resolver-option name="aro" max-queries="20" hosts-path="/etc/hosts" hosts-value="127.0.0.1 localhost"
servers="192.168.1.1,8.8.8.8" opt-resource-enabled="true"
cache-min-time-to-live="30" cache-max-time-to-live="600" cache-negative-time-to-live="10"
query-time-out="5000" rd-flag="true" search-domains="local,remote" n-dots="-1" rotate-servers="true"
round-robin-inet-address="true" hosts-refresh-period="10000"
/>
</vertx-options>
</subsystem>
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public void testAddVertxOption() throws IOException {
operation.get(ATTR_MAX_EVENTLOOP_EXECUTE_TIME).set(60);
operation.get(ATTR_MAX_WORKER_EXECUTE_TIME).set(70);
operation.get(ATTR_WARNING_EXECUTION_TIME).set(80);
operation.get(ATTR_DISABLE_TCCL).set(true);
operation.get(ATTR_USE_DAEMON_THREAD).set(true);
operation.get(ATTR_FS_CLASS_PATH_RESOLVING_ENABLED).set(true);
operation.get(ATTR_FS_FILE_CACHE_ENABLED).set(true);
operation.get(ATTR_FS_FILE_CACHE_DIR).set("/tmp/.vertx-cache");
executeOperation(managementClient, operation);

ModelNode response = executeOperation(managementClient, readVertxOptionOperation(vertxOptionName));
Expand All @@ -65,6 +70,11 @@ public void testAddVertxOption() throws IOException {
Assert.assertEquals(60L, result.get(ATTR_MAX_EVENTLOOP_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_DISABLE_TCCL).asBoolean());
Assert.assertTrue(result.get(ATTR_USE_DAEMON_THREAD).asBoolean());
Assert.assertTrue(result.get(ATTR_FS_CLASS_PATH_RESOLVING_ENABLED).asBoolean());
Assert.assertTrue(result.get(ATTR_FS_FILE_CACHE_ENABLED).asBoolean());
Assert.assertEquals("/tmp/.vertx-cache", result.get(ATTR_FS_FILE_CACHE_DIR).asString());

VertxOptions vertxOptions = readVertxOptions(managementClient, vertxOptionName);
Assert.assertEquals(10, vertxOptions.getEventLoopPoolSize());
Expand All @@ -76,6 +86,12 @@ public void testAddVertxOption() throws IOException {
Assert.assertEquals(60L, vertxOptions.getMaxEventLoopExecuteTime());
Assert.assertEquals(70L, vertxOptions.getMaxWorkerExecuteTime());
Assert.assertEquals(80L, vertxOptions.getWarningExceptionTime());
Assert.assertTrue(vertxOptions.getDisableTCCL());
Assert.assertTrue(vertxOptions.getUseDaemonThread());
Assert.assertNotNull(vertxOptions.getFileSystemOptions());
Assert.assertTrue(vertxOptions.getFileSystemOptions().isFileCachingEnabled());
Assert.assertTrue(vertxOptions.getFileSystemOptions().isClassPathResolvingEnabled());
Assert.assertEquals("/tmp/.vertx-cache", vertxOptions.getFileSystemOptions().getFileCacheDir());

// clear resources
executeOperation(managementClient, vertxOptionOperation(vertxOptionName, "remove"));
Expand All @@ -87,6 +103,7 @@ public void testAddressResolverOption() throws IOException {
final String addressResolverName = "aro";
ModelNode operation = addressResolverOperation(addressResolverName, "add");
operation.get(ATTR_HOSTS_PATH).set("local-path");
operation.get(ATTR_HOSTS_VALUE).set("127.0.0.1 localhost");
operation.get(ATTR_SERVERS).add("localhost").add("127.0.0.1");
operation.get(ATTR_OPT_RES_ENABLED).set(true);
operation.get(ATTR_CACHE_MIN_TTL).set(1024);
Expand All @@ -99,6 +116,7 @@ public void testAddressResolverOption() throws IOException {
operation.get(ATTR_N_DOTS).set(8);
operation.get(ATTR_ROTATE_SERVERS).set(true);
operation.get(ATTR_ROUND_ROBIN_INET_ADDRESS).set(true);
operation.get(ATTR_HOSTS_REFRESH_PERIOD).set(100);
executeOperation(managementClient, operation);

ModelNode response = executeOperation(managementClient, addressResolverOperation(addressResolverName, "read-resource"));
Expand All @@ -123,6 +141,8 @@ public void testAddressResolverOption() throws IOException {
Assert.assertEquals(8, result.get(ATTR_N_DOTS).asInt());
Assert.assertTrue(result.get(ATTR_ROTATE_SERVERS).asBoolean());
Assert.assertTrue(result.get(ATTR_ROUND_ROBIN_INET_ADDRESS).asBoolean());
Assert.assertEquals(100, result.get(ATTR_HOSTS_REFRESH_PERIOD).asInt());
Assert.assertEquals("127.0.0.1 localhost", result.get(ATTR_HOSTS_VALUE).asString());

final String optionName = "vo";
ModelNode addVertxOption = vertxOptionOperation(optionName, "add");
Expand All @@ -146,6 +166,8 @@ public void testAddressResolverOption() throws IOException {
Assert.assertEquals(8, addressResolverOptions.getNdots());
Assert.assertTrue(addressResolverOptions.isRotateServers());
Assert.assertTrue(addressResolverOptions.isRoundRobinInetAddress());
Assert.assertEquals(100, addressResolverOptions.getHostsRefreshPeriod());
Assert.assertEquals("127.0.0.1 localhost", addressResolverOptions.getHostsValue().toString());

// clear resources
executeOperation(managementClient, vertxOptionOperation(optionName, "remove"));
Expand Down

0 comments on commit 350f21c

Please sign in to comment.