HHH-10163 QueryResultsRegion is not invalidated from evictAll()

This commit is contained in:
Radim Vansa 2015-10-05 12:47:25 +02:00 committed by Galder Zamarreño
parent 6b8c302494
commit 957a210610
3 changed files with 34 additions and 7 deletions

View File

@ -64,7 +64,7 @@ public abstract class BaseTransactionalDataRegion
private Strategy strategy;
protected enum Strategy {
VALIDATION, TOMBSTONES, VERSIONED_ENTRIES
NONE, VALIDATION, TOMBSTONES, VERSIONED_ENTRIES
}
/**
@ -89,6 +89,16 @@ public abstract class BaseTransactionalDataRegion
&& !configuration.transaction().autoCommit();
// TODO: make these timeouts configurable
tombstoneExpiration = InfinispanRegionFactory.PENDING_PUTS_CACHE_CONFIGURATION.expiration().maxIdle();
if (!isRegionAccessStrategyEnabled()) {
strategy = Strategy.NONE;
}
}
/**
* @return True if this region is accessed through RegionAccessStrategy, false if it is accessed directly.
*/
protected boolean isRegionAccessStrategyEnabled() {
return true;
}
@Override
@ -182,9 +192,10 @@ public abstract class BaseTransactionalDataRegion
@Override
protected void runInvalidation(boolean inTransaction) {
if (strategy == null) {
return;
throw new IllegalStateException("Strategy was not set");
}
switch (strategy) {
case NONE:
case VALIDATION:
super.runInvalidation(inTransaction);
return;
@ -247,9 +258,10 @@ public abstract class BaseTransactionalDataRegion
@Override
public Map toMap() {
if (strategy == null) {
return Collections.EMPTY_MAP;
throw new IllegalStateException("Strategy was not set");
}
switch (strategy) {
case NONE:
case VALIDATION:
return super.toMap();
case TOMBSTONES:

View File

@ -74,6 +74,12 @@ public class QueryResultsRegionImpl extends BaseTransactionalDataRegion implemen
if (transactional) {
log.warn("Use non-transactional query caches for best performance!");
}
}
@Override
protected boolean isRegionAccessStrategyEnabled() {
return false;
}
@Override

View File

@ -42,10 +42,7 @@ import org.infinispan.util.concurrent.IsolationLevel;
import org.jboss.logging.Logger;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
/**
* Tests of QueryResultRegionImpl.
@ -379,6 +376,18 @@ public class QueryRegionImplTest extends AbstractGeneralDataRegionTest {
});
}
@Test
@TestForIssue(jiraKey = "HHH-10163")
public void testEvictAll() throws Exception {
withQueryRegion((sessionFactory, region) -> {
withSession(sessionFactory, s -> region.put(s, KEY, VALUE1));
withSession(sessionFactory, s -> assertEquals(VALUE1, region.get(s, KEY)));
region.evictAll();
withSession(sessionFactory, s -> assertNull(region.get(s, KEY)));
assertEquals(Collections.EMPTY_MAP, region.toMap());
});
}
@Listener
public class GetBlocker {
private final CountDownLatch latch;