Skip to content

Commit

Permalink
ISPN-7532 Do not log configuration warnings for templates
Browse files Browse the repository at this point in the history
- Also extract some configuration exceptions to log
- Do not disable expiration reaper in server
  • Loading branch information
tristantarrant committed Feb 27, 2017
1 parent bb462b6 commit 6f017cc
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private void validateStoreAttributes() {
ConfigurationBuilder builder = getBuilder();

if (!shared && !fetchPersistentState && !purgeOnStartup
&& builder.clustering().cacheMode().isClustered())
&& builder.clustering().cacheMode().isClustered() && !getBuilder().template())
log.staleEntriesWithoutFetchPersistentStateOrPurgeOnStartup();

if (fetchPersistentState && attributes.attribute(FETCH_PERSISTENT_STATE).isModified() &&
Expand All @@ -211,7 +211,7 @@ private void validateStoreAttributes() {
}

if (shared && !preload && builder.indexing().enabled()
&& builder.indexing().indexLocalOnly())
&& builder.indexing().indexLocalOnly() && !getBuilder().template())
log.localIndexingWithSharedCacheLoaderRequiresPreload();

if (transactional && !builder.transaction().transactionMode().isTransactional())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ public ConfigurationBuilder template(boolean template) {
return this;
}

public boolean template() {
return template;
}

@SuppressWarnings("unchecked")
public void validate() {
if (attributes.attribute(SIMPLE_CACHE).get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void validate() {
if (size > 0) {
strategy(EvictionStrategy.LIRS);
log.debugf("Max entries configured (%d) without eviction strategy. Eviction strategy overriden to %s", size, strategy);
} else if (getBuilder().persistence().passivation() && strategy != EvictionStrategy.MANUAL) {
} else if (getBuilder().persistence().passivation() && strategy != EvictionStrategy.MANUAL && !getBuilder().template()) {
log.passivationWithoutEviction();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public void validate() {
if (clustering().cacheMode().isInvalidation()) {
throw log.invalidConfigurationIndexingWithInvalidation();
}
if (indexedEntities().isEmpty()) {
if (indexedEntities().isEmpty() && !getBuilder().template()) {
//TODO [anistor] This warning will become a CacheConfigurationException in infinispan 9; do nothing if there are some programmatically defined entity mappings
log.noIndexableClassesDefined();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,19 @@ public void validate() {
b.validate();
StoreConfiguration storeConfiguration = b.create();
if (storeConfiguration.shared() && storeConfiguration.singletonStore().enabled()) {
throw new CacheConfigurationException("Invalid cache loader configuration for " + storeConfiguration.getClass().getSimpleName()
+ " If a cache loader is configured as a singleton, the cache loader cannot be shared in a cluster!");
throw log.singletonStoreCannotBeShared(storeConfiguration.getClass().getSimpleName());
}
if (!storeConfiguration.shared() && storeConfiguration.transactional() && !isLocalCache) {
throw new CacheConfigurationException("Invalid cache loader configuration for " + storeConfiguration.getClass().getSimpleName()
+ ". In order for a cache loader to be transactional, it must also be shared.");
throw log.clusteredTransactionalStoreMustBeShared(storeConfiguration.getClass().getSimpleName());
}
if (storeConfiguration.async().enabled() && storeConfiguration.transactional()) {
throw new CacheConfigurationException("Invalid cache loader configuration for " + storeConfiguration.getClass().getSimpleName()
+ ". A cache loader cannot be both Asynchronous and transactional.");
throw log.transactionalStoreCannotBeAsync(storeConfiguration.getClass().getSimpleName());
}
if (storeConfiguration.fetchPersistentState())
numFetchPersistentState++;
}
if (numFetchPersistentState > 1)
throw new CacheConfigurationException("Maximum one store can be set to 'fetchPersistentState'!");
throw log.onlyOneFetchPersistentStoreAllowed();

// If we have a store we have to guarantee the reaper expiration thread is enabled
if (!stores.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
import org.infinispan.commons.configuration.Builder;
import org.infinispan.commons.configuration.attributes.AttributeSet;
import org.infinispan.configuration.global.GlobalConfiguration;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;

/**
* @author Mircea.Markus@jboss.com
* @since 5.2
*/
public class SitesConfigurationBuilder extends AbstractConfigurationChildBuilder implements Builder<SitesConfiguration> {
private final static Log log = LogFactory.getLog(SitesConfigurationBuilder.class);
private final AttributeSet attributes;
private final List<BackupConfigurationBuilder> backups = new ArrayList<>(2);
private final BackupForBuilder backupForBuilder;
Expand Down Expand Up @@ -72,7 +75,7 @@ public void validate() {

for (BackupConfigurationBuilder bcb : backups) {
if (!backupNames.add(bcb.site())) {
throw new CacheConfigurationException("Multiple sites with name '" + bcb.site() + "' are configured. That is not allowed!");
throw log.multipleSitesWithSameName(bcb.site());
}
bcb.validate();
}
Expand All @@ -83,7 +86,7 @@ public void validate() {
if (bcb.site().equals(site)) found = true;
}
if (!found) {
throw new CacheConfigurationException("The site '" + site + "' should be defined within the set of backups!");
throw log.siteMustBeInBackups(site);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ public void validate() {
Attribute<Boolean> awaitInitialTransfer = attributes.attribute(AWAIT_INITIAL_TRANSFER);
if (awaitInitialTransfer.isModified() && awaitInitialTransfer.get()
&& !getClusteringBuilder().cacheMode().needsStateTransfer())
throw new CacheConfigurationException(
"awaitInitialTransfer can be enabled only if cache mode is distributed or replicated.");
throw log.awaitInitialTransferOnlyForDistOrRepl();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public void validate() {
throw log.invalidLockingModeForTotalOrder(lockingMode());
}
}
if (!attributes.attribute(NOTIFICATIONS).get()) {
if (!attributes.attribute(NOTIFICATIONS).get() && !getBuilder().template()) {
log.transactionNotificationsDisabled();
}
if (attributes.attribute(TRANSACTION_MODE).get() == TransactionMode.TRANSACTIONAL && !cacheMode.isSynchronous()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.infinispan.commons.configuration.Builder;
import org.infinispan.commons.configuration.attributes.AttributeSet;
import org.infinispan.configuration.global.GlobalConfiguration;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;

/**
* Configuration Builder to configure the state transfer between sites.
Expand All @@ -18,6 +20,7 @@
*/
public class XSiteStateTransferConfigurationBuilder extends AbstractConfigurationChildBuilder
implements Builder<XSiteStateTransferConfiguration> {
private static final Log log = LogFactory.getLog(XSiteStateTransferConfigurationBuilder.class);
private final BackupConfigurationBuilder backupConfigurationBuilder;
private final AttributeSet attributes;

Expand All @@ -31,10 +34,10 @@ public XSiteStateTransferConfigurationBuilder(ConfigurationBuilder builder,
@Override
public void validate() {
if (attributes.attribute(TIMEOUT).get() <= 0) {
throw new CacheConfigurationException("Timeout must be higher or equals than 1 (one).");
throw log.invalidXSiteStateTransferTimeout();
}
if (attributes.attribute(WAIT_TIME).get() <= 0) {
throw new CacheConfigurationException("Waiting time between retries must be higher or equals than 1 (one).");
throw log.invalidXSiteStateTransferWaitTime();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void registerInternalCache(String name, Configuration configuration, Enum
builder.jmxStatistics().disable(); // Internal caches must not be included in stats counts
GlobalConfiguration globalConfiguration = cacheManager.getCacheManagerConfiguration();
if (flags.contains(Flag.PERSISTENT) && globalConfiguration.globalState().enabled()) {
builder.persistence().addSingleFileStore().location(globalConfiguration.globalState().persistentLocation()).purgeOnStartup(false).preload(true);
builder.persistence().addSingleFileStore().location(globalConfiguration.globalState().persistentLocation()).purgeOnStartup(false).preload(true).fetchPersistentState(true);
}
internalCaches.put(name, flags);
SecurityActions.defineConfiguration(cacheManager, name, builder.build());
Expand Down
29 changes: 28 additions & 1 deletion core/src/main/java/org/infinispan/util/logging/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -1518,5 +1518,32 @@ TimeoutException timeoutWaitingForView(int expectedViewId, int currentViewId,
void errorSendingResponse(ReplicableCommand command);

@Message(value = "Unsupported async cache mode '%s' for transactional caches", id = 441)
CacheConfigurationException unsupportedAsyncCacheMode(CacheMode cacheModed);
CacheConfigurationException unsupportedAsyncCacheMode(CacheMode cacheMode);

@Message(value = "Invalid cache loader configuration for '%s'. If a cache loader is configured as a singleton, the cache loader cannot be shared in a cluster!", id = 442)
CacheConfigurationException singletonStoreCannotBeShared(String name);

@Message(value = "Invalid cache loader configuration for '%s'. In order for a cache loader to be transactional, it must also be shared.", id = 443)
CacheConfigurationException clusteredTransactionalStoreMustBeShared(String simpleName);

@Message(value = "Invalid cache loader configuration for '%s'. A cache loader cannot be both Asynchronous and transactional.", id = 444)
CacheConfigurationException transactionalStoreCannotBeAsync(String simpleName);

@Message(value = "At most one store can be set to 'fetchPersistentState'!", id = 445)
CacheConfigurationException onlyOneFetchPersistentStoreAllowed();

@Message(value = "Multiple sites with name '%s' are configured. That is not allowed!", id = 446)
CacheConfigurationException multipleSitesWithSameName(String site);

@Message(value = "The site '%s' must be defined within the set of backups!", id = 447)
CacheConfigurationException siteMustBeInBackups(String site);

@Message(value = "'awaitInitialTransfer' can be enabled only if cache mode is distributed or replicated.", id = 448)
CacheConfigurationException awaitInitialTransferOnlyForDistOrRepl();

@Message(value = "XSite state transfer timeout must be higher or equals than 1 (one).", id = 449)
CacheConfigurationException invalidXSiteStateTransferTimeout();

@Message(value = "XSite state transfer waiting time between retries must be higher or equals than 1 (one).", id = 450)
CacheConfigurationException invalidXSiteStateTransferWaitTime();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
package org.jboss.as.clustering.infinispan.subsystem;

import org.infinispan.commons.util.Util;
import org.infinispan.configuration.cache.AbstractStoreConfiguration;
import org.infinispan.configuration.cache.PersistenceConfiguration;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SimpleAttributeDefinition;
Expand All @@ -45,28 +47,28 @@ public class BaseStoreConfigurationResource extends BaseLoaderConfigurationResou
.setXmlName(Attribute.FETCH_STATE.getLocalName())
.setAllowExpression(true)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setDefaultValue(new ModelNode().set(true))
.setDefaultValue(new ModelNode().set(AbstractStoreConfiguration.FETCH_PERSISTENT_STATE.getDefaultValue()))
.build();
static final SimpleAttributeDefinition PASSIVATION =
new SimpleAttributeDefinitionBuilder(ModelKeys.PASSIVATION, ModelType.BOOLEAN, true)
.setXmlName(Attribute.PASSIVATION.getLocalName())
.setAllowExpression(true)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setDefaultValue(new ModelNode().set(false))
.setDefaultValue(new ModelNode().set(PersistenceConfiguration.PASSIVATION.getDefaultValue()))
.build();
static final SimpleAttributeDefinition PURGE =
new SimpleAttributeDefinitionBuilder(ModelKeys.PURGE, ModelType.BOOLEAN, true)
.setXmlName(Attribute.PURGE.getLocalName())
.setAllowExpression(true)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setDefaultValue(new ModelNode().set(true))
.setDefaultValue(new ModelNode().set(AbstractStoreConfiguration.PURGE_ON_STARTUP.getDefaultValue()))
.build();
static final SimpleAttributeDefinition READ_ONLY =
new SimpleAttributeDefinitionBuilder(ModelKeys.READ_ONLY, ModelType.BOOLEAN, true)
.setXmlName(Attribute.READ_ONLY.getLocalName())
.setAllowExpression(false)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setDefaultValue(new ModelNode().set(false))
.setDefaultValue(new ModelNode().set(AbstractStoreConfiguration.IGNORE_MODIFICATIONS.getDefaultValue()))
.build();
static final SimpleAttributeDefinition SINGLETON =
new SimpleAttributeDefinitionBuilder(ModelKeys.SINGLETON, ModelType.BOOLEAN, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<memory>
<object/>
</memory>
<expiration interval="-1"/>
<store-as-binary keys="false" values="false"/>
<data-container key-equivalence="org.infinispan.commons.equivalence.AnyServerEquivalence"
value-equivalence="org.infinispan.commons.equivalence.AnyServerEquivalence" />
Expand Down

0 comments on commit 6f017cc

Please sign in to comment.