00001 /* 00002 * ContinuousQueryCache.hpp 00003 * 00004 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 00005 * 00006 * Oracle is a registered trademarks of Oracle Corporation and/or its 00007 * affiliates. 00008 * 00009 * This software is the confidential and proprietary information of Oracle 00010 * Corporation. You shall not disclose such confidential and proprietary 00011 * information and shall use it only in accordance with the terms of the 00012 * license agreement you entered into with Oracle. 00013 * 00014 * This notice may not be removed or altered. 00015 */ 00016 #ifndef COH_CONTINUOUS_QUERY_CACHE_HPP 00017 #define COH_CONTINUOUS_QUERY_CACHE_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/net/CacheService.hpp" 00022 #include "coherence/net/NamedCache.hpp" 00023 #include "coherence/util/AbstractMap.hpp" 00024 #include "coherence/util/Comparator.hpp" 00025 #include "coherence/util/filter/MapEventFilter.hpp" 00026 #include "coherence/util/MapEvent.hpp" 00027 #include "coherence/util/MapIndex.hpp" 00028 #include "coherence/util/MapListener.hpp" 00029 #include "coherence/util/MultiplexingMapListener.hpp" 00030 #include "coherence/util/Set.hpp" 00031 #include "coherence/util/ValueExtractor.hpp" 00032 00033 COH_OPEN_NAMESPACE3(coherence,net,cache) 00034 00035 using coherence::net::CacheService; 00036 using coherence::net::NamedCache; 00037 using coherence::util::AbstractMap; 00038 using coherence::util::Comparator; 00039 using coherence::util::Filter; 00040 using coherence::util::filter::MapEventFilter; 00041 using coherence::util::MapEvent; 00042 using coherence::util::MapIndex; 00043 using coherence::util::MapListener; 00044 using coherence::util::MultiplexingMapListener; 00045 using coherence::util::Set; 00046 using coherence::util::ValueExtractor; 00047 00048 00049 /** 00050 * Create a materialized view of a NamedCache using the Coherence 00051 * <i>Continuous Query</i> capability. 00052 * 00053 * @author tb, js 2008.07.23 00054 */ 00055 class COH_EXPORT ContinuousQueryCache 00056 : public class_spec<ContinuousQueryCache, 00057 extends<AbstractMap>, 00058 implements<NamedCache> > 00059 { 00060 friend class factory<ContinuousQueryCache>; 00061 00062 // ----- constructors --------------------------------------------------- 00063 00064 protected: 00065 /** 00066 * Create a materialized view of a NamedCache using a Filter. A 00067 * materialized view is an implementation of <i>Continuous Query</i> 00068 * exposed through the standard NamedCache API. This constructor 00069 * allows a client to receive all events, including those that result 00070 * from the initial population of the ContinuousQueryCache. In other 00071 * words, all contents of the ContinuousQueryCache will be delivered 00072 * to the listener as a sequence of events, including those items that 00073 * already exist in the underlying (unfiltered) cache. 00074 * 00075 * @param hCache the NamedCache to create a view of 00076 * @param vFilter the Filter that defines the view 00077 * @param fCacheValues pass true to cache both the keys and values of 00078 * the materialized view locally, or false to 00079 * only cache the keys 00080 * @param hListener an initial MapListener that will receive all 00081 * the events from the ContinuousQueryCache, 00082 * including those corresponding to its initial 00083 * population 00084 */ 00085 ContinuousQueryCache(NamedCache::Handle hCache, 00086 Filter::View vFilter, bool fCacheValues = false, 00087 MapListener::Handle hListener = NULL); 00088 00089 00090 // ----- accessors ------------------------------------------------------ 00091 00092 public: 00093 /** 00094 * Obtain the NamedCache that this ContinuousQueryCache is based on. 00095 * 00096 * @return the underlying NamedCache 00097 */ 00098 virtual NamedCache::View getCache() const; 00099 00100 /** 00101 * Obtain the NamedCache that this ContinuousQueryCache is based on. 00102 * 00103 * @return the underlying NamedCache 00104 */ 00105 virtual NamedCache::Handle getCache(); 00106 00107 /** 00108 * Obtain the Filter that this ContinuousQueryCache is using to query 00109 * the underlying NamedCache. 00110 * 00111 * @return the Filter that this cache uses to select its contents from 00112 * the underlying NamedCache 00113 */ 00114 virtual Filter::View getFilter() const; 00115 00116 /** 00117 * Determine if this ContinuousQueryCache caches values locally. 00118 * 00119 * @return true if this object caches values locally, and false if it 00120 * relies on the underlying NamedCache 00121 */ 00122 virtual bool isCacheValues() const; 00123 00124 /** 00125 * Modify the local-caching option for the ContinuousQueryCache. By 00126 * changing this value from <tt>false</tt> to <tt>true</tt>, the 00127 * ContinuousQueryCache will fully realize its contents locally and 00128 * maintain them coherently in a manner analogous to the Coherence 00129 * NearCache. By changing this value from <tt>true</tt> to 00130 * <tt>false</tt>, the ContinuousQueryCache will discard its locally 00131 * cached data and rely on the underlying NamedCache. 00132 * 00133 * @param fCacheValues pass true to enable local caching, or false to 00134 * disable it 00135 */ 00136 virtual void setCacheValues(bool fCacheValues); 00137 00138 /** 00139 * Determine if this ContinuousQueryCache disallows data modification 00140 * operations. 00141 * 00142 * @return true if this ContinuousQueryCache has been configured as 00143 * read-only 00144 */ 00145 virtual bool isReadOnly() const; 00146 00147 /** 00148 * Modify the read-only option for the ContinuousQueryCache. Note that 00149 * the cache can be made read-only, but the opposite (making it 00150 * mutable) is explicitly disallowed. 00151 * 00152 * @param fReadOnly pass true to prohibit clients from making 00153 * modifications to this cache 00154 */ 00155 virtual void setReadOnly(bool fReadOnly); 00156 00157 00158 /** 00159 * Obtain the state of the ContinousQueryCache. 00160 * 00161 * @return one of the STATE_ enums 00162 */ 00163 virtual int32_t getState() const; 00164 00165 /** 00166 * Return a reconnection interval (in milliseconds). This value 00167 * indicates how often the ContinuousQueryCache should attempt to 00168 * re-connect with the underlying [clustered] cache in case the 00169 * connection is severed. 00170 * 00171 * @return a reconnection interval (in milliseconds) 00172 */ 00173 virtual int64_t getReconnectInterval() const; 00174 00175 /** 00176 * Specify a reconnection interval (in milliseconds). This value 00177 * indicates how often the ContinuousQueryCache should attempt to 00178 * re-connect with the underlying [clustered] cache in case the 00179 * connection is severed. 00180 * 00181 * @param cReconnectMillis reconnection interval (in milliseconds). 00182 * The value of zero means that the ContinuousQueryCache cannot 00183 * be used when not connected. If the value is positive, the 00184 * local content could be accessed (read-only) even if 00185 * connection is severed. 00186 */ 00187 virtual void setReconnectInterval(int64_t cReconnectMillis); 00188 00189 protected: 00190 /** 00191 * Create the internal cache used by the ContinuousQueryCache. 00192 * 00193 * @return a new ObservableMap that will represent the materialized 00194 * view of the ContinuousQueryCache 00195 */ 00196 virtual ObservableMap::Handle instantiateInternalCache(); 00197 00198 /** 00199 * Obtain a reference to the internal cache. The internal cache 00200 * maintains all of the keys in the ContinuousQueryCache, and if 00201 * isCacheValues()is true, it also maintains the up-to-date values 00202 * corresponding to those keys. 00203 * 00204 * @return the internal cache that represents the materialized view of 00205 * the ContinuousQueryCache 00206 */ 00207 virtual ObservableMap::View getInternalCache() const; 00208 00209 /** 00210 * Obtain a reference to the internal cache. The internal cache 00211 * maintains all of the keys in the ContinuousQueryCache, and if 00212 * isCacheValues()is true, it also maintains the up-to-date values 00213 * corresponding to those keys. 00214 * 00215 * @return the internal cache that represents the materialized view of 00216 * the ContinuousQueryCache 00217 */ 00218 virtual ObservableMap::Handle getInternalCache(); 00219 00220 /** 00221 * Determine if the ContinuousQueryCache has any listeners that cannot 00222 * be served by this Map listening to lite events. 00223 * 00224 * @return true iff there is at least one listener 00225 */ 00226 virtual bool isObserved() const; 00227 00228 /** 00229 * Specify whether the ContinuousQueryCache has any listeners that 00230 * cannot be served by this Map listening to lite events. 00231 * 00232 * @param fObserved true iff there is at least one listener 00233 */ 00234 virtual void setObserved(bool fObserved); 00235 00236 /** 00237 * Change the state of the ContinousQueryCache. 00238 * 00239 * @param nState one of the STATE_ enums 00240 */ 00241 virtual void changeState(int32_t nState) const; 00242 00243 00244 // ----- Map interface -------------------------------------------------- 00245 00246 public: 00247 /** 00248 * {@inheritDoc} 00249 */ 00250 virtual Object::Holder get(Object::View vKey) const; 00251 00252 /** 00253 * {@inheritDoc} 00254 */ 00255 using Map::get; 00256 00257 /** 00258 * {@inheritDoc} 00259 */ 00260 virtual Object::Holder put(Object::View vKey, Object::Holder ohValue); 00261 00262 /** 00263 * {@inheritDoc} 00264 */ 00265 virtual Object::Holder remove(Object::View vKey); 00266 00267 /** 00268 * {@inheritDoc} 00269 */ 00270 virtual void putAll(Map::View vMap); 00271 00272 /** 00273 * {@inheritDoc} 00274 */ 00275 virtual void clear(); 00276 00277 /** 00278 * {@inheritDoc} 00279 */ 00280 virtual Set::View keySet() const; 00281 00282 /** 00283 * {@inheritDoc} 00284 */ 00285 virtual Set::Handle keySet(); 00286 00287 /** 00288 * {@inheritDoc} 00289 */ 00290 virtual Set::View entrySet() const; 00291 00292 /** 00293 * {@inheritDoc} 00294 */ 00295 virtual Set::Handle entrySet(); 00296 00297 /** 00298 * {@inheritDoc} 00299 */ 00300 virtual size32_t size() const; 00301 00302 00303 // ----- CacheMap interface --------------------------------------------- 00304 00305 public: 00306 /** 00307 * {@inheritDoc} 00308 */ 00309 virtual Map::View getAll(Collection::View vKeys) const; 00310 00311 /** 00312 * {@inheritDoc} 00313 */ 00314 virtual Object::Holder put(Object::View vKey, 00315 Object::Holder ohValue, int64_t cMillis); 00316 00317 00318 // ----- ObservableMap interface ---------------------------------------- 00319 00320 public: 00321 /** 00322 * {@inheritDoc} 00323 */ 00324 virtual void addKeyListener(MapListener::Handle hListener, 00325 Object::View vKey, bool fLite); 00326 00327 /** 00328 * {@inheritDoc} 00329 */ 00330 virtual void removeKeyListener(MapListener::Handle hListener, 00331 Object::View vKey); 00332 00333 /** 00334 * {@inheritDoc} 00335 */ 00336 virtual void addFilterListener(MapListener::Handle hListener, 00337 Filter::View vFilter = NULL, bool fLite = false); 00338 00339 /** 00340 * {@inheritDoc} 00341 */ 00342 virtual void removeFilterListener(MapListener::Handle hListener, 00343 Filter::View vFilter = NULL); 00344 00345 00346 // ----- QueryMap interface --------------------------------------------- 00347 00348 public: 00349 /** 00350 * {@inheritDoc} 00351 */ 00352 virtual Set::View keySet(Filter::View vFilter) const; 00353 00354 /** 00355 * {@inheritDoc} 00356 */ 00357 virtual Set::View entrySet(Filter::View vFilter) const; 00358 00359 /** 00360 * {@inheritDoc} 00361 */ 00362 virtual Set::View entrySet(Filter::View vFilter, 00363 Comparator::View vComparator) const; 00364 00365 /** 00366 * {@inheritDoc} 00367 */ 00368 virtual void addIndex(ValueExtractor::View vExtractor, 00369 bool fOrdered, Comparator::View vComparator); 00370 00371 /** 00372 * {@inheritDoc} 00373 */ 00374 virtual void removeIndex(ValueExtractor::View vExtractor); 00375 00376 00377 // ----- InvocableMap interface ----------------------------------------- 00378 00379 public: 00380 /** 00381 * {@inheritDoc} 00382 */ 00383 virtual Object::Holder invoke(Object::View vKey, 00384 InvocableMap::EntryProcessor::Handle hAgent); 00385 00386 /** 00387 * {@inheritDoc} 00388 */ 00389 virtual Map::View invokeAll(Collection::View vCollKeys, 00390 InvocableMap::EntryProcessor::Handle hAgent); 00391 00392 /** 00393 * {@inheritDoc} 00394 */ 00395 virtual Map::View invokeAll(Filter::View vFilter, 00396 InvocableMap::EntryProcessor::Handle hAgent); 00397 00398 /** 00399 * {@inheritDoc} 00400 */ 00401 virtual Object::Holder aggregate(Collection::View vCollKeys, 00402 InvocableMap::EntryAggregator::Handle hAgent) const; 00403 00404 /** 00405 * {@inheritDoc} 00406 */ 00407 virtual Object::Holder aggregate(Filter::View vFilter, 00408 InvocableMap::EntryAggregator::Handle hAgent) const; 00409 00410 00411 // ----- ConcurrentMap interface ---------------------------------------- 00412 00413 public: 00414 /** 00415 * {@inheritDoc} 00416 */ 00417 virtual bool lock(Object::View vKey, int64_t cWait) const; 00418 00419 /** 00420 * {@inheritDoc} 00421 */ 00422 virtual bool lock(Object::View vKey) const; 00423 00424 /** 00425 * {@inheritDoc} 00426 */ 00427 virtual bool unlock(Object::View vKey) const; 00428 00429 00430 // ----- NamedCache interface ------------------------------------------- 00431 00432 public: 00433 /** 00434 * {@inheritDoc} 00435 */ 00436 virtual String::View getCacheName() const; 00437 00438 /** 00439 * {@inheritDoc} 00440 */ 00441 virtual CacheService::Handle getCacheService(); 00442 00443 /** 00444 * {@inheritDoc} 00445 */ 00446 virtual CacheService::View getCacheService() const; 00447 00448 /** 00449 * {@inheritDoc} 00450 */ 00451 virtual bool isActive() const; 00452 00453 /** 00454 * {@inheritDoc} 00455 */ 00456 virtual void release(); 00457 00458 /** 00459 * {@inheritDoc} 00460 */ 00461 virtual void destroy(); 00462 00463 00464 // ----- inner class: AsynchronousEvent --------------------------------- 00465 00466 public: 00467 /** 00468 * Encapsulates an event and a listener that are to be dispatched 00469 * asynchronously. 00470 */ 00471 class AsynchronousEvent 00472 : public class_spec<AsynchronousEvent> 00473 { 00474 friend class factory<AsynchronousEvent>; 00475 00476 // ----- constructors/destructor ---------------------------- 00477 00478 protected: 00479 /** 00480 * @internal 00481 */ 00482 AsynchronousEvent(MapEvent::Handle hEvent, 00483 MapListener::Handle hListener); 00484 00485 // ----- AsynchronousEvent interface ------------------------- 00486 00487 public: 00488 /** 00489 * Dispatch the event. 00490 */ 00491 virtual void dispatch(); 00492 00493 // ----- data members --------------------------------------- 00494 00495 protected: 00496 /** 00497 * The event to dispatch. 00498 */ 00499 MemberHandle<MapEvent> m_hEvent; 00500 00501 /** 00502 * The listener to receive the event. 00503 */ 00504 MemberHandle<MapListener> m_hListener; 00505 }; 00506 00507 00508 // ----- inner interface: EventQueueDaemon ------------------------------ 00509 00510 public: 00511 /** 00512 * Daemon thread used to dispatch messages asynchronously. 00513 */ 00514 class COH_EXPORT TaskDaemon 00515 : public interface_spec<TaskDaemon> 00516 { 00517 public: 00518 /** 00519 * Schedule an event for asynchronous processing 00520 * 00521 * @param hEvent the event to dispatch 00522 */ 00523 virtual void scheduleDispatch( 00524 AsynchronousEvent::Handle hEvent) = 0; 00525 00526 /** 00527 * Start the daemon thread. 00528 */ 00529 virtual void start() = 0; 00530 00531 /** 00532 * Stop the daemon thread. 00533 */ 00534 virtual void stop() = 0; 00535 }; 00536 00537 00538 // ----- internal ------------------------------------------------------- 00539 00540 protected: 00541 /** 00542 * Return a filter which merges the ContinousQueueCache's filter with 00543 * the supplied filter. 00544 * 00545 * @param vFilter the filter to merge with this cache's filter 00546 * 00547 * @return the merged filter 00548 */ 00549 virtual Filter::View mergeFilter(Filter::View vFilter) const; 00550 00551 /** 00552 * Check the read-only setting to verify that the cache is NOT 00553 * read-only. 00554 * 00555 * @throws IllegalStateException if the ContinuousQueryCache is 00556 * read-only 00557 */ 00558 virtual void checkReadOnly() const; 00559 00560 /** 00561 * Check the passed value to verify that it does belong in this 00562 * ContinuousQueryCache. 00563 * 00564 * @param vEntry a key value pair to check. 00565 * 00566 * @throws IllegalArgumentException if the entry does not belong in 00567 * this ContinuousQueryCache (based on the cache's filter) 00568 */ 00569 virtual void checkEntry(Map::Entry::View vEntry); 00570 00571 /** 00572 * Check the passed value to verify that it does belong in this 00573 * ContinuousQueryCache. 00574 * 00575 * @param vKey the key for the entry 00576 * @param ohValue the value for the entry 00577 * 00578 * @throws IllegalArgumentException if the entry does not belong in 00579 * this ContinuousQueryCache (based on the cache's filter) 00580 */ 00581 virtual void checkEntry(Object::View vKey, Object::Holder ohValue); 00582 00583 /** 00584 * Set up the listeners that keep the ContinuousQueryCache up-to-date. 00585 * 00586 * @param fReload pass true to force a data reload 00587 */ 00588 virtual void configureSynchronization(bool fReload) const; 00589 00590 /** 00591 * Ensure that the ContinousQueryCache listeners have been registered 00592 * and its content synchronized with the underlying NamedCache. 00593 * 00594 * @param fReload the value to pass to the #configureSynchronization 00595 * method if the ContinousQueryCache needs to be 00596 * configured and synchronized 00597 */ 00598 virtual void ensureSynchronized(bool fReload) const; 00599 00600 /** 00601 * Called when an event has occurred. Allows the key to be logged as 00602 * requiring deferred synchronization if the event occurs during the 00603 * configuration or population of the ContinuousQueryCache. 00604 * 00605 * @param vKey the key that the event is related to 00606 * 00607 * @return true if the event processing has been deferred 00608 */ 00609 virtual bool isEventDeferred(Object::View vKey) const; 00610 00611 /** 00612 * Removes the mapping for this key from this map if present. This 00613 * method exists to allow sub-classes to optmiize remove 00614 * functionalitly for situations in which the original value is not 00615 * required. 00616 * 00617 * @param vKey key whose mapping is to be removed from the map 00618 * 00619 * @return true iff the Map changed as the result of this operation 00620 */ 00621 virtual bool removeBlind(Object::View vKey); 00622 00623 /** 00624 * Obtain a set of keys that are represented by this Map. 00625 * 00626 * @return an internal Set of keys that are contained by this Map 00627 */ 00628 virtual Set::View getInternalKeySet() const; 00629 00630 /** 00631 * Return the underlying cache. 00632 * 00633 * @return the underlying cache 00634 */ 00635 virtual NamedCache::Handle getCacheInternal() const; 00636 00637 /** 00638 * Factory Method: Instantiate a MapListener for adding items to the 00639 * query, and (if there are listeners on the ContinuousQueryCache) for 00640 * dispatching inserts and updates. 00641 * 00642 * @return a new MapListener that will add items to and update items 00643 * in the ContinuousQueryCache 00644 */ 00645 virtual MapListener::Handle instantiateAddListener() const; 00646 00647 /** 00648 * Factory Method: Instantiate a MapListener for evicting items from 00649 * the query. 00650 * 00651 * @return a new MapListener that will listen to all events that will 00652 * remove items from the ContinuousQueryCache 00653 */ 00654 virtual MapListener::Handle instantiateRemoveListener() const; 00655 00656 /** 00657 * Instantiate and register a MemberListener with the underlying 00658 * caches's service. 00659 * <p> 00660 * The primary goal of that listener is invalidation of the front map 00661 * in case of the service [automatic] restart. 00662 */ 00663 virtual void registerServiceListener() const; 00664 00665 /** 00666 * Unregister underlying caches's service member listener. 00667 */ 00668 virtual void unregisterServiceListener(); 00669 00670 /** 00671 * Factory Method: Instantiate a listener on the internal map that 00672 * will direct events to the passed listener, either synchronously or 00673 * asynchronously as appropriate. 00674 * 00675 * @param hListener the listener to route to 00676 * 00677 * @return a new EventRouter specific to the passed listener 00678 */ 00679 virtual MultiplexingMapListener::Handle instantiateEventRouter( 00680 MapListener::Handle hListener); 00681 00682 /** 00683 * Create a self-processing event queue. 00684 * 00685 * @return a QueueProcessor onto which events can be placed in order 00686 * to be dispatched asynchronously 00687 */ 00688 virtual TaskDaemon::Handle instantiateEventQueue(); 00689 00690 /** 00691 * Obtain this ContinuousQueryCache's event queue. 00692 * 00693 * @return the event queue that this ContinuousQueryCache uses to 00694 * dispatch its events to its non-synchronous listeners 00695 */ 00696 virtual TaskDaemon::Handle getEventQueue(); 00697 00698 /** 00699 * Obtain the existing event queue or create one if none exists. 00700 * 00701 * @return the event queue that this ContinuousQueryCache uses to 00702 * dispatch its events to its non-synchronous listeners 00703 */ 00704 virtual TaskDaemon::Handle ensureEventQueue(); 00705 00706 /** 00707 * Shut down running event queue. 00708 */ 00709 virtual void shutdownEventQueue(); 00710 00711 /** 00712 * Create a new key set. 00713 * 00714 * @return the new key set 00715 */ 00716 virtual Set::Handle instantiateKeySet(); 00717 00718 /** 00719 * Create a new EntrySet 00720 * 00721 * @return the new empty set 00722 */ 00723 virtual Set::Handle instantiateEntrySet(); 00724 00725 /** 00726 * Ensure that the map of indexes maintained by this cache exists. 00727 * 00728 * @return the map of indexes. 00729 */ 00730 virtual Map::Handle ensureIndexMap(); 00731 00732 /** 00733 * Get the map of indexes maintained by this cache. 00734 * 00735 * @return the map of indexes. 00736 */ 00737 virtual Map::View getIndexMap() const; 00738 00739 /** 00740 * Get the map of indexes maintained by this cache. 00741 * 00742 * @return the map of indexes. 00743 */ 00744 virtual Map::Handle getIndexMap(); 00745 00746 /** 00747 * Release the the entire index map. 00748 */ 00749 virtual void releaseIndexMap(); 00750 00751 00752 // ----- Object interface ----------------------------------------------- 00753 00754 protected: 00755 /** 00756 * {@inheritDoc} 00757 */ 00758 virtual void onInit(); 00759 00760 00761 // ----- constants ------------------------------------------------------ 00762 00763 public: 00764 /** 00765 * State: Disconnected state. The content of the ContinousQueryCache is 00766 * not fully synchronized with the underlying [clustered] cache. If the 00767 * value of the ReconnectInterval property is zero, it must be 00768 * configured (synchronized) before it can be used. 00769 */ 00770 static const int32_t STATE_DISCONNECTED = 0; 00771 00772 /** 00773 * State: The ContinuousQueryCache is configuring or re-configuring its 00774 * listeners and content. 00775 */ 00776 static const int32_t STATE_CONFIGURING = 1; 00777 00778 /** 00779 * State: The ContinousQueryCache has been configured. 00780 */ 00781 static const int32_t STATE_CONFIGURED = 2; 00782 00783 /** 00784 * State: The ContinousQueryCache has been configured and fully 00785 * synchronized. 00786 */ 00787 static const int32_t STATE_SYNCHRONIZED = 3; 00788 00789 00790 // ----- data members --------------------------------------------------- 00791 00792 protected: 00793 /** 00794 * The underlying NamedCache object. 00795 */ 00796 mutable MemberHandle<NamedCache> m_hCache; 00797 00798 /** 00799 * The name of the underlying NamedCache. A copy is kept here because 00800 * the reference to the underlying NamedCache is discarded when this 00801 * cache is released. 00802 */ 00803 FinalView<String> m_vsName; 00804 00805 /** 00806 * The filter that represents the subset of information from the 00807 * underlying NamedCache that this ContinuousQueryCache represents. 00808 */ 00809 FinalView<Filter> m_vFilter; 00810 00811 /** 00812 * The option of whether or not to locally cache values. 00813 */ 00814 bool m_fCacheValues; 00815 00816 /** 00817 * The option to disallow modifications through this 00818 * ContinuousQueryCache interface. 00819 */ 00820 bool m_fReadOnly; 00821 00822 /** 00823 * The interval (in millisceonds) that indicates how often the 00824 * ContinuousQueryCache should attempt to synchronize its content with 00825 * the underlying cache in case the connection is severed. 00826 */ 00827 int64_t m_cReconnectMillis; 00828 00829 /** 00830 * The timestamp when the synchronization was last attempted. 00831 */ 00832 mutable Volatile<int64_t> m_ldtConnectionTimestamp; 00833 00834 /** 00835 * The keys that are in this ContinuousQueryCache, and (if 00836 * m_fCacheValues is true) the corresponding values as well. 00837 */ 00838 mutable MemberHandle<ObservableMap> m_hMapLocal; 00839 00840 /** 00841 * State of the ContinousQueryCache. One of the STATE_* enums. 00842 */ 00843 mutable Volatile<int32_t> m_nState; 00844 00845 /** 00846 * While the ContinuousQueryCache is configuring or re-configuring its 00847 * listeners and content, any events that are received must be logged 00848 * to ensure that the corresponding content is in sync. 00849 */ 00850 mutable MemberHandle<Map> m_hMapSyncReq; 00851 00852 /** 00853 * The event queue for this ContinuousQueryCache. 00854 */ 00855 MemberHandle<TaskDaemon> m_hTaskQueue; 00856 00857 /** 00858 * Keeps track of whether the ContinuousQueryCache has listeners that 00859 * require this cache to cache values. 00860 */ 00861 bool m_fListeners; 00862 00863 /** 00864 * The MapEventFilter that uses the ContinuousQueryCache's filter to 00865 * select events that would add elements to this cache's contents. 00866 */ 00867 mutable MemberView<MapEventFilter> m_vFilterAdd; 00868 00869 /** 00870 * The MapEventFilter that uses the ContinuousQueryCache's filter to 00871 * select events that would remove elements from this cache's contents. 00872 */ 00873 mutable MemberView<MapEventFilter> m_vFilterRemove; 00874 00875 /** 00876 * The listener that gets information about what should be in this 00877 * cache. 00878 */ 00879 mutable WeakHandle<MapListener> m_whListenerAdd; 00880 00881 /** 00882 * The listener that gets information about what should be thrown out 00883 * of this cache. 00884 */ 00885 mutable WeakHandle<MapListener> m_whListenerRemove; 00886 00887 /** 00888 * The cache service MemberListener for the underlying NamedCache. 00889 */ 00890 mutable WeakHandle<MemberListener> m_whListenerService; 00891 00892 /* 00893 * The initial MapListener that will receive all the events from the 00894 * ContinuousQueryCache, including those corresponding to its initial 00895 * population. 00896 */ 00897 MemberHandle<MapListener> m_hListener; 00898 00899 /** 00900 * The map of indexes maintained by this cache. The keys of the Map are 00901 * ValueExtractor objects, and for each key, the corresponding value 00902 * stored in the Map is a MapIndex object. 00903 */ 00904 FinalHandle<Map> m_hMapIndex; 00905 00906 /** 00907 * KeySet backed by this cache 00908 */ 00909 MemberHandle<Set> m_hSetKeys; 00910 00911 /** 00912 * EntrySet backed by this cache 00913 */ 00914 MemberHandle<Set> m_hSetEntries; 00915 00916 00917 // ----- friends -------------------------------------------------------- 00918 00919 friend class AddListener; 00920 friend class RemoveListener; 00921 friend class ServiceListener; 00922 friend class EventRouter; 00923 friend class KeySet; 00924 friend class EntrySet; 00925 friend class KeySetMuterator; 00926 friend class EntrySetIterator; 00927 }; 00928 00929 COH_CLOSE_NAMESPACE3 00930 00931 #endif // COH_CONTINUOUS_QUERY_CACHE_HPP 00932