Java Code Examples for org.infinispan.configuration.global.GlobalConfigurationBuilder#clusteredDefault()

The following examples show how to use org.infinispan.configuration.global.GlobalConfigurationBuilder#clusteredDefault() . 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: L1SerializationIssueTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private EmbeddedCacheManager createManager() {
    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.globalJmxStatistics().allowDuplicateDomains(true);

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


    ConfigurationBuilder distConfigBuilder = new ConfigurationBuilder();
    ClusteringConfigurationBuilder clusterConfBuilder = distConfigBuilder.clustering();
    clusterConfBuilder.cacheMode(CacheMode.DIST_SYNC);
    clusterConfBuilder.hash().numOwners(NUM_OWNERS);
    clusterConfBuilder.l1().enabled(L1_ENABLED)
            .lifespan(L1_LIFESPAN_MS)
            .cleanupTaskFrequency(L1_CLEANER_MS);

    Configuration distCacheConfiguration = distConfigBuilder.build();

    cacheManager.defineConfiguration(CACHE_NAME, distCacheConfiguration);
    return cacheManager;
}
 
Example 2
Source File: TestCacheManagerFactory.java    From keycloak with Apache License 2.0 6 votes vote down vote up
<T extends StoreConfigurationBuilder<?, T> & RemoteStoreConfigurationChildBuilder<T>> EmbeddedCacheManager createManager(int threadId, String cacheName, Class<T> builderClass) {
    System.setProperty("java.net.preferIPv4Stack", "true");
    System.setProperty("jgroups.tcp.port", "53715");
    GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();

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

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

    gcb.globalJmxStatistics().allowDuplicateDomains(allowDuplicateJMXDomains);

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

    Configuration invalidationCacheConfiguration = getCacheBackedByRemoteStore(threadId, cacheName, builderClass);

    cacheManager.defineConfiguration(cacheName, invalidationCacheConfiguration);
    cacheManager.defineConfiguration("local", new ConfigurationBuilder().build());
    return cacheManager;

}
 
Example 3
Source File: ClusteredCacheBehaviorTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public EmbeddedCacheManager createManager() {
    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.globalJmxStatistics().allowDuplicateDomains(allowDuplicateJMXDomains);

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


    ConfigurationBuilder invalidationConfigBuilder = new ConfigurationBuilder();
    if (clustered) {
        invalidationConfigBuilder.clustering().cacheMode(async ? CacheMode.INVALIDATION_ASYNC : CacheMode.INVALIDATION_SYNC);
    }
    Configuration invalidationCacheConfiguration = invalidationConfigBuilder.build();

    cacheManager.defineConfiguration(InfinispanConnectionProvider.REALM_CACHE_NAME, invalidationCacheConfiguration);
    return cacheManager;

}
 
Example 4
Source File: OutdatedTopologyExceptionReproducerTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private EmbeddedCacheManager createManager() {
        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.globalJmxStatistics().allowDuplicateDomains(allowDuplicateJMXDomains);

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


        ConfigurationBuilder invalidationConfigBuilder = new ConfigurationBuilder();
        if (clustered) {
            invalidationConfigBuilder.clustering().cacheMode(async ? CacheMode.INVALIDATION_ASYNC : CacheMode.INVALIDATION_SYNC);
        }

        // Uncomment this to have test fixed!!!
//        invalidationConfigBuilder.customInterceptors()
//                .addInterceptor()
//                .before(NonTransactionalLockingInterceptor.class)
//                .interceptorClass(StateTransferInterceptor.class);

        Configuration invalidationCacheConfiguration = invalidationConfigBuilder.build();

        cacheManager.defineConfiguration(InfinispanConnectionProvider.REALM_CACHE_NAME, invalidationCacheConfiguration);
        return cacheManager;

    }
 
Example 5
Source File: DistributedCacheConcurrentWritesTest.java    From keycloak with Apache License 2.0 5 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);
    }
    Configuration distConfig = distConfigBuilder.build();

    cacheManager.defineConfiguration(InfinispanConnectionProvider.USER_SESSION_CACHE_NAME, distConfig);
    return cacheManager;

}
 
Example 6
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;

}