Search in sources :

Example 1 with ClusteringConfigurationBuilder

use of org.infinispan.configuration.cache.ClusteringConfigurationBuilder in project keycloak by keycloak.

the class L1SerializationIssueTest method createManager.

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.jmx().domain(InfinispanConnectionProvider.JMX_DOMAIN).enable();
    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;
}
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) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager)

Example 2 with ClusteringConfigurationBuilder

use of org.infinispan.configuration.cache.ClusteringConfigurationBuilder in project wildfly by wildfly.

the class InfinispanLegacyRoutingProviderFactory method accept.

@Override
public void accept(ConfigurationBuilder builder) {
    ClusteringConfigurationBuilder clustering = builder.clustering();
    CacheMode mode = clustering.cacheMode();
    clustering.cacheMode(mode.needsStateTransfer() ? CacheMode.REPL_SYNC : CacheMode.LOCAL);
    clustering.l1().disable();
    // Workaround for ISPN-8722
    AttributeSet attributes = ConfigurationBuilderAttributesAccessor.INSTANCE.apply(clustering);
    attributes.attribute(ClusteringConfiguration.BIAS_ACQUISITION).reset();
    attributes.attribute(ClusteringConfiguration.BIAS_LIFESPAN).reset();
    attributes.attribute(ClusteringConfiguration.INVALIDATION_BATCH_SIZE).reset();
    // Ensure we use the default data container
    builder.addModule(DataContainerConfigurationBuilder.class).evictable(null);
    // Disable expiration
    builder.expiration().lifespan(-1).maxIdle(-1);
    // Disable eviction
    builder.memory().storage(StorageType.HEAP).maxCount(-1).whenFull(EvictionStrategy.NONE);
    builder.persistence().clearStores();
    StateTransferConfigurationBuilder stateTransfer = clustering.stateTransfer().fetchInMemoryState(mode.needsStateTransfer());
    attributes = ConfigurationBuilderAttributesAccessor.INSTANCE.apply(stateTransfer);
    attributes.attribute(StateTransferConfiguration.AWAIT_INITIAL_TRANSFER).reset();
    attributes.attribute(StateTransferConfiguration.TIMEOUT).reset();
}
Also used : DataContainerConfigurationBuilder(org.wildfly.clustering.infinispan.spi.DataContainerConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) AttributeSet(org.infinispan.commons.configuration.attributes.AttributeSet) CacheMode(org.infinispan.configuration.cache.CacheMode) StateTransferConfigurationBuilder(org.infinispan.configuration.cache.StateTransferConfigurationBuilder)

Example 3 with ClusteringConfigurationBuilder

use of org.infinispan.configuration.cache.ClusteringConfigurationBuilder in project hibernate-orm by hibernate.

the class InfinispanRegionFactoryTestCase method testBuildTimestampsRegionWithCacheNameOverride.

@Test
public void testBuildTimestampsRegionWithCacheNameOverride() {
    final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
    final String myTimestampsCache = "mytimestamps-cache";
    Properties p = createProperties();
    p.setProperty(TIMESTAMPS_CACHE_RESOURCE_PROP, myTimestampsCache);
    InfinispanRegionFactory factory = createRegionFactory(p, (f, m) -> {
        ClusteringConfigurationBuilder builder = new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL);
        m.defineConfiguration(myTimestampsCache, builder.build());
    });
    try {
        TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
        assertTrue(isDefinedCache(factory, timestamps));
        // default timestamps cache is async replicated
        assertEquals(CacheMode.LOCAL, region.getCache().getCacheConfiguration().clustering().cacheMode());
    } finally {
        factory.stop();
    }
}
Also used : TimestampsRegionImpl(org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) InfinispanRegionFactory(org.hibernate.cache.infinispan.InfinispanRegionFactory) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) Properties(java.util.Properties) Test(org.junit.Test)

Example 4 with ClusteringConfigurationBuilder

use of org.infinispan.configuration.cache.ClusteringConfigurationBuilder in project wildfly by wildfly.

the class ClusteredCacheBuilder method configure.

@Override
public Builder<Configuration> configure(OperationContext context, ModelNode model) throws OperationFailedException {
    Mode mode = ModelNodes.asEnum(MODE.resolveModelAttribute(context, model), Mode.class);
    ClusteringConfigurationBuilder builder = new ConfigurationBuilder().clustering().cacheMode(mode.apply(this.mode));
    if (mode.isSynchronous()) {
        builder.sync().replTimeout(REMOTE_TIMEOUT.resolveModelAttribute(context, model).asLong());
    } else {
        builder.async();
    }
    this.clustering = builder.create();
    return super.configure(context, model);
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) CacheMode(org.infinispan.configuration.cache.CacheMode)

Example 5 with ClusteringConfigurationBuilder

use of org.infinispan.configuration.cache.ClusteringConfigurationBuilder in project wildfly by wildfly.

the class DistributedCacheBuilder method configure.

@Override
public Builder<Configuration> configure(OperationContext context, ModelNode model) throws OperationFailedException {
    this.consistentHashStrategy = ModelNodes.asEnum(CONSISTENT_HASH_STRATEGY.resolveModelAttribute(context, model), ConsistentHashStrategy.class);
    ClusteringConfigurationBuilder builder = new ConfigurationBuilder().clustering();
    this.hash = builder.hash().capacityFactor(CAPACITY_FACTOR.resolveModelAttribute(context, model).asInt()).numOwners(OWNERS.resolveModelAttribute(context, model).asInt()).numSegments(SEGMENTS.resolveModelAttribute(context, model).asInt()).create();
    long l1Lifespan = L1_LIFESPAN.resolveModelAttribute(context, model).asLong();
    this.l1 = builder.l1().enabled(l1Lifespan > 0).lifespan(l1Lifespan).create();
    this.global = new InjectedValueDependency<>(InfinispanRequirement.CONFIGURATION.getServiceName(context, this.containerName), GlobalConfiguration.class);
    return super.configure(context, model);
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) HashConfigurationBuilder(org.infinispan.configuration.cache.HashConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration)

Aggregations

ClusteringConfigurationBuilder (org.infinispan.configuration.cache.ClusteringConfigurationBuilder)6 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)4 CacheMode (org.infinispan.configuration.cache.CacheMode)3 AttributeSet (org.infinispan.commons.configuration.attributes.AttributeSet)2 StateTransferConfigurationBuilder (org.infinispan.configuration.cache.StateTransferConfigurationBuilder)2 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)2 DataContainerConfigurationBuilder (org.wildfly.clustering.infinispan.spi.DataContainerConfigurationBuilder)2 Properties (java.util.Properties)1 InfinispanRegionFactory (org.hibernate.cache.infinispan.InfinispanRegionFactory)1 TimestampsRegionImpl (org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl)1 Configuration (org.infinispan.configuration.cache.Configuration)1 HashConfigurationBuilder (org.infinispan.configuration.cache.HashConfigurationBuilder)1 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)1 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)1 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1 Test (org.junit.Test)1