You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bb...@apache.org on 2021/04/30 13:55:10 UTC
[geode-native] branch develop updated: Revert "GEODE-8991:
Implement cached region clean up (#757)" (#798)
This is an automated email from the ASF dual-hosted git repository.
bbender pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push:
new 085cdb9 Revert "GEODE-8991: Implement cached region clean up (#757)" (#798)
085cdb9 is described below
commit 085cdb9c76faf6ec4b040b9d1e00378d95cccebe
Author: Blake Bender <bb...@pivotal.io>
AuthorDate: Fri Apr 30 06:54:55 2021 -0700
Revert "GEODE-8991: Implement cached region clean up (#757)" (#798)
- Consistent failures in legacy C++ test testThinClientHADistOps in CI
---
cppcache/integration/test/RegisterKeysTest.cpp | 97 +-------------------------
cppcache/src/ConcurrentEntriesMap.cpp | 2 -
cppcache/src/ConcurrentEntriesMap.hpp | 5 --
cppcache/src/EntriesMap.hpp | 3 -
cppcache/src/LocalRegion.cpp | 70 ++-----------------
cppcache/src/LocalRegion.hpp | 17 +----
cppcache/src/RegionInternal.cpp | 2 -
cppcache/src/RegionInternal.hpp | 58 ++++++++-------
cppcache/src/ThinClientPoolHADM.cpp | 7 --
cppcache/src/ThinClientPoolHADM.hpp | 1 -
cppcache/src/ThinClientRedundancyManager.cpp | 1 -
cppcache/src/ThinClientRegion.cpp | 17 -----
cppcache/src/ThinClientRegion.hpp | 2 -
13 files changed, 44 insertions(+), 238 deletions(-)
diff --git a/cppcache/integration/test/RegisterKeysTest.cpp b/cppcache/integration/test/RegisterKeysTest.cpp
index 058e1c9..2ce04a2 100644
--- a/cppcache/integration/test/RegisterKeysTest.cpp
+++ b/cppcache/integration/test/RegisterKeysTest.cpp
@@ -24,7 +24,6 @@
#include <geode/Cache.hpp>
#include <geode/CacheFactory.hpp>
#include <geode/EntryEvent.hpp>
-#include <geode/RegionEvent.hpp>
#include <geode/RegionFactory.hpp>
#include <geode/RegionShortcut.hpp>
@@ -34,11 +33,8 @@
class CacheListenerMock : public apache::geode::client::CacheListener {
public:
- MOCK_METHOD1(afterDestroy, void(const apache::geode::client::EntryEvent&));
- MOCK_METHOD1(afterCreate, void(const apache::geode::client::EntryEvent&));
- MOCK_METHOD1(afterRegionLive,
- void(const apache::geode::client::RegionEvent&));
- MOCK_METHOD1(afterRegionDisconnected, void(apache::geode::client::Region&));
+ MOCK_METHOD1(afterDestroy,
+ void(const apache::geode::client::EntryEvent& event));
};
namespace {
@@ -54,7 +50,6 @@ using apache::geode::client::RegionShortcut;
using ::testing::_;
using ::testing::DoAll;
using ::testing::InvokeWithoutArgs;
-using ::testing::Return;
ACTION_P(CvNotifyOne, cv) { cv->notify_one(); }
@@ -161,10 +156,6 @@ TEST(RegisterKeysTest, RegisterAllWithConsistencyDisabled) {
bool destroyed = false;
std::condition_variable cv;
auto listener = std::make_shared<CacheListenerMock>();
-
- EXPECT_CALL(*listener, afterCreate(_)).WillRepeatedly(Return());
- EXPECT_CALL(*listener, afterRegionLive(_)).WillRepeatedly(Return());
- EXPECT_CALL(*listener, afterRegionDisconnected(_)).WillRepeatedly(Return());
EXPECT_CALL(*listener, afterDestroy(_))
.Times(1)
.WillOnce(DoAll(InvokeWithoutArgs([&destroyed] { destroyed = true; }),
@@ -195,90 +186,6 @@ TEST(RegisterKeysTest, RegisterAllWithConsistencyDisabled) {
}
}
-TEST(RegisterKeysTest, RegisterAnyAndClusterRestart) {
- std::mutex mutex_create;
- std::condition_variable cv_create;
-
- std::mutex mutex_shutdown;
- std::condition_variable cv_shutdown;
-
- std::mutex mutex_live;
- std::condition_variable cv_live;
-
- Cluster cluster{LocatorCount{1}, ServerCount{1}};
- cluster.start();
-
- auto& gfsh = cluster.getGfsh();
- gfsh.create().region().withName("region").withType("REPLICATE").execute();
-
- auto cache = createTestCache();
- {
- auto poolFactory =
- cache.getPoolManager().createFactory().setSubscriptionEnabled(true);
- cluster.applyLocators(poolFactory);
- poolFactory.create("default");
- }
-
- auto listener = std::make_shared<CacheListenerMock>();
- EXPECT_CALL(*listener, afterRegionLive(_))
- .WillRepeatedly(CvNotifyOne(&cv_live));
- EXPECT_CALL(*listener, afterRegionDisconnected(_))
- .WillRepeatedly(CvNotifyOne(&cv_shutdown));
-
- auto region = cache.createRegionFactory(RegionShortcut::CACHING_PROXY)
- .setPoolName("default")
- .setCacheListener(listener)
- .create("region");
- region->registerAllKeys(false, true);
- EXPECT_EQ(region->keys().size(), 0);
-
- auto producer_cache = createTestCache();
- {
- auto poolFactory = producer_cache.getPoolManager().createFactory();
- cluster.applyLocators(poolFactory);
- poolFactory.create("default");
- }
-
- auto producer_region = setupProxyRegion(producer_cache);
-
- auto N = 100U;
- EXPECT_CALL(*listener, afterCreate(_))
- .Times(N)
- .WillRepeatedly(CvNotifyOne(&cv_create));
-
- auto producer = std::thread([&producer_region, N] {
- for (auto i = 0U; i < N;) {
- auto key = "entry-" + std::to_string(i++);
- auto value = "{\"entryName\": \"" + key + "\"}";
- producer_region->put(key, value);
- }
- });
-
- {
- std::unique_lock<std::mutex> lock(mutex_create);
- cv_create.wait(lock, [®ion, N] { return region->keys().size() == N; });
- }
-
- producer.join();
- gfsh.shutdown().execute();
-
- {
- std::unique_lock<std::mutex> lock(mutex_shutdown);
- cv_shutdown.wait(lock);
- }
-
- for (auto& server : cluster.getServers()) {
- server.start();
- }
-
- {
- std::unique_lock<std::mutex> lock(mutex_live);
- cv_live.wait(lock);
- }
-
- EXPECT_EQ(region->keys().size(), 0);
-}
-
TEST(RegisterKeysTest, RegisterAnyWithCachingRegion) {
Cluster cluster{LocatorCount{1}, ServerCount{1}};
diff --git a/cppcache/src/ConcurrentEntriesMap.cpp b/cppcache/src/ConcurrentEntriesMap.cpp
index a9b17f8..cea4e8b 100644
--- a/cppcache/src/ConcurrentEntriesMap.cpp
+++ b/cppcache/src/ConcurrentEntriesMap.cpp
@@ -177,8 +177,6 @@ void ConcurrentEntriesMap::getValues(
}
}
-bool ConcurrentEntriesMap::empty() const { return m_size == 0; }
-
uint32_t ConcurrentEntriesMap::size() const { return m_size; }
int ConcurrentEntriesMap::addTrackerForEntry(
diff --git a/cppcache/src/ConcurrentEntriesMap.hpp b/cppcache/src/ConcurrentEntriesMap.hpp
index 18f09dd..bcd0cd5 100644
--- a/cppcache/src/ConcurrentEntriesMap.hpp
+++ b/cppcache/src/ConcurrentEntriesMap.hpp
@@ -151,11 +151,6 @@ class ConcurrentEntriesMap : public EntriesMap {
std::vector<std::shared_ptr<Cacheable>>& result) const override;
/**
- * @brief return whether there are no entries.
- */
- bool empty() const override;
-
- /**
* @brief return the number of entries in the map.
*/
uint32_t size() const override;
diff --git a/cppcache/src/EntriesMap.hpp b/cppcache/src/EntriesMap.hpp
index 32fc39d..b2cff83 100644
--- a/cppcache/src/EntriesMap.hpp
+++ b/cppcache/src/EntriesMap.hpp
@@ -126,9 +126,6 @@ class EntriesMap {
virtual void getValues(
std::vector<std::shared_ptr<Cacheable>>& result) const = 0;
- /** @brief return whether there are no entryies. */
- virtual bool empty() const = 0;
-
/** @brief return the number of entries in the map. */
virtual uint32_t size() const = 0;
diff --git a/cppcache/src/LocalRegion.cpp b/cppcache/src/LocalRegion.cpp
index 3367a23..0b3503c 100644
--- a/cppcache/src/LocalRegion.cpp
+++ b/cppcache/src/LocalRegion.cpp
@@ -17,7 +17,6 @@
#include "LocalRegion.hpp"
-#include <regex>
#include <vector>
#include <geode/PoolManager.hpp>
@@ -30,7 +29,6 @@
#include "EntriesMapFactory.hpp"
#include "EntryExpiryTask.hpp"
#include "ExpiryTaskManager.hpp"
-#include "InterestResultPolicy.hpp"
#include "LRUEntriesMap.hpp"
#include "RegionExpiryTask.hpp"
#include "RegionGlobalLocks.hpp"
@@ -452,15 +450,6 @@ void LocalRegion::destroy(
throwExceptionIfError("Region::destroy", err);
}
-void LocalRegion::localDestroyNoCallbacks(
- const std::shared_ptr<CacheableKey>& key) {
- std::shared_ptr<VersionTag> versionTag;
- GfErrType err = destroyNoThrow(
- key, nullptr, -1, CacheEventFlags::LOCAL | CacheEventFlags::NOCALLBACKS,
- versionTag);
- throwExceptionIfError("Region::localDestroy", err);
-}
-
void LocalRegion::localDestroy(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Serializable>& aCallbackArgument) {
@@ -1764,16 +1753,12 @@ GfErrType LocalRegion::updateNoThrow(
m_entries->removeTrackerForEntry(key);
}
}
-
- if (!eventFlags.isNoCallbacks()) {
- // invokeCacheListenerForEntryEvent method has the check that if oldValue
- // is a CacheableToken then it sets it to nullptr; also determines if it
- // should be AFTER_UPDATE or AFTER_CREATE depending on oldValue
- err = invokeCacheListenerForEntryEvent(key, oldValue, value,
- aCallbackArgument, eventFlags,
- TAction::s_afterEventType);
- }
-
+ // invokeCacheListenerForEntryEvent method has the check that if oldValue
+ // is a CacheableToken then it sets it to nullptr; also determines if it
+ // should be AFTER_UPDATE or AFTER_CREATE depending on oldValue
+ err =
+ invokeCacheListenerForEntryEvent(key, oldValue, value, aCallbackArgument,
+ eventFlags, TAction::s_afterEventType);
return err;
}
@@ -3220,49 +3205,6 @@ void LocalRegion::acquireGlobals(bool) {}
void LocalRegion::releaseGlobals(bool) {}
-void LocalRegion::clearKeysOfInterest(
- const std::unordered_map<std::shared_ptr<CacheableKey>,
- InterestResultPolicy>& interest_list) {
- if (m_entries->empty()) {
- return;
- }
-
- for (const auto& kv : interest_list) {
- localDestroyNoCallbacks(kv.first);
- }
-}
-
-void LocalRegion::clearKeysOfInterestRegex(const std::string& pattern) {
- if (m_entries->empty()) {
- return;
- }
-
- std::regex expression{pattern};
- for (const auto& key : keys()) {
- if (std::regex_search(key->toString(), expression)) {
- localDestroyNoCallbacks(key);
- }
- }
-}
-
-void LocalRegion::clearKeysOfInterestRegex(
- const std::unordered_map<std::string, InterestResultPolicy>&
- interest_list) {
- if (m_entries->empty()) {
- return;
- }
-
- for (const auto& kv : interest_list) {
- const auto& regex = kv.first;
- if (regex == ".*") {
- localClear();
- break;
- } else {
- clearKeysOfInterestRegex(kv.first);
- }
- }
-}
-
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/LocalRegion.hpp b/cppcache/src/LocalRegion.hpp
index 297c442..9f37af8 100644
--- a/cppcache/src/LocalRegion.hpp
+++ b/cppcache/src/LocalRegion.hpp
@@ -72,13 +72,12 @@ namespace client {
} while (0)
#endif
-class CreateActions;
-class DestroyActions;
-class InvalidateActions;
-class InterestResultPolicy;
class PutActions;
class PutActionsTx;
+class CreateActions;
+class DestroyActions;
class RemoveActions;
+class InvalidateActions;
class VersionedCacheableObjectPartList;
typedef std::unordered_map<std::shared_ptr<CacheableKey>,
@@ -199,8 +198,6 @@ class APACHE_GEODE_EXPORT LocalRegion : public RegionInternal {
void localDestroy(const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override;
- virtual void localDestroyNoCallbacks(
- const std::shared_ptr<CacheableKey>& key);
bool remove(const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument =
@@ -575,14 +572,6 @@ class APACHE_GEODE_EXPORT LocalRegion : public RegionInternal {
std::shared_ptr<EventId> eventId, std::shared_ptr<Cacheable>& fullObject,
std::shared_ptr<VersionTag>& versionTag);
- void clearKeysOfInterest(
- const std::unordered_map<std::shared_ptr<CacheableKey>,
- InterestResultPolicy>& interest_list);
- void clearKeysOfInterestRegex(const std::string& regex);
- void clearKeysOfInterestRegex(
- const std::unordered_map<std::string, InterestResultPolicy>&
- interest_list);
-
private:
std::shared_ptr<Region> findSubRegion(const std::string& name);
GfErrType invalidateRegionNoThrowOnSubRegions(
diff --git a/cppcache/src/RegionInternal.cpp b/cppcache/src/RegionInternal.cpp
index e3a541c..ea01843 100644
--- a/cppcache/src/RegionInternal.cpp
+++ b/cppcache/src/RegionInternal.cpp
@@ -39,8 +39,6 @@ const CacheEventFlags CacheEventFlags::CACHE_CLOSE(
CacheEventFlags::GF_CACHE_CLOSE);
const CacheEventFlags CacheEventFlags::NOCACHEWRITER(
CacheEventFlags::GF_NOCACHEWRITER);
-const CacheEventFlags CacheEventFlags::NOCALLBACKS(
- CacheEventFlags::GF_NOCALLBACKS);
RegionInternal::RegionInternal(CacheImpl* cacheImpl,
RegionAttributes attributes)
diff --git a/cppcache/src/RegionInternal.hpp b/cppcache/src/RegionInternal.hpp
index 207b91f..4e4358d 100644
--- a/cppcache/src/RegionInternal.hpp
+++ b/cppcache/src/RegionInternal.hpp
@@ -45,18 +45,17 @@ namespace client {
*/
class CacheEventFlags {
private:
- uint16_t m_flags;
- static const uint16_t GF_NORMAL = 0x01;
- static const uint16_t GF_LOCAL = 0x02;
- static const uint16_t GF_NOTIFICATION = 0x04;
- static const uint16_t GF_NOTIFICATION_UPDATE = 0x08;
- static const uint16_t GF_EVICTION = 0x10;
- static const uint16_t GF_EXPIRATION = 0x20;
- static const uint16_t GF_CACHE_CLOSE = 0x40;
- static const uint16_t GF_NOCACHEWRITER = 0x80;
- static const uint16_t GF_NOCALLBACKS = 0x100;
-
- inline explicit CacheEventFlags(const uint16_t flags) : m_flags(flags) {}
+ uint8_t m_flags;
+ static const uint8_t GF_NORMAL = 0x01;
+ static const uint8_t GF_LOCAL = 0x02;
+ static const uint8_t GF_NOTIFICATION = 0x04;
+ static const uint8_t GF_NOTIFICATION_UPDATE = 0x08;
+ static const uint8_t GF_EVICTION = 0x10;
+ static const uint8_t GF_EXPIRATION = 0x20;
+ static const uint8_t GF_CACHE_CLOSE = 0x40;
+ static const uint8_t GF_NOCACHEWRITER = 0x80;
+
+ inline explicit CacheEventFlags(const uint8_t flags) : m_flags(flags) {}
public:
static const CacheEventFlags NORMAL;
@@ -67,7 +66,6 @@ class CacheEventFlags {
static const CacheEventFlags EXPIRATION;
static const CacheEventFlags CACHE_CLOSE;
static const CacheEventFlags NOCACHEWRITER;
- static const CacheEventFlags NOCALLBACKS;
inline CacheEventFlags(const CacheEventFlags& flags) = default;
@@ -86,36 +84,46 @@ class CacheEventFlags {
return (m_flags == flags.m_flags);
}
- inline bool isNormal() const { return (m_flags & GF_NORMAL) > 0; }
+ inline bool isNormal() const {
+ return (m_flags & GF_NORMAL) > 0 ? true : false;
+ }
- inline bool isLocal() const { return (m_flags & GF_LOCAL) > 0; }
+ inline bool isLocal() const {
+ return (m_flags & GF_LOCAL) > 0 ? true : false;
+ }
- inline bool isNotification() const { return (m_flags & GF_NOTIFICATION) > 0; }
+ inline bool isNotification() const {
+ return (m_flags & GF_NOTIFICATION) > 0 ? true : false;
+ }
inline bool isNotificationUpdate() const {
- return (m_flags & GF_NOTIFICATION_UPDATE) > 0;
+ return (m_flags & GF_NOTIFICATION_UPDATE) > 0 ? true : false;
}
- inline bool isEviction() const { return (m_flags & GF_EVICTION) > 0; }
+ inline bool isEviction() const {
+ return (m_flags & GF_EVICTION) > 0 ? true : false;
+ }
- inline bool isExpiration() const { return (m_flags & GF_EXPIRATION) > 0; }
+ inline bool isExpiration() const {
+ return (m_flags & GF_EXPIRATION) > 0 ? true : false;
+ }
- inline bool isCacheClose() const { return (m_flags & GF_CACHE_CLOSE) > 0; }
+ inline bool isCacheClose() const {
+ return (m_flags & GF_CACHE_CLOSE) > 0 ? true : false;
+ }
inline bool isNoCacheWriter() const {
- return (m_flags & GF_NOCACHEWRITER) > 0;
+ return (m_flags & GF_NOCACHEWRITER) > 0 ? true : false;
}
- inline bool isNoCallbacks() const { return (m_flags & GF_NOCALLBACKS) > 0; }
-
inline bool isEvictOrExpire() const {
- return (m_flags & (GF_EVICTION | GF_EXPIRATION)) > 0;
+ return (m_flags & (GF_EVICTION | GF_EXPIRATION)) > 0 ? true : false;
}
// special optimized method for CacheWriter invocation condition
inline bool invokeCacheWriter() const {
return ((m_flags & (GF_NOTIFICATION | GF_EVICTION | GF_EXPIRATION |
- GF_NOCACHEWRITER | GF_NOCALLBACKS)) == 0x0);
+ GF_NOCACHEWRITER)) == 0x0);
}
};
diff --git a/cppcache/src/ThinClientPoolHADM.cpp b/cppcache/src/ThinClientPoolHADM.cpp
index a8f5591..3d43c85 100644
--- a/cppcache/src/ThinClientPoolHADM.cpp
+++ b/cppcache/src/ThinClientPoolHADM.cpp
@@ -295,13 +295,6 @@ void ThinClientPoolHADM::sendNotConMesToAllregions() {
}
}
-void ThinClientPoolHADM::clearKeysOfInterestAllRegions() {
- std::lock_guard<decltype(m_regionsLock)> guard(m_regionsLock);
- for (auto region : m_regions) {
- region->clearKeysOfInterest();
- }
-}
-
std::shared_ptr<TcrEndpoint> ThinClientPoolHADM::createEP(
const char* endpointName) {
return std::make_shared<TcrPoolEndPoint>(
diff --git a/cppcache/src/ThinClientPoolHADM.hpp b/cppcache/src/ThinClientPoolHADM.hpp
index 087eccc..f1094e1 100644
--- a/cppcache/src/ThinClientPoolHADM.hpp
+++ b/cppcache/src/ThinClientPoolHADM.hpp
@@ -120,7 +120,6 @@ class ThinClientPoolHADM : public ThinClientPoolDM {
void addRegion(ThinClientRegion* theTCR);
void removeRegion(ThinClientRegion* theTCR);
void sendNotConMesToAllregions();
- void clearKeysOfInterestAllRegions();
void addDisMessToQueue(ThinClientRegion* theTCR);
friend class ThinClientHARegion;
diff --git a/cppcache/src/ThinClientRedundancyManager.cpp b/cppcache/src/ThinClientRedundancyManager.cpp
index 25310c1..8a2db40 100644
--- a/cppcache/src/ThinClientRedundancyManager.cpp
+++ b/cppcache/src/ThinClientRedundancyManager.cpp
@@ -455,7 +455,6 @@ GfErrType ThinClientRedundancyManager::maintainRedundancyLevel(
// that we can send it back to the caller, to avoid missing out due
// to nonfatal errors such as server not available
if (m_poolHADM && !m_IsAllEpDisCon) {
- m_poolHADM->clearKeysOfInterestAllRegions();
m_poolHADM->sendNotConMesToAllregions();
m_IsAllEpDisCon = true;
}
diff --git a/cppcache/src/ThinClientRegion.cpp b/cppcache/src/ThinClientRegion.cpp
index 9363ec5..aba0f97 100644
--- a/cppcache/src/ThinClientRegion.cpp
+++ b/cppcache/src/ThinClientRegion.cpp
@@ -1998,23 +1998,6 @@ GfErrType ThinClientRegion::registerStoredRegex(
return retVal;
}
-void ThinClientRegion::clearKeysOfInterest() {
- if (!getAttributes().getCachingEnabled()) {
- return;
- }
-
- clearKeysOfInterestRegex(m_interestListRegex);
- clearKeysOfInterestRegex(m_interestListRegexForUpdatesAsInvalidates);
- clearKeysOfInterestRegex(m_durableInterestListRegex);
- clearKeysOfInterestRegex(m_durableInterestListRegexForUpdatesAsInvalidates);
-
- LocalRegion::clearKeysOfInterest(m_interestList);
- LocalRegion::clearKeysOfInterest(m_interestListForUpdatesAsInvalidates);
- LocalRegion::clearKeysOfInterest(m_durableInterestList);
- LocalRegion::clearKeysOfInterest(
- m_durableInterestListForUpdatesAsInvalidates);
-}
-
GfErrType ThinClientRegion::registerKeys(TcrEndpoint* endpoint,
const TcrMessage* request,
TcrMessageReply* reply) {
diff --git a/cppcache/src/ThinClientRegion.hpp b/cppcache/src/ThinClientRegion.hpp
index b57da76..94fbac0 100644
--- a/cppcache/src/ThinClientRegion.hpp
+++ b/cppcache/src/ThinClientRegion.hpp
@@ -191,8 +191,6 @@ class ThinClientRegion : public LocalRegion {
const std::shared_ptr<Serializable>& callBack,
std::shared_ptr<VersionTag> versionTag) override;
- void clearKeysOfInterest();
-
protected:
GfErrType getNoThrow_remote(
const std::shared_ptr<CacheableKey>& keyPtr,