Skip to content

Commit

Permalink
WFLY-6906 Silence "ISPN000152: Passivation configured without an evic…
Browse files Browse the repository at this point in the history
…tion policy being selected. Only manually evicted entities will be passivated."
  • Loading branch information
pferraro committed Nov 16, 2016
1 parent dba9ddf commit d828933
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
Expand Up @@ -22,6 +22,10 @@


package org.jboss.as.clustering.controller.validation; package org.jboss.as.clustering.controller.validation;


import java.lang.reflect.Array;
import java.util.EnumSet;
import java.util.Set;

import org.jboss.as.controller.operations.validation.EnumValidator; import org.jboss.as.controller.operations.validation.EnumValidator;
import org.jboss.as.controller.operations.validation.ParameterValidator; import org.jboss.as.controller.operations.validation.ParameterValidator;


Expand All @@ -31,19 +35,20 @@
public class EnumValidatorBuilder<E extends Enum<E>> extends AbstractParameterValidatorBuilder { public class EnumValidatorBuilder<E extends Enum<E>> extends AbstractParameterValidatorBuilder {


private final Class<E> enumClass; private final Class<E> enumClass;
private final E[] allowed; private final Set<E> allowed;


public EnumValidatorBuilder(Class<E> enumClass) { public EnumValidatorBuilder(Class<E> enumClass) {
this(enumClass, enumClass.getEnumConstants()); this(enumClass, EnumSet.allOf(enumClass));
} }


public EnumValidatorBuilder(Class<E> enumClass, @SuppressWarnings("unchecked") E... allowed) { public EnumValidatorBuilder(Class<E> enumClass, Set<E> allowed) {
this.enumClass = enumClass; this.enumClass = enumClass;
this.allowed = allowed; this.allowed = allowed;
} }


@SuppressWarnings("unchecked")
@Override @Override
public ParameterValidator build() { public ParameterValidator build() {
return new EnumValidator<>(this.enumClass, this.allowsUndefined, this.allowsExpressions, this.allowed); return new EnumValidator<>(this.enumClass, this.allowsUndefined, this.allowsExpressions, this.allowed.toArray((E[]) Array.newInstance(this.enumClass, this.allowed.size())));
} }
} }
Expand Up @@ -28,6 +28,7 @@
import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.configuration.cache.EvictionConfiguration; import org.infinispan.configuration.cache.EvictionConfiguration;
import org.infinispan.configuration.cache.EvictionConfigurationBuilder; import org.infinispan.configuration.cache.EvictionConfigurationBuilder;
import org.infinispan.configuration.cache.PersistenceConfiguration;
import org.infinispan.eviction.EvictionStrategy; import org.infinispan.eviction.EvictionStrategy;
import org.infinispan.eviction.EvictionType; import org.infinispan.eviction.EvictionType;
import org.jboss.as.clustering.controller.ResourceServiceBuilder; import org.jboss.as.clustering.controller.ResourceServiceBuilder;
Expand All @@ -36,31 +37,47 @@
import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PathAddress;
import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.clustering.service.Builder; import org.wildfly.clustering.service.Builder;
import org.wildfly.clustering.service.InjectedValueDependency;
import org.wildfly.clustering.service.ValueDependency;


/** /**
* @author Paul Ferraro * @author Paul Ferraro
*/ */
public class EvictionBuilder extends ComponentBuilder<EvictionConfiguration> implements ResourceServiceBuilder<EvictionConfiguration> { public class EvictionBuilder extends ComponentBuilder<EvictionConfiguration> implements ResourceServiceBuilder<EvictionConfiguration> {


private final EvictionConfigurationBuilder builder = new ConfigurationBuilder().eviction(); private final EvictionConfigurationBuilder builder = new ConfigurationBuilder().eviction();
private final ValueDependency<PersistenceConfiguration> persistence;

private volatile EvictionStrategy strategy;


EvictionBuilder(PathAddress cacheAddress) { EvictionBuilder(PathAddress cacheAddress) {
super(CacheComponent.EVICTION, cacheAddress); super(CacheComponent.EVICTION, cacheAddress);
this.persistence = new InjectedValueDependency<>(CacheComponent.PERSISTENCE.getServiceName(cacheAddress), PersistenceConfiguration.class);
}

@Override
public ServiceBuilder<EvictionConfiguration> build(ServiceTarget target) {
return this.persistence.register(super.build(target));
} }


@Override @Override
public Builder<EvictionConfiguration> configure(OperationContext context, ModelNode model) throws OperationFailedException { public Builder<EvictionConfiguration> configure(OperationContext context, ModelNode model) throws OperationFailedException {
EvictionStrategy strategy = ModelNodes.asEnum(STRATEGY.resolveModelAttribute(context, model), EvictionStrategy.class); this.strategy = ModelNodes.asEnum(STRATEGY.resolveModelAttribute(context, model), EvictionStrategy.class);
this.builder.strategy(strategy); if (this.strategy.isEnabled()) {
if (strategy.isEnabled()) {
this.builder.type(EvictionType.COUNT).size(MAX_ENTRIES.resolveModelAttribute(context, model).asLong()); this.builder.type(EvictionType.COUNT).size(MAX_ENTRIES.resolveModelAttribute(context, model).asLong());
} }
return this; return this;
} }


@Override @Override
public EvictionConfiguration getValue() { public EvictionConfiguration getValue() {
return this.builder.create(); if ((this.strategy == EvictionStrategy.NONE) && this.persistence.getValue().passivation()) {
// When passivation is enabled, convert NONE to MANUAL, which silences log WARNs on cache configuration validation
this.strategy = EvictionStrategy.MANUAL;
}
return this.builder.strategy(this.strategy).create();
} }
} }
Expand Up @@ -22,6 +22,8 @@


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


import java.util.EnumSet;

import org.infinispan.eviction.EvictionStrategy; import org.infinispan.eviction.EvictionStrategy;
import org.jboss.as.clustering.controller.MetricHandler; import org.jboss.as.clustering.controller.MetricHandler;
import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceDescriptor;
Expand Down Expand Up @@ -59,7 +61,7 @@ public class EvictionResourceDefinition extends ComponentResourceDefinition {
static final PathElement LEGACY_PATH = PathElement.pathElement(PATH.getValue(), "EVICTION"); static final PathElement LEGACY_PATH = PathElement.pathElement(PATH.getValue(), "EVICTION");


enum Attribute implements org.jboss.as.clustering.controller.Attribute { enum Attribute implements org.jboss.as.clustering.controller.Attribute {
STRATEGY("strategy", ModelType.STRING, new ModelNode(EvictionStrategy.NONE.name()), new EnumValidatorBuilder<>(EvictionStrategy.class)), STRATEGY("strategy", ModelType.STRING, new ModelNode(EvictionStrategy.NONE.name()), new EnumValidatorBuilder<>(EvictionStrategy.class, EnumSet.complementOf(EnumSet.of(EvictionStrategy.MANUAL)))),
MAX_ENTRIES("max-entries", ModelType.LONG, new ModelNode(-1L)), MAX_ENTRIES("max-entries", ModelType.LONG, new ModelNode(-1L)),
; ;
private final AttributeDefinition definition; private final AttributeDefinition definition;
Expand Down

0 comments on commit d828933

Please sign in to comment.