use of org.infinispan.AdvancedCache in project hibernate-orm by hibernate.
the class InfinispanRegionFactory method buildQueryResultsRegion.
@Override
public QueryResultsRegion buildQueryResultsRegion(String regionName, Map<String, Object> configValues) {
if (log.isDebugEnabled()) {
log.debug("Building query results cache region [" + regionName + "]");
}
final AdvancedCache cache = getCache(regionName, DataType.QUERY, null);
final QueryResultsRegionImpl region = new QueryResultsRegionImpl(cache, regionName, transactionManager, this);
startRegion(region);
return region;
}
use of org.infinispan.AdvancedCache in project hibernate-orm by hibernate.
the class InfinispanRegionFactory method buildEntityRegion.
@Override
public EntityRegion buildEntityRegion(String regionName, Map<String, Object> configValues, CacheDataDescription metadata) {
if (log.isDebugEnabled()) {
log.debugf("Building entity cache region [%s] (mutable=%s, versioned=%s)", regionName, metadata.isMutable(), metadata.isVersioned());
}
final AdvancedCache cache = getCache(regionName, metadata.isMutable() ? DataType.ENTITY : DataType.IMMUTABLE_ENTITY, metadata);
final EntityRegionImpl region = new EntityRegionImpl(cache, regionName, transactionManager, metadata, this, getCacheKeysFactory());
startRegion(region);
return region;
}
use of org.infinispan.AdvancedCache in project hibernate-orm by hibernate.
the class InfinispanRegionFactory method buildNaturalIdRegion.
@Override
public NaturalIdRegion buildNaturalIdRegion(String regionName, Map<String, Object> configValues, CacheDataDescription metadata) {
if (log.isDebugEnabled()) {
log.debug("Building natural id cache region [" + regionName + "]");
}
final AdvancedCache cache = getCache(regionName, DataType.NATURAL_ID, metadata);
final NaturalIdRegionImpl region = new NaturalIdRegionImpl(cache, regionName, transactionManager, metadata, this, getCacheKeysFactory());
startRegion(region);
return region;
}
use of org.infinispan.AdvancedCache in project hibernate-orm by hibernate.
the class EntityCollectionInvalidationTest method testConcurrentLoadAndRemoval.
@TestForIssue(jiraKey = "HHH-9881")
@Test
public void testConcurrentLoadAndRemoval() throws Exception {
if (!remoteCustomerCache.getCacheConfiguration().clustering().cacheMode().isInvalidation()) {
// This test is tailored for invalidation-based strategies, using pending puts cache
return;
}
AtomicReference<Exception> getException = new AtomicReference<>();
AtomicReference<Exception> deleteException = new AtomicReference<>();
Phaser getPhaser = new Phaser(2);
HookInterceptor hookInterceptor = new HookInterceptor(getException);
AdvancedCache remotePPCache = remoteCustomerCache.getCacheManager().getCache(remoteCustomerCache.getName() + "-" + InfinispanRegionFactory.DEF_PENDING_PUTS_RESOURCE).getAdvancedCache();
remotePPCache.getAdvancedCache().addInterceptor(hookInterceptor, 0);
IdContainer idContainer = new IdContainer();
withTxSession(localFactory, s -> {
Customer customer = new Customer();
customer.setName("JBoss");
s.persist(customer);
idContainer.customerId = customer.getId();
});
// start loading
Thread getThread = new Thread(() -> {
try {
withTxSession(remoteFactory, s -> {
s.get(Customer.class, idContainer.customerId);
});
} catch (Exception e) {
log.error("Failure to get customer", e);
getException.set(e);
}
}, "get-thread");
Thread deleteThread = new Thread(() -> {
try {
withTxSession(localFactory, s -> {
Customer customer = s.get(Customer.class, idContainer.customerId);
s.delete(customer);
});
} catch (Exception e) {
log.error("Failure to delete customer", e);
deleteException.set(e);
}
}, "delete-thread");
// get thread should block on the beginning of PutFromLoadValidator#acquirePutFromLoadLock
hookInterceptor.block(getPhaser, getThread);
getThread.start();
arriveAndAwait(getPhaser);
deleteThread.start();
deleteThread.join();
hookInterceptor.unblock();
arriveAndAwait(getPhaser);
getThread.join();
if (getException.get() != null) {
throw new IllegalStateException("get-thread failed", getException.get());
}
if (deleteException.get() != null) {
throw new IllegalStateException("delete-thread failed", deleteException.get());
}
Customer localCustomer = getCustomer(idContainer.customerId, localFactory);
assertNull(localCustomer);
Customer remoteCustomer = getCustomer(idContainer.customerId, remoteFactory);
assertNull(remoteCustomer);
assertTrue(remoteCustomerCache.isEmpty());
}
use of org.infinispan.AdvancedCache in project hibernate-orm by hibernate.
the class InvalidationTest method getPendingPutsCache.
protected AdvancedCache getPendingPutsCache(Class<Item> entityClazz) {
EntityRegionImpl region = (EntityRegionImpl) sessionFactory().getCache().getEntityRegionAccess(entityClazz.getName()).getRegion();
AdvancedCache entityCache = region.getCache();
return (AdvancedCache) entityCache.getCacheManager().getCache(entityCache.getName() + "-" + InfinispanRegionFactory.DEF_PENDING_PUTS_RESOURCE).getAdvancedCache();
}
Aggregations