16 #ifndef HAZELCAST_CLIENT_NEARCACHEDMIXEDMAP_H_ 17 #define HAZELCAST_CLIENT_NEARCACHEDMIXEDMAP_H_ 19 #include "hazelcast/client/internal/nearcache/NearCache.h" 20 #include "hazelcast/client/protocol/codec/MapAddNearCacheEntryListenerCodec.h" 21 #include "hazelcast/client/mixedtype/ClientMapProxy.h" 22 #include "hazelcast/client/config/NearCacheConfig.h" 24 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) 26 #pragma warning(disable: 4251) //for dll export 63 bool containsKeyInternal(
const serialization::pimpl::Data &keyData);
66 boost::shared_ptr<TypedData> getInternal(serialization::pimpl::Data &keyData);
69 virtual std::auto_ptr<serialization::pimpl::Data> removeInternal(
70 const serialization::pimpl::Data &key);
73 virtual bool removeInternal(
74 const serialization::pimpl::Data &key,
const serialization::pimpl::Data &value);
76 virtual void removeAllInternal(
const serialization::pimpl::Data &predicateData);
78 virtual void deleteInternal(
const serialization::pimpl::Data &key);
80 virtual bool tryRemoveInternal(
const serialization::pimpl::Data &key,
long timeoutInMillis);
83 tryPutInternal(
const serialization::pimpl::Data &key,
const serialization::pimpl::Data &value,
84 long timeoutInMillis);
86 virtual std::auto_ptr<serialization::pimpl::Data> putInternal(
const serialization::pimpl::Data &key,
87 const serialization::pimpl::Data &value,
88 long timeoutInMillis);
90 virtual void tryPutTransientInternal(
const serialization::pimpl::Data &key,
91 const serialization::pimpl::Data &value,
int ttlInMillis);
93 virtual std::auto_ptr<serialization::pimpl::Data>
94 putIfAbsentInternal(
const serialization::pimpl::Data &keyData,
95 const serialization::pimpl::Data &valueData,
98 virtual bool replaceIfSameInternal(
const serialization::pimpl::Data &keyData,
99 const serialization::pimpl::Data &valueData,
100 const serialization::pimpl::Data &newValueData);
102 virtual std::auto_ptr<serialization::pimpl::Data>
103 replaceInternal(
const serialization::pimpl::Data &keyData,
104 const serialization::pimpl::Data &valueData);
107 setInternal(
const serialization::pimpl::Data &keyData,
const serialization::pimpl::Data &valueData,
110 virtual bool evictInternal(
const serialization::pimpl::Data &keyData);
112 virtual EntryVector getAllInternal(
const ClientMapProxy::PID_TO_KEY_MAP &pIdToKeyData);
114 virtual std::auto_ptr<serialization::pimpl::Data>
115 executeOnKeyInternal(
const serialization::pimpl::Data &keyData,
116 const serialization::pimpl::Data &processor);
119 putAllInternal(
const std::map<int, EntryVector> &entries);
122 typedef std::map<boost::shared_ptr<serialization::pimpl::Data>,
bool> MARKER_MAP;
124 map::impl::nearcache::KeyStateMarker *getKeyStateMarker();
126 void addNearCacheInvalidateListener(std::auto_ptr<client::impl::BaseEventHandler> handler);
128 class ClientMapAddNearCacheEventHandler
129 :
public protocol::codec::MapAddNearCacheEntryListenerCodec::AbstractEventHandler {
131 ClientMapAddNearCacheEventHandler(
137 void beforeListenerRegister() {
142 void onListenerRegister() {
147 virtual void handleIMapInvalidationEventV10(std::auto_ptr<Data> key) {
149 if (key.get() == NULL) {
152 nearCache->remove(boost::shared_ptr<serialization::pimpl::Data>(key));
157 virtual void handleIMapBatchInvalidationEventV10(
const std::vector<Data> &keys) {
158 for (std::vector<serialization::pimpl::Data>::const_iterator it = keys.begin();
159 it != keys.end(); ++it) {
160 nearCache->remove(boost::shared_ptr<serialization::pimpl::Data>(
161 new serialization::pimpl::Data(*it)));
165 virtual void handleIMapInvalidationEventV14(std::auto_ptr<serialization::pimpl::Data> key,
166 const std::string &sourceUuid,
167 const util::UUID &partitionUuid,
168 const int64_t &sequence) {
170 handleIMapInvalidationEventV10(key);
174 handleIMapBatchInvalidationEventV14(
const std::vector<serialization::pimpl::Data> &keys,
175 const std::vector<std::string> &sourceUuids,
176 const std::vector<util::UUID> &partitionUuids,
177 const std::vector<int64_t> &sequences) {
179 handleIMapBatchInvalidationEventV10(keys);
183 boost::shared_ptr<internal::nearcache::NearCache<serialization::pimpl::Data, TypedData> > nearCache;
186 boost::shared_ptr<spi::impl::ListenerMessageCodec> createNearCacheEntryListenerCodec();
188 void resetToUnmarkedState(boost::shared_ptr<serialization::pimpl::Data> &key);
190 void unmarkRemainingMarkedKeys(std::map<boost::shared_ptr<serialization::pimpl::Data>,
bool> &markers);
192 void tryToPutNearCache(boost::shared_ptr<serialization::pimpl::Data> &keyData,
193 boost::shared_ptr<TypedData> &response);
199 void invalidateNearCache(
const serialization::pimpl::Data &key);
201 void invalidateNearCache(boost::shared_ptr<serialization::pimpl::Data> key);
204 class NearCacheEntryListenerMessageCodec :
public spi::impl::ListenerMessageCodec {
206 NearCacheEntryListenerMessageCodec(
const std::string &name, int32_t listenerFlags);
208 virtual std::auto_ptr<protocol::ClientMessage> encodeAddRequest(
bool localOnly)
const;
210 virtual std::string decodeAddResponse(protocol::ClientMessage &responseMessage)
const;
212 virtual std::auto_ptr<protocol::ClientMessage>
213 encodeRemoveRequest(
const std::string &realRegistrationId)
const;
215 virtual bool decodeRemoveResponse(protocol::ClientMessage &clientMessage)
const;
219 int32_t listenerFlags;
222 bool cacheLocalEntries;
223 bool invalidateOnChange;
224 map::impl::nearcache::KeyStateMarker *keyStateMarker;
226 boost::shared_ptr<internal::nearcache::NearCache<serialization::pimpl::Data, TypedData> > nearCache;
228 boost::shared_ptr<std::string> invalidationListenerId;
238 EntryVector populateFromNearCache(
const PID_TO_KEY_MAP &pIdToKeyData, PID_TO_KEY_MAP &nonCachedPidToKeyMap,
239 MARKER_MAP &markers);
245 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) Definition: LocalMapStats.h:31
Definition: NearCacheConfig.h:363
NearCache is the contract point to store keys and values in underlying com.hazelcast.cache.impl.nearcache.NearCacheRecordStore.
Definition: NearCache.h:68
Concurrent, distributed, observable and queryable map client.
Definition: ClientMapProxy.h:62
Concurrent, distributed, observable and queryable map client.
Definition: NearCachedClientMapProxy.h:51
Definition: MapEntryView.h:32