diff --git a/subsystem/src/main/java/org/wildfly/extension/vertx/AddressResolverResourceDefinition.java b/subsystem/src/main/java/org/wildfly/extension/vertx/AddressResolverResourceDefinition.java index e35a5d8..dc67140 100644 --- a/subsystem/src/main/java/org/wildfly/extension/vertx/AddressResolverResourceDefinition.java +++ b/subsystem/src/main/java/org/wildfly/extension/vertx/AddressResolverResourceDefinition.java @@ -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 VERTX_ADDRESS_RESOLVER_OPTIONS_ATTRS = new ArrayList<>(); static { VERTX_ADDRESS_RESOLVER_OPTIONS_ATTRS.add(ATTR_HOSTS_PATH); @@ -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 getVertxAddressResolverOptionsAttrs() { @@ -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; } 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 dc10a59..a110381 100644 --- a/subsystem/src/main/java/org/wildfly/extension/vertx/VertxConstants.java +++ b/subsystem/src/main/java/org/wildfly/extension/vertx/VertxConstants.java @@ -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"; 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 9fd810b..eddb0e7 100644 --- a/subsystem/src/main/java/org/wildfly/extension/vertx/VertxOptionsAttributes.java +++ b/subsystem/src/main/java/org/wildfly/extension/vertx/VertxOptionsAttributes.java @@ -107,6 +107,16 @@ static List 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) @@ -117,6 +127,11 @@ static List 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) @@ -137,10 +152,13 @@ static List 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); 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 841e459..278c98a 100644 --- a/subsystem/src/main/java/org/wildfly/extension/vertx/VertxOptionsResourceDefinition.java +++ b/subsystem/src/main/java/org/wildfly/extension/vertx/VertxOptionsResourceDefinition.java @@ -23,8 +23,10 @@ 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; @@ -32,6 +34,7 @@ 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; @@ -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)) { @@ -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; } 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 10ed3e9..010e66c 100644 --- a/subsystem/src/main/resources/org/wildfly/extension/vertx/LocalDescriptions.properties +++ b/subsystem/src/main/resources/org/wildfly/extension/vertx/LocalDescriptions.properties @@ -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 @@ -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 \ No newline at end of file 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 a4f9fa4..9da06df 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 @@ -73,9 +73,11 @@ + + @@ -100,6 +102,7 @@ + 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 b5f0de2..ac91b31 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 @@ -6,7 +6,20 @@ - - + + \ No newline at end of file diff --git a/testsuite/integration/basic/src/test/java/org/wildfly/extension/vertx/test/basic/management/VertxOptionsManagementTestCase.java b/testsuite/integration/basic/src/test/java/org/wildfly/extension/vertx/test/basic/management/VertxOptionsManagementTestCase.java index b3463ce..e58b028 100644 --- a/testsuite/integration/basic/src/test/java/org/wildfly/extension/vertx/test/basic/management/VertxOptionsManagementTestCase.java +++ b/testsuite/integration/basic/src/test/java/org/wildfly/extension/vertx/test/basic/management/VertxOptionsManagementTestCase.java @@ -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)); @@ -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()); @@ -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")); @@ -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); @@ -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")); @@ -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"); @@ -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"));