Skip to content
Permalink
Browse files

WFLY-5685 Deployment-specific caches do not expose management metrics…

…/operations
  • Loading branch information
pferraro committed Apr 4, 2019
1 parent 2f952c1 commit 6146b2644c12809531c993c98619d630399b9b9d
Showing with 483 additions and 4 deletions.
  1. +52 −0 ...in/java/org/jboss/as/clustering/infinispan/subsystem/CacheComponentRuntimeResourceDefinition.java
  2. +60 −0 .../extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerResource.java
  3. +4 −0 .../src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerResourceDefinition.java
  4. +15 −2 ...src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerServiceConfigurator.java
  5. +64 −0 ...on/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheRuntimeResourceDefinition.java
  6. +51 −0 ...sion/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheRuntimeResourceProvider.java
  7. +2 −1 ...sion/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ClusteredCacheMetricExecutor.java
  8. +2 −1 ...inispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/InfinispanModel.java
  9. +46 −0 .../src/main/java/org/jboss/as/clustering/infinispan/subsystem/LockingRuntimeResourceDefinition.java
  10. +46 −0 ...n/src/main/java/org/jboss/as/clustering/infinispan/subsystem/MemoryRuntimeResourceDefinition.java
  11. +48 −0 ...java/org/jboss/as/clustering/infinispan/subsystem/PartitionHandlingRuntimeResourceDefinition.java
  12. +46 −0 .../main/java/org/jboss/as/clustering/infinispan/subsystem/PersistenceRuntimeResourceDefinition.java
  13. +46 −0 .../main/java/org/jboss/as/clustering/infinispan/subsystem/TransactionRuntimeResourceDefinition.java
  14. +1 −0 .../src/main/resources/modules/system/layers/base/org/jboss/as/clustering/infinispan/main/module.xml
@@ -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);
}
}
@@ -0,0 +1,60 @@
/*
* 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 java.util.Collections;
import java.util.Map;

import org.jboss.as.clustering.controller.ChildResourceProvider;
import org.jboss.as.clustering.controller.ComplexResource;
import org.jboss.as.controller.registry.Resource;
import org.wildfly.clustering.Registrar;
import org.wildfly.clustering.Registration;

/**
* @author Paul Ferraro
*/
public class CacheContainerResource extends ComplexResource implements Registrar<String> {

private static final String CHILD_TYPE = CacheRuntimeResourceDefinition.WILDCARD_PATH.getKey();

public CacheContainerResource(Resource resource) {
this(resource, Collections.singletonMap(CHILD_TYPE, new CacheRuntimeResourceProvider()));
}

private CacheContainerResource(Resource resource, Map<String, ChildResourceProvider> providers) {
super(resource, providers, CacheContainerResource::new);
}

@Override
public Registration register(String cache) {
ChildResourceProvider handler = this.apply(CHILD_TYPE);
handler.getChildren().add(cache);
return new Registration() {
@Override
public void close() {
handler.getChildren().remove(cache);
}
};
}
}
@@ -288,6 +288,8 @@ public ModelNode transformOperation(ModelNode operation) {
ReplicatedCacheResourceDefinition.buildTransformation(version, builder);
InvalidationCacheResourceDefinition.buildTransformation(version, builder);
LocalCacheResourceDefinition.buildTransformation(version, builder);

CacheRuntimeResourceDefinition.buildTransformation(version, builder);
}

CacheContainerResourceDefinition() {
@@ -308,6 +310,7 @@ public ManagementResourceRegistration register(ManagementResourceRegistration pa
.addRequiredChildren(EnumSet.complementOf(EnumSet.of(ThreadPoolResourceDefinition.CLIENT)))
.addRequiredChildren(ScheduledThreadPoolResourceDefinition.class)
.addRequiredSingletonChildren(NoTransportResourceDefinition.PATH)
.setResourceTransformation(CacheContainerResource::new)
;
ResourceServiceHandler handler = new CacheContainerServiceHandler();
new SimpleResourceRegistration(descriptor, handler).register(registration);
@@ -336,6 +339,7 @@ public void execute(OperationContext context, ModelNode legacyOperation) throws

if (registration.isRuntimeOnlyRegistrationValid()) {
new MetricHandler<>(new CacheContainerMetricExecutor(), CacheContainerMetric.class).register(registration);
new CacheRuntimeResourceDefinition().register(registration);
}

new JGroupsTransportResourceDefinition().register(registration);
@@ -27,6 +27,8 @@
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -58,6 +60,8 @@
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.clustering.Registrar;
import org.wildfly.clustering.Registration;
import org.wildfly.clustering.infinispan.spi.CacheContainer;
import org.wildfly.clustering.infinispan.spi.InfinispanRequirement;
import org.wildfly.clustering.service.FunctionalService;
@@ -70,10 +74,13 @@
@Listener
public class CacheContainerServiceConfigurator extends CapabilityServiceNameProvider implements ResourceServiceConfigurator, Function<EmbeddedCacheManager, CacheContainer>, Supplier<EmbeddedCacheManager>, Consumer<EmbeddedCacheManager> {

private final Map<String, Registration> registrations = new ConcurrentHashMap<>();
private final List<ServiceName> aliases = new LinkedList<>();
private final String name;
private final SupplierDependency<GlobalConfiguration> configuration;

private volatile Registrar<String> registrar;

public CacheContainerServiceConfigurator(PathAddress address) {
super(CONTAINER, address);
this.name = address.getLastElement().getValue();
@@ -121,6 +128,7 @@ public CacheContainerServiceConfigurator configure(OperationContext context, Mod
for (ModelNode alias : ModelNodes.optionalList(ALIASES.resolveModelAttribute(context, model)).orElse(Collections.emptyList())) {
this.aliases.add(InfinispanRequirement.CONTAINER.getServiceName(context.getCapabilityServiceSupport(), alias.asString()));
}
this.registrar = (CacheContainerResource) context.readResource(PathAddress.EMPTY_ADDRESS);
return this;
}

@@ -137,11 +145,16 @@ public CacheContainerServiceConfigurator configure(OperationContext context, Mod

@CacheStarted
public void cacheStarted(CacheStartedEvent event) {
InfinispanLogger.ROOT_LOGGER.cacheStarted(event.getCacheName(), this.name);
String cacheName = event.getCacheName();
InfinispanLogger.ROOT_LOGGER.cacheStarted(cacheName, this.name);
this.registrations.put(cacheName, this.registrar.register(cacheName));
}

@CacheStopped
public void cacheStopped(CacheStoppedEvent event) {
InfinispanLogger.ROOT_LOGGER.cacheStopped(event.getCacheName(), this.name);
String cacheName = event.getCacheName();
try (Registration registration = this.registrations.remove(cacheName)) {
InfinispanLogger.ROOT_LOGGER.cacheStopped(cacheName, this.name);
}
}
}
@@ -0,0 +1,64 @@
/*
* 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.clustering.controller.MetricHandler;
import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder;

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

static final PathElement WILDCARD_PATH = PathElement.pathElement("cache");

static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
if (InfinispanModel.VERSION_10_0_0.requiresTransformation(version)) {
parent.discardChildResource(WILDCARD_PATH);
}
}

CacheRuntimeResourceDefinition() {
super(new Parameters(WILDCARD_PATH, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(WILDCARD_PATH)).setRuntime());
}

@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
ManagementResourceRegistration registration = parent.registerSubModel(this);

new MetricHandler<>(new CacheMetricExecutor(), CacheMetric.class).register(registration);
new MetricHandler<>(new ClusteredCacheMetricExecutor(), ClusteredCacheMetric.class).register(registration);

new LockingRuntimeResourceDefinition().register(registration);
new MemoryRuntimeResourceDefinition().register(registration);
new PartitionHandlingRuntimeResourceDefinition().register(registration);
new PersistenceRuntimeResourceDefinition().register(registration);
new TransactionRuntimeResourceDefinition().register(registration);

return registration;
}
}
@@ -0,0 +1,51 @@
/*
* 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 java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.concurrent.ConcurrentHashMap;

import org.jboss.as.clustering.controller.ChildResourceProvider;
import org.jboss.as.clustering.controller.ComplexResource;
import org.jboss.as.clustering.controller.SimpleChildResourceProvider;
import org.jboss.as.controller.registry.PlaceholderResource;
import org.wildfly.common.function.Functions;

/**
* @author Paul Ferraro
*/
public class CacheRuntimeResourceProvider extends SimpleChildResourceProvider {

private static final ChildResourceProvider CHILD_PROVIDER = new SimpleChildResourceProvider(Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
LockingRuntimeResourceDefinition.PATH.getValue(),
MemoryRuntimeResourceDefinition.PATH.getValue(),
PersistenceRuntimeResourceDefinition.PATH.getValue(),
PartitionHandlingRuntimeResourceDefinition.PATH.getValue(),
TransactionRuntimeResourceDefinition.PATH.getValue()))));

public CacheRuntimeResourceProvider() {
super(ConcurrentHashMap.newKeySet(), Functions.constantSupplier(new ComplexResource(PlaceholderResource.INSTANCE, Collections.singletonMap(CacheComponentRuntimeResourceDefinition.WILDCARD_PATH.getKey(), CHILD_PROVIDER))));
}
}
@@ -44,6 +44,7 @@ public ModelNode execute(OperationContext context, Metric<RpcManagerImpl> metric

Cache<?, ?> cache = new PassiveServiceSupplier<Cache<?, ?>>(context.getServiceRegistry(true), InfinispanCacheRequirement.CACHE.getServiceName(context, containerName, cacheName)).get();

return (cache != null) ? metric.execute((RpcManagerImpl) cache.getAdvancedCache().getRpcManager()) : null;
RpcManagerImpl manager = (cache != null) ? (RpcManagerImpl) cache.getAdvancedCache().getRpcManager() : null;
return (manager != null) ? metric.execute(manager) : null;
}
}
@@ -40,8 +40,9 @@
VERSION_7_0_0(7, 0, 0), // WildFly 13
VERSION_8_0_0(8, 0, 0), // WildFly 14-15, EAP 7.2
VERSION_9_0_0(9, 0, 0), // WildFly 16
VERSION_10_0_0(10, 0, 0), // WildFly 17
;
static final InfinispanModel CURRENT = VERSION_9_0_0;
static final InfinispanModel CURRENT = VERSION_10_0_0;

private final ModelVersion version;

@@ -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.infinispan.subsystem;

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

/**
* @author Paul Ferraro
*/
public class LockingRuntimeResourceDefinition extends CacheComponentRuntimeResourceDefinition {

static final PathElement PATH = pathElement("locking");

LockingRuntimeResourceDefinition() {
super(PATH);
}

@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
ManagementResourceRegistration registration = super.register(parent);
new MetricHandler<>(new LockingMetricExecutor(), LockingMetric.class).register(registration);
return registration;
}
}

0 comments on commit 6146b26

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