HHH-7256 Use minimalPuts in Infinispan
putFromLoad now checks for minimalPuts to verify whether the entry is already present in the cache. By doing this, Hibernate stats appear more precise since putForExternalReads that are no-op because the cache already contains the entry are not counted as puts. This avoids confusion amongst users. This should be reverted to checking PFER's return value when https://issues.jboss.org/browse/ISPN-1986 has been implemented.
This commit is contained in:
parent
a67c1afe10
commit
55de90ec42
|
@ -68,12 +68,25 @@ public class TransactionalAccessDelegate {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException {
|
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) {
|
||||||
|
return putFromLoad(key, value, txTimestamp, version, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride)
|
||||||
|
throws CacheException {
|
||||||
if (!region.checkValid()) {
|
if (!region.checkValid()) {
|
||||||
if (isTrace) log.tracef("Region %s not valid", region.getName());
|
if (isTrace) log.tracef("Region %s not valid", region.getName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In theory, since putForExternalRead is already as minimal as it can
|
||||||
|
// get, we shouldn't be need this check. However, without the check and
|
||||||
|
// without https://issues.jboss.org/browse/ISPN-1986, it's impossible to
|
||||||
|
// know whether the put actually occurred. Knowing this is crucial so
|
||||||
|
// that Hibernate can expose accurate statistics.
|
||||||
|
if (minimalPutOverride && cacheAdapter.containsKey(key))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!putValidator.acquirePutFromLoadLock(key)) {
|
if (!putValidator.acquirePutFromLoadLock(key)) {
|
||||||
if (isTrace) log.tracef("Put from load lock not acquired for key %s", key);
|
if (isTrace) log.tracef("Put from load lock not acquired for key %s", key);
|
||||||
return false;
|
return false;
|
||||||
|
@ -88,14 +101,6 @@ public class TransactionalAccessDelegate {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride)
|
|
||||||
throws CacheException {
|
|
||||||
// We ignore minimalPutOverride. Infinispan putForExternalRead is
|
|
||||||
// already about as minimal as we can get; it will promptly return
|
|
||||||
// if it discovers that the node we want to write to already exists
|
|
||||||
return putFromLoad(key, value, txTimestamp, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoftLock lockItem(Object key, Object version) throws CacheException {
|
public SoftLock lockItem(Object key, Object version) throws CacheException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue