use of org.infinispan.configuration.cache.CacheMode in project hibernate-orm by hibernate.
the class CorrectnessTestCase method beforeClass.
@BeforeClassOnce
public void beforeClass() {
TestResourceTracker.testStarted(getClass().getSimpleName());
Arrays.asList(new File(System.getProperty("java.io.tmpdir")).listFiles((dir, name) -> name.startsWith("family_") || name.startsWith("invalidations-"))).stream().forEach(f -> f.delete());
StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder().enableAutoClose().applySetting(Environment.USE_SECOND_LEVEL_CACHE, "true").applySetting(Environment.USE_QUERY_CACHE, "true").applySetting(Environment.DRIVER, "org.h2.Driver").applySetting(Environment.URL, "jdbc:h2:mem:" + getDbName() + ";TRACE_LEVEL_FILE=4").applySetting(Environment.DIALECT, H2Dialect.class.getName()).applySetting(Environment.HBM2DDL_AUTO, "create-drop").applySetting(Environment.CACHE_REGION_FACTORY, FailingInfinispanRegionFactory.class.getName()).applySetting(TestInfinispanRegionFactory.CACHE_MODE, cacheMode).applySetting(Environment.USE_MINIMAL_PUTS, "false").applySetting(Environment.GENERATE_STATISTICS, "false");
applySettings(ssrb);
sessionFactories = new SessionFactory[NUM_NODES];
for (int i = 0; i < NUM_NODES; ++i) {
StandardServiceRegistry registry = ssrb.build();
Metadata metadata = buildMetadata(registry);
sessionFactories[i] = metadata.buildSessionFactory();
}
}
use of org.infinispan.configuration.cache.CacheMode in project hibernate-orm by hibernate.
the class BaseTransactionalDataRegion method createAccessDelegate.
protected synchronized AccessDelegate createAccessDelegate(AccessType accessType) {
if (accessType == null) {
throw new IllegalArgumentException();
}
if (this.accessType != null && !this.accessType.equals(accessType)) {
throw new IllegalStateException("This region was already set up for " + this.accessType + ", cannot use using " + accessType);
}
this.accessType = accessType;
CacheMode cacheMode = cache.getCacheConfiguration().clustering().cacheMode();
if (accessType == AccessType.NONSTRICT_READ_WRITE) {
prepareForVersionedEntries();
return new NonStrictAccessDelegate(this);
}
if (cacheMode.isDistributed() || cacheMode.isReplicated()) {
prepareForTombstones();
return new TombstoneAccessDelegate(this);
} else {
prepareForValidation();
if (cache.getCacheConfiguration().transaction().transactionMode().isTransactional()) {
return new TxInvalidationCacheAccessDelegate(this, validator);
} else {
return new NonTxInvalidationCacheAccessDelegate(this, validator);
}
}
}
use of org.infinispan.configuration.cache.CacheMode in project hibernate-orm by hibernate.
the class BaseTransactionalDataRegion method replaceCommonInterceptors.
private void replaceCommonInterceptors() {
CacheMode cacheMode = cache.getCacheConfiguration().clustering().cacheMode();
if (!cacheMode.isReplicated() && !cacheMode.isDistributed()) {
return;
}
LockingInterceptor lockingInterceptor = new LockingInterceptor();
cache.getComponentRegistry().registerComponent(lockingInterceptor, LockingInterceptor.class);
if (!cache.addInterceptorBefore(lockingInterceptor, NonTransactionalLockingInterceptor.class)) {
throw new IllegalStateException("Misconfigured cache, interceptor chain is " + cache.getInterceptorChain());
}
cache.removeInterceptor(NonTransactionalLockingInterceptor.class);
UnorderedDistributionInterceptor distributionInterceptor = new UnorderedDistributionInterceptor();
cache.getComponentRegistry().registerComponent(distributionInterceptor, UnorderedDistributionInterceptor.class);
if (!cache.addInterceptorBefore(distributionInterceptor, NonTxDistributionInterceptor.class)) {
throw new IllegalStateException("Misconfigured cache, interceptor chain is " + cache.getInterceptorChain());
}
cache.removeInterceptor(NonTxDistributionInterceptor.class);
EntryWrappingInterceptor ewi = cache.getComponentRegistry().getComponent(EntryWrappingInterceptor.class);
try {
Field isUsingLockDelegation = EntryWrappingInterceptor.class.getDeclaredField("isUsingLockDelegation");
isUsingLockDelegation.setAccessible(true);
isUsingLockDelegation.set(ewi, false);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new IllegalStateException(e);
}
}
use of org.infinispan.configuration.cache.CacheMode in project wildfly by wildfly.
the class ClientMappingsCacheBuilderProvider method getBuilders.
@Override
public Collection<CapabilityServiceBuilder<?>> getBuilders(ServiceNameRegistry<ClusteringCacheRequirement> registry, String containerName, String aliasCacheName) {
List<CapabilityServiceBuilder<?>> builders = new LinkedList<>();
if (aliasCacheName == null) {
String cacheName = BeanManagerFactoryBuilderConfiguration.CLIENT_MAPPINGS_CACHE_NAME;
builders.add(new TemplateConfigurationBuilder(ServiceName.parse(InfinispanCacheRequirement.CONFIGURATION.resolve(containerName, cacheName)), containerName, cacheName, aliasCacheName, builder -> {
CacheMode mode = builder.clustering().cacheMode();
builder.clustering().cacheMode(mode.isClustered() ? CacheMode.REPL_SYNC : CacheMode.LOCAL);
builder.clustering().l1().disable();
builder.persistence().clearStores();
}));
builders.add(new CacheBuilder<>(ServiceName.parse(InfinispanCacheRequirement.CACHE.resolve(containerName, cacheName)), containerName, cacheName));
ServiceNameRegistry<ClusteringCacheRequirement> routingRegistry = requirement -> ServiceName.parse(requirement.resolve(containerName, cacheName));
for (CacheBuilderProvider provider : ServiceLoader.load(this.providerClass, this.providerClass.getClassLoader())) {
builders.addAll(provider.getBuilders(routingRegistry, containerName, cacheName));
}
}
return builders;
}
use of org.infinispan.configuration.cache.CacheMode in project wildfly by wildfly.
the class RouteCacheGroupBuilderProvider method getBuilders.
@Override
public Collection<CapabilityServiceBuilder<?>> getBuilders(ServiceNameRegistry<ClusteringCacheRequirement> registry, String containerName, String aliasCacheName) {
List<CapabilityServiceBuilder<?>> builders = new LinkedList<>();
if (aliasCacheName == null) {
builders.add(new TemplateConfigurationBuilder(ServiceName.parse(InfinispanCacheRequirement.CONFIGURATION.resolve(containerName, CACHE_NAME)), containerName, CACHE_NAME, aliasCacheName, builder -> {
CacheMode mode = builder.clustering().cacheMode();
builder.clustering().cacheMode(mode.isClustered() ? CacheMode.REPL_SYNC : CacheMode.LOCAL);
builder.clustering().l1().disable();
builder.persistence().clearStores();
}));
builders.add(new CacheBuilder<>(ServiceName.parse(InfinispanCacheRequirement.CACHE.resolve(containerName, CACHE_NAME)), containerName, CACHE_NAME));
ServiceNameRegistry<ClusteringCacheRequirement> routingRegistry = requirement -> ServiceName.parse(requirement.resolve(containerName, CACHE_NAME));
for (CacheBuilderProvider provider : ServiceLoader.load(this.providerClass, this.providerClass.getClassLoader())) {
builders.addAll(provider.getBuilders(routingRegistry, containerName, CACHE_NAME));
}
}
return builders;
}
Aggregations