Skip to content
Permalink
Browse files

Merge pull request #12209 from pferraro/infinispan

WFLY-5685 Deployment-specific caches do not expose management metrics operations
  • Loading branch information
bstansberry committed Apr 28, 2019
2 parents d64510a + c67b45d commit 7b45b909c6094dc0eb80bad65d8d9e04b8ed1596
Showing with 846 additions and 242 deletions.
  1. +46 −0 clustering/common/src/main/java/org/jboss/as/clustering/controller/ChildResourceProvider.java
  2. +172 −0 clustering/common/src/main/java/org/jboss/as/clustering/controller/ComplexResource.java
  3. +59 −0 clustering/common/src/main/java/org/jboss/as/clustering/controller/SimpleChildResourceProvider.java
  4. +52 −0 ...in/java/org/jboss/as/clustering/infinispan/subsystem/CacheComponentRuntimeResourceDefinition.java
  5. +5 −5 ...an/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerMetric.java
  6. +60 −0 .../extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerResource.java
  7. +4 −0 .../src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerResourceDefinition.java
  8. +15 −2 ...src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerServiceConfigurator.java
  9. +16 −16 .../infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheMetric.java
  10. +64 −0 ...on/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheRuntimeResourceDefinition.java
  11. +51 −0 ...sion/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheRuntimeResourceProvider.java
  12. +4 −4 ...an/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ClusteredCacheMetric.java
  13. +2 −1 ...sion/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ClusteredCacheMetricExecutor.java
  14. +1 −1 ...finispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/EvictionMetric.java
  15. +2 −1 ...inispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/InfinispanModel.java
  16. +3 −3 ...nfinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/LockingMetric.java
  17. +46 −0 .../src/main/java/org/jboss/as/clustering/infinispan/subsystem/LockingRuntimeResourceDefinition.java
  18. +46 −0 ...n/src/main/java/org/jboss/as/clustering/infinispan/subsystem/MemoryRuntimeResourceDefinition.java
  19. +0 −79 ...g/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/MetricKeys.java
  20. +48 −0 ...java/org/jboss/as/clustering/infinispan/subsystem/PartitionHandlingRuntimeResourceDefinition.java
  21. +46 −0 .../main/java/org/jboss/as/clustering/infinispan/subsystem/PersistenceRuntimeResourceDefinition.java
  22. +2 −2 .../infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/StoreMetric.java
  23. +3 −3 ...ispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/TransactionMetric.java
  24. +46 −0 .../main/java/org/jboss/as/clustering/infinispan/subsystem/TransactionRuntimeResourceDefinition.java
  25. +21 −122 ...n/extension/src/main/java/org/wildfly/extension/clustering/singleton/SingletonPolicyResource.java
  26. +1 −0 .../src/main/resources/modules/system/layers/base/org/jboss/as/clustering/infinispan/main/module.xml
  27. +31 −3 ...tegration/clustering/src/test/java/org/jboss/as/test/clustering/single/web/SimpleWebTestCase.java
@@ -0,0 +1,46 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.clustering.controller;

import java.util.Set;

import org.jboss.as.controller.registry.Resource;

/**
* Provides child resources.
* @author Paul Ferraro
*/
public interface ChildResourceProvider {
/**
* Returns a child resource with the specified name.
* @param name a resource name
* @return a resource
*/
Resource getChild(String name);

/**
* Returns the complete set of child resource names.
* @return a set of resource names
*/
Set<String> getChildren();
}
@@ -0,0 +1,172 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.clustering.controller;

import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Function;

import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.registry.DelegatingResource;
import org.jboss.as.controller.registry.Resource;

/**
* A generic {@link Resource} decorator augmented to support additional runtime children.
* @author Paul Ferraro
*/
public class ComplexResource extends DelegatingResource implements Function<String, ChildResourceProvider> {

private final Map<String, ChildResourceProvider> providers;
private final BiFunction<Resource, Map<String, ChildResourceProvider>, Resource> factory;

/**
* Constructs a new resource.
* @param resource the concrete resource
* @param providers a set of providers for specific child types
*/
public ComplexResource(Resource resource, Map<String, ChildResourceProvider> providers) {
this(resource, providers, ComplexResource::new);
}

/**
* Constructs a new resource.
* @param resource the concrete resource
* @param providers a set of providers for specific child types
* @param factory a function used to clone this resource
*/
protected ComplexResource(Resource resource, Map<String, ChildResourceProvider> providers, BiFunction<Resource, Map<String, ChildResourceProvider>, Resource> factory) {
super(resource);
this.providers = providers;
this.factory = factory;
}

@Override
public ChildResourceProvider apply(String childType) {
return this.providers.get(childType);
}

@Override
public Resource clone() {
return this.factory.apply(super.clone(), this.providers);
}

@Override
public Resource getChild(PathElement path) {
ChildResourceProvider provider = this.apply(path.getKey());
return (provider != null) ? provider.getChild(path.getValue()) : super.getChild(path);
}

@Override
public Set<Resource.ResourceEntry> getChildren(String childType) {
ChildResourceProvider provider = this.apply(childType);
if (provider != null) {
Set<String> names = provider.getChildren();
Set<Resource.ResourceEntry> entries = !names.isEmpty() ? new HashSet<>() : Collections.emptySet();
for (String name : names) {
Resource resource = provider.getChild(name);
entries.add(new SimpleResourceEntry(PathElement.pathElement(childType, name), resource));
}
return entries;
}
return super.getChildren(childType);
}

@Override
public Set<String> getChildrenNames(String childType) {
ChildResourceProvider provider = this.apply(childType);
return (provider != null) ? provider.getChildren() : super.getChildrenNames(childType);
}

@Override
public Set<String> getChildTypes() {
Set<String> childTypes = new HashSet<>(super.getChildTypes());
childTypes.addAll(this.providers.keySet());
return childTypes;
}

@Override
public boolean hasChild(PathElement path) {
ChildResourceProvider provider = this.apply(path.getKey());
return (provider != null) ? provider.getChild(path.getValue()) != null : super.hasChild(path);
}

@Override
public boolean hasChildren(String childType) {
ChildResourceProvider provider = this.apply(childType);
return (provider != null) ? !provider.getChildren().isEmpty() : super.hasChildren(childType);
}

@Override
public Resource navigate(PathAddress address) {
return (address.size() == 1) ? this.requireChild(address.getLastElement()) : super.navigate(address);
}

@Override
public Resource requireChild(PathElement path) {
Resource resource = this.getChild(path);
if (resource == null) {
throw new NoSuchResourceException(path);
}
return resource;
}

private static class SimpleResourceEntry extends DelegatingResource implements Resource.ResourceEntry {

private final PathElement path;

SimpleResourceEntry(PathElement path, Resource resource) {
super(resource);
this.path = path;
}

@Override
public String getName() {
return this.path.getValue();
}

@Override
public PathElement getPathElement() {
return this.path;
}

@Override
public int hashCode() {
return this.path.hashCode();
}

@Override
public boolean equals(Object object) {
if (!(object instanceof Resource.ResourceEntry)) return false;
return this.path.equals(((Resource.ResourceEntry) object).getPathElement());
}

@Override
public String toString() {
return this.path.toString();
}
}
}
@@ -0,0 +1,59 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.clustering.controller;

import java.util.Set;
import java.util.function.Supplier;

import org.jboss.as.controller.registry.PlaceholderResource;
import org.jboss.as.controller.registry.Resource;
import org.wildfly.common.function.Functions;

/**
* A simple {@link ChildResourceProvider} containing a predefined set of children.
* @author Paul Ferraro
*/
public class SimpleChildResourceProvider implements ChildResourceProvider {

private final Set<String> children;
private final Supplier<Resource> provider;

public SimpleChildResourceProvider(Set<String> children) {
this(children, Functions.constantSupplier(PlaceholderResource.INSTANCE));
}

public SimpleChildResourceProvider(Set<String> children, Supplier<Resource> provider) {
this.children = children;
this.provider = provider;
}

@Override
public Resource getChild(String name) {
return this.children.contains(name) ? this.provider.get() : null;
}

@Override
public Set<String> getChildren() {
return this.children;
}
}
@@ -0,0 +1,52 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.clustering.infinispan.subsystem;

import org.jboss.as.clustering.controller.ChildResourceDefinition;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.registry.ManagementResourceRegistration;

/**
* @author Paul Ferraro
*/
public class CacheComponentRuntimeResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> {

static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE);

static final PathElement pathElement(String name) {
return PathElement.pathElement("component", name);
}

CacheComponentRuntimeResourceDefinition(PathElement path) {
this(path, path);
}

CacheComponentRuntimeResourceDefinition(PathElement path, PathElement resolverPath) {
super(new Parameters(path, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(resolverPath)).setRuntime());
}

@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
return parent.registerSubModel(this);
}
}
@@ -35,33 +35,33 @@
*/
public enum CacheContainerMetric implements Metric<EmbeddedCacheManager> {

CACHE_MANAGER_STATUS(MetricKeys.CACHE_MANAGER_STATUS, ModelType.STRING) {
CACHE_MANAGER_STATUS("cache-manager-status", ModelType.STRING) {
@Override
public ModelNode execute(EmbeddedCacheManager manager) {
return new ModelNode(manager.getStatus().toString());
}
},
CLUSTER_NAME(MetricKeys.CLUSTER_NAME, ModelType.STRING) {
CLUSTER_NAME("cluster-name", ModelType.STRING) {
@Override
public ModelNode execute(EmbeddedCacheManager manager) {
String clusterName = manager.getClusterName();
return (clusterName != null) ? new ModelNode(clusterName) : null;
}
},
COORDINATOR_ADDRESS(MetricKeys.COORDINATOR_ADDRESS, ModelType.STRING) {
COORDINATOR_ADDRESS("coordinator-address", ModelType.STRING) {
@Override
public ModelNode execute(EmbeddedCacheManager manager) {
Address address = manager.getCoordinator();
return (address != null) ? new ModelNode(address.toString()) : null;
}
},
IS_COORDINATOR(MetricKeys.IS_COORDINATOR, ModelType.BOOLEAN) {
IS_COORDINATOR("is-coordinator", ModelType.BOOLEAN) {
@Override
public ModelNode execute(EmbeddedCacheManager manager) {
return new ModelNode(manager.isCoordinator());
}
},
LOCAL_ADDRESS(MetricKeys.LOCAL_ADDRESS, ModelType.STRING) {
LOCAL_ADDRESS("local-address", ModelType.STRING) {
@Override
public ModelNode execute(EmbeddedCacheManager manager) {
Address address = manager.getAddress();

0 comments on commit 7b45b90

Please sign in to comment.
You can’t perform that action at this time.