Lines 50-55
Link Here
|
50 |
* @since TOPLink/Java 1.0 |
50 |
* @since TOPLink/Java 1.0 |
51 |
*/ |
51 |
*/ |
52 |
public class IdentityMapManager implements Serializable, Cloneable { |
52 |
public class IdentityMapManager implements Serializable, Cloneable { |
|
|
53 |
protected static final String MONITOR_PREFIX = "Info:Cache:"; |
53 |
|
54 |
|
54 |
/** A table of identity maps with the key being the domain Class. */ |
55 |
/** A table of identity maps with the key being the domain Class. */ |
55 |
protected Map<Class, IdentityMap> identityMaps; |
56 |
protected Map<Class, IdentityMap> identityMaps; |
Lines 94-107
Link Here
|
94 |
public CacheKey acquireDeferredLock(Object primaryKey, Class domainClass, ClassDescriptor descriptor) { |
95 |
public CacheKey acquireDeferredLock(Object primaryKey, Class domainClass, ClassDescriptor descriptor) { |
95 |
CacheKey cacheKey = null; |
96 |
CacheKey cacheKey = null; |
96 |
if (this.isCacheAccessPreCheckRequired) { |
97 |
if (this.isCacheAccessPreCheckRequired) { |
97 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
98 |
this.session.startOperationProfile(SessionProfiler.Caching); |
98 |
acquireReadLock(); |
99 |
acquireReadLock(); |
|
|
100 |
IdentityMap identityMap = getIdentityMap(descriptor, false); |
99 |
try { |
101 |
try { |
100 |
cacheKey = getIdentityMap(descriptor, false).acquireDeferredLock(primaryKey); |
102 |
cacheKey = identityMap.acquireDeferredLock(primaryKey); |
101 |
} finally { |
103 |
} finally { |
102 |
releaseReadLock(); |
104 |
releaseReadLock(); |
103 |
} |
105 |
} |
104 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
106 |
this.session.endOperationProfile(SessionProfiler.Caching); |
|
|
107 |
if (cacheKey.getObject() == null) { |
108 |
this.session.updateProfile(MONITOR_PREFIX + domainClass.getSimpleName(), identityMap.getSize()); |
109 |
} |
105 |
} else { |
110 |
} else { |
106 |
cacheKey = getIdentityMap(descriptor, false).acquireDeferredLock(primaryKey); |
111 |
cacheKey = getIdentityMap(descriptor, false).acquireDeferredLock(primaryKey); |
107 |
} |
112 |
} |
Lines 121-134
Link Here
|
121 |
} |
126 |
} |
122 |
CacheKey cacheKey = null; |
127 |
CacheKey cacheKey = null; |
123 |
if (this.isCacheAccessPreCheckRequired) { |
128 |
if (this.isCacheAccessPreCheckRequired) { |
124 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
129 |
this.session.startOperationProfile(SessionProfiler.Caching); |
125 |
acquireReadLock(); |
130 |
acquireReadLock(); |
|
|
131 |
IdentityMap identityMap = getIdentityMap(descriptor, false); |
126 |
try { |
132 |
try { |
127 |
cacheKey = getIdentityMap(descriptor, false).acquireLock(primaryKey, forMerge); |
133 |
cacheKey = identityMap.acquireLock(primaryKey, forMerge); |
128 |
} finally { |
134 |
} finally { |
129 |
releaseReadLock(); |
135 |
releaseReadLock(); |
130 |
} |
136 |
} |
131 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
137 |
this.session.endOperationProfile(SessionProfiler.Caching); |
|
|
138 |
if (cacheKey.getObject() == null) { |
139 |
this.session.updateProfile(MONITOR_PREFIX + domainClass.getSimpleName(), identityMap.getSize()); |
140 |
} |
132 |
} else { |
141 |
} else { |
133 |
cacheKey = getIdentityMap(descriptor, false).acquireLock(primaryKey, forMerge); |
142 |
cacheKey = getIdentityMap(descriptor, false).acquireLock(primaryKey, forMerge); |
134 |
} |
143 |
} |
Lines 148-161
Link Here
|
148 |
} |
157 |
} |
149 |
CacheKey cacheKey = null; |
158 |
CacheKey cacheKey = null; |
150 |
if (this.isCacheAccessPreCheckRequired) { |
159 |
if (this.isCacheAccessPreCheckRequired) { |
151 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
160 |
this.session.startOperationProfile(SessionProfiler.Caching); |
152 |
acquireReadLock(); |
161 |
acquireReadLock(); |
|
|
162 |
IdentityMap identityMap = getIdentityMap(descriptor, false); |
153 |
try { |
163 |
try { |
154 |
cacheKey = getIdentityMap(descriptor, false).acquireLockNoWait(primaryKey, forMerge); |
164 |
cacheKey = identityMap.acquireLockNoWait(primaryKey, forMerge); |
155 |
} finally { |
165 |
} finally { |
156 |
releaseReadLock(); |
166 |
releaseReadLock(); |
157 |
} |
167 |
} |
158 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
168 |
this.session.endOperationProfile(SessionProfiler.Caching); |
|
|
169 |
if (cacheKey.getObject() == null) { |
170 |
this.session.updateProfile(MONITOR_PREFIX + domainClass.getSimpleName(), identityMap.getSize()); |
171 |
} |
159 |
} else { |
172 |
} else { |
160 |
cacheKey = getIdentityMap(descriptor, false).acquireLockNoWait(primaryKey, forMerge); |
173 |
cacheKey = getIdentityMap(descriptor, false).acquireLockNoWait(primaryKey, forMerge); |
161 |
} |
174 |
} |
Lines 175-188
Link Here
|
175 |
} |
188 |
} |
176 |
CacheKey cacheKey = null; |
189 |
CacheKey cacheKey = null; |
177 |
if (this.isCacheAccessPreCheckRequired) { |
190 |
if (this.isCacheAccessPreCheckRequired) { |
178 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
191 |
this.session.startOperationProfile(SessionProfiler.Caching); |
179 |
acquireReadLock(); |
192 |
acquireReadLock(); |
|
|
193 |
IdentityMap identityMap = getIdentityMap(descriptor, false); |
180 |
try { |
194 |
try { |
181 |
cacheKey = getIdentityMap(descriptor, false).acquireLockWithWait(primaryKey, forMerge, wait); |
195 |
cacheKey = identityMap.acquireLockWithWait(primaryKey, forMerge, wait); |
182 |
} finally { |
196 |
} finally { |
183 |
releaseReadLock(); |
197 |
releaseReadLock(); |
184 |
} |
198 |
} |
185 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
199 |
this.session.endOperationProfile(SessionProfiler.Caching); |
|
|
200 |
if (cacheKey.getObject() == null) { |
201 |
this.session.updateProfile(MONITOR_PREFIX + domainClass.getSimpleName(), identityMap.getSize()); |
202 |
} |
186 |
} else { |
203 |
} else { |
187 |
cacheKey = getIdentityMap(descriptor, false).acquireLockWithWait(primaryKey, forMerge, wait); |
204 |
cacheKey = getIdentityMap(descriptor, false).acquireLockWithWait(primaryKey, forMerge, wait); |
188 |
} |
205 |
} |
Lines 207-219
Link Here
|
207 |
* Provides access for setting a concurrency lock on an IdentityMap. |
224 |
* Provides access for setting a concurrency lock on an IdentityMap. |
208 |
*/ |
225 |
*/ |
209 |
public void acquireReadLock() { |
226 |
public void acquireReadLock() { |
210 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
227 |
this.session.startOperationProfile(SessionProfiler.Caching); |
211 |
|
228 |
|
212 |
if (this.session.getDatasourceLogin().shouldSynchronizedReadOnWrite()) { |
229 |
if (this.session.getDatasourceLogin().shouldSynchronizedReadOnWrite()) { |
213 |
getCacheMutex().acquireReadLock(); |
230 |
getCacheMutex().acquireReadLock(); |
214 |
} |
231 |
} |
215 |
|
232 |
|
216 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
233 |
this.session.endOperationProfile(SessionProfiler.Caching); |
217 |
} |
234 |
} |
218 |
|
235 |
|
219 |
/** |
236 |
/** |
Lines 230-243
Link Here
|
230 |
} |
247 |
} |
231 |
CacheKey cacheKey = null; |
248 |
CacheKey cacheKey = null; |
232 |
if (this.isCacheAccessPreCheckRequired) { |
249 |
if (this.isCacheAccessPreCheckRequired) { |
233 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
250 |
this.session.startOperationProfile(SessionProfiler.Caching); |
234 |
acquireReadLock(); |
251 |
acquireReadLock(); |
235 |
try { |
252 |
try { |
236 |
cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKey(primaryKey); |
253 |
cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKey(primaryKey); |
237 |
} finally { |
254 |
} finally { |
238 |
releaseReadLock(); |
255 |
releaseReadLock(); |
239 |
} |
256 |
} |
240 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
257 |
this.session.endOperationProfile(SessionProfiler.Caching); |
241 |
} else { |
258 |
} else { |
242 |
cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKey(primaryKey); |
259 |
cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKey(primaryKey); |
243 |
} |
260 |
} |
Lines 260-273
Link Here
|
260 |
} |
277 |
} |
261 |
CacheKey cacheKey = null; |
278 |
CacheKey cacheKey = null; |
262 |
if (this.isCacheAccessPreCheckRequired) { |
279 |
if (this.isCacheAccessPreCheckRequired) { |
263 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
280 |
this.session.startOperationProfile(SessionProfiler.Caching); |
264 |
acquireReadLock(); |
281 |
acquireReadLock(); |
265 |
try { |
282 |
try { |
266 |
cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKeyNoWait(primaryKey); |
283 |
cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKeyNoWait(primaryKey); |
267 |
} finally { |
284 |
} finally { |
268 |
releaseReadLock(); |
285 |
releaseReadLock(); |
269 |
} |
286 |
} |
270 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
287 |
this.session.endOperationProfile(SessionProfiler.Caching); |
271 |
} else { |
288 |
} else { |
272 |
cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKeyNoWait(primaryKey); |
289 |
cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKeyNoWait(primaryKey); |
273 |
} |
290 |
} |
Lines 427-439
Link Here
|
427 |
return false; |
444 |
return false; |
428 |
} |
445 |
} |
429 |
if (this.isCacheAccessPreCheckRequired) { |
446 |
if (this.isCacheAccessPreCheckRequired) { |
430 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
447 |
this.session.startOperationProfile(SessionProfiler.Caching); |
431 |
acquireReadLock(); |
448 |
acquireReadLock(); |
432 |
try { |
449 |
try { |
433 |
return map.containsKey(key); |
450 |
return map.containsKey(key); |
434 |
} finally { |
451 |
} finally { |
435 |
releaseReadLock(); |
452 |
releaseReadLock(); |
436 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
453 |
this.session.endOperationProfile(SessionProfiler.Caching); |
437 |
} |
454 |
} |
438 |
} else { |
455 |
} else { |
439 |
return map.containsKey(key); |
456 |
return map.containsKey(key); |
Lines 445-451
Link Here
|
445 |
*/ |
462 |
*/ |
446 |
public Vector getAllFromIdentityMap(Expression selectionCriteria, Class theClass, Record translationRow, int valueHolderPolicy, boolean shouldReturnInvalidatedObjects) { |
463 |
public Vector getAllFromIdentityMap(Expression selectionCriteria, Class theClass, Record translationRow, int valueHolderPolicy, boolean shouldReturnInvalidatedObjects) { |
447 |
ClassDescriptor descriptor = this.session.getDescriptor(theClass); |
464 |
ClassDescriptor descriptor = this.session.getDescriptor(theClass); |
448 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
465 |
this.session.startOperationProfile(SessionProfiler.Caching); |
449 |
Vector objects = null; |
466 |
Vector objects = null; |
450 |
try { |
467 |
try { |
451 |
if (selectionCriteria != null) { |
468 |
if (selectionCriteria != null) { |
Lines 477-494
Link Here
|
477 |
if ((object.getClass() == theClass) || (theClass.isInstance(object))) { |
494 |
if ((object.getClass() == theClass) || (theClass.isInstance(object))) { |
478 |
if (selectionCriteria == null) { |
495 |
if (selectionCriteria == null) { |
479 |
objects.add(object); |
496 |
objects.add(object); |
480 |
this.session.incrementProfile(SessionProfiler.CacheHits); |
|
|
481 |
} else { |
497 |
} else { |
482 |
try { |
498 |
try { |
483 |
if (selectionCriteria.doesConform(object, this.session, (AbstractRecord)translationRow, valueHolderPolicy)) { |
499 |
if (selectionCriteria.doesConform(object, this.session, (AbstractRecord)translationRow, valueHolderPolicy)) { |
484 |
objects.addElement(object); |
500 |
objects.add(object); |
485 |
this.session.incrementProfile(SessionProfiler.CacheHits); |
|
|
486 |
} |
501 |
} |
487 |
} catch (QueryException queryException) { |
502 |
} catch (QueryException queryException) { |
488 |
if (queryException.getErrorCode() == QueryException.MUST_INSTANTIATE_VALUEHOLDERS) { |
503 |
if (queryException.getErrorCode() == QueryException.MUST_INSTANTIATE_VALUEHOLDERS) { |
489 |
if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_IGNORE_EXCEPTION_RETURN_CONFORMED) { |
504 |
if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_IGNORE_EXCEPTION_RETURN_CONFORMED) { |
490 |
objects.add(object); |
505 |
objects.add(object); |
491 |
this.session.incrementProfile(SessionProfiler.CacheHits); |
|
|
492 |
} else if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_THROW_INDIRECTION_EXCEPTION) { |
506 |
} else if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_THROW_INDIRECTION_EXCEPTION) { |
493 |
throw queryException; |
507 |
throw queryException; |
494 |
} |
508 |
} |
Lines 500-506
Link Here
|
500 |
} |
514 |
} |
501 |
} |
515 |
} |
502 |
} finally { |
516 |
} finally { |
503 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
517 |
this.session.endOperationProfile(SessionProfiler.Caching); |
504 |
} |
518 |
} |
505 |
return objects; |
519 |
return objects; |
506 |
} |
520 |
} |
Lines 510-516
Link Here
|
510 |
*/ |
524 |
*/ |
511 |
public void invalidateObjects(Expression selectionCriteria, Class theClass, Record translationRow, boolean shouldInvalidateOnException) { |
525 |
public void invalidateObjects(Expression selectionCriteria, Class theClass, Record translationRow, boolean shouldInvalidateOnException) { |
512 |
ClassDescriptor descriptor = this.session.getDescriptor(theClass); |
526 |
ClassDescriptor descriptor = this.session.getDescriptor(theClass); |
513 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
527 |
this.session.startOperationProfile(SessionProfiler.Caching); |
514 |
try { |
528 |
try { |
515 |
IdentityMap map = getIdentityMap(descriptor, true); |
529 |
IdentityMap map = getIdentityMap(descriptor, true); |
516 |
if(map == null) { |
530 |
if(map == null) { |
Lines 591-597
Link Here
|
591 |
} |
605 |
} |
592 |
} |
606 |
} |
593 |
} finally { |
607 |
} finally { |
594 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
608 |
this.session.endOperationProfile(SessionProfiler.Caching); |
595 |
} |
609 |
} |
596 |
} |
610 |
} |
597 |
|
611 |
|
Lines 608-620
Link Here
|
608 |
} |
622 |
} |
609 |
CacheKey cacheKey = null; |
623 |
CacheKey cacheKey = null; |
610 |
if (this.isCacheAccessPreCheckRequired) { |
624 |
if (this.isCacheAccessPreCheckRequired) { |
611 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
625 |
this.session.startOperationProfile(SessionProfiler.Caching); |
612 |
acquireReadLock(); |
626 |
acquireReadLock(); |
613 |
try { |
627 |
try { |
614 |
cacheKey = map.getCacheKeyForLock(primaryKey); |
628 |
cacheKey = map.getCacheKeyForLock(primaryKey); |
615 |
} finally { |
629 |
} finally { |
616 |
releaseReadLock(); |
630 |
releaseReadLock(); |
617 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
631 |
this.session.endOperationProfile(SessionProfiler.Caching); |
618 |
} |
632 |
} |
619 |
} else { |
633 |
} else { |
620 |
cacheKey = map.getCacheKeyForLock(primaryKey); |
634 |
cacheKey = map.getCacheKeyForLock(primaryKey); |
Lines 635-647
Link Here
|
635 |
} |
649 |
} |
636 |
CacheKey cacheKey = null; |
650 |
CacheKey cacheKey = null; |
637 |
if (this.isCacheAccessPreCheckRequired) { |
651 |
if (this.isCacheAccessPreCheckRequired) { |
638 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
652 |
this.session.startOperationProfile(SessionProfiler.Caching); |
639 |
acquireReadLock(); |
653 |
acquireReadLock(); |
640 |
try { |
654 |
try { |
641 |
cacheKey = map.getCacheKey(primaryKey); |
655 |
cacheKey = map.getCacheKey(primaryKey); |
642 |
} finally { |
656 |
} finally { |
643 |
releaseReadLock(); |
657 |
releaseReadLock(); |
644 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
658 |
this.session.endOperationProfile(SessionProfiler.Caching); |
645 |
} |
659 |
} |
646 |
} else { |
660 |
} else { |
647 |
cacheKey = map.getCacheKey(primaryKey); |
661 |
cacheKey = map.getCacheKey(primaryKey); |
Lines 702-708
Link Here
|
702 |
} |
716 |
} |
703 |
Object domainObject = null; |
717 |
Object domainObject = null; |
704 |
if (this.isCacheAccessPreCheckRequired) { |
718 |
if (this.isCacheAccessPreCheckRequired) { |
705 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
719 |
this.session.startOperationProfile(SessionProfiler.Caching); |
706 |
acquireReadLock(); |
720 |
acquireReadLock(); |
707 |
try { |
721 |
try { |
708 |
cacheKey = map.getCacheKey(key); |
722 |
cacheKey = map.getCacheKey(key); |
Lines 724-735
Link Here
|
724 |
} |
738 |
} |
725 |
|
739 |
|
726 |
if (this.isCacheAccessPreCheckRequired) { |
740 |
if (this.isCacheAccessPreCheckRequired) { |
727 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
741 |
this.session.endOperationProfile(SessionProfiler.Caching); |
728 |
if (domainObject == null) { |
|
|
729 |
this.session.incrementProfile(SessionProfiler.CacheMisses); |
730 |
} else { |
731 |
this.session.incrementProfile(SessionProfiler.CacheHits); |
732 |
} |
733 |
} |
742 |
} |
734 |
|
743 |
|
735 |
return domainObject; |
744 |
return domainObject; |
Lines 737-743
Link Here
|
737 |
|
746 |
|
738 |
public Object getFromIdentityMap(Expression selectionCriteria, Class theClass, Record translationRow, int valueHolderPolicy, boolean conforming, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) { |
747 |
public Object getFromIdentityMap(Expression selectionCriteria, Class theClass, Record translationRow, int valueHolderPolicy, boolean conforming, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) { |
739 |
UnitOfWorkImpl unitOfWork = (conforming) ? (UnitOfWorkImpl)this.session : null; |
748 |
UnitOfWorkImpl unitOfWork = (conforming) ? (UnitOfWorkImpl)this.session : null; |
740 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
749 |
this.session.startOperationProfile(SessionProfiler.Caching); |
741 |
try { |
750 |
try { |
742 |
if (selectionCriteria != null) { |
751 |
if (selectionCriteria != null) { |
743 |
// PERF: Avoid clone of expression. |
752 |
// PERF: Avoid clone of expression. |
Lines 768-774
Link Here
|
768 |
if (selectionCriteria == null) { |
777 |
if (selectionCriteria == null) { |
769 |
// bug 2782991: if first found was deleted nothing returned. |
778 |
// bug 2782991: if first found was deleted nothing returned. |
770 |
if (!(conforming && unitOfWork.isObjectDeleted(object))) { |
779 |
if (!(conforming && unitOfWork.isObjectDeleted(object))) { |
771 |
this.session.incrementProfile(SessionProfiler.CacheHits); |
|
|
772 |
return object; |
780 |
return object; |
773 |
} |
781 |
} |
774 |
} |
782 |
} |
Lines 778-784
Link Here
|
778 |
if (selectionCriteria.doesConform(object, this.session, (AbstractRecord)translationRow, valueHolderPolicy)) { |
786 |
if (selectionCriteria.doesConform(object, this.session, (AbstractRecord)translationRow, valueHolderPolicy)) { |
779 |
// bug 2782991: if first found was deleted nothing returned. |
787 |
// bug 2782991: if first found was deleted nothing returned. |
780 |
if (!(conforming && unitOfWork.isObjectDeleted(object))) { |
788 |
if (!(conforming && unitOfWork.isObjectDeleted(object))) { |
781 |
this.session.incrementProfile(SessionProfiler.CacheHits); |
|
|
782 |
return object; |
789 |
return object; |
783 |
} |
790 |
} |
784 |
} |
791 |
} |
Lines 787-793
Link Here
|
787 |
if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_IGNORE_EXCEPTION_RETURN_CONFORMED) { |
794 |
if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_IGNORE_EXCEPTION_RETURN_CONFORMED) { |
788 |
// bug 2782991: if first found was deleted nothing returned. |
795 |
// bug 2782991: if first found was deleted nothing returned. |
789 |
if (!(conforming && unitOfWork.isObjectDeleted(object))) { |
796 |
if (!(conforming && unitOfWork.isObjectDeleted(object))) { |
790 |
this.session.incrementProfile(SessionProfiler.CacheHits); |
|
|
791 |
return object; |
797 |
return object; |
792 |
} |
798 |
} |
793 |
} else if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_IGNORE_EXCEPTION_RETURN_NOT_CONFORMED) { |
799 |
} else if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_IGNORE_EXCEPTION_RETURN_NOT_CONFORMED) { |
Lines 802-808
Link Here
|
802 |
} |
808 |
} |
803 |
} |
809 |
} |
804 |
} finally { |
810 |
} finally { |
805 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
811 |
this.session.endOperationProfile(SessionProfiler.Caching); |
806 |
} |
812 |
} |
807 |
return null; |
813 |
return null; |
808 |
} |
814 |
} |
Lines 813-819
Link Here
|
813 |
*/ |
819 |
*/ |
814 |
public Object getFromIdentityMapWithDeferredLock(Object key, Class theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) { |
820 |
public Object getFromIdentityMapWithDeferredLock(Object key, Class theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) { |
815 |
if (key == null) { |
821 |
if (key == null) { |
816 |
this.session.incrementProfile(SessionProfiler.CacheMisses); |
|
|
817 |
return null; |
822 |
return null; |
818 |
} |
823 |
} |
819 |
|
824 |
|
Lines 824-830
Link Here
|
824 |
CacheKey cacheKey; |
829 |
CacheKey cacheKey; |
825 |
Object domainObject = null; |
830 |
Object domainObject = null; |
826 |
if (this.isCacheAccessPreCheckRequired) { |
831 |
if (this.isCacheAccessPreCheckRequired) { |
827 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
832 |
this.session.startOperationProfile(SessionProfiler.Caching); |
828 |
acquireReadLock(); |
833 |
acquireReadLock(); |
829 |
try { |
834 |
try { |
830 |
cacheKey = map.getCacheKey(key); |
835 |
cacheKey = map.getCacheKey(key); |
Lines 846-857
Link Here
|
846 |
|
851 |
|
847 |
|
852 |
|
848 |
if (this.isCacheAccessPreCheckRequired) { |
853 |
if (this.isCacheAccessPreCheckRequired) { |
849 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
854 |
this.session.endOperationProfile(SessionProfiler.Caching); |
850 |
if (domainObject == null) { |
|
|
851 |
this.session.incrementProfile(SessionProfiler.CacheMisses); |
852 |
} else { |
853 |
this.session.incrementProfile(SessionProfiler.CacheHits); |
854 |
} |
855 |
} |
855 |
} |
856 |
|
856 |
|
857 |
return domainObject; |
857 |
return domainObject; |
Lines 968-981
Link Here
|
968 |
IdentityMap map = getIdentityMap(descriptor, false); |
968 |
IdentityMap map = getIdentityMap(descriptor, false); |
969 |
Object wrapper; |
969 |
Object wrapper; |
970 |
if (this.isCacheAccessPreCheckRequired) { |
970 |
if (this.isCacheAccessPreCheckRequired) { |
971 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
971 |
this.session.startOperationProfile(SessionProfiler.Caching); |
972 |
acquireReadLock(); |
972 |
acquireReadLock(); |
973 |
try { |
973 |
try { |
974 |
wrapper = map.getWrapper(primaryKey); |
974 |
wrapper = map.getWrapper(primaryKey); |
975 |
} finally { |
975 |
} finally { |
976 |
releaseReadLock(); |
976 |
releaseReadLock(); |
977 |
} |
977 |
} |
978 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
978 |
this.session.endOperationProfile(SessionProfiler.Caching); |
979 |
} else { |
979 |
} else { |
980 |
wrapper = map.getWrapper(primaryKey); |
980 |
wrapper = map.getWrapper(primaryKey); |
981 |
} |
981 |
} |
Lines 1006-1019
Link Here
|
1006 |
IdentityMap map = getIdentityMap(descriptor, false); |
1006 |
IdentityMap map = getIdentityMap(descriptor, false); |
1007 |
Object value; |
1007 |
Object value; |
1008 |
if (this.isCacheAccessPreCheckRequired) { |
1008 |
if (this.isCacheAccessPreCheckRequired) { |
1009 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
1009 |
this.session.startOperationProfile(SessionProfiler.Caching); |
1010 |
acquireReadLock(); |
1010 |
acquireReadLock(); |
1011 |
try { |
1011 |
try { |
1012 |
value = map.getWriteLockValue(primaryKey); |
1012 |
value = map.getWriteLockValue(primaryKey); |
1013 |
} finally { |
1013 |
} finally { |
1014 |
releaseReadLock(); |
1014 |
releaseReadLock(); |
1015 |
} |
1015 |
} |
1016 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
1016 |
this.session.endOperationProfile(SessionProfiler.Caching); |
1017 |
} else { |
1017 |
} else { |
1018 |
value = map.getWriteLockValue(primaryKey); |
1018 |
value = map.getWriteLockValue(primaryKey); |
1019 |
} |
1019 |
} |
Lines 1219-1225
Link Here
|
1219 |
CacheKey cacheKey; |
1219 |
CacheKey cacheKey; |
1220 |
|
1220 |
|
1221 |
if (this.isCacheAccessPreCheckRequired) { |
1221 |
if (this.isCacheAccessPreCheckRequired) { |
1222 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
1222 |
this.session.startOperationProfile(SessionProfiler.Caching); |
1223 |
// This is atomic so considered a read lock. |
1223 |
// This is atomic so considered a read lock. |
1224 |
acquireReadLock(); |
1224 |
acquireReadLock(); |
1225 |
try { |
1225 |
try { |
Lines 1227-1233
Link Here
|
1227 |
} finally { |
1227 |
} finally { |
1228 |
releaseReadLock(); |
1228 |
releaseReadLock(); |
1229 |
} |
1229 |
} |
1230 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
1230 |
this.session.endOperationProfile(SessionProfiler.Caching); |
1231 |
} else { |
1231 |
} else { |
1232 |
cacheKey = map.put(keys, implementation, writeLockValue, readTime); |
1232 |
cacheKey = map.put(keys, implementation, writeLockValue, readTime); |
1233 |
} |
1233 |
} |
Lines 1311-1317
Link Here
|
1311 |
Object value; |
1311 |
Object value; |
1312 |
|
1312 |
|
1313 |
if (this.isCacheAccessPreCheckRequired) { |
1313 |
if (this.isCacheAccessPreCheckRequired) { |
1314 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
1314 |
this.session.startOperationProfile(SessionProfiler.Caching); |
1315 |
// This is atomic so considered a read lock. |
1315 |
// This is atomic so considered a read lock. |
1316 |
acquireReadLock(); |
1316 |
acquireReadLock(); |
1317 |
try { |
1317 |
try { |
Lines 1319-1325
Link Here
|
1319 |
} finally { |
1319 |
} finally { |
1320 |
releaseReadLock(); |
1320 |
releaseReadLock(); |
1321 |
} |
1321 |
} |
1322 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
1322 |
this.session.endOperationProfile(SessionProfiler.Caching); |
1323 |
} else { |
1323 |
} else { |
1324 |
value = map.remove(key, objectToRemove); |
1324 |
value = map.remove(key, objectToRemove); |
1325 |
} |
1325 |
} |
Lines 1353-1359
Link Here
|
1353 |
IdentityMap map = getIdentityMap(descriptor, false); |
1353 |
IdentityMap map = getIdentityMap(descriptor, false); |
1354 |
|
1354 |
|
1355 |
if (this.isCacheAccessPreCheckRequired) { |
1355 |
if (this.isCacheAccessPreCheckRequired) { |
1356 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
1356 |
this.session.startOperationProfile(SessionProfiler.Caching); |
1357 |
// This is atomic so considered a read lock. |
1357 |
// This is atomic so considered a read lock. |
1358 |
acquireReadLock(); |
1358 |
acquireReadLock(); |
1359 |
try { |
1359 |
try { |
Lines 1361-1367
Link Here
|
1361 |
} finally { |
1361 |
} finally { |
1362 |
releaseReadLock(); |
1362 |
releaseReadLock(); |
1363 |
} |
1363 |
} |
1364 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
1364 |
this.session.endOperationProfile(SessionProfiler.Caching); |
1365 |
} else { |
1365 |
} else { |
1366 |
map.setWrapper(primaryKey, wrapper); |
1366 |
map.setWrapper(primaryKey, wrapper); |
1367 |
} |
1367 |
} |
Lines 1378-1384
Link Here
|
1378 |
IdentityMap map = getIdentityMap(descriptor, false); |
1378 |
IdentityMap map = getIdentityMap(descriptor, false); |
1379 |
|
1379 |
|
1380 |
if (this.isCacheAccessPreCheckRequired) { |
1380 |
if (this.isCacheAccessPreCheckRequired) { |
1381 |
this.session.startOperationProfile(SessionProfiler.CACHE); |
1381 |
this.session.startOperationProfile(SessionProfiler.Caching); |
1382 |
// This is atomic so considered a read lock. |
1382 |
// This is atomic so considered a read lock. |
1383 |
acquireReadLock(); |
1383 |
acquireReadLock(); |
1384 |
try { |
1384 |
try { |
Lines 1386-1392
Link Here
|
1386 |
} finally { |
1386 |
} finally { |
1387 |
releaseReadLock(); |
1387 |
releaseReadLock(); |
1388 |
} |
1388 |
} |
1389 |
this.session.endOperationProfile(SessionProfiler.CACHE); |
1389 |
this.session.endOperationProfile(SessionProfiler.Caching); |
1390 |
} else { |
1390 |
} else { |
1391 |
map.setWriteLockValue(primaryKey, writeLockValue); |
1391 |
map.setWriteLockValue(primaryKey, writeLockValue); |
1392 |
} |
1392 |
} |