Skip to content

Commit

Permalink
WFLY-5327 Auto-enable simple cache optimization for non-tx and non-pe…
Browse files Browse the repository at this point in the history
…rsistent caches
  • Loading branch information
pferraro committed Nov 12, 2015
1 parent 0174d30 commit e431834
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Expand Up @@ -26,6 +26,7 @@
import org.infinispan.configuration.cache.Configuration;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.configuration.cache.LockingConfiguration;
import org.infinispan.configuration.cache.PersistenceConfiguration;
import org.infinispan.configuration.cache.TransactionConfiguration;
import org.infinispan.configuration.cache.VersioningScheme;
import org.infinispan.transaction.LockingMode;
Expand All @@ -41,6 +42,7 @@ public class LocalCacheBuilder extends CacheConfigurationBuilder {

private final InjectedValue<TransactionConfiguration> transaction = new InjectedValue<>();
private final InjectedValue<LockingConfiguration> locking = new InjectedValue<>();
private final InjectedValue<PersistenceConfiguration> persistence = new InjectedValue<>();

private final String containerName;
private final String cacheName;
Expand All @@ -56,6 +58,7 @@ public ServiceBuilder<Configuration> build(ServiceTarget target) {
return super.build(target)
.addDependency(CacheComponent.TRANSACTION.getServiceName(this.containerName, this.cacheName), TransactionConfiguration.class, this.transaction)
.addDependency(CacheComponent.LOCKING.getServiceName(this.containerName, this.cacheName), LockingConfiguration.class, this.locking)
.addDependency(CacheComponent.PERSISTENCE.getServiceName(this.containerName, this.cacheName), PersistenceConfiguration.class, this.persistence)
;
}

Expand All @@ -64,7 +67,14 @@ public ConfigurationBuilder createConfigurationBuilder() {
ConfigurationBuilder builder = super.createConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.LOCAL);

if ((this.transaction.getValue().lockingMode() == LockingMode.OPTIMISTIC) && (this.locking.getValue().isolationLevel() == IsolationLevel.REPEATABLE_READ)) {
TransactionConfiguration transaction = this.transaction.getValue();
LockingConfiguration locking = this.locking.getValue();
PersistenceConfiguration persistence = this.persistence.getValue();

// Auto-enable simple cache optimization if cache is non-transactional and non-persistent
builder.simpleCache(!transaction.transactionMode().isTransactional() && !persistence.usingStores());

if ((transaction.lockingMode() == LockingMode.OPTIMISTIC) && (locking.isolationLevel() == IsolationLevel.REPEATABLE_READ)) {
builder.locking().writeSkewCheck(true);
builder.versioning().enable().scheme(VersioningScheme.SIMPLE);
}
Expand Down
Expand Up @@ -80,7 +80,6 @@ public AttributeDefinition getDefinition() {
}
}

@SuppressWarnings("deprecation")
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
ResourceTransformationDescriptionBuilder builder = InfinispanModel.VERSION_4_0_0.requiresTransformation(version) ? parent.addChildRedirection(PATH, LEGACY_PATH) : parent.addChildResource(PATH);

Expand Down
Expand Up @@ -93,7 +93,6 @@ public AttributeDefinition getDefinition() {

private final boolean allowRuntimeOnlyRegistration;

@SuppressWarnings("deprecation")
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder builder) {
if (InfinispanModel.VERSION_4_0_0.requiresTransformation(version)) {
builder.discardChildResource(StoreWriteThroughResourceDefinition.PATH);
Expand Down
Expand Up @@ -37,7 +37,7 @@ infinispan.cache-container.local-address=The local address of the node. May retu
infinispan.cache-container.cluster-name=The name of the cluster this node belongs to. May return null if the cache manager is not started.
# cache container children
infinispan.cache-container.transport=A transport child of the cache container.
infinispan.cache-container.local-cache=A replicated cache child of the cache container.
infinispan.cache-container.local-cache=A local cache child of the cache container.
infinispan.cache-container.invalidation-cache=An invalidation cache child of the cache container.
infinispan.cache-container.replicated-cache=A replicated cache child of the cache container.
infinispan.cache-container.distributed-cache=A distributed cache child of the cache container.
Expand Down

0 comments on commit e431834

Please sign in to comment.