Skip to content

Commit

Permalink
[WFLY-9176] Don't do a recursive readResourceFromRoot to inspect the …
Browse files Browse the repository at this point in the history
…names of children
  • Loading branch information
bstansberry committed Aug 5, 2017
1 parent c16deb4 commit bb565cf
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 51 deletions.
Expand Up @@ -185,7 +185,7 @@ private BatchSubsystemAdd() {
protected void performBoottime(final OperationContext context, final ModelNode operation, final ModelNode model)
throws OperationFailedException {
// Check if the request-controller subsystem exists
final boolean rcPresent = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS).hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, RequestControllerExtension.SUBSYSTEM_NAME));
final boolean rcPresent = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, RequestControllerExtension.SUBSYSTEM_NAME));

context.addStep(new AbstractDeploymentChainStep() {
public void execute(DeploymentProcessorTarget processorTarget) {
Expand Down Expand Up @@ -238,4 +238,4 @@ public void execute(DeploymentProcessorTarget processorTarget) {
.install();
}
}
}
}
Expand Up @@ -187,7 +187,7 @@ protected void populateModel(final ModelNode operation, final ModelNode model) t
protected void performBoottime(final OperationContext context, final ModelNode operation, final ModelNode model)
throws OperationFailedException {
// Check if the request-controller subsystem exists
final boolean rcPresent = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS).hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, RequestControllerExtension.SUBSYSTEM_NAME));
final boolean rcPresent = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, RequestControllerExtension.SUBSYSTEM_NAME));

context.addStep(new AbstractDeploymentChainStep() {
public void execute(DeploymentProcessorTarget processorTarget) {
Expand Down
Expand Up @@ -23,9 +23,9 @@
package org.jboss.as.clustering.jgroups.subsystem;

import static org.jboss.as.clustering.jgroups.logging.JGroupsLogger.ROOT_LOGGER;
import static org.jboss.as.clustering.jgroups.subsystem.JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_CHANNEL;
import static org.jboss.as.clustering.jgroups.subsystem.JGroupsSubsystemResourceDefinition.CAPABILITIES;
import static org.jboss.as.clustering.jgroups.subsystem.JGroupsSubsystemResourceDefinition.CLUSTERING_CAPABILITIES;
import static org.jboss.as.clustering.jgroups.subsystem.JGroupsSubsystemResourceDefinition.Attribute.*;

import java.util.ServiceLoader;

Expand All @@ -39,7 +39,6 @@
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceTarget;
import org.jgroups.Version;
Expand All @@ -63,8 +62,7 @@ public void installServices(OperationContext context, ModelNode model) throws Op
// Handle case where JGroups subsystem is added to a running server
// In this case, the Infinispan subsystem may have already registered default group capabilities
if (context.getProcessType().isServer() && !context.isBooting()) {
Resource rootResource = context.readResourceFromRoot(address.getParent());
if (rootResource.hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "infinispan"))) {
if (context.readResourceFromRoot(address.getParent(),false).hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "infinispan"))) {
// Following restart, default group services will be installed by this handler, rather than the infinispan subsystem handler
context.addStep((ctx, operation) -> {
ctx.reloadRequired();
Expand Down
Expand Up @@ -139,9 +139,9 @@ protected JCAThreadPoolResourceDefinition(boolean blocking, boolean registerRunt
private static void checkThreadPool(final OperationContext context, final ModelNode operation, final String type) throws OperationFailedException {
PathAddress threadPoolPath = context.getCurrentAddress();
PathAddress workManagerPath = threadPoolPath.getParent();
Set<Resource.ResourceEntry> entrySet = context.readResourceFromRoot(workManagerPath).getChildren(type);
Set<String> entrySet = context.readResourceFromRoot(workManagerPath, false).getChildrenNames(type);
if (entrySet.size() > 0
&& !entrySet.iterator().next().getName().equals(threadPoolPath.getLastElement().getValue())) {
&& !entrySet.iterator().next().equals(threadPoolPath.getLastElement().getValue())) {
throw ConnectorLogger.ROOT_LOGGER.oneThreadPoolWorkManager(threadPoolPath.getLastElement().getValue(), type, workManagerPath.getLastElement().getValue());
}
}
Expand Down
Expand Up @@ -109,7 +109,7 @@ protected void performRuntime(OperationContext context, ModelNode operation, Mod
final ManagedExecutorServiceService service = new ManagedExecutorServiceService(name, jndiName, hungTaskThreshold, longRunningTasks, coreThreads, maxThreads, keepAliveTime, keepAliveTimeUnit, threadLifeTime, queueLength, rejectPolicy);
final ServiceBuilder<ManagedExecutorServiceAdapter> serviceBuilder = context.getServiceTarget().addService(ConcurrentServiceNames.getManagedExecutorServiceServiceName(name), service);

boolean rcPresent = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS).hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, RequestControllerExtension.SUBSYSTEM_NAME));
boolean rcPresent = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, RequestControllerExtension.SUBSYSTEM_NAME));
String contextService = null;
if(model.hasDefined(ManagedExecutorServiceResourceDefinition.CONTEXT_SERVICE)) {
contextService = ManagedExecutorServiceResourceDefinition.CONTEXT_SERVICE_AD.resolveModelAttribute(context, model).asString();
Expand Down
Expand Up @@ -55,7 +55,7 @@ private ManagedScheduledExecutorServiceAdd() {
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {

boolean rcPresent = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS).hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, RequestControllerExtension.SUBSYSTEM_NAME));
boolean rcPresent = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, RequestControllerExtension.SUBSYSTEM_NAME));

final String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue();

Expand Down
Expand Up @@ -123,13 +123,13 @@ public void execute(final OperationContext context, final ModelNode operation) t

final PathAddress subsystemsAddress = context.getCurrentAddress().getParent();

if (context.readResourceFromRoot(subsystemsAddress).hasChild(OPENJDK_SUBSYSTEM_ELEMENT)) {
if (context.readResourceFromRoot(subsystemsAddress, false).hasChild(OPENJDK_SUBSYSTEM_ELEMENT)) {
throw new OperationFailedException("can not migrate: the new iiop-openjdk subsystem is already defined");
}

final Map<PathAddress, ModelNode> migrateOperations = new LinkedHashMap<>();

if (!context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS).hasChild(OPENJDK_EXTENSION_ELEMENT)) {
if (!context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).hasChild(OPENJDK_EXTENSION_ELEMENT)) {
addOpenjdkExtension(context, migrateOperations);
}

Expand Down
Expand Up @@ -55,7 +55,7 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
String addressSetting = PathAddress.pathAddress(operation.require(OP_ADDR)).getLastElement().getValue();

PathAddress hornetqServerAddress = context.getCurrentAddress().getParent();
Resource hornetqServer = context.readResourceFromRoot(hornetqServerAddress, true);
Resource hornetqServer = context.readResourceFromRoot(hornetqServerAddress, false);

checkExpiryAddress(context, operation, hornetqServer, addressSetting);
checkDeadLetterAddress(context, operation, hornetqServer, addressSetting);
Expand Down
Expand Up @@ -136,7 +136,7 @@ static void validateConnectors(OperationContext context, ModelNode operation, Mo

private static Set<String> getAvailableConnectors(final OperationContext context,final ModelNode operation) throws OperationFailedException{
PathAddress hornetqServer = context.getCurrentAddress().getParent();
Resource hornetQServerResource = context.readResourceFromRoot(hornetqServer);
Resource hornetQServerResource = context.readResourceFromRoot(hornetqServer, false);
Set<String> availableConnectors = new HashSet<String>();
availableConnectors.addAll(hornetQServerResource.getChildrenNames(CommonAttributes.HTTP_CONNECTOR));
availableConnectors.addAll(hornetQServerResource.getChildrenNames(CommonAttributes.IN_VM_CONNECTOR));
Expand Down
Expand Up @@ -55,7 +55,7 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
String addressSetting = PathAddress.pathAddress(operation.require(OP_ADDR)).getLastElement().getValue();

PathAddress address = pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
Resource activeMQServer = context.readResourceFromRoot(MessagingServices.getActiveMQServerPathAddress(address), true);
Resource activeMQServer = context.readResourceFromRoot(MessagingServices.getActiveMQServerPathAddress(address), false);

checkExpiryAddress(context, operation, activeMQServer, addressSetting);
checkDeadLetterAddress(context, operation, activeMQServer, addressSetting);
Expand Down
Expand Up @@ -151,7 +151,7 @@ static void validateConnectors(OperationContext context, ModelNode operation, Mo
private static Set<String> getAvailableConnectors(final OperationContext context,final ModelNode operation) throws OperationFailedException{
PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR));
PathAddress active = MessagingServices.getActiveMQServerPathAddress(address);
Resource activeMQServerResource = context.readResourceFromRoot(active);
Resource activeMQServerResource = context.readResourceFromRoot(active, false);
Set<String> availableConnectors = new HashSet<String>();
availableConnectors.addAll(activeMQServerResource.getChildrenNames(CommonAttributes.HTTP_CONNECTOR));
availableConnectors.addAll(activeMQServerResource.getChildrenNames(CommonAttributes.IN_VM_CONNECTOR));
Expand Down
Expand Up @@ -42,7 +42,6 @@
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;

Expand Down Expand Up @@ -165,9 +164,7 @@ static boolean forwardToRuntimeQueue(OperationContext context, ModelNode operati
String queueName = address.getLastElement().getValue();

PathAddress activeMQPathAddress = MessagingServices.getActiveMQServerPathAddress(address);
Resource serverResource = context.readResourceFromRoot(activeMQPathAddress);
boolean hasChild = serverResource.hasChild(address.getLastElement());
if (hasChild) {
if (context.readResourceFromRoot(activeMQPathAddress, false).hasChild(address.getLastElement())) {
return false;
} else {
// there is no registered queue resource, forward to the runtime-queue address instead
Expand Down
Expand Up @@ -21,19 +21,18 @@
*/
package org.wildfly.extension.picketlink.common.model.validator;

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.wildfly.extension.picketlink.logging.PicketLinkLogger.ROOT_LOGGER;

import java.util.Set;

import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.operations.common.Util;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
import org.wildfly.extension.picketlink.common.model.ModelElement;

import java.util.Set;

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.wildfly.extension.picketlink.logging.PicketLinkLogger.ROOT_LOGGER;

/**
* @author Pedro Igor
*/
Expand All @@ -57,8 +56,7 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
protected void validateOccurrence(OperationContext context, ModelNode operation) throws OperationFailedException {
PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
PathAddress parentAddress = Util.getParentAddressByKey(address, this.parentElement.getName());
Resource parentResource = context.readResourceFromRoot(parentAddress);
Set<String> elements = parentResource.getChildrenNames(this.element.getName());
Set<String> elements = context.readResourceFromRoot(parentAddress, false).getChildrenNames(this.element.getName());

if (elements.size() > this.maxOccurs) {
throw ROOT_LOGGER.invalidChildTypeOccurrence(parentAddress.getLastElement().toString(), this.maxOccurs, this.element
Expand Down
Expand Up @@ -55,8 +55,7 @@ protected void validateType(OperationContext context, ModelNode operation) throw
ModelNode typeNode = context.readResource(EMPTY_ADDRESS, false).getModel();
String type = getType(context, typeNode);
PathAddress parentAddress = pathAddress.getParent();
Resource parentResource = context.readResourceFromRoot(parentAddress);
Set<Resource.ResourceEntry> children = parentResource.getChildren(this.element.getName());
Set<Resource.ResourceEntry> children = context.readResourceFromRoot(parentAddress, true).getChildren(this.element.getName());

for (Resource.ResourceEntry child : children) {
String existingResourceName = child.getName();
Expand Down
Expand Up @@ -22,20 +22,19 @@

package org.wildfly.extension.picketlink.idm.model;

import static org.wildfly.extension.picketlink.logging.PicketLinkLogger.ROOT_LOGGER;

import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.RestartParentResourceRemoveHandler;
import org.jboss.as.controller.operations.common.Util;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceName;
import org.wildfly.extension.picketlink.common.model.ModelElement;
import org.wildfly.extension.picketlink.idm.service.PartitionManagerService;

import static org.wildfly.extension.picketlink.logging.PicketLinkLogger.ROOT_LOGGER;

/**
* @author Pedro Silva
*/
Expand Down Expand Up @@ -80,9 +79,8 @@ protected ServiceName getParentServiceName(PathAddress parentAddress) {

private void checkIfLastIdentityStore(OperationContext context) throws OperationFailedException {
PathAddress parentAddress = Util.getParentAddressByKey(context.getCurrentAddress(), ModelElement.IDENTITY_CONFIGURATION.getName());
Resource resource = context.readResourceFromRoot(parentAddress);

if (resource.getChildTypes().size() == 1) {
if (context.readResourceFromRoot(parentAddress, false).getChildTypes().size() == 1) {
throw ROOT_LOGGER.idmNoIdentityStoreProvided(parentAddress.getLastElement().getValue());
}
}
Expand Down
Expand Up @@ -233,11 +233,11 @@ protected void performBoottime(OperationContext context, ModelNode operation, Mo

boolean jts = model.hasDefined(JTS) && model.get(JTS).asBoolean();

final Resource subsystemResource = context.readResourceFromRoot(PathAddress.pathAddress(TransactionExtension.SUBSYSTEM_PATH));
final Resource subsystemResource = context.readResourceFromRoot(PathAddress.pathAddress(TransactionExtension.SUBSYSTEM_PATH), false);
final List<ServiceName> deps = new LinkedList<>();

for (Resource.ResourceEntry re : subsystemResource.getChildren(CM_RESOURCE)) {
deps.add(TxnServices.JBOSS_TXN_CMR.append(re.getName()));
for (String name : subsystemResource.getChildrenNames(CM_RESOURCE)) {
deps.add(TxnServices.JBOSS_TXN_CMR.append(name));
}

//recovery environment
Expand Down
Expand Up @@ -32,7 +32,6 @@
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.controller.registry.Resource.ResourceEntry;
import org.jboss.as.webservices.util.WSServices;
import org.jboss.msc.service.ServiceName;

Expand Down Expand Up @@ -72,11 +71,11 @@ static ServiceName getPropertyServiceName(final ServiceName configServiceName, f

static List<ServiceName> getServiceNameDependencies(final OperationContext context, final ServiceName baseServiceName, final PathAddress address, final String childType) {
final List<ServiceName> childrenServiceNames = new LinkedList<ServiceName>();
final Resource resource = context.readResourceFromRoot(address);
final Resource resource = context.readResourceFromRoot(address, false);
final ServiceName sn = baseServiceName.append(childType);
for (ResourceEntry re : resource.getChildren(childType)) {
childrenServiceNames.add(sn.append(re.getName()));
for (String name : resource.getChildrenNames(childType)) {
childrenServiceNames.add(sn.append(name));
}
return childrenServiceNames;
}
}
}

0 comments on commit bb565cf

Please sign in to comment.