From f8186e10c24a4951785ab43dbaadbec3195df2e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Galder=20Zamarren=CC=83o?= Date: Fri, 8 May 2015 17:39:02 +0200 Subject: [PATCH] HHH-9776 elementCountInMemory should be local * By default Cache.size() is now cluster-wide and hence to calculate elementCountInMemory, local flag needs to be passed in (as well as skip cache load in case there's a remote store plugged into it). --- .../hibernate/cache/infinispan/impl/BaseRegion.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java index d626ec6161..4e894ea076 100644 --- a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java +++ b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java @@ -59,7 +59,7 @@ public abstract class BaseRegion implements Region { } private final String name; - private final AdvancedCache regionClearCache; + private final AdvancedCache localAndSkipLoadCache; private final TransactionManager tm; private final Object invalidationMutex = new Object(); @@ -83,7 +83,7 @@ public abstract class BaseRegion implements Region { this.name = name; this.tm = cache.getTransactionManager(); this.factory = factory; - this.regionClearCache = cache.withFlags( + this.localAndSkipLoadCache = cache.withFlags( Flag.CACHE_MODE_LOCAL, Flag.ZERO_LOCK_ACQUISITION_TIMEOUT, Flag.SKIP_CACHE_LOAD ); @@ -97,7 +97,7 @@ public abstract class BaseRegion implements Region { @Override public long getElementCountInMemory() { if ( checkValid() ) { - return cache.size(); + return localAndSkipLoadCache.size(); } return 0; @@ -171,10 +171,10 @@ public abstract class BaseRegion implements Region { Transaction tx = getCurrentTransaction(); if ( tx != null ) { log.tracef("Transaction, clearing one element at the time"); - Caches.removeAll(regionClearCache); + Caches.removeAll(localAndSkipLoadCache); } else { log.tracef("Non-transactional, clear in one go"); - regionClearCache.clear(); + localAndSkipLoadCache.clear(); } log.tracef("Transition state from CLEARING to VALID");