org.infinispan.transaction.LockingMode Java Examples

The following examples show how to use org.infinispan.transaction.LockingMode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultInfinispanConnectionProviderFactory.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private Configuration getRevisionCacheConfig(long maxEntries) {
    ConfigurationBuilder cb = new ConfigurationBuilder();
    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);

    cb.memory()
            .evictionStrategy(EvictionStrategy.REMOVE)
            .evictionType(EvictionType.COUNT)
            .size(maxEntries);

    return cb.build();
}
 
Example #2
Source File: ConcurrencyLockingTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
protected DefaultCacheManager getVersionedCacheManager() {
    GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();


    boolean allowDuplicateJMXDomains = true;

    gcb.globalJmxStatistics().allowDuplicateDomains(allowDuplicateJMXDomains);

    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;
}
 
Example #3
Source File: ReplicatedServer.java    From unitime with Apache License 2.0 4 votes vote down vote up
private boolean isOptimisticLocking() {
	return iOfferingLocks.getAdvancedCache().getCacheConfiguration().transaction().lockingMode() == LockingMode.OPTIMISTIC;
}
 
Example #4
Source File: CacheConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
private Configuration transactionalConfiguration() {
    return new ConfigurationBuilder().transaction().transactionMode(TransactionMode.TRANSACTIONAL).lockingMode(LockingMode.PESSIMISTIC).build();
}
 
Example #5
Source File: DistributedCacheWriteSkewTest.java    From keycloak with Apache License 2.0 4 votes vote down vote up
public static EmbeddedCacheManager createManager(String nodeName) {
    System.setProperty("java.net.preferIPv4Stack", "true");
    System.setProperty("jgroups.tcp.port", "53715");
    GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();

    boolean clustered = true;
    boolean async = false;
    boolean allowDuplicateJMXDomains = true;

    if (clustered) {
        gcb = gcb.clusteredDefault();
        gcb.transport().clusterName("test-clustering");
        gcb.transport().nodeName(nodeName);
    }
    gcb.globalJmxStatistics().allowDuplicateDomains(allowDuplicateJMXDomains);

    EmbeddedCacheManager cacheManager = new DefaultCacheManager(gcb.build());


    ConfigurationBuilder distConfigBuilder = new ConfigurationBuilder();
    if (clustered) {
        distConfigBuilder.clustering().cacheMode(async ? CacheMode.DIST_ASYNC : CacheMode.DIST_SYNC);
        distConfigBuilder.clustering().hash().numOwners(1);

        // Disable L1 cache
        distConfigBuilder.clustering().hash().l1().enabled(false);

        //distConfigBuilder.storeAsBinary().enable().storeKeysAsBinary(false).storeValuesAsBinary(true);

        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.versioning().enabled(true);
        distConfigBuilder.versioning().scheme(VersioningScheme.SIMPLE);


       // 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;

}