00001 /* 00002 * Copyright (c) 2000, 2020, Oracle and/or its affiliates. 00003 * 00004 * Licensed under the Universal Permissive License v 1.0 as shown at 00005 * http://oss.oracle.com/licenses/upl. 00006 */ 00007 #ifndef COH_CACHING_MAP_HPP 00008 #define COH_CACHING_MAP_HPP 00009 00010 #include "coherence/lang.ns" 00011 00012 #include "coherence/internal/net/NamedCacheDeactivationListener.hpp" 00013 00014 #include "coherence/net/cache/CacheMap.hpp" 00015 #include "coherence/net/cache/SimpleCacheStatistics.hpp" 00016 #include "coherence/net/NamedCache.hpp" 00017 00018 #include "coherence/util/AbstractMapListener.hpp" 00019 #include "coherence/util/Collection.hpp" 00020 #include "coherence/util/ConcurrentMap.hpp" 00021 #include "coherence/util/Filter.hpp" 00022 #include "coherence/util/List.hpp" 00023 #include "coherence/util/Map.hpp" 00024 #include "coherence/util/MapListener.hpp" 00025 #include "coherence/util/MapListenerSupport.hpp" 00026 #include "coherence/util/MultiplexingMapListener.hpp" 00027 #include "coherence/util/Set.hpp" 00028 00029 #include "coherence/util/filter/CacheEventFilter.hpp" 00030 #include "coherence/util/filter/MapEventFilter.hpp" 00031 00032 COH_OPEN_NAMESPACE3(coherence,net,cache) 00033 00034 using coherence::internal::net::NamedCacheDeactivationListener; 00035 using coherence::net::NamedCache; 00036 using coherence::util::AbstractMapListener; 00037 using coherence::util::Collection; 00038 using coherence::util::ConcurrentMap; 00039 using coherence::util::Filter; 00040 using coherence::util::List; 00041 using coherence::util::Map; 00042 using coherence::util::MapListener; 00043 using coherence::util::MapListenerSupport; 00044 using coherence::util::MultiplexingMapListener; 00045 using coherence::util::Set; 00046 using coherence::util::filter::CacheEventFilter; 00047 using coherence::util::filter::MapEventFilter; 00048 00049 00050 /** 00051 * Map implementation that wraps two maps - a front map (assumed to be 00052 * "inexpensive" and probably "incomplete") and a back map (assumed to 00053 * be "complete" and "correct", but more "expensive") - using a 00054 * read-through/write-through approach. 00055 * 00056 * If the back map implements ObservableMap interface, the CachingMap provides 00057 * four different strategies of invalidating the front map entries that have 00058 * changed by other processes in the back map: 00059 * 00060 * listen_none strategy instructs the cache not to listen for invalidation 00061 * events at all. This is the best choice for raw performance and 00062 * scalability when business requirements permit the use of data which 00063 * might not be absolutely current. Freshness of data can be guaranteed 00064 * by use of a sufficiently brief eviction policy for the front map; 00065 * listen_present strategy instructs the CachingMap to listen to the 00066 * back map events related <b>only</b> to the items currently present in 00067 * the front map. This strategy works best when each instance of a front 00068 * map contains distinct subset of data relative to the other front map 00069 * instances (e.g. sticky data access patterns); 00070 * listen_all strategy instructs the CachingMap to listen to <b>all</b> 00071 * back map events. This strategy is optimal for read-heavy tiered access 00072 * patterns where there is significant overlap between the different 00073 * instances of front maps; 00074 * listen_auto strategy instructs the CachingMap implementation to switch 00075 * automatically between listen_present and listen_all strategies based 00076 * on the cache statistics. 00077 * listen_logical strategy instructs the CachingMap to listen to <b>all</b> 00078 * back map events that are <b>not synthetic</b>. A synthetic event could 00079 * be emitted as a result of eviction or expiration. With this 00080 * invalidation strategy, it is possible for the front map to contain 00081 * cache entries that have been synthetically removed from the back 00082 * (though any subsequent re-insertion will cause the corresponding 00083 * entries in the front map to be invalidated). 00084 * 00085 * The front map implementation is assumed to be thread safe; additionally 00086 * any modifications to the front map are allowed only after the corresponding 00087 * lock is acquired against the ControlMap. 00088 * 00089 * <b>Note:</b> NULL values are not cached in the front map and therefore this 00090 * implementation is not optimized for maps that allow NULL values to be 00091 * stored. 00092 * 00093 * @author tb 2008.06.12 00094 */ 00095 class COH_EXPORT CachingMap 00096 : public class_spec<CachingMap, 00097 extends<Object>, 00098 implements<Map> > 00099 { 00100 friend class factory<CachingMap>; 00101 00102 // ----- handle definitions (needed for nested classes) ----------------- 00103 00104 public: 00105 typedef this_spec::Handle Handle; 00106 typedef this_spec::View View; 00107 typedef this_spec::Holder Holder; 00108 00109 00110 // ----- enums ---------------------------------------------------------- 00111 00112 public: 00113 /** 00114 * Enum for invalidation strategies 00115 */ 00116 enum InvalidationStrategy 00117 { 00118 /** 00119 * No invalidation strategy. 00120 */ 00121 listen_none, 00122 00123 /** 00124 * Invalidation strategy that instructs the CachingMap to listen 00125 * to the back map events related <b>only</b> to the items 00126 * currently present in the front map; this strategy serves best 00127 * when the changes to the back map come mostly from the 00128 * CachingMap itself. 00129 */ 00130 listen_present, 00131 00132 /** 00133 * Invalidation strategy that instructs the CachingMap to listen 00134 * to <b>all</b> back map events; this strategy is preferred when 00135 * updates to the back map are frequent and with high probability 00136 * come from the outside of this CachingMap; for example multiple 00137 * CachingMap instances using the same back map with a large 00138 * degree of key set overlap between front maps. 00139 */ 00140 listen_all, 00141 00142 /** 00143 * Invalidation strategy that instructs the CachingMap 00144 * implementation to switch automatically between listen_present 00145 * and listen_all strategies based on the cache statistics. 00146 */ 00147 listen_auto, 00148 00149 /** 00150 * Invalidation strategy that instructs the CachingMap to listen 00151 * to <b>all</b> back map events that are <b>not synthetic</b>. A 00152 * synthetic event could be emitted as a result of eviction or 00153 * expiration. With this invalidation strategy, it is possible 00154 * for the front map to contain cache entries that have been 00155 * synthetically removed from the back (though any subsequent 00156 * re-insertion will cause the corresponding entries in the front 00157 * map to be invalidated). 00158 */ 00159 listen_logical 00160 }; 00161 00162 00163 // ----- constructors --------------------------------------------------- 00164 00165 protected: 00166 /** 00167 * Construct a CachingMap using two specified maps: 00168 * <i>FrontMap</i> (aka "cache", "near" or "shallow") and 00169 * <i>BackMap</i> (aka "actual", "real" or "deep"). 00170 * 00171 * If the BackMap implements the ObservableMap interface a listener 00172 * will be added to the BackMap to invalidate FrontMap items updated 00173 * [externally] in the back map using the listen_auto strategy. 00174 * 00175 * If no MapControl is specified then a new one is created. 00176 * 00177 * @param hMapFront front map 00178 * @param hMapBack back map 00179 * @param strategy specifies the strategy used for the front map 00180 * invalidation; valid values are LISTEN_* 00181 * constants 00182 * @param hMapControl the ConcurrentMap to keep track of front map 00183 * updates; may be NULL 00184 */ 00185 CachingMap(CacheMap::Handle hMapFront, CacheMap::Handle hMapBack, 00186 InvalidationStrategy strategy = listen_auto, 00187 ConcurrentMap::Handle hMapControl = NULL); 00188 00189 00190 // ----- life-cycle ----------------------------------------------------- 00191 00192 public: 00193 /** 00194 * Release the CachingMap. If the BackMap implements an ObservableMap 00195 * calling this method is necessary to remove the BackMap listener. 00196 * Any access to the CachingMap which has been released will cause 00197 * IllegalStateException. 00198 * 00199 * @throws IllegalStateException if accessing the CachingMap 00200 * which has been released 00201 */ 00202 virtual void release(); 00203 00204 00205 // ----- accessors ------------------------------------------------------ 00206 00207 public: 00208 /** 00209 * Obtain the front map reference. 00210 * 00211 * <b>Note:</b> direct modifications of the returned map may cause an 00212 * unpredictable behavior of the CachingMap. 00213 * 00214 * @return the front Map 00215 */ 00216 virtual CacheMap::Handle getFrontMap() const; 00217 00218 /** 00219 * Obtain the back map reference. 00220 * 00221 * <b>Note:</b> direct modifications of the returned map may cause an 00222 * unpredictable behavior of the CachingMap. 00223 * 00224 * @return the back Map 00225 */ 00226 virtual CacheMap::Handle getBackMap() const; 00227 00228 /** 00229 * Obtain the invalidation strategy used by this CachingMap. 00230 * 00231 * @return one of LISTEN_* values 00232 */ 00233 virtual InvalidationStrategy getInvalidationStrategy() const; 00234 00235 /** 00236 * Obtain the ConcurrentMap that should be used to synchronize 00237 * the front map modification access. 00238 * 00239 * @return a ConcurrentMap controlling the front map modifications 00240 */ 00241 virtual ConcurrentMap::Handle getControlMap() const; 00242 00243 /** 00244 * Obtain the CacheStatistics for this cache. 00245 * 00246 * @return a CacheStatistics object 00247 */ 00248 virtual CacheStatistics::Handle getCacheStatistics() const; 00249 00250 /** 00251 * Determine the rough number of front map invalidation hits since 00252 * the cache statistics were last reset. 00253 * 00254 * An invalidation hit is an externally induced map event for an entry 00255 * that exists in the front map. 00256 * 00257 * @return the number of cache invalidation hits 00258 */ 00259 virtual int64_t getInvalidationHits() const; 00260 00261 /** 00262 * Determine the rough number of front map invalidation misses since 00263 * the cache statistics were last reset. 00264 * 00265 * An invalidation miss is an externally induced map event for an 00266 * entry that does not exists in the front map. 00267 * 00268 * @return the number of cache invalidation misses 00269 */ 00270 virtual int64_t getInvalidationMisses() const; 00271 00272 /** 00273 * Determine the total number of registerListener(Object::View vKey) 00274 * operations since the cache statistics were last reset. 00275 * 00276 * @return the total number of listener registrations 00277 */ 00278 virtual int64_t getTotalRegisterListener() const; 00279 00280 protected: 00281 /** 00282 * Determine if changes to the back map affect the front map so that 00283 * data in the front map stays in sync. 00284 * 00285 * @return true if the front map has a means to stay in sync with the 00286 * back map so that it does not contain stale data 00287 */ 00288 virtual bool isCoherent() const; 00289 00290 00291 // ----- CachingMap interface ------------------------------------------- 00292 00293 protected: 00294 /** 00295 * Invalidate the key from the front. The caller must have the key 00296 * locked. 00297 * 00298 * @param vKey the key to invalidate 00299 */ 00300 virtual void invalidateFront(Object::View vKey) const; 00301 00302 /** 00303 * Helper method used by put() and putAll() to perform common 00304 * maintanence tasks after completing an operation against the back. 00305 * This includes removing the keys from the control map, and 00306 * evaluating if it is safe to update the front with the "new" value. 00307 * The implementation makes use of the following assumption: if 00308 * listEvents == IGNORE_LIST then oKey does not exist in the 00309 * front, and there is no key based listener for it. Any key passed 00310 * to this method must be locked in the control map by the caller. 00311 * 00312 * @param vKey the key 00313 * @param ohValue the new value 00314 * @param hlistEvents the event list associated with the key 00315 * @param cMillis the number of milliseconds until the cache entry 00316 * will expire 00317 */ 00318 virtual void finalizePut(Object::View vKey, Object::Holder ohValue, 00319 List::Handle hlistEvents, int64_t cMillis); 00320 00321 public: 00322 /** 00323 * Implementation of put method that optionally skips the return value 00324 * retrieval and allows to specify an expiry for the cache entry. 00325 * 00326 * @param vKey the key 00327 * @param ohValue the value 00328 * @param fReturn if true, the return value is required; otherwise 00329 * the return value will be ignored 00330 * @param cMillis the number of milliseconds until the cache entry 00331 * will expire 00332 * @return previous value (if required) 00333 * 00334 * @throws UnsupportedOperationException if the requested expiry is a 00335 * positive value and either the front map or the back map 00336 * implementations do not support the expiration functionality 00337 */ 00338 virtual Object::Holder put(Object::View vKey, Object::Holder ohValue, 00339 bool fReturn, int64_t cMillis); 00340 00341 /** 00342 * Get all the specified keys, if they are in the cache. For each key 00343 * that is in the cache, that key and its corresponding value will be 00344 * placed in the map that is returned by this method. The absence of 00345 * a key in the returned map indicates that it was not in the cache, 00346 * which may imply (for caches that can load behind the scenes) that 00347 * the requested data could not be loaded. 00348 * 00349 * <b>Note:</b> this implementation does not differentiate between 00350 * missing keys or NULL values stored in the back map; in both cases 00351 * the returned map will not contain the corresponding entry. 00352 * 00353 * @param vColKeys a collection of keys that may be in the named 00354 * cache 00355 * 00356 * @return a Map of keys to values for the specified keys passed in 00357 * <tt>col</tt> 00358 */ 00359 virtual Map::View getAll(Collection::View vColKeys) const; 00360 00361 00362 // ----- Map interface -------------------------------------------------- 00363 00364 public: 00365 /** 00366 * {@inheritDoc} 00367 */ 00368 virtual size32_t size() const; 00369 00370 /** 00371 * {@inheritDoc} 00372 */ 00373 virtual bool isEmpty() const; 00374 00375 /** 00376 * {@inheritDoc} 00377 */ 00378 virtual bool containsKey(Object::View vKey) const; 00379 00380 /** 00381 * {@inheritDoc} 00382 */ 00383 virtual bool containsValue(Object::View vValue) const; 00384 00385 /** 00386 * {@inheritDoc} 00387 */ 00388 virtual Object::Holder get(Object::View vKey) const; 00389 00390 /** 00391 * {@inheritDoc} 00392 */ 00393 virtual Object::Holder get(Object::View vKey); 00394 00395 /** 00396 * {@inheritDoc} 00397 */ 00398 virtual Object::Holder put(Object::View vKey, Object::Holder ohValue); 00399 00400 /** 00401 * {@inheritDoc} 00402 */ 00403 virtual Object::Holder remove(Object::View vKey); 00404 using Map::remove; 00405 00406 /** 00407 * {@inheritDoc} 00408 */ 00409 virtual void putAll(Map::View vMap); 00410 00411 /** 00412 * {@inheritDoc} 00413 */ 00414 virtual void clear(); 00415 00416 /** 00417 * {@inheritDoc} 00418 */ 00419 virtual Set::View keySet() const; 00420 00421 /** 00422 * {@inheritDoc} 00423 */ 00424 virtual Set::Handle keySet(); 00425 00426 /** 00427 * {@inheritDoc} 00428 */ 00429 virtual Collection::View values() const; 00430 00431 /** 00432 * {@inheritDoc} 00433 */ 00434 virtual Collection::Handle values(); 00435 00436 /** 00437 * {@inheritDoc} 00438 */ 00439 virtual Set::View entrySet() const; 00440 00441 /** 00442 * {@inheritDoc} 00443 */ 00444 virtual Set::Handle entrySet(); 00445 00446 00447 // ----- Object interface ----------------------------------------------- 00448 00449 public: 00450 /** 00451 * {@inheritDoc} 00452 */ 00453 virtual TypedHandle<const String> toString() const; 00454 00455 protected: 00456 /** 00457 * {@inheritDoc} 00458 */ 00459 virtual void onInit(); 00460 00461 00462 // ----- back map listener support -------------------------------------- 00463 00464 public: 00465 /** 00466 * Register the global back map listener. 00467 */ 00468 virtual void registerListener() const; 00469 00470 /** 00471 * Unregister the global back map listener. 00472 */ 00473 virtual void unregisterListener() const; 00474 00475 /** 00476 * Register the back map listener for the specified key. 00477 * 00478 * @param vKey the key 00479 */ 00480 virtual void registerListener(Object::View vKey) const; 00481 00482 /** 00483 * Register the back map listeners for the specified set of keys. 00484 * 00485 * @param hSetKeys the key set 00486 * 00487 * @since 12.2.1 00488 */ 00489 virtual void registerListeners(Set::Handle hSetKeys) const; 00490 00491 /** 00492 * Unregister the back map listener for the specified key. 00493 * 00494 * @param vKey the key 00495 */ 00496 virtual void unregisterListener(Object::View vKey) const; 00497 00498 /** 00499 * Unregister the back map listener for the specified keys. 00500 * 00501 * Note: all the keys in the passed-in set must be locked and will be 00502 * unlocked. 00503 * 00504 * @param hSetKeys Set of keys to unregister (and unlock) 00505 * 00506 * @since 12.2.1 00507 */ 00508 virtual void unregisterListeners(Set::Handle hSetKeys) const; 00509 00510 /** 00511 * Register the global front map listener. 00512 */ 00513 virtual void registerFrontListener() const; 00514 00515 /** 00516 * Unregister the global front map listener. 00517 */ 00518 virtual void unregisterFrontListener() const; 00519 00520 /** 00521 * Register back cache deactivation listener. 00522 */ 00523 virtual void registerDeactivationListener() const; 00524 00525 /** 00526 * Unregister back cache deactivation listener. 00527 */ 00528 virtual void unregisterDeactivationListener() const; 00529 00530 /** 00531 * Reset the front map 00532 */ 00533 virtual void resetFrontMap(); 00534 00535 /** 00536 * Ensure that a strategy has been choosen and that any appropriate 00537 * global listeners have been registered. 00538 * 00539 * @return the current strategy 00540 */ 00541 virtual InvalidationStrategy ensureInvalidationStrategy() const; 00542 00543 /** 00544 * Reset the "current invalidation strategy" flag. 00545 * 00546 * This method should be called <b>only</b> while the access to the 00547 * front map is fully synchronzied and the front map is empty to 00548 * prevent stalled data. 00549 */ 00550 virtual void resetInvalidationStrategy(); 00551 00552 // ----- inner class: PrimingListener ----------------------------------- 00553 00554 protected: 00555 /** 00556 * MapListener for back map responsible for keeping the front map 00557 * coherent with the back map. This listener is registered as a 00558 * synchronous listener for lite events (carrying only a key) and 00559 * generates a "priming" event when registered. 00560 * 00561 * @since 12.2.1 00562 */ 00563 class PrimingListener 00564 : public class_spec<PrimingListener, 00565 extends<MultiplexingMapListener>, 00566 implements<MapListenerSupport::PrimingListener> > 00567 { 00568 friend class factory<PrimingListener>; 00569 00570 // ----- constructors --------------------------------------- 00571 00572 protected: 00573 /** 00574 * Construct a PrimingListener 00575 * 00576 * @param hMap the map associated with this listener 00577 */ 00578 PrimingListener(CachingMap::Handle hMap); 00579 00580 // ----- MultiplexingMapListener interface ------------------ 00581 00582 /** 00583 * {@inheritDoc} 00584 */ 00585 virtual void onMapEvent(MapEvent::View vEvent); 00586 00587 // ---- data members ---------------------------------------- 00588 00589 protected: 00590 /** 00591 * The map associated with this listener. 00592 */ 00593 WeakHandle<CachingMap> m_whMap; 00594 }; 00595 00596 // ----- inner class: SimpleListener -------------------------------- 00597 00598 protected: 00599 /** 00600 * MapListener for back map responsible for keeping the front map 00601 * coherent with the back map. This listener is registered as a 00602 * synchronous listener for lite events (carrying only a key). 00603 */ 00604 class SimpleListener 00605 : public class_spec<SimpleListener, 00606 extends<MultiplexingMapListener>, 00607 implements<MapListenerSupport::SynchronousListener> > 00608 { 00609 friend class factory<SimpleListener>; 00610 00611 // ----- constructors --------------------------------------- 00612 00613 protected: 00614 /** 00615 * Construct a SimpleListener 00616 * 00617 * @param hMap the map associated with this listener 00618 */ 00619 SimpleListener(CachingMap::Handle hMap); 00620 00621 // ----- MultiplexingMapListener interface ------------------ 00622 00623 /** 00624 * {@inheritDoc} 00625 */ 00626 virtual void onMapEvent(MapEvent::View vEvent); 00627 00628 // ---- data members ---------------------------------------- 00629 00630 protected: 00631 /** 00632 * The map associated with this listener. 00633 */ 00634 WeakHandle<CachingMap> m_whMap; 00635 }; 00636 00637 // ----- inner class: DeactivationListener -------------------------- 00638 00639 protected: 00640 /** 00641 * DeactivationListener for the back NamedCache. 00642 * The primary goal of that listener is invalidation of the front map 00643 * when the back cache is destroyed or all storage nodes are stopped. 00644 */ 00645 class DeactivationListener 00646 : public class_spec<DeactivationListener, 00647 extends<AbstractMapListener>, 00648 implements<NamedCacheDeactivationListener> > 00649 { 00650 friend class factory<DeactivationListener>; 00651 00652 // ----- constructors --------------------------------------- 00653 00654 protected: 00655 /** 00656 * Construct a DeactivationListener 00657 * 00658 * @param hMap the map associated with this listener 00659 */ 00660 DeactivationListener(CachingMap::Handle hMap); 00661 00662 // ----- NamedCacheDeactivationListener interface ------------------ 00663 00664 /** 00665 * {@inheritDoc} 00666 */ 00667 virtual void entryDeleted(MapEvent::View vEvent); 00668 00669 /** 00670 * {@inheritDoc} 00671 */ 00672 virtual void entryUpdated(MapEvent::View vEvent); 00673 00674 // ---- data members ---------------------------------------- 00675 00676 protected: 00677 /** 00678 * The map associated with this listener. 00679 */ 00680 WeakHandle<CachingMap> m_whMap; 00681 }; 00682 00683 // ----- inner class: FrontMapListener ---------------------------------- 00684 00685 protected: 00686 /** 00687 * MapListener for back map responsible for keeping the front map 00688 * coherent with the back map. This listener is registered as a 00689 * synchronous listener for lite events (carrying only a key). 00690 */ 00691 class FrontMapListener 00692 : public class_spec<FrontMapListener, 00693 extends<AbstractMapListener>, 00694 implements<MapListenerSupport::SynchronousListener> > 00695 { 00696 friend class factory<FrontMapListener>; 00697 00698 // ----- constructors --------------------------------------- 00699 00700 protected: 00701 /** 00702 * Construct a FrontMapListener 00703 * 00704 * @param hMap the map associated with this listener 00705 */ 00706 FrontMapListener(CachingMap::Handle hMap); 00707 00708 // ----- MapListener interface ------------------------------ 00709 00710 public: 00711 /** 00712 * {@inheritDoc} 00713 */ 00714 virtual void entryDeleted(MapEvent::View vEvent); 00715 00716 // ---- helper registration methods ------------------------- 00717 00718 public: 00719 /** 00720 * Register this listener with the "front" map. 00721 */ 00722 virtual void registerWithMap(); 00723 00724 /** 00725 * Unregister this listener with the "front" map. 00726 */ 00727 virtual void unregisterFromMap(); 00728 00729 // ---- data members ---------------------------------------- 00730 00731 protected: 00732 /** 00733 * The filter associated with this listener. 00734 */ 00735 FinalView<Filter> f_vFilter; 00736 00737 /** 00738 * The map associated with this listener. 00739 */ 00740 WeakHandle<CachingMap> m_whMap; 00741 }; 00742 00743 00744 // ----- listener support ----------------------------------------------- 00745 00746 protected: 00747 /** 00748 * Factory pattern: instantiate back map listener. 00749 * 00750 * @param strategy the strategy to instantiate a back map listener for 00751 * 00752 * @return an instance of back map listener responsible for keeping 00753 * the front map coherent with the back map 00754 */ 00755 virtual MapListener::Handle instantiateBackMapListener(InvalidationStrategy strategy); 00756 00757 /** 00758 * Factory pattern: instantiate front map listener. 00759 * 00760 * @return an instance of front map listener 00761 */ 00762 virtual FrontMapListener::Handle instantiateFrontMapListener(); 00763 00764 /** 00765 * Validate the front map entry for the specified back map event. 00766 * 00767 * @param vEvent the MapEvent from the back map 00768 */ 00769 virtual void validate(MapEvent::View vEvent); 00770 00771 /** 00772 * Set up a thread local Set to hold all the keys that might be evicted 00773 * from the front cache. 00774 * 00775 * @return a Set to hold all the keys in the ThreadLocal object or null 00776 * if the bulk unregistering is not needed 00777 * 00778 * @since 12.2.1 00779 */ 00780 virtual Set::Handle setKeyHolder() const; 00781 00782 /** 00783 * Remove the key holder from the ThreadLocal object. 00784 * 00785 * @since 12.2.1 00786 */ 00787 virtual void removeKeyHolder() const; 00788 00789 /** 00790 * Check if the specified event is a "priming" one. 00791 * 00792 * @since 12.2.1 00793 */ 00794 static bool isPriming(MapEvent::View vEvent); 00795 00796 // ----- constants and data fields ------------------------------------- 00797 00798 protected : 00799 /** 00800 * The "back" map, considered to be "complete" yet "expensive" to 00801 * access. 00802 */ 00803 mutable FinalHandle<CacheMap> f_hMapBack; 00804 00805 /** 00806 * The "front" map, considered to be "incomplete" yet "inexpensive" to 00807 * access. 00808 */ 00809 mutable FinalHandle<CacheMap> f_hMapFront; 00810 00811 /** 00812 * The invalidation strategy that this map is to use. 00813 */ 00814 mutable InvalidationStrategy m_strategyTarget; 00815 00816 /** 00817 * The current invalidation strategy, which at times could be different 00818 * from the target strategy. 00819 */ 00820 mutable InvalidationStrategy m_strategyCurrent; 00821 00822 /** 00823 * An optional listener for the "back" map. 00824 */ 00825 mutable MemberHandle<MapListener> m_hListener; 00826 00827 /** 00828 * An optional Simplelistener for the "back" map. 00829 * @see note in CachingMap::onInit() 00830 * 00831 * @since 12.2.1 00832 */ 00833 mutable MemberHandle<MapListener> m_hSimpleListener; 00834 00835 /** 00836 * An optional DeactivationListener for the "back" map. 00837 * @see note in CachingMap::onInit() 00838 * 00839 * @since 12.1.3 00840 */ 00841 mutable MemberHandle<DeactivationListener> m_hListenerDeactivation; 00842 00843 /** 00844 * An optional listener for the "front" map. 00845 */ 00846 mutable FinalHandle<FrontMapListener> f_hListenerFront; 00847 00848 /** 00849 * A filter that selects events for the back-map listener. 00850 */ 00851 mutable MemberHandle<Filter> m_hFilterListener; 00852 00853 /** 00854 * The ConcurrentMap to keep track of front map updates. 00855 * Values are list of events received by the listener while the 00856 * corresponding key was locked. Use of LOCK_ALL is restricited to 00857 * non-blocking operations to prevent deadlock with the service thread. 00858 */ 00859 mutable FinalHandle<ConcurrentMap> f_hMapControl; 00860 00861 /** 00862 * The CacheStatistics object maintained by this cache. 00863 */ 00864 mutable FinalHandle<SimpleCacheStatistics> f_hStats; 00865 00866 /** 00867 * The rough (ie unsynchronized) number of times the front map entries 00868 * that were present in the front map were invalidated by the listener. 00869 */ 00870 mutable /*volatile stat*/ int64_t m_cInvalidationHits; 00871 00872 /** 00873 * The rough (ie unsynchronized) number of times the front map entries 00874 * that were absent in the front map received invalidation event. 00875 */ 00876 mutable /*volatile stat*/ int64_t m_cInvalidationMisses; 00877 00878 /** 00879 * The total number of registerListener(oKey) operations. 00880 */ 00881 mutable /*volatile stat*/ int64_t m_cRegisterListener; 00882 00883 /** 00884 * True if the cache has been released. 00885 */ 00886 bool m_fReleased; 00887 00888 /** 00889 * The ThreadLocal to hold all the keys that are evicted while the front cache 00890 * is updated during get or getAll operation. 00891 * 00892 * @since 12.2.1 00893 */ 00894 mutable FinalHandle<ThreadLocalReference> f_htloKeys; 00895 00896 // ----- constants ------------------------------------------------------ 00897 00898 protected : 00899 /** 00900 * A unique Object that serves as a control key for global operations 00901 * such as clear and release and synchronization point for the current 00902 * strategy change. 00903 */ 00904 FinalView<Object> f_vKeyGlobal; 00905 }; 00906 00907 COH_CLOSE_NAMESPACE3 00908 00909 #endif // COH_CACHING_MAP_HPP