Wildfly:如何在 IO 子系统中动态配置工作线程
Wildfly: How to configure worker threads in IO subsystem dynamically
我想在 standalone.xml 的 wildfly-8.2.0 中动态配置以下部分:
<worker name="default" io-threads="100" task-max-threads="100"/>
基本上我不希望这些值被硬编码并在服务器启动时计算它们并将它们作为 jboss 引导参数传递。我做了这样的事情:
<worker name="default" io-threads="${my.io.threads:100}" task-max-threads="${my.task.max.threads:1000}"/>
我在启动 wildfly 服务器时将这些参数作为 -Dmy.io.threads 和 -Dmy.task.max.threads 传递。但它无法解析 standalone.xml,但出现以下异常:
ERROR [org.jboss.as.server] (Controller Boot Thread) JBAS015956: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: JBAS014676: Failed to parse configuration
at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:112) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.server.ServerService.boot(ServerService.java:331) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.controller.AbstractControllerService.run(AbstractControllerService.java:259) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_45]
Caused by: java.lang.NumberFormatException: For input string: "${my.io.threads:100}"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) [rt.jar:1.8.0_45]
at java.lang.Integer.parseInt(Integer.java:569) [rt.jar:1.8.0_45]
at java.lang.Integer.parseInt(Integer.java:615) [rt.jar:1.8.0_45]
at org.jboss.dmr.StringModelValue.asInt(StringModelValue.java:139) [jboss-dmr-1.2.0.Final.jar:1.2.0.Final]
at org.jboss.dmr.ModelNode.asInt(ModelNode.java:240) [jboss-dmr-1.2.0.Final.jar:1.2.0.Final]
at org.jboss.as.controller.AttributeParser.parse(AttributeParser.java:116) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.controller.AttributeParser.parse(AttributeParser.java:82) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.controller.AttributeParser$DiscardOldDefaultValueParser.parse(AttributeParser.java:177) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.controller.AttributeParser.parseAndSetParameter(AttributeParser.java:61) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.controller.PersistentResourceXMLDescription.parse(PersistentResourceXMLDescription.java:83) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.controller.PersistentResourceXMLDescription.parseChildren(PersistentResourceXMLDescription.java:135) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.controller.PersistentResourceXMLDescription.parse(PersistentResourceXMLDescription.java:107) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.wildfly.extension.io.IOSubsystemParser_1_0.readElement(IOSubsystemParser_1_0.java:71)
at org.wildfly.extension.io.IOSubsystemParser_1_0.readElement(IOSubsystemParser_1_0.java:41)
at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:69) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
at org.jboss.as.server.parsing.StandaloneXml.parseServerProfile(StandaloneXml.java:1131) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.server.parsing.StandaloneXml.readServerElement_1_4(StandaloneXml.java:458) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:145) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:107) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:104) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
... 3 more
我了解到 IO 子系统不支持表达式。还有其他方法可以实现这一目标吗?是否有任何内部参数在启动时传递时会覆盖这些值?
由于它不支持表达式,因此无法对其进行动态配置。但是在 WildFly 10.0.0.Final 中,如果留空则动态生成。
Specify the number of I/O threads to create for the worker. If not specified, a default will be chosen, which is calculated by cpuCount * 2
Wildfly-8.2.0 不支持 IO 子系统的工作部分中的 io-threads
和 task-max-threads
属性的表达式。我在 WFCORE 项目下提出了一个 Jira ticket 问题,由 Jboss 团队解决这个问题。
我想在 standalone.xml 的 wildfly-8.2.0 中动态配置以下部分:
<worker name="default" io-threads="100" task-max-threads="100"/>
基本上我不希望这些值被硬编码并在服务器启动时计算它们并将它们作为 jboss 引导参数传递。我做了这样的事情:
<worker name="default" io-threads="${my.io.threads:100}" task-max-threads="${my.task.max.threads:1000}"/>
我在启动 wildfly 服务器时将这些参数作为 -Dmy.io.threads 和 -Dmy.task.max.threads 传递。但它无法解析 standalone.xml,但出现以下异常:
ERROR [org.jboss.as.server] (Controller Boot Thread) JBAS015956: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: JBAS014676: Failed to parse configuration
at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:112) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.server.ServerService.boot(ServerService.java:331) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.controller.AbstractControllerService.run(AbstractControllerService.java:259) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_45]
Caused by: java.lang.NumberFormatException: For input string: "${my.io.threads:100}"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) [rt.jar:1.8.0_45]
at java.lang.Integer.parseInt(Integer.java:569) [rt.jar:1.8.0_45]
at java.lang.Integer.parseInt(Integer.java:615) [rt.jar:1.8.0_45]
at org.jboss.dmr.StringModelValue.asInt(StringModelValue.java:139) [jboss-dmr-1.2.0.Final.jar:1.2.0.Final]
at org.jboss.dmr.ModelNode.asInt(ModelNode.java:240) [jboss-dmr-1.2.0.Final.jar:1.2.0.Final]
at org.jboss.as.controller.AttributeParser.parse(AttributeParser.java:116) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.controller.AttributeParser.parse(AttributeParser.java:82) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.controller.AttributeParser$DiscardOldDefaultValueParser.parse(AttributeParser.java:177) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.controller.AttributeParser.parseAndSetParameter(AttributeParser.java:61) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.controller.PersistentResourceXMLDescription.parse(PersistentResourceXMLDescription.java:83) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.controller.PersistentResourceXMLDescription.parseChildren(PersistentResourceXMLDescription.java:135) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.controller.PersistentResourceXMLDescription.parse(PersistentResourceXMLDescription.java:107) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
at org.wildfly.extension.io.IOSubsystemParser_1_0.readElement(IOSubsystemParser_1_0.java:71)
at org.wildfly.extension.io.IOSubsystemParser_1_0.readElement(IOSubsystemParser_1_0.java:41)
at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:69) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
at org.jboss.as.server.parsing.StandaloneXml.parseServerProfile(StandaloneXml.java:1131) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.server.parsing.StandaloneXml.readServerElement_1_4(StandaloneXml.java:458) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:145) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:107) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:104) [wildfly-controller-8.2.0.Final.jar:8.2.0.Final]
... 3 more
我了解到 IO 子系统不支持表达式。还有其他方法可以实现这一目标吗?是否有任何内部参数在启动时传递时会覆盖这些值?
由于它不支持表达式,因此无法对其进行动态配置。但是在 WildFly 10.0.0.Final 中,如果留空则动态生成。
Specify the number of I/O threads to create for the worker. If not specified, a default will be chosen, which is calculated by cpuCount * 2
Wildfly-8.2.0 不支持 IO 子系统的工作部分中的 io-threads
和 task-max-threads
属性的表达式。我在 WFCORE 项目下提出了一个 Jira ticket 问题,由 Jboss 团队解决这个问题。