Search in sources :

Example 1 with EmbeddedTransactionManagerLookup

use of org.infinispan.transaction.lookup.EmbeddedTransactionManagerLookup in project keycloak by keycloak.

the class ConcurrencyVersioningTest method getVersionedCacheManager.

protected DefaultCacheManager getVersionedCacheManager() {
    GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();
    gcb.jmx().domain(InfinispanConnectionProvider.JMX_DOMAIN).enable();
    final DefaultCacheManager cacheManager = new DefaultCacheManager(gcb.build());
    ConfigurationBuilder invalidationConfigBuilder = new ConfigurationBuilder();
    invalidationConfigBuilder.transaction().transactionMode(TransactionMode.TRANSACTIONAL).transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()).locking().isolationLevel(IsolationLevel.REPEATABLE_READ);
    // KEYCLOAK-13692 - Per ISPN-7613 Infinispan:
    // * Automatically enables versioning when needed,
    // * writeSkewCheck automatically enabled for OPTIMISTIC and REPEATABLE_READ transactions
    // .writeSkewCheck(true).versioning()
    // .enable().scheme(VersioningScheme.SIMPLE);
    Configuration invalidationCacheConfiguration = invalidationConfigBuilder.build();
    cacheManager.defineConfiguration(InfinispanConnectionProvider.REALM_CACHE_NAME, invalidationCacheConfiguration);
    return cacheManager;
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) EmbeddedTransactionManagerLookup(org.infinispan.transaction.lookup.EmbeddedTransactionManagerLookup)

Example 2 with EmbeddedTransactionManagerLookup

use of org.infinispan.transaction.lookup.EmbeddedTransactionManagerLookup in project keycloak by keycloak.

the class DefaultInfinispanConnectionProviderFactory method getRevisionCacheConfig.

private Configuration getRevisionCacheConfig(long maxEntries) {
    ConfigurationBuilder cb = createCacheConfigurationBuilder();
    cb.invocationBatching().enable().transaction().transactionMode(TransactionMode.TRANSACTIONAL);
    // Use Embedded manager even in managed ( wildfly/eap ) environment. We don't want infinispan to participate in global transaction
    cb.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup());
    cb.transaction().lockingMode(LockingMode.PESSIMISTIC);
    if (cb.memory().storage().canStoreReferences()) {
        cb.encoding().mediaType(MediaType.APPLICATION_OBJECT_TYPE);
    }
    cb.memory().evictionStrategy(EvictionStrategy.REMOVE).evictionType(EvictionType.COUNT).size(maxEntries);
    return cb.build();
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) RemoteStoreConfigurationBuilder(org.infinispan.persistence.remote.configuration.RemoteStoreConfigurationBuilder) InfinispanUtil.createCacheConfigurationBuilder(org.keycloak.connections.infinispan.InfinispanUtil.createCacheConfigurationBuilder) EmbeddedTransactionManagerLookup(org.infinispan.transaction.lookup.EmbeddedTransactionManagerLookup)

Example 3 with EmbeddedTransactionManagerLookup

use of org.infinispan.transaction.lookup.EmbeddedTransactionManagerLookup in project keycloak by keycloak.

the class DistributedCacheWriteSkewTest method createManager.

public static EmbeddedCacheManager createManager(String nodeName) {
    System.setProperty("java.net.preferIPv4Stack", "true");
    System.setProperty("jgroups.tcp.port", "53715");
    GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();
    gcb = gcb.clusteredDefault();
    gcb.transport().clusterName("test-clustering");
    gcb.transport().nodeName(nodeName);
    gcb.jmx().domain(InfinispanConnectionProvider.JMX_DOMAIN).enable();
    EmbeddedCacheManager cacheManager = new DefaultCacheManager(gcb.build());
    ConfigurationBuilder distConfigBuilder = new ConfigurationBuilder();
    distConfigBuilder.clustering().cacheMode(CacheMode.DIST_SYNC);
    distConfigBuilder.clustering().hash().numOwners(1);
    // Disable L1 cache
    distConfigBuilder.clustering().hash().l1().enabled(false);
    // distConfigBuilder.storeAsBinary().enable().storeKeysAsBinary(false).storeValuesAsBinary(true);
    // KEYCLOAK-13692 - Per ISPN-7613 Infinispan:
    // * Automatically enables versioning when needed,
    // * writeSkewCheck automatically enabled for OPTIMISTIC and REPEATABLE_READ transactions
    // so the following explicit settings of these are not needed anymore
    // distConfigBuilder.versioning().enabled(true);
    // distConfigBuilder.versioning().scheme(VersioningScheme.SIMPLE);
    // distConfigBuilder.locking().writeSkewCheck(true);
    distConfigBuilder.locking().isolationLevel(IsolationLevel.REPEATABLE_READ);
    distConfigBuilder.locking().concurrencyLevel(32);
    distConfigBuilder.locking().lockAcquisitionTimeout(1000, TimeUnit.SECONDS);
    // distConfigBuilder.invocationBatching().enable();
    // distConfigBuilder.transaction().transactionMode(TransactionMode.TRANSACTIONAL);
    distConfigBuilder.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup());
    distConfigBuilder.transaction().lockingMode(LockingMode.OPTIMISTIC);
    Configuration distConfig = distConfigBuilder.build();
    cacheManager.defineConfiguration(InfinispanConnectionProvider.USER_SESSION_CACHE_NAME, distConfig);
    return cacheManager;
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) EmbeddedTransactionManagerLookup(org.infinispan.transaction.lookup.EmbeddedTransactionManagerLookup) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager)

Example 4 with EmbeddedTransactionManagerLookup

use of org.infinispan.transaction.lookup.EmbeddedTransactionManagerLookup in project keycloak by keycloak.

the class ConcurrencyLockingTest method getVersionedCacheManager.

protected DefaultCacheManager getVersionedCacheManager() {
    GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();
    gcb.jmx().domain(InfinispanConnectionProvider.JMX_DOMAIN).enable();
    final DefaultCacheManager cacheManager = new DefaultCacheManager(gcb.build());
    ConfigurationBuilder invalidationConfigBuilder = new ConfigurationBuilder();
    Configuration invalidationCacheConfiguration = invalidationConfigBuilder.build();
    cacheManager.defineConfiguration(InfinispanConnectionProvider.REALM_CACHE_NAME, invalidationCacheConfiguration);
    ConfigurationBuilder counterConfigBuilder = new ConfigurationBuilder();
    counterConfigBuilder.invocationBatching().enable();
    counterConfigBuilder.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup());
    counterConfigBuilder.transaction().lockingMode(LockingMode.PESSIMISTIC);
    Configuration counterCacheConfiguration = counterConfigBuilder.build();
    cacheManager.defineConfiguration("COUNTER_CACHE", counterCacheConfiguration);
    return cacheManager;
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) EmbeddedTransactionManagerLookup(org.infinispan.transaction.lookup.EmbeddedTransactionManagerLookup)

Aggregations

ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)4 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)4 EmbeddedTransactionManagerLookup (org.infinispan.transaction.lookup.EmbeddedTransactionManagerLookup)4 Configuration (org.infinispan.configuration.cache.Configuration)3 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)3 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1 RemoteStoreConfigurationBuilder (org.infinispan.persistence.remote.configuration.RemoteStoreConfigurationBuilder)1 InfinispanUtil.createCacheConfigurationBuilder (org.keycloak.connections.infinispan.InfinispanUtil.createCacheConfigurationBuilder)1