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);
82 virtual bool tryPutInternal(
const serialization::pimpl::Data &key,
const serialization::pimpl::Data &value,
83 long timeoutInMillis);
85 virtual std::auto_ptr<serialization::pimpl::Data> putInternal(
const serialization::pimpl::Data &key,
86 const serialization::pimpl::Data &value,
87 long timeoutInMillis);
89 virtual void tryPutTransientInternal(
const serialization::pimpl::Data &key,
90 const serialization::pimpl::Data &value,
int ttlInMillis);
92 virtual std::auto_ptr<serialization::pimpl::Data> putIfAbsentInternal(
const serialization::pimpl::Data &keyData,
93 const serialization::pimpl::Data &valueData,
96 virtual bool replaceIfSameInternal(
const serialization::pimpl::Data &keyData,
97 const serialization::pimpl::Data &valueData,
98 const serialization::pimpl::Data &newValueData);
100 virtual std::auto_ptr<serialization::pimpl::Data> replaceInternal(
const serialization::pimpl::Data &keyData,
101 const serialization::pimpl::Data &valueData);
103 virtual void setInternal(
const serialization::pimpl::Data &keyData,
const serialization::pimpl::Data &valueData,
106 virtual bool evictInternal(
const serialization::pimpl::Data &keyData);
108 EntryVector getAllInternal(ClientMapProxy::PID_TO_KEY_MAP &pIdToKeyData);
110 virtual std::auto_ptr<serialization::pimpl::Data>
111 executeOnKeyInternal(
const serialization::pimpl::Data &keyData,
112 const serialization::pimpl::Data &processor);
115 putAllInternal(
const std::map<int, EntryVector> &entries);
117 typedef std::map<boost::shared_ptr<serialization::pimpl::Data>,
bool> MARKER_MAP;
119 map::impl::nearcache::KeyStateMarker *getKeyStateMarker();
121 void addNearCacheInvalidateListener(std::auto_ptr<client::impl::BaseEventHandler> handler);
123 class ClientMapAddNearCacheEventHandler
124 :
public protocol::codec::MapAddNearCacheEntryListenerCodec::AbstractEventHandler {
126 ClientMapAddNearCacheEventHandler(
132 void beforeListenerRegister() {
137 void onListenerRegister() {
142 void handleIMapInvalidation(std::auto_ptr<serialization::pimpl::Data> key) {
144 if (key.get() == NULL) {
147 nearCache->remove(boost::shared_ptr<serialization::pimpl::Data>(key));
152 void handleIMapBatchInvalidation(
const std::vector<serialization::pimpl::Data> &keys) {
153 for (std::vector<serialization::pimpl::Data>::const_iterator it = keys.begin();
154 it != keys.end(); ++it) {
155 nearCache->remove(boost::shared_ptr<serialization::pimpl::Data>(
156 new serialization::pimpl::Data(*it)));
161 boost::shared_ptr<internal::nearcache::NearCache<serialization::pimpl::Data, TypedData> > nearCache;
164 std::auto_ptr<protocol::codec::IAddListenerCodec> createNearCacheEntryListenerCodec();
166 void resetToUnmarkedState(boost::shared_ptr<serialization::pimpl::Data> &key);
168 void unmarkRemainingMarkedKeys(std::map<boost::shared_ptr<serialization::pimpl::Data>,
bool> &markers);
170 void tryToPutNearCache(boost::shared_ptr<serialization::pimpl::Data> &keyData,
171 boost::shared_ptr<TypedData> &response);
177 void invalidateNearCache(
const serialization::pimpl::Data &key);
179 void invalidateNearCache(boost::shared_ptr<serialization::pimpl::Data> key);
183 bool cacheLocalEntries;
184 bool invalidateOnChange;
185 map::impl::nearcache::KeyStateMarker *keyStateMarker;
187 boost::shared_ptr<internal::nearcache::NearCache<serialization::pimpl::Data, TypedData> > nearCache;
189 boost::shared_ptr<std::string> invalidationListenerId;
198 EntryVector populateFromNearCache(PID_TO_KEY_MAP &pIdToKeyData, MARKER_MAP &markers);
204 #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:61
Concurrent, distributed, observable and queryable map client.
Definition: NearCachedClientMapProxy.h:51
Definition: MapEntryView.h:32