Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.2.1.2.0)

E77779-01

coherence/net/cache/ContinuousQueryCache.hpp

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