diff --git a/src/hotrod/impl/CustomClientListener.h b/src/hotrod/impl/CustomClientListener.h index c8be308d..07d0bb37 100644 --- a/src/hotrod/impl/CustomClientListener.h +++ b/src/hotrod/impl/CustomClientListener.h @@ -49,7 +49,7 @@ class CustomClientListener : public ClientListener - virtual void processEvent(ClientCacheEntryCreatedEvent> marshEv, std::vectorlistId, uint8_t isCustom) const + virtual void processEvent(ClientCacheEntryCreatedEvent> marshEv, std::vector/*listId*/, uint8_t /*isCustom*/) const { for (auto callable: createdCallbacks) { @@ -57,7 +57,7 @@ class CustomClientListener : public ClientListener } } - virtual void processEvent(ClientCacheEntryModifiedEvent> marshEv, std::vectorlistId, uint8_t isCustom) const + virtual void processEvent(ClientCacheEntryModifiedEvent> marshEv, std::vector/*listId*/, uint8_t /*isCustom*/) const { for (auto callable: modifiedCallbacks) { @@ -65,7 +65,7 @@ class CustomClientListener : public ClientListener } } - virtual void processEvent(ClientCacheEntryRemovedEvent> marshEv, std::vectorlistId, uint8_t isCustom) const + virtual void processEvent(ClientCacheEntryRemovedEvent> marshEv, std::vector/*listId*/, uint8_t /*isCustom*/) const { for (auto callable: removedCallbacks) { @@ -73,7 +73,7 @@ class CustomClientListener : public ClientListener } } - virtual void processEvent(ClientCacheEntryExpiredEvent> marshEv, std::vectorlistId, uint8_t isCustom) const + virtual void processEvent(ClientCacheEntryExpiredEvent> marshEv, std::vector/*listId*/, uint8_t /*isCustom*/) const { for (auto callable: expiredCallbacks) { @@ -81,7 +81,7 @@ class CustomClientListener : public ClientListener } } - virtual void processEvent(ClientCacheEntryCustomEvent ev, std::vectorlistId, uint8_t isCustom) const + virtual void processEvent(ClientCacheEntryCustomEvent ev, std::vector/*listId*/, uint8_t /*isCustom*/) const { for (auto callable: customCallbacks) { diff --git a/src/hotrod/impl/NearRemoteCacheImpl.h b/src/hotrod/impl/NearRemoteCacheImpl.h index c0274fae..fa64b03e 100644 --- a/src/hotrod/impl/NearRemoteCacheImpl.h +++ b/src/hotrod/impl/NearRemoteCacheImpl.h @@ -130,7 +130,7 @@ class NearRemoteCacheImpl: public RemoteCacheImpl { _nearMap[key] = value; } - void removeElementFromMap(std::vector& key) { + void removeElementFromMap(const std::vector& key) { std::lock_guard guard(_nearMutex); auto it = std::find(_nearFifo.begin(), _nearFifo.end(), key); if (it != _nearFifo.end()) { @@ -150,59 +150,25 @@ class NearRemoteCacheImpl: public RemoteCacheImpl { _nearMap.clear(); } void startListener() { - std::string convStr("___eager-key-value-version-converter"); - cl.converterFactoryName = std::vector(convStr.begin(), - convStr.end()); - cl.useRawData = true; - std::function f = - [this] (ClientCacheEntryCustomEvent ce) {listener(this->_nearMap, ce);}; + std::function> ev)> created = + [this] (ClientCacheEntryCreatedEvent> ev) {removeElementFromMap(ev.getKey());}; + std::function> ev)> removed = + [this] (ClientCacheEntryRemovedEvent> ev) {removeElementFromMap(ev.getKey());}; + std::function> ev)> expired = + [this] (ClientCacheEntryExpiredEvent> ev) {removeElementFromMap(ev.getKey());}; + std::function> ev)> modified = + [this] (ClientCacheEntryModifiedEvent> ev) {removeElementFromMap(ev.getKey());}; std::function < void() > failOverHandler = [this] () { this->invalidateCache(); }; - cl.add_listener(f); + cl.add_listener(created); + cl.add_listener(removed); + cl.add_listener(modified); + cl.add_listener(expired); this->addClientListener(cl, filterFactoryParams, converterFactoryParams, failOverHandler); } - void listener( - std::map, VersionedValueImpl > > &map, - ClientCacheEntryCustomEvent &ce) { - // bytearray format is - const std::vector &v = ce.getEventData(); - if (v.size() == 0) - return; - unsigned int sizeKey = v[0]; - if (sizeKey == 0) - return; - auto i = v.begin() + 1; - auto f = v.begin() + 1 + sizeKey; - std::vector key(i, f); - unsigned int sizeValue; - std::vector value; - if (sizeKey + 1 < v.size()) { - sizeValue = *(v.data() + sizeKey + 1); - const char* i1 = v.data() + sizeKey + 2; - const char* f1 = v.data() + sizeKey + 2 + sizeValue; - value = std::vector(i1, f1); - } - else - { - // If no value it's an entry removed event - removeElementFromMap(key); - return; - } - unsigned long version = 0; - if (v.size() - sizeKey - sizeValue - 2 >= 8) { - for (unsigned int i = 0; i < 8; i++) { - version = (version << 8) + v[sizeKey + sizeValue + 2 + i]; - } - } - VersionedValueImpl > vv; - vv.setValue(value); - vv.setVersion(version); - addElementToMap(key, vv); - } - }; }