9
9
import org .hibernate .cache .CacheException ;
10
10
import org .hibernate .cache .infinispan .impl .BaseRegion ;
11
11
import org .hibernate .cache .infinispan .util .Caches ;
12
-
13
12
import org .infinispan .AdvancedCache ;
14
13
import org .infinispan .util .logging .Log ;
15
14
import org .infinispan .util .logging .LogFactory ;
@@ -111,7 +110,8 @@ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object ve
111
110
return false ;
112
111
}
113
112
114
- if ( !putValidator .acquirePutFromLoadLock ( key ) ) {
113
+ PutFromLoadValidator .Lock lock = putValidator .acquirePutFromLoadLock (key );
114
+ if ( lock == null ) {
115
115
if ( TRACE_ENABLED ) {
116
116
log .tracef ( "Put from load lock not acquired for key %s" , key );
117
117
}
@@ -131,7 +131,7 @@ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object ve
131
131
}
132
132
}
133
133
finally {
134
- putValidator .releasePutFromLoadLock ( key );
134
+ putValidator .releasePutFromLoadLock ( key , lock );
135
135
}
136
136
137
137
return true ;
@@ -185,7 +185,7 @@ public boolean update(Object key, Object value, Object currentVersion, Object pr
185
185
* @throws CacheException if removing the cached item fails
186
186
*/
187
187
public void remove (Object key ) throws CacheException {
188
- if ( !putValidator .invalidateKey ( key ) ) {
188
+ if ( !putValidator .beginInvalidatingKey ( key ) ) {
189
189
throw new CacheException (
190
190
"Failed to invalidate pending putFromLoad calls for key " + key + " from region " + region .getName ()
191
191
);
@@ -216,7 +216,7 @@ public void removeAll() throws CacheException {
216
216
* @throws CacheException if evicting the item fails
217
217
*/
218
218
public void evict (Object key ) throws CacheException {
219
- if ( !putValidator .invalidateKey ( key ) ) {
219
+ if ( !putValidator .beginInvalidatingKey ( key ) ) {
220
220
throw new CacheException (
221
221
"Failed to invalidate pending putFromLoad calls for key " + key + " from region " + region .getName ()
222
222
);
@@ -240,4 +240,19 @@ public void evictAll() throws CacheException {
240
240
Caches .broadcastEvictAll ( cache );
241
241
}
242
242
243
+ /**
244
+ * Called when we have finished the attempted update/delete (which may or
245
+ * may not have been successful), after transaction completion. This method
246
+ * is used by "asynchronous" concurrency strategies.
247
+ *
248
+ * @param key The item key
249
+ * @throws org.hibernate.cache.CacheException Propogated from underlying {@link org.hibernate.cache.spi.Region}
250
+ */
251
+ public void unlockItem (Object key ) throws CacheException {
252
+ if ( !putValidator .endInvalidatingKey (key ) ) {
253
+ // TODO: localization
254
+ log .warn ("Failed to end invalidating pending putFromLoad calls for key " + key + " from region "
255
+ + region .getName () + "; the key won't be cached in the future." );
256
+ }
257
+ }
243
258
}
0 commit comments