HHH-10163 QueryResultsRegion is not invalidated from evictAll()
This commit is contained in:
parent
6b8c302494
commit
957a210610
|
@ -64,7 +64,7 @@ public abstract class BaseTransactionalDataRegion
|
||||||
private Strategy strategy;
|
private Strategy strategy;
|
||||||
|
|
||||||
protected enum Strategy {
|
protected enum Strategy {
|
||||||
VALIDATION, TOMBSTONES, VERSIONED_ENTRIES
|
NONE, VALIDATION, TOMBSTONES, VERSIONED_ENTRIES
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,6 +89,16 @@ public abstract class BaseTransactionalDataRegion
|
||||||
&& !configuration.transaction().autoCommit();
|
&& !configuration.transaction().autoCommit();
|
||||||
// TODO: make these timeouts configurable
|
// TODO: make these timeouts configurable
|
||||||
tombstoneExpiration = InfinispanRegionFactory.PENDING_PUTS_CACHE_CONFIGURATION.expiration().maxIdle();
|
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
|
@Override
|
||||||
|
@ -182,9 +192,10 @@ public abstract class BaseTransactionalDataRegion
|
||||||
@Override
|
@Override
|
||||||
protected void runInvalidation(boolean inTransaction) {
|
protected void runInvalidation(boolean inTransaction) {
|
||||||
if (strategy == null) {
|
if (strategy == null) {
|
||||||
return;
|
throw new IllegalStateException("Strategy was not set");
|
||||||
}
|
}
|
||||||
switch (strategy) {
|
switch (strategy) {
|
||||||
|
case NONE:
|
||||||
case VALIDATION:
|
case VALIDATION:
|
||||||
super.runInvalidation(inTransaction);
|
super.runInvalidation(inTransaction);
|
||||||
return;
|
return;
|
||||||
|
@ -247,9 +258,10 @@ public abstract class BaseTransactionalDataRegion
|
||||||
@Override
|
@Override
|
||||||
public Map toMap() {
|
public Map toMap() {
|
||||||
if (strategy == null) {
|
if (strategy == null) {
|
||||||
return Collections.EMPTY_MAP;
|
throw new IllegalStateException("Strategy was not set");
|
||||||
}
|
}
|
||||||
switch (strategy) {
|
switch (strategy) {
|
||||||
|
case NONE:
|
||||||
case VALIDATION:
|
case VALIDATION:
|
||||||
return super.toMap();
|
return super.toMap();
|
||||||
case TOMBSTONES:
|
case TOMBSTONES:
|
||||||
|
|
|
@ -74,6 +74,12 @@ public class QueryResultsRegionImpl extends BaseTransactionalDataRegion implemen
|
||||||
if (transactional) {
|
if (transactional) {
|
||||||
log.warn("Use non-transactional query caches for best performance!");
|
log.warn("Use non-transactional query caches for best performance!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isRegionAccessStrategyEnabled() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -42,10 +42,7 @@ import org.infinispan.util.concurrent.IsolationLevel;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertNotEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of QueryResultRegionImpl.
|
* 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
|
@Listener
|
||||||
public class GetBlocker {
|
public class GetBlocker {
|
||||||
private final CountDownLatch latch;
|
private final CountDownLatch latch;
|
||||||
|
|
Loading…
Reference in New Issue