-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate IO subsystem to SubsystemResourceXMLSchema.
- Loading branch information
Showing
12 changed files
with
77 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
io/subsystem/src/main/java/org/wildfly/extension/io/IOSubsystemResourceDescription.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.wildfly.extension.io; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import org.jboss.as.controller.AttributeDefinition; | ||
import org.jboss.as.controller.SubsystemResourceDescription; | ||
import org.jboss.as.controller.capability.RuntimeCapability; | ||
import org.wildfly.io.IOServiceDescriptor; | ||
import org.wildfly.subsystem.resource.capability.CapabilityReference; | ||
import org.wildfly.subsystem.resource.capability.CapabilityReferenceAttributeDefinition; | ||
import org.xnio.XnioWorker; | ||
|
||
/** | ||
* Describes the IO subsystem resource. | ||
*/ | ||
public enum IOSubsystemResourceDescription implements SubsystemResourceDescription { | ||
INSTANCE; | ||
|
||
static final RuntimeCapability<Void> DEFAULT_WORKER_CAPABILITY = RuntimeCapability.Builder.of(IOServiceDescriptor.DEFAULT_WORKER).build(); | ||
|
||
static final CapabilityReferenceAttributeDefinition<XnioWorker> DEFAULT_WORKER = new CapabilityReferenceAttributeDefinition.Builder<>("default-worker", CapabilityReference.builder(DEFAULT_WORKER_CAPABILITY, IOServiceDescriptor.NAMED_WORKER).build()) | ||
.setRequired(false) | ||
.build(); | ||
|
||
@Override | ||
public String getName() { | ||
return "io"; | ||
} | ||
|
||
@Override | ||
public Stream<AttributeDefinition> getAttributes() { | ||
return Stream.of(DEFAULT_WORKER); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,7 @@ | |
|
||
import org.jboss.as.controller.OperationContext; | ||
import org.jboss.as.controller.OperationFailedException; | ||
import org.jboss.as.controller.PathElement; | ||
import org.jboss.as.controller.ResourceDefinition; | ||
import org.jboss.as.controller.ResourceRegistration; | ||
import org.jboss.as.controller.SubsystemRegistration; | ||
import org.jboss.as.controller.capability.RuntimeCapability; | ||
import org.jboss.as.controller.descriptions.ParentResourceDescriptionResolver; | ||
|
@@ -26,8 +24,6 @@ | |
import org.wildfly.subsystem.resource.ManagementResourceRegistrationContext; | ||
import org.wildfly.subsystem.resource.ResourceDescriptor; | ||
import org.wildfly.subsystem.resource.SubsystemResourceDefinitionRegistrar; | ||
import org.wildfly.subsystem.resource.capability.CapabilityReference; | ||
import org.wildfly.subsystem.resource.capability.CapabilityReferenceAttributeDefinition; | ||
import org.wildfly.subsystem.resource.operation.ResourceOperationRuntimeHandler; | ||
import org.wildfly.subsystem.service.ResourceServiceConfigurator; | ||
import org.wildfly.subsystem.service.ResourceServiceInstaller; | ||
|
@@ -38,32 +34,24 @@ | |
/** | ||
* @author <a href="mailto:[email protected]">Tomaz Cerar</a> (c) 2013 Red Hat Inc. | ||
*/ | ||
class IOSubsystemRegistrar implements SubsystemResourceDefinitionRegistrar, ResourceServiceConfigurator { | ||
class IOSubsystemResourceRegistrar implements SubsystemResourceDefinitionRegistrar, ResourceServiceConfigurator { | ||
|
||
static final String NAME = "io"; | ||
static final PathElement PATH = SubsystemResourceDefinitionRegistrar.pathElement(NAME); | ||
static final ParentResourceDescriptionResolver RESOLVER = new SubsystemResourceDescriptionResolver(NAME, IOSubsystemRegistrar.class); | ||
static final ParentResourceDescriptionResolver RESOLVER = new SubsystemResourceDescriptionResolver(IOSubsystemResourceDescription.INSTANCE.getName(), IOSubsystemResourceRegistrar.class); | ||
|
||
static final RuntimeCapability<Void> MAX_THREADS_CAPABILITY = RuntimeCapability.Builder.of(IOServiceDescriptor.MAX_THREADS).build(); | ||
|
||
static final RuntimeCapability<Void> DEFAULT_WORKER_CAPABILITY = RuntimeCapability.Builder.of(IOServiceDescriptor.DEFAULT_WORKER).build(); | ||
|
||
static final ModelNode LEGACY_DEFAULT_WORKER = new ModelNode("default"); | ||
|
||
static final CapabilityReferenceAttributeDefinition<XnioWorker> DEFAULT_WORKER = new CapabilityReferenceAttributeDefinition.Builder<>("default-worker", CapabilityReference.builder(DEFAULT_WORKER_CAPABILITY, IOServiceDescriptor.NAMED_WORKER).build()) | ||
.setRequired(false) | ||
.build(); | ||
|
||
// Tracks max-threads for all workers | ||
private final AtomicInteger maxThreads = new AtomicInteger(); | ||
|
||
@Override | ||
public ManagementResourceRegistration register(SubsystemRegistration parent, ManagementResourceRegistrationContext context) { | ||
ManagementResourceRegistration registration = parent.registerSubsystemModel(ResourceDefinition.builder(ResourceRegistration.of(PATH), RESOLVER).build()); | ||
ManagementResourceRegistration registration = parent.registerSubsystemModel(ResourceDefinition.builder(IOSubsystemResourceDescription.INSTANCE, RESOLVER).build()); | ||
|
||
ResourceDescriptor descriptor = ResourceDescriptor.builder(RESOLVER) | ||
.addAttributes(List.of(DEFAULT_WORKER)) | ||
.addCapabilities(List.of(DEFAULT_WORKER_CAPABILITY, MAX_THREADS_CAPABILITY)) | ||
.addAttributes(IOSubsystemResourceDescription.INSTANCE.getAttributes().toList()) | ||
.addCapabilities(List.of(IOSubsystemResourceDescription.DEFAULT_WORKER_CAPABILITY, MAX_THREADS_CAPABILITY)) | ||
.withRuntimeHandler(ResourceOperationRuntimeHandler.configureParentService(this)) | ||
.build(); | ||
ManagementResourceRegistrar.of(descriptor).register(registration); | ||
|
@@ -82,9 +70,9 @@ public ResourceServiceInstaller configure(OperationContext context, ModelNode mo | |
List<ResourceServiceInstaller> installers = new ArrayList<>(2); | ||
installers.add(CapabilityServiceInstaller.builder(MAX_THREADS_CAPABILITY, AtomicInteger::intValue, Functions.constantSupplier(this.maxThreads)).build()); | ||
|
||
ServiceDependency<XnioWorker> defaultWorker = DEFAULT_WORKER.resolve(context, model); | ||
ServiceDependency<XnioWorker> defaultWorker = IOSubsystemResourceDescription.DEFAULT_WORKER.resolve(context, model); | ||
if (defaultWorker.isPresent()) { | ||
installers.add(CapabilityServiceInstaller.builder(DEFAULT_WORKER_CAPABILITY, defaultWorker).build()); | ||
installers.add(CapabilityServiceInstaller.builder(IOSubsystemResourceDescription.DEFAULT_WORKER_CAPABILITY, defaultWorker).build()); | ||
} | ||
|
||
return ResourceServiceInstaller.combine(installers); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters