Skip to content

Commit 64f91f1

Browse files
rvansasebersole
authored andcommitted
HHH-10030 Add read-write cache concurrency strategy to Infinispan 2LC
* AccessType.READ_WRITE is now supported cache concurrency strategy * Added checks that we're caching in local or invalidation cache (distributed and replicated cache does not work ATM) * Refactored test-suite: Running on both transactional and read-write caches (these should yield the same results) ** CustomParemeterized runner is used for that ** Moved all entities used in functional tests to one package ** Removed already disabled tests related to class loaders (not needed since Infinispan 5.1) (cherry picked from commit 3689924)
1 parent b63da4b commit 64f91f1

File tree

122 files changed

+7272
-8585
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+7272
-8585
lines changed

hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ public class InfinispanRegionFactory implements RegionFactory {
104104
*/
105105
public static final String INFINISPAN_CONFIG_RESOURCE_PROP = "hibernate.cache.infinispan.cfg";
106106

107-
/**
108-
* Property name that controls whether Infinispan statistics are enabled.
109-
* The property value is expected to be a boolean true or false, and it
110-
* overrides statistic configuration in base Infinispan configuration,
111-
* if provided.
112-
*/
107+
/**
108+
* Property name that controls whether Infinispan statistics are enabled.
109+
* The property value is expected to be a boolean true or false, and it
110+
* overrides statistic configuration in base Infinispan configuration,
111+
* if provided.
112+
*/
113113
public static final String INFINISPAN_GLOBAL_STATISTICS_PROP = "hibernate.cache.infinispan.statistics";
114114

115115
/**
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
5+
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
6+
*/
7+
package org.hibernate.cache.infinispan.access;
8+
9+
import org.hibernate.cache.CacheException;
10+
import org.hibernate.cache.spi.access.SoftLock;
11+
import org.hibernate.engine.spi.SessionImplementor;
12+
13+
/**
14+
* Defines the strategy for access to entity or collection data in a Infinispan instance.
15+
* <p/>
16+
* The intent of this class is to encapsulate common code and serve as a delegate for
17+
* {@link org.hibernate.cache.spi.access.EntityRegionAccessStrategy}
18+
* and {@link org.hibernate.cache.spi.access.CollectionRegionAccessStrategy} implementations.
19+
*
20+
* @author Radim Vansa &lt;[email protected]&gt;
21+
*/
22+
public interface AccessDelegate {
23+
Object get(SessionImplementor session, Object key, long txTimestamp) throws CacheException;
24+
25+
/**
26+
* Attempt to cache an object, after loading from the database.
27+
*
28+
* @param session Current session
29+
* @param key The item key
30+
* @param value The item
31+
* @param txTimestamp a timestamp prior to the transaction start time
32+
* @param version the item version number
33+
* @return <tt>true</tt> if the object was successfully cached
34+
*/
35+
boolean putFromLoad(SessionImplementor session, Object key, Object value, long txTimestamp, Object version);
36+
37+
/**
38+
* Attempt to cache an object, after loading from the database, explicitly
39+
* specifying the minimalPut behavior.
40+
*
41+
* @param session Current session.
42+
* @param key The item key
43+
* @param value The item
44+
* @param txTimestamp a timestamp prior to the transaction start time
45+
* @param version the item version number
46+
* @param minimalPutOverride Explicit minimalPut flag
47+
* @return <tt>true</tt> if the object was successfully cached
48+
* @throws org.hibernate.cache.CacheException Propogated from underlying {@link org.hibernate.cache.spi.Region}
49+
*/
50+
boolean putFromLoad(SessionImplementor session, Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride)
51+
throws CacheException;
52+
53+
/**
54+
* Called after an item has been inserted (before the transaction completes),
55+
* instead of calling evict().
56+
*
57+
* @param session Current session
58+
* @param key The item key
59+
* @param value The item
60+
* @param version The item's version value
61+
* @return Were the contents of the cache actual changed by this operation?
62+
* @throws CacheException if the insert fails
63+
*/
64+
boolean insert(SessionImplementor session, Object key, Object value, Object version) throws CacheException;
65+
66+
/**
67+
* Called after an item has been updated (before the transaction completes),
68+
* instead of calling evict().
69+
*
70+
* @param session Current session
71+
* @param key The item key
72+
* @param value The item
73+
* @param currentVersion The item's current version value
74+
* @param previousVersion The item's previous version value
75+
* @return Whether the contents of the cache actual changed by this operation
76+
* @throws CacheException if the update fails
77+
*/
78+
boolean update(SessionImplementor session, Object key, Object value, Object currentVersion, Object previousVersion)
79+
throws CacheException;
80+
81+
/**
82+
* Called after an item has become stale (before the transaction completes).
83+
*
84+
* @param session Current session
85+
* @param key The key of the item to remove
86+
* @throws CacheException if removing the cached item fails
87+
*/
88+
void remove(SessionImplementor session, Object key) throws CacheException;
89+
90+
/**
91+
* Called to evict data from the entire region
92+
*
93+
* @throws CacheException if eviction the region fails
94+
*/
95+
void removeAll() throws CacheException;
96+
97+
/**
98+
* Forcibly evict an item from the cache immediately without regard for transaction
99+
* isolation.
100+
*
101+
* @param key The key of the item to remove
102+
* @throws CacheException if evicting the item fails
103+
*/
104+
void evict(Object key) throws CacheException;
105+
106+
/**
107+
* Forcibly evict all items from the cache immediately without regard for transaction
108+
* isolation.
109+
*
110+
* @throws CacheException if evicting items fails
111+
*/
112+
void evictAll() throws CacheException;
113+
114+
/**
115+
* Called when we have finished the attempted update/delete (which may or
116+
* may not have been successful), after transaction completion. This method
117+
* is used by "asynchronous" concurrency strategies.
118+
*
119+
*
120+
* @param session
121+
* @param key The item key
122+
* @throws org.hibernate.cache.CacheException Propogated from underlying {@link org.hibernate.cache.spi.Region}
123+
*/
124+
void unlockItem(SessionImplementor session, Object key) throws CacheException;
125+
126+
/**
127+
* Called after an item has been inserted (after the transaction completes),
128+
* instead of calling release().
129+
* This method is used by "asynchronous" concurrency strategies.
130+
*
131+
*
132+
* @param session
133+
* @param key The item key
134+
* @param value The item
135+
* @param version The item's version value
136+
* @return Were the contents of the cache actual changed by this operation?
137+
* @throws CacheException Propagated from underlying {@link org.hibernate.cache.spi.Region}
138+
*/
139+
boolean afterInsert(SessionImplementor session, Object key, Object value, Object version);
140+
141+
/**
142+
* Called after an item has been updated (after the transaction completes),
143+
* instead of calling release(). This method is used by "asynchronous"
144+
* concurrency strategies.
145+
*
146+
*
147+
* @param session
148+
* @param key The item key
149+
* @param value The item
150+
* @param currentVersion The item's current version value
151+
* @param previousVersion The item's previous version value
152+
* @param lock The lock previously obtained from {@link #lockItem}
153+
* @return Were the contents of the cache actual changed by this operation?
154+
* @throws CacheException Propagated from underlying {@link org.hibernate.cache.spi.Region}
155+
*/
156+
boolean afterUpdate(SessionImplementor session, Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock);
157+
}

0 commit comments

Comments
 (0)