This is an automated email from the ASF dual-hosted git repository. jbarrett 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 38a6c8b GEODE-6642: Remove CacheAttributes (#475) 38a6c8b is described below commit 38a6c8b6b32da8baca118287019ba035d124c870 Author: Jacob Barrett <jbarr...@pivotal.io> AuthorDate: Thu Apr 18 18:30:28 2019 -0700 GEODE-6642: Remove CacheAttributes (#475) * GEODE-6642: Remove CacheAttributes CacheAttributes based Cache creation was removed but the header was accidently left in the public header location. Removal does not effect public API or ABI. All methods to construct or use it on the public API had already been removed. Removes code dependent on CacheAttributes Cleans up ownership of heap objects --- clicache/src/geode_defs.hpp | 6 - cppcache/include/geode/CacheAttributes.hpp | 106 ------------- cppcache/include/geode/CacheFactory.hpp | 3 - cppcache/include/geode/Region.hpp | 2 +- cppcache/src/CacheAttributes.cpp | 51 ------ cppcache/src/CacheFactory.cpp | 32 ---- cppcache/src/CacheImpl.cpp | 40 +---- cppcache/src/CacheImpl.hpp | 14 -- cppcache/src/CacheXmlParser.hpp | 1 - cppcache/src/LocalRegion.cpp | 2 +- cppcache/src/LocalRegion.hpp | 67 ++++---- cppcache/src/PoolFactory.cpp | 6 +- cppcache/src/Region.cpp | 2 +- cppcache/src/RegionInternal.cpp | 2 +- cppcache/src/RegionInternal.hpp | 66 ++++---- cppcache/src/TcrConnectionManager.cpp | 61 +------- cppcache/src/TcrHADistributionManager.cpp | 10 +- cppcache/src/TcrHADistributionManager.hpp | 5 +- .../src/ThinClientCacheDistributionManager.cpp | 1 - cppcache/src/ThinClientHARegion.cpp | 82 ++++------ cppcache/src/ThinClientHARegion.hpp | 52 +++---- cppcache/src/ThinClientPoolRegion.cpp | 14 +- cppcache/src/ThinClientPoolRegion.hpp | 33 ++-- cppcache/src/ThinClientRegion.cpp | 173 ++++++++++----------- cppcache/src/ThinClientRegion.hpp | 95 +++++------ 25 files changed, 266 insertions(+), 660 deletions(-) diff --git a/clicache/src/geode_defs.hpp b/clicache/src/geode_defs.hpp index 103650a..9333c88 100644 --- a/clicache/src/geode_defs.hpp +++ b/clicache/src/geode_defs.hpp @@ -61,12 +61,6 @@ /// @file AttributesMutator.hpp /// Declares the AttributesMutator class. -/// @file CacheAttributes.hpp -/// Declares the CacheAttributes class. - -/// @file CacheAttributesFactory.hpp -/// Declares the CacheAttributesFactory class. - /// @file CacheableBuiltins.hpp /// Declares the CacheableBuiltinKey and CacheableBuiltinArray /// template classes and their instantiations for CacheableBoolean, diff --git a/cppcache/include/geode/CacheAttributes.hpp b/cppcache/include/geode/CacheAttributes.hpp deleted file mode 100644 index 90f87aa..0000000 --- a/cppcache/include/geode/CacheAttributes.hpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#ifndef GEODE_CACHEATTRIBUTES_H_ -#define GEODE_CACHEATTRIBUTES_H_ - -/** - * @file - */ - -#include <string> - -#include "internal/geode_globals.hpp" - -namespace apache { -namespace geode { -namespace client { - -/** - * @class CacheAttributes CacheAttributes.hpp - * Defines attributes for configuring a cache. - * Currently the following attributes are defined: - * redundancyLevel: Redundancy for HA client queues. - * endpoints: Cache level endpoints list. - * - * To create an instance of this interface, use {@link - * CacheAttributesFactory::createCacheAttributes}. - * - * For compatibility rules and default values, see {@link - * CacheAttributesFactory}. - * - * <p>Note that the <code>CacheAttributes</code> are not distributed with the - * region. - * - * @see CacheAttributesFactory - */ -class CacheAttributesFactory; - -class APACHE_GEODE_EXPORT CacheAttributes { - /** - * @brief public static methods - */ - public: - /** - * Gets redundancy level for regions in the cache. - */ - int getRedundancyLevel(); - - /** - * Gets cache level endpoints list. - */ - const std::string& getEndpoints(); - - ~CacheAttributes() = delete; - - bool operator==(const CacheAttributes& other) const; - - bool operator!=(const CacheAttributes& other) const; - - private: - /** Sets redundancy level. - * - */ - void setRedundancyLevel(int redundancyLevel); - - /** Sets cache level endpoints list. - * - */ - void setEndpoints(const std::string& endpoints); - void setEndpoints(std::string&& endpoints); - - // will be created by the factory - - CacheAttributes(const CacheAttributes& rhs) = default; - CacheAttributes(); - - int m_redundancyLevel; - std::string m_endpoints; - bool m_cacheMode; - - friend class CacheAttributesFactory; - friend class CacheImpl; - - const CacheAttributes& operator=(const CacheAttributes&); -}; -} // namespace client -} // namespace geode -} // namespace apache - -#endif // GEODE_CACHEATTRIBUTES_H_ diff --git a/cppcache/include/geode/CacheFactory.hpp b/cppcache/include/geode/CacheFactory.hpp index 87358fe..813df0c 100644 --- a/cppcache/include/geode/CacheFactory.hpp +++ b/cppcache/include/geode/CacheFactory.hpp @@ -23,7 +23,6 @@ #include <string> #include "Cache.hpp" -#include "CacheAttributes.hpp" #include "PoolFactory.hpp" #include "internal/geode_globals.hpp" @@ -144,8 +143,6 @@ class APACHE_GEODE_EXPORT CacheFactory { bool pdxReadSerialized; std::shared_ptr<AuthInitialize> authInitialize; - Cache create(const std::shared_ptr<CacheAttributes>& attrs) const; - friend class CppCacheLibrary; friend class RegionFactory; friend class RegionXmlCreation; diff --git a/cppcache/include/geode/Region.hpp b/cppcache/include/geode/Region.hpp index f2c9519..afde4da 100644 --- a/cppcache/include/geode/Region.hpp +++ b/cppcache/include/geode/Region.hpp @@ -1477,7 +1477,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> { protected: explicit Region(CacheImpl* cacheImpl); - virtual ~Region(); + virtual ~Region() noexcept; CacheImpl* m_cacheImpl; }; diff --git a/cppcache/src/CacheAttributes.cpp b/cppcache/src/CacheAttributes.cpp deleted file mode 100644 index d3136ce..0000000 --- a/cppcache/src/CacheAttributes.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <cstdlib> -#include <string> - -#include <geode/CacheAttributes.hpp> - -#include "Utils.hpp" - -namespace apache { -namespace geode { -namespace client { - -CacheAttributes::CacheAttributes() - : m_redundancyLevel(0), m_endpoints(nullptr), m_cacheMode(false) {} - -int CacheAttributes::getRedundancyLevel() { return m_redundancyLevel; } - -const std::string& CacheAttributes::getEndpoints() { return m_endpoints; } - -/** Return true if all the attributes are equal to those of other. */ -bool CacheAttributes::operator==(const CacheAttributes& other) const { - if (m_redundancyLevel != other.m_redundancyLevel) return false; - if (m_endpoints != other.m_endpoints) return false; - - return true; -} - -/** Return true if any of the attributes are not equal to those of other. */ -bool CacheAttributes::operator!=(const CacheAttributes& other) const { - return !(*this == other); -} - -} // namespace client -} // namespace geode -} // namespace apache diff --git a/cppcache/src/CacheFactory.cpp b/cppcache/src/CacheFactory.cpp index 72e63dd..dd43d1e 100644 --- a/cppcache/src/CacheFactory.cpp +++ b/cppcache/src/CacheFactory.cpp @@ -121,38 +121,6 @@ Cache CacheFactory::create() const { return cache; } -Cache CacheFactory::create( - const std::shared_ptr<CacheAttributes>& attrs) const { - auto cache = - Cache(dsProp, ignorePdxUnreadFields, pdxReadSerialized, authInitialize); - cache.m_cacheImpl->setAttributes(attrs); - - try { - auto&& cacheXml = cache.m_cacheImpl->getDistributedSystem() - .getSystemProperties() - .cacheXMLFile(); - if (!cacheXml.empty()) { - cache.initializeDeclarativeCache(cacheXml); - } else { - cache.m_cacheImpl->initServices(); - } - } catch (const RegionExistsException&) { - LOGWARN("Attempt to create existing regions declaratively"); - } catch (const Exception&) { - if (!cache.isClosed()) { - cache.close(); - } - throw; - } catch (...) { - if (!cache.isClosed()) { - cache.close(); - } - throw UnknownException("Exception thrown in CacheFactory::create"); - } - - return cache; -} - CacheFactory& CacheFactory::set(std::string name, std::string value) { if (this->dsProp == nullptr) { this->dsProp = Properties::create(); diff --git a/cppcache/src/CacheImpl.cpp b/cppcache/src/CacheImpl.cpp index 87e0c61..4ba2b12 100644 --- a/cppcache/src/CacheImpl.cpp +++ b/cppcache/src/CacheImpl.cpp @@ -66,7 +66,6 @@ CacheImpl::CacheImpl(Cache* c, const std::shared_ptr<Properties>& dsProps, m_distributedSystem(DistributedSystem::create(DEFAULT_DS_NAME, dsProps)), m_clientProxyMembershipIDFactory(m_distributedSystem.getName()), m_cache(c), - m_attributes(nullptr), m_tcrConnectionManager(nullptr), m_remoteQueryServicePtr(nullptr), m_destroyPending(false), @@ -116,22 +115,6 @@ CacheImpl::CacheImpl(Cache* c, const std::shared_ptr<Properties>& dsProps, void CacheImpl::initServices() { m_tcrConnectionManager = new TcrConnectionManager(this); - if (!m_initDone && m_attributes != nullptr && - !m_attributes->getEndpoints().empty()) { - if (getPoolManager().getAll().size() > 0 && getCacheMode()) { - LOGWARN( - "At least one pool has been created so ignoring cache level " - "redundancy setting"); - } - m_tcrConnectionManager->init(); - m_remoteQueryServicePtr = std::make_shared<RemoteQueryService>(this); - // StartAdminRegion - auto& prop = m_distributedSystem.getSystemProperties(); - if (prop.statisticsEnabled()) { - m_adminRegion = AdminRegion::create(this); - } - m_initDone = true; - } } void CacheImpl::netDown() { @@ -153,12 +136,7 @@ CacheImpl::RegionKind CacheImpl::getRegionKind( RegionKind regionKind = CPP_REGION; std::string endpoints; - if (m_attributes != nullptr && - !(endpoints = m_attributes->getEndpoints()).empty() && - (m_attributes->getRedundancyLevel() > 0 || - m_tcrConnectionManager->isDurable())) { - regionKind = THINCLIENT_HA_REGION; - } else if (!endpoints.empty() && regionAttributes.getEndpoints().empty()) { + if (!endpoints.empty() && regionAttributes.getEndpoints().empty()) { regionAttributes.setEndpoints(endpoints); } @@ -173,8 +151,8 @@ CacheImpl::RegionKind CacheImpl::getRegionKind( if ((pPtr != nullptr && (pPtr->getSubscriptionRedundancy() > 0 || pPtr->getSubscriptionEnabled())) || m_tcrConnectionManager->isDurable()) { - regionKind = THINCLIENT_HA_REGION; // As of now ThinClinetHARegion deals - // with Pool as well. + // As of now ThinClinetHARegion deals with Pool as well. + regionKind = THINCLIENT_HA_REGION; } else { regionKind = THINCLIENT_POOL_REGION; } @@ -238,13 +216,6 @@ const std::string& CacheImpl::getName() const { bool CacheImpl::isClosed() const { return m_closed; } -void CacheImpl::setAttributes( - const std::shared_ptr<CacheAttributes>& attributes) { - if (m_attributes == nullptr && attributes != nullptr) { - m_attributes = attributes; - } -} - DistributedSystem& CacheImpl::getDistributedSystem() { return m_distributedSystem; } @@ -529,8 +500,6 @@ std::shared_ptr<RegionInternal> CacheImpl::createRegion_internal( RegionKind regionKind = getRegionKind(attrs); const auto& poolName = attrs.getPoolName(); const auto& regionEndpoints = attrs.getEndpoints(); - const std::string cacheEndpoints = - m_attributes ? m_attributes->getEndpoints() : ""; if (!poolName.empty()) { auto pool = getPoolManager().find(poolName); @@ -548,8 +517,7 @@ std::shared_ptr<RegionInternal> CacheImpl::createRegion_internal( } } - if (!poolName.empty() && - (!regionEndpoints.empty() || !cacheEndpoints.empty())) { + if (!poolName.empty() && !regionEndpoints.empty()) { LOGERROR( "Cache or region endpoints cannot be specified when pool name is " "specified for region %s", diff --git a/cppcache/src/CacheImpl.hpp b/cppcache/src/CacheImpl.hpp index 3ab93ad..f9ca86f 100644 --- a/cppcache/src/CacheImpl.hpp +++ b/cppcache/src/CacheImpl.hpp @@ -27,7 +27,6 @@ #include <ace/RW_Thread_Mutex.h> #include <geode/Cache.hpp> -#include <geode/CacheAttributes.hpp> #include <geode/PoolManager.hpp> #include <geode/TypeRegistry.hpp> #include <geode/internal/geode_globals.hpp> @@ -131,14 +130,6 @@ class APACHE_GEODE_EXPORT CacheImpl : private NonCopyable, */ bool isClosed() const; - /** Get the <code>CacheAttributes</code> for this cache. */ - inline std::shared_ptr<CacheAttributes> getAttributes() const { - return m_attributes; - } - - /** Set the <code>CacheAttributes</code> for this cache. */ - void setAttributes(const std::shared_ptr<CacheAttributes>& attributes); - /** * Returns the distributed system that this cache was * {@link CacheFactory::create created} with. @@ -264,10 +255,6 @@ class APACHE_GEODE_EXPORT CacheImpl : private NonCopyable, // Pool helpers for unit tests int getPoolSize(const char* poolName); - bool getCacheMode() { - return m_attributes == nullptr ? false : m_attributes->m_cacheMode; - } - bool getPdxIgnoreUnreadFields() { this->throwIfClosed(); @@ -384,7 +371,6 @@ class APACHE_GEODE_EXPORT CacheImpl : private NonCopyable, std::recursive_mutex> m_regions; Cache* m_cache; - std::shared_ptr<CacheAttributes> m_attributes; std::unique_ptr<EvictionController> m_evictionController; TcrConnectionManager* m_tcrConnectionManager; std::shared_ptr<RemoteQueryService> m_remoteQueryServicePtr; diff --git a/cppcache/src/CacheXmlParser.hpp b/cppcache/src/CacheXmlParser.hpp index ed1c83e..09d349b 100644 --- a/cppcache/src/CacheXmlParser.hpp +++ b/cppcache/src/CacheXmlParser.hpp @@ -26,7 +26,6 @@ #include <stack> #include <geode/Cache.hpp> -#include <geode/CacheAttributes.hpp> #include <geode/CacheListener.hpp> #include <geode/CacheLoader.hpp> #include <geode/ExceptionTypes.hpp> diff --git a/cppcache/src/LocalRegion.cpp b/cppcache/src/LocalRegion.cpp index f3b28dd..79e469d 100644 --- a/cppcache/src/LocalRegion.cpp +++ b/cppcache/src/LocalRegion.cpp @@ -726,7 +726,7 @@ void LocalRegion::registerEntryExpiryTask( expProps.setExpiryTaskId(id); } -LocalRegion::~LocalRegion() { +LocalRegion::~LocalRegion() noexcept { TryWriteGuard guard(m_rwLock, m_destroyPending); if (!m_destroyPending) { release(false); diff --git a/cppcache/src/LocalRegion.hpp b/cppcache/src/LocalRegion.hpp index 698f544..c1806b7 100644 --- a/cppcache/src/LocalRegion.hpp +++ b/cppcache/src/LocalRegion.hpp @@ -124,7 +124,11 @@ class APACHE_GEODE_EXPORT LocalRegion : public RegionInternal { RegionAttributes attributes, const std::shared_ptr<CacheStatistics>& stats, bool enableTimeStatistics = true); - virtual ~LocalRegion() override; + + LocalRegion(const LocalRegion&) = delete; + LocalRegion& operator=(const LocalRegion&) = delete; + + ~LocalRegion() noexcept override; const std::string& getName() const override; const std::string& getFullPath() const override; @@ -139,10 +143,10 @@ class APACHE_GEODE_EXPORT LocalRegion : public RegionInternal { } void updateAccessAndModifiedTime(bool modified) override; std::shared_ptr<CacheStatistics> getStatistics() const override; - virtual void clear(const std::shared_ptr<Serializable>& aCallbackArgument = - nullptr) override; - virtual void localClear(const std::shared_ptr<Serializable>& - aCallbackArgument = nullptr) override; + void clear(const std::shared_ptr<Serializable>& aCallbackArgument = + nullptr) override; + void localClear(const std::shared_ptr<Serializable>& aCallbackArgument = + nullptr) override; GfErrType localClearNoThrow( const std::shared_ptr<Serializable>& aCallbackArgument = nullptr, const CacheEventFlags eventFlags = CacheEventFlags::NORMAL); @@ -241,9 +245,8 @@ class APACHE_GEODE_EXPORT LocalRegion : public RegionInternal { bool containsKey(const std::shared_ptr<CacheableKey>& keyPtr) const override; virtual bool containsKeyOnServer( const std::shared_ptr<CacheableKey>& keyPtr) const override; - virtual std::vector<std::shared_ptr<CacheableKey>> getInterestList() - const override; - virtual std::vector<std::shared_ptr<CacheableString>> getInterestListRegex() + std::vector<std::shared_ptr<CacheableKey>> getInterestList() const override; + std::vector<std::shared_ptr<CacheableString>> getInterestListRegex() const override; /** @brief Public Methods from RegionInternal @@ -255,39 +258,40 @@ class APACHE_GEODE_EXPORT LocalRegion : public RegionInternal { void setPersistenceManager( std::shared_ptr<PersistenceManager>& pmPtr) override; - virtual GfErrType getNoThrow( + GfErrType getNoThrow( const std::shared_ptr<CacheableKey>& key, std::shared_ptr<Cacheable>& value, const std::shared_ptr<Serializable>& aCallbackArgument) override; - virtual GfErrType getAllNoThrow( + GfErrType getAllNoThrow( const std::vector<std::shared_ptr<CacheableKey>>& keys, const std::shared_ptr<HashMapOfCacheable>& values, const std::shared_ptr<HashMapOfException>& exceptions, const bool addToLocalCache, const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) override; - virtual GfErrType putNoThrow( - const std::shared_ptr<CacheableKey>& key, - const std::shared_ptr<Cacheable>& value, - const std::shared_ptr<Serializable>& aCallbackArgument, - std::shared_ptr<Cacheable>& oldValue, int updateCount, - const CacheEventFlags eventFlags, std::shared_ptr<VersionTag> versionTag, - DataInput* delta = nullptr, - std::shared_ptr<EventId> eventId = nullptr) override; - virtual GfErrType putNoThrowTX( - const std::shared_ptr<CacheableKey>& key, - const std::shared_ptr<Cacheable>& value, - const std::shared_ptr<Serializable>& aCallbackArgument, - std::shared_ptr<Cacheable>& oldValue, int updateCount, - const CacheEventFlags eventFlags, std::shared_ptr<VersionTag> versionTag, - DataInput* delta = nullptr, std::shared_ptr<EventId> eventId = nullptr); - virtual GfErrType createNoThrow( + GfErrType putNoThrow(const std::shared_ptr<CacheableKey>& key, + const std::shared_ptr<Cacheable>& value, + const std::shared_ptr<Serializable>& aCallbackArgument, + std::shared_ptr<Cacheable>& oldValue, int updateCount, + const CacheEventFlags eventFlags, + std::shared_ptr<VersionTag> versionTag, + DataInput* delta = nullptr, + std::shared_ptr<EventId> eventId = nullptr) override; + GfErrType putNoThrowTX(const std::shared_ptr<CacheableKey>& key, + const std::shared_ptr<Cacheable>& value, + const std::shared_ptr<Serializable>& aCallbackArgument, + std::shared_ptr<Cacheable>& oldValue, int updateCount, + const CacheEventFlags eventFlags, + std::shared_ptr<VersionTag> versionTag, + DataInput* delta = nullptr, + std::shared_ptr<EventId> eventId = nullptr); + GfErrType createNoThrow( const std::shared_ptr<CacheableKey>& key, const std::shared_ptr<Cacheable>& value, const std::shared_ptr<Serializable>& aCallbackArgument, int updateCount, const CacheEventFlags eventFlags, std::shared_ptr<VersionTag> versionTag) override; - virtual GfErrType destroyNoThrow( + GfErrType destroyNoThrow( const std::shared_ptr<CacheableKey>& key, const std::shared_ptr<Serializable>& aCallbackArgument, int updateCount, const CacheEventFlags eventFlags, @@ -296,7 +300,7 @@ class APACHE_GEODE_EXPORT LocalRegion : public RegionInternal { const std::shared_ptr<CacheableKey>& key, const std::shared_ptr<Serializable>& aCallbackArgument, int updateCount, const CacheEventFlags eventFlags, std::shared_ptr<VersionTag> versionTag); - virtual GfErrType removeNoThrow( + GfErrType removeNoThrow( const std::shared_ptr<CacheableKey>& key, const std::shared_ptr<Cacheable>& value, const std::shared_ptr<Serializable>& aCallbackArgument, int updateCount, @@ -313,7 +317,7 @@ class APACHE_GEODE_EXPORT LocalRegion : public RegionInternal { virtual GfErrType removeAllNoThrow( const std::vector<std::shared_ptr<CacheableKey>>& keys, const std::shared_ptr<Serializable>& aCallbackArgument = nullptr); - virtual GfErrType invalidateNoThrow( + GfErrType invalidateNoThrow( const std::shared_ptr<CacheableKey>& keyPtr, const std::shared_ptr<Serializable>& aCallbackArgument, int updateCount, const CacheEventFlags eventFlags, @@ -460,7 +464,7 @@ class APACHE_GEODE_EXPORT LocalRegion : public RegionInternal { virtual GfErrType destroyRegionNoThrow_remote( const std::shared_ptr<Serializable>& aCallbackArgument); virtual GfErrType unregisterKeysBeforeDestroyRegion(); - virtual const std::shared_ptr<Pool>& getPool() const override { + const std::shared_ptr<Pool>& getPool() const override { return m_attachedPool; } @@ -563,9 +567,6 @@ class APACHE_GEODE_EXPORT LocalRegion : public RegionInternal { std::chrono::seconds getRegionExpiryDuration() const; std::chrono::seconds getEntryExpiryDuration() const; void invokeAfterAllEndPointDisconnected(); - // Disallow copy constructor and assignment operator. - LocalRegion(const LocalRegion&); - LocalRegion& operator=(const LocalRegion&); virtual GfErrType getNoThrow_FullObject( std::shared_ptr<EventId> eventId, std::shared_ptr<Cacheable>& fullObject, diff --git a/cppcache/src/PoolFactory.cpp b/cppcache/src/PoolFactory.cpp index deaed13..c9f82d7 100644 --- a/cppcache/src/PoolFactory.cpp +++ b/cppcache/src/PoolFactory.cpp @@ -249,11 +249,7 @@ std::shared_ptr<Pool> PoolFactory::create(std::string name) { if (m_cache.isClosed()) { throw CacheClosedException("Cache is closed"); } - if (cacheImpl->getCacheMode() && m_isSubscriptionRedundancy) { - LOGWARN( - "At least one pool has been created so ignoring cache level " - "redundancy setting"); - } + auto&& tccm = cacheImpl->tcrConnectionManager(); LOGDEBUG("PoolFactory::create mulitusermode = %d ", diff --git a/cppcache/src/Region.cpp b/cppcache/src/Region.cpp index 6d1a150..da166b4 100644 --- a/cppcache/src/Region.cpp +++ b/cppcache/src/Region.cpp @@ -25,7 +25,7 @@ namespace client { Region::Region(CacheImpl* cacheImpl) : m_cacheImpl(cacheImpl) {} -Region::~Region() {} +Region::~Region() noexcept = default; Cache& Region::getCache() { return *m_cacheImpl->getCache(); } diff --git a/cppcache/src/RegionInternal.cpp b/cppcache/src/RegionInternal.cpp index 2f7e72f..ea01843 100644 --- a/cppcache/src/RegionInternal.cpp +++ b/cppcache/src/RegionInternal.cpp @@ -44,7 +44,7 @@ RegionInternal::RegionInternal(CacheImpl* cacheImpl, RegionAttributes attributes) : Region(cacheImpl), m_regionAttributes(attributes) {} -RegionInternal::~RegionInternal() {} +RegionInternal::~RegionInternal() noexcept = default; void RegionInternal::registerKeys( const std::vector<std::shared_ptr<CacheableKey>>&, bool, bool, bool) { diff --git a/cppcache/src/RegionInternal.hpp b/cppcache/src/RegionInternal.hpp index 4a984c3..ce29887 100644 --- a/cppcache/src/RegionInternal.hpp +++ b/cppcache/src/RegionInternal.hpp @@ -55,13 +55,8 @@ class CacheEventFlags { static const uint8_t GF_CACHE_CLOSE = 0x40; static const uint8_t GF_NOCACHEWRITER = 0x80; - // private constructor inline explicit CacheEventFlags(const uint8_t flags) : m_flags(flags) {} - // disable constructors and assignment - CacheEventFlags(); - CacheEventFlags& operator=(const CacheEventFlags&); - public: static const CacheEventFlags NORMAL; static const CacheEventFlags LOCAL; @@ -72,8 +67,10 @@ class CacheEventFlags { static const CacheEventFlags CACHE_CLOSE; static const CacheEventFlags NOCACHEWRITER; - inline CacheEventFlags(const CacheEventFlags& flags) - : m_flags(flags.m_flags) {} + inline CacheEventFlags(const CacheEventFlags& flags) = default; + + CacheEventFlags() = delete; + CacheEventFlags& operator=(const CacheEventFlags&) = delete; inline CacheEventFlags operator|(const CacheEventFlags& flags) const { return CacheEventFlags(m_flags | flags.m_flags); @@ -141,26 +138,25 @@ class MapEntryImpl; */ class RegionInternal : public Region { public: - /** - * @brief destructor - */ - virtual ~RegionInternal() override; - /** @brief Default implementation of Public Methods from Region - */ - virtual void registerKeys( - const std::vector<std::shared_ptr<CacheableKey>>& keys, - bool isDurable = false, bool getInitialValues = false, - bool receiveValues = true) override; - virtual void unregisterKeys( + RegionInternal(const RegionInternal&) = delete; + RegionInternal& operator=(const RegionInternal&) = delete; + + ~RegionInternal() noexcept override; + + void registerKeys(const std::vector<std::shared_ptr<CacheableKey>>& keys, + bool isDurable = false, bool getInitialValues = false, + bool receiveValues = true) override; + + void unregisterKeys( const std::vector<std::shared_ptr<CacheableKey>>& keys) override; - virtual void registerAllKeys(bool isDurable = false, - bool getInitialValues = false, - bool receiveValues = true) override; - virtual void unregisterAllKeys() override; - - virtual void registerRegex(const std::string& regex, bool isDurable = false, - bool getInitialValues = false, - bool receiveValues = true) override; + + void registerAllKeys(bool isDurable = false, bool getInitialValues = false, + bool receiveValues = true) override; + void unregisterAllKeys() override; + + void registerRegex(const std::string& regex, bool isDurable = false, + bool getInitialValues = false, + bool receiveValues = true) override; virtual void unregisterRegex(const std::string& regex) override; virtual std::shared_ptr<SelectResults> query( @@ -168,11 +164,11 @@ class RegionInternal : public Region { std::chrono::milliseconds timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT) override; - virtual bool existsValue(const std::string& predicate, - std::chrono::milliseconds timeout = - DEFAULT_QUERY_RESPONSE_TIMEOUT) override; + bool existsValue(const std::string& predicate, + std::chrono::milliseconds timeout = + DEFAULT_QUERY_RESPONSE_TIMEOUT) override; - virtual std::shared_ptr<Serializable> selectValue( + std::shared_ptr<Serializable> selectValue( const std::string& predicate, std::chrono::milliseconds timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT) override; @@ -263,7 +259,7 @@ class RegionInternal : public Region { virtual RegionStats* getRegionStats() = 0; virtual bool cacheEnabled() = 0; - virtual bool isDestroyed() const override = 0; + bool isDestroyed() const override = 0; virtual void evict(int32_t percentage) = 0; virtual CacheImpl* getCacheImpl() const = 0; virtual std::shared_ptr<TombstoneList> getTombstoneList(); @@ -290,12 +286,9 @@ class RegionInternal : public Region { inline bool isConcurrencyCheckEnabled() const { return m_regionAttributes.getConcurrencyChecksEnabled(); } - virtual const std::shared_ptr<Pool>& getPool() const override = 0; + const std::shared_ptr<Pool>& getPool() const override = 0; protected: - /** - * @brief constructor - */ RegionInternal(CacheImpl* cache, RegionAttributes attributes); void setLruEntriesLimit(uint32_t limit); @@ -332,9 +325,6 @@ class RegionInternal : public Region { inline bool regionExpiryEnabled() const { return m_regionAttributes.getRegionExpiryEnabled(); } - - RegionInternal(const RegionInternal&) = delete; - RegionInternal& operator=(const RegionInternal&) = delete; }; } // namespace client diff --git a/cppcache/src/TcrConnectionManager.cpp b/cppcache/src/TcrConnectionManager.cpp index cb6dcae..0a862ff 100644 --- a/cppcache/src/TcrConnectionManager.cpp +++ b/cppcache/src/TcrConnectionManager.cpp @@ -94,47 +94,8 @@ void TcrConnectionManager::init(bool isPool) { m_pingTaskId, pingInterval.count()); } - auto cacheAttributes = m_cache->getAttributes(); - const auto &endpoints = cacheAttributes->getEndpoints(); m_redundancyManager->m_HAenabled = false; - if (cacheAttributes != nullptr && - (cacheAttributes->getRedundancyLevel() > 0 || m_isDurable) && - !endpoints.empty() && endpoints != "none") { - // no distributaion manager at this point - initializeHAEndpoints(endpoints.c_str()); - m_redundancyManager->initialize(cacheAttributes->getRedundancyLevel()); - // Call maintain redundancy level, so primary is available for notification - // operations. - GfErrType err = m_redundancyManager->maintainRedundancyLevel(true); - m_redundancyManager->m_HAenabled = - m_redundancyManager->m_HAenabled || - ThinClientBaseDM::isDeltaEnabledOnServer(); - - const auto redundancyChecker = new ExpiryHandler_T<TcrConnectionManager>( - this, &TcrConnectionManager::checkRedundancy); - const auto redundancyMonitorInterval = props.redundancyMonitorInterval(); - - m_servermonitorTaskId = m_cache->getExpiryTaskManager().scheduleExpiryTask( - redundancyChecker, std::chrono::seconds(1), redundancyMonitorInterval, - false); - LOGFINE( - "TcrConnectionManager::TcrConnectionManager Registered server " - "monitor task with id = %ld, interval = %ld", - m_servermonitorTaskId, redundancyMonitorInterval.count()); - - if (ThinClientBaseDM::isFatalError(err)) { - GfErrTypeToException("TcrConnectionManager::init", err); - } - - m_redundancyTask = std::unique_ptr<Task<TcrConnectionManager>>( - new Task<TcrConnectionManager>(this, &TcrConnectionManager::redundancy, - NC_Redundancy)); - m_redundancyTask->start(); - - m_redundancyManager->m_HAenabled = true; - } - startFailoverAndCleanupThreads(isPool); } @@ -161,6 +122,7 @@ void TcrConnectionManager::startFailoverAndCleanupThreads(bool isPool) { void TcrConnectionManager::close() { LOGFINE("TcrConnectionManager is closing"); + if (m_pingTaskId > 0) { m_cache->getExpiryTaskManager().cancelTask(m_pingTaskId); } @@ -172,27 +134,6 @@ void TcrConnectionManager::close() { m_failoverTask = nullptr; } - auto cacheAttributes = m_cache->getAttributes(); - if (cacheAttributes != nullptr && - (cacheAttributes->getRedundancyLevel() > 0 || m_isDurable)) { - if (m_servermonitorTaskId > 0) { - m_cache->getExpiryTaskManager().cancelTask(m_servermonitorTaskId); - } - if (m_redundancyTask != nullptr) { - m_redundancyTask->stopNoblock(); - m_redundancySema.release(); - m_redundancyTask->wait(); - // now stop cleanup task - // stopCleanupTask(); - m_redundancyTask = nullptr; - } - - m_redundancyManager->close(); - delete m_redundancyManager; - m_redundancyManager = nullptr; - - removeHAEndpoints(); - } LOGFINE("TcrConnectionManager is closed"); } diff --git a/cppcache/src/TcrHADistributionManager.cpp b/cppcache/src/TcrHADistributionManager.cpp index 91dfa06..af0529e 100644 --- a/cppcache/src/TcrHADistributionManager.cpp +++ b/cppcache/src/TcrHADistributionManager.cpp @@ -33,10 +33,8 @@ namespace geode { namespace client { TcrHADistributionManager::TcrHADistributionManager( - ThinClientRegion* theRegion, TcrConnectionManager& connManager, - std::shared_ptr<CacheAttributes> cacheAttributes) + ThinClientRegion* theRegion, TcrConnectionManager& connManager) : ThinClientDistributionManager(connManager, theRegion), - m_cacheAttributes(cacheAttributes), m_theTcrConnManager(connManager) { GF_R_ASSERT(theRegion != nullptr); } @@ -62,10 +60,8 @@ GfErrType TcrHADistributionManager::registerInterestForRegion( } void TcrHADistributionManager::getEndpointNames( - std::unordered_set<std::string>& endpointNames) { - Utils::parseEndpointNamesString(m_cacheAttributes->getEndpoints(), - endpointNames); -} + std::unordered_set<std::string>&) {} + GfErrType TcrHADistributionManager::sendRequestToEP(const TcrMessage& request, TcrMessageReply& reply, TcrEndpoint* endpoint) { diff --git a/cppcache/src/TcrHADistributionManager.hpp b/cppcache/src/TcrHADistributionManager.hpp index fb293ae..ce90c3d 100644 --- a/cppcache/src/TcrHADistributionManager.hpp +++ b/cppcache/src/TcrHADistributionManager.hpp @@ -20,7 +20,6 @@ #ifndef GEODE_TCRHADISTRIBUTIONMANAGER_H_ #define GEODE_TCRHADISTRIBUTIONMANAGER_H_ -#include <geode/CacheAttributes.hpp> #include <geode/internal/geode_base.hpp> #include "TcrConnectionManager.hpp" @@ -41,8 +40,7 @@ class APACHE_GEODE_EXPORT TcrHADistributionManager : public ThinClientDistributionManager { public: TcrHADistributionManager(ThinClientRegion* theRegion, - TcrConnectionManager& connManager, - std::shared_ptr<CacheAttributes> cacheAttributes); + TcrConnectionManager& connManager); ~TcrHADistributionManager() override = default; TcrHADistributionManager(const TcrHADistributionManager&) = delete; TcrHADistributionManager& operator=(const TcrHADistributionManager&) = delete; @@ -88,7 +86,6 @@ class APACHE_GEODE_EXPORT TcrHADistributionManager bool postFailoverAction(TcrEndpoint* endpoint) override; private: - std::shared_ptr<CacheAttributes> m_cacheAttributes; TcrConnectionManager& m_theTcrConnManager; GfErrType sendRequestToPrimary(TcrMessage& request, TcrMessageReply& reply) { diff --git a/cppcache/src/ThinClientCacheDistributionManager.cpp b/cppcache/src/ThinClientCacheDistributionManager.cpp index 7a67a10..e33e0d7 100644 --- a/cppcache/src/ThinClientCacheDistributionManager.cpp +++ b/cppcache/src/ThinClientCacheDistributionManager.cpp @@ -19,7 +19,6 @@ #include <algorithm> -#include <geode/CacheAttributes.hpp> #include <geode/ExceptionTypes.hpp> #include <geode/internal/geode_globals.hpp> diff --git a/cppcache/src/ThinClientHARegion.cpp b/cppcache/src/ThinClientHARegion.cpp index 3d11082..1910919 100644 --- a/cppcache/src/ThinClientHARegion.cpp +++ b/cppcache/src/ThinClientHARegion.cpp @@ -35,42 +35,26 @@ ThinClientHARegion::ThinClientHARegion( bool enableNotification) : ThinClientRegion(name, cache, rPtr, attributes, stats, shared), m_attributes(attributes), - m_processedMarker(false), - m_poolDM(false) { + m_processedMarker(false) { setClientNotificationEnabled(enableNotification); } void ThinClientHARegion::initTCR() { try { - const bool isPool = !m_attributes.getPoolName().empty(); - - if (isPool) { - m_tcrdm = dynamic_cast<ThinClientPoolHADM*>( - m_cacheImpl->getCache() - ->getPoolManager() - .find(m_attributes.getPoolName()) - .get()); - if (m_tcrdm) { - m_poolDM = true; - // Pool DM should only be inited once and it - // is already done in PoolFactory::create(); - // m_tcrdm->init(); - ThinClientPoolHADM* poolDM = dynamic_cast<ThinClientPoolHADM*>(m_tcrdm); - poolDM->addRegion(this); - poolDM->incRegionCount(); - - } else { - throw IllegalStateException("pool not found"); - } + m_tcrdm = std::dynamic_pointer_cast<ThinClientBaseDM>( + m_cacheImpl->getCache()->getPoolManager().find( + m_attributes.getPoolName())); + if (m_tcrdm) { + // Pool DM should only be inited once and it + // is already done in PoolFactory::create(); + // m_tcrdm->init(); + auto poolDM = std::dynamic_pointer_cast<ThinClientPoolHADM>(m_tcrdm); + poolDM->addRegion(this); + poolDM->incRegionCount(); } else { - m_poolDM = false; - m_tcrdm = new TcrHADistributionManager( - this, m_cacheImpl->tcrConnectionManager(), - m_cacheImpl->getAttributes()); - m_tcrdm->init(); + throw IllegalStateException("pool not found"); } } catch (const Exception& ex) { - _GEODE_SAFE_DELETE(m_tcrdm); LOGERROR( "ThinClientHARegion: failed to create a DistributionManager " "object due to: %s: %s", @@ -124,30 +108,24 @@ bool ThinClientHARegion::getProcessedMarker() { return m_processedMarker || !isDurableClient(); } -void ThinClientHARegion::destroyDM(bool keepEndpoints) { - if (m_poolDM) { - LOGDEBUG( - "ThinClientHARegion::destroyDM( ): removing region from " - "ThinClientPoolHADM list."); - ThinClientPoolHADM* poolDM = dynamic_cast<ThinClientPoolHADM*>(m_tcrdm); - poolDM->removeRegion(this); - poolDM->decRegionCount(); - } else { - ThinClientRegion::destroyDM(keepEndpoints); - } +void ThinClientHARegion::destroyDM(bool) { + LOGDEBUG( + "ThinClientHARegion::destroyDM( ): removing region from " + "ThinClientPoolHADM list."); + auto poolDM = std::dynamic_pointer_cast<ThinClientPoolHADM>(m_tcrdm); + poolDM->removeRegion(this); + poolDM->decRegionCount(); } void ThinClientHARegion::addDisMessToQueue() { - if (m_poolDM) { - ThinClientPoolHADM* poolDM = dynamic_cast<ThinClientPoolHADM*>(m_tcrdm); - poolDM->addDisMessToQueue(this); - - if (poolDM->m_redundancyManager->m_globalProcessedMarker && - !m_processedMarker) { - TcrMessage* regionMsg = new TcrMessageClientMarker( - new DataOutput(m_cacheImpl->createDataOutput()), true); - receiveNotification(regionMsg); - } + auto poolDM = std::dynamic_pointer_cast<ThinClientPoolHADM>(m_tcrdm); + poolDM->addDisMessToQueue(this); + + if (poolDM->m_redundancyManager->m_globalProcessedMarker && + !m_processedMarker) { + TcrMessage* regionMsg = new TcrMessageClientMarker( + new DataOutput(m_cacheImpl->createDataOutput()), true); + receiveNotification(regionMsg); } } @@ -158,13 +136,13 @@ GfErrType ThinClientHARegion::getNoThrow_FullObject( new DataOutput(m_cacheImpl->createDataOutput()), eventId); TcrMessageReply reply(true, nullptr); - ThinClientPoolHADM* poolHADM = dynamic_cast<ThinClientPoolHADM*>(m_tcrdm); + auto poolHADM = std::dynamic_pointer_cast<ThinClientPoolHADM>(m_tcrdm); GfErrType err = GF_NOTCON; if (poolHADM) { err = poolHADM->sendRequestToPrimary(fullObjectMsg, reply); } else { - err = static_cast<TcrHADistributionManager*>(m_tcrdm)->sendRequestToPrimary( - fullObjectMsg, reply); + err = std::static_pointer_cast<TcrHADistributionManager>(m_tcrdm) + ->sendRequestToPrimary(fullObjectMsg, reply); } if (err == GF_NOERR) { fullObject = reply.getValue(); diff --git a/cppcache/src/ThinClientHARegion.hpp b/cppcache/src/ThinClientHARegion.hpp index ae11962..d6fe7a5 100644 --- a/cppcache/src/ThinClientHARegion.hpp +++ b/cppcache/src/ThinClientHARegion.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_THINCLIENTHAREGION_H_ -#define GEODE_THINCLIENTHAREGION_H_ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -19,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#pragma once + +#ifndef GEODE_THINCLIENTHAREGION_H_ +#define GEODE_THINCLIENTHAREGION_H_ #include <geode/Pool.hpp> #include "ThinClientRegion.hpp" -/** - * @file - */ - namespace apache { namespace geode { namespace client { @@ -44,47 +39,42 @@ namespace client { */ class APACHE_GEODE_EXPORT ThinClientHARegion : public ThinClientRegion { public: - /** - * @brief constructor/destructor - */ ThinClientHARegion(const std::string& name, CacheImpl* cache, const std::shared_ptr<RegionInternal>& rPtr, RegionAttributes attributes, const std::shared_ptr<CacheStatistics>& stats, bool shared = false, bool enableNotification = true); - virtual ~ThinClientHARegion() { - if (m_poolDM) m_tcrdm = nullptr; - }; + ThinClientHARegion(const ThinClientHARegion&) = delete; + ThinClientHARegion& operator=(const ThinClientHARegion&) = delete; - virtual void initTCR(); + ~ThinClientHARegion() noexcept override = default; - bool getProcessedMarker(); + void initTCR() override; - void setProcessedMarker(bool mark = true) { m_processedMarker = mark; } - void addDisMessToQueue(); + bool getProcessedMarker() override; + + void setProcessedMarker(bool mark = true) override { + m_processedMarker = mark; + } + void addDisMessToQueue() override; protected: - virtual GfErrType getNoThrow_FullObject( + GfErrType getNoThrow_FullObject( std::shared_ptr<EventId> eventId, std::shared_ptr<Cacheable>& fullObject, - std::shared_ptr<VersionTag>& versionTag); + std::shared_ptr<VersionTag>& versionTag) override; private: RegionAttributes m_attributes; volatile bool m_processedMarker; - void handleMarker(); - - bool m_poolDM; + void handleMarker() override; - // Disallow copy constructor and assignment operator. - ThinClientHARegion(const ThinClientHARegion&); - ThinClientHARegion& operator=(const ThinClientHARegion&); + void acquireGlobals(bool isFailover) override; + void releaseGlobals(bool isFailover) override; - void acquireGlobals(bool isFailover); - void releaseGlobals(bool isFailover); - - void destroyDM(bool keepEndpoints); + void destroyDM(bool keepEndpoints) override; }; + } // namespace client } // namespace geode } // namespace apache diff --git a/cppcache/src/ThinClientPoolRegion.cpp b/cppcache/src/ThinClientPoolRegion.cpp index 9d82f3a..e58db8b 100644 --- a/cppcache/src/ThinClientPoolRegion.cpp +++ b/cppcache/src/ThinClientPoolRegion.cpp @@ -39,18 +39,12 @@ ThinClientPoolRegion::ThinClientPoolRegion( const std::shared_ptr<CacheStatistics>& stats, bool shared) : ThinClientRegion(name, cache, rPtr, attributes, stats, shared) {} -ThinClientPoolRegion::~ThinClientPoolRegion() { m_tcrdm = nullptr; } - void ThinClientPoolRegion::initTCR() { try { - ThinClientPoolDM* poolDM = dynamic_cast<ThinClientPoolDM*>( - getCache() - .getPoolManager() - .find(m_regionAttributes.getPoolName()) - .get()); - m_tcrdm = dynamic_cast<ThinClientBaseDM*>(poolDM); + auto poolDM = std::dynamic_pointer_cast<ThinClientPoolDM>( + getCache().getPoolManager().find(m_regionAttributes.getPoolName())); + m_tcrdm = poolDM; if (!m_tcrdm) { - // TODO: create a PoolNotFound exception. throw IllegalStateException("pool not found"); } poolDM->incRegionCount(); @@ -62,7 +56,7 @@ void ThinClientPoolRegion::initTCR() { } void ThinClientPoolRegion::destroyDM(bool) { - dynamic_cast<ThinClientPoolDM*>(m_tcrdm)->decRegionCount(); + std::dynamic_pointer_cast<ThinClientPoolDM>(m_tcrdm)->decRegionCount(); } } // namespace client diff --git a/cppcache/src/ThinClientPoolRegion.hpp b/cppcache/src/ThinClientPoolRegion.hpp index 9e79255..cccd3d1 100644 --- a/cppcache/src/ThinClientPoolRegion.hpp +++ b/cppcache/src/ThinClientPoolRegion.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_THINCLIENTPOOLREGION_H_ -#define GEODE_THINCLIENTPOOLREGION_H_ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -19,12 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* - * ThinClientPoolRegion.hpp - * - * Created on: Nov 20, 2008 - * Author: abhaware - */ + +#pragma once + +#ifndef GEODE_THINCLIENTPOOLREGION_H_ +#define GEODE_THINCLIENTPOOLREGION_H_ #include "ThinClientHARegion.hpp" @@ -33,25 +27,22 @@ namespace geode { namespace client { class ThinClientPoolRegion : public ThinClientRegion { public: - /** - * @brief constructor/initializer/destructor - */ ThinClientPoolRegion(const std::string& name, CacheImpl* cache, const std::shared_ptr<RegionInternal>& rPtr, RegionAttributes attributes, const std::shared_ptr<CacheStatistics>& stats, bool shared = false); - virtual void initTCR(); - virtual ~ThinClientPoolRegion(); + ThinClientPoolRegion(const ThinClientPoolRegion&) = delete; + ThinClientPoolRegion& operator=(const ThinClientPoolRegion&) = delete; - private: - virtual void destroyDM(bool keepEndpoints); + void initTCR() override; + ~ThinClientPoolRegion() noexcept override = default; - // Disallow copy constructor and assignment operator. - ThinClientPoolRegion(const ThinClientPoolRegion&); - ThinClientPoolRegion& operator=(const ThinClientPoolRegion&); + private: + void destroyDM(bool keepEndpoints) override; }; + } // namespace client } // namespace geode } // namespace apache diff --git a/cppcache/src/ThinClientRegion.cpp b/cppcache/src/ThinClientRegion.cpp index 21eb0f4..d812d32 100644 --- a/cppcache/src/ThinClientRegion.cpp +++ b/cppcache/src/ThinClientRegion.cpp @@ -358,11 +358,10 @@ ThinClientRegion::ThinClientRegion( void ThinClientRegion::initTCR() { try { - m_tcrdm = - new TcrDistributionManager(this, m_cacheImpl->tcrConnectionManager()); + m_tcrdm = std::make_shared<TcrDistributionManager>( + this, m_cacheImpl->tcrConnectionManager()); m_tcrdm->init(); } catch (const Exception& ex) { - _GEODE_SAFE_DELETE(m_tcrdm); LOGERROR("Exception while initializing region: %s: %s", ex.getName().c_str(), ex.what()); throw; @@ -628,10 +627,7 @@ std::shared_ptr<SelectResults> ThinClientRegion::query( std::shared_ptr<RemoteQuery> queryPtr; - // TODO: - ThinClientPoolDM* poolDM = dynamic_cast<ThinClientPoolDM*>(m_tcrdm); - - if (poolDM) { + if (auto poolDM = std::dynamic_pointer_cast<ThinClientPoolDM>(m_tcrdm)) { queryPtr = std::dynamic_pointer_cast<RemoteQuery>( poolDM->getQueryServiceWithoutCheck()->newQuery(squery.c_str())); } else { @@ -639,7 +635,7 @@ std::shared_ptr<SelectResults> ThinClientRegion::query( m_cacheImpl->getQueryService()->newQuery(squery.c_str())); } - return queryPtr->execute(timeout, "Region::query", m_tcrdm, nullptr); + return queryPtr->execute(timeout, "Region::query", m_tcrdm.get(), nullptr); } bool ThinClientRegion::existsValue(const std::string& predicate, @@ -723,9 +719,9 @@ std::shared_ptr<Serializable> ThinClientRegion::selectValue( std::vector<std::shared_ptr<CacheableKey>> ThinClientRegion::serverKeys() { CHECK_DESTROY_PENDING(TryReadGuard, Region::serverKeys); - TcrMessageReply reply(true, m_tcrdm); + TcrMessageReply reply(true, m_tcrdm.get()); TcrMessageKeySet request(new DataOutput(m_cacheImpl->createDataOutput()), - m_fullPath, m_tcrdm); + m_fullPath, m_tcrdm.get()); reply.setMessageTypeRequest(TcrMessage::KEY_SET); std::vector<std::shared_ptr<CacheableKey>> serverKeys; ChunkedKeySetResponse resultCollector(request, serverKeys, reply); @@ -772,11 +768,10 @@ bool ThinClientRegion::containsKeyOnServer( TcrMessageContainsKey request( new DataOutput(m_cacheImpl->createDataOutput()), this, keyPtr, - static_cast<std::shared_ptr<Serializable>>(nullptr), true, m_tcrdm); - TcrMessageReply reply(true, m_tcrdm); + static_cast<std::shared_ptr<Serializable>>(nullptr), true, m_tcrdm.get()); + TcrMessageReply reply(true, m_tcrdm.get()); reply.setMessageTypeRequest(TcrMessage::CONTAINS_KEY); err = m_tcrdm->sendSyncRequest(request, reply); - // if ( err != GF_NOERR ) return ret; switch (reply.getMessageType()) { case TcrMessage::RESPONSE: @@ -818,8 +813,9 @@ bool ThinClientRegion::containsValueForKey_remote( TcrMessageContainsKey request( new DataOutput(m_cacheImpl->createDataOutput()), this, keyPtr, - static_cast<std::shared_ptr<Serializable>>(nullptr), false, m_tcrdm); - TcrMessageReply reply(true, m_tcrdm); + static_cast<std::shared_ptr<Serializable>>(nullptr), false, + m_tcrdm.get()); + TcrMessageReply reply(true, m_tcrdm.get()); reply.setMessageTypeRequest(TcrMessage::CONTAINS_KEY); err = m_tcrdm->sendSyncRequest(request, reply); // if ( err != GF_NOERR ) return ret; @@ -866,8 +862,8 @@ void ThinClientRegion::clear( TcrMessageClearRegion request(new DataOutput(m_cacheImpl->createDataOutput()), this, aCallbackArgument, - std::chrono::milliseconds(-1), m_tcrdm); - TcrMessageReply reply(true, m_tcrdm); + std::chrono::milliseconds(-1), m_tcrdm.get()); + TcrMessageReply reply(true, m_tcrdm.get()); err = m_tcrdm->sendSyncRequest(request, reply); if (err != GF_NOERR) GfErrTypeToException("Region::clear", err); @@ -909,8 +905,8 @@ GfErrType ThinClientRegion::getNoThrow_remote( /** @brief Create message and send to bridge server */ TcrMessageRequest request(new DataOutput(m_cacheImpl->createDataOutput()), - this, keyPtr, aCallbackArgument, m_tcrdm); - TcrMessageReply reply(true, m_tcrdm); + this, keyPtr, aCallbackArgument, m_tcrdm.get()); + TcrMessageReply reply(true, m_tcrdm.get()); err = m_tcrdm->sendSyncRequest(request, reply); if (err != GF_NOERR) return err; @@ -947,11 +943,9 @@ GfErrType ThinClientRegion::invalidateNoThrow_remote( std::shared_ptr<VersionTag>& versionTag) { GfErrType err = GF_NOERR; - /** @brief Create message and send to bridge server */ - TcrMessageInvalidate request(new DataOutput(m_cacheImpl->createDataOutput()), - this, keyPtr, aCallbackArgument, m_tcrdm); - TcrMessageReply reply(true, m_tcrdm); + this, keyPtr, aCallbackArgument, m_tcrdm.get()); + TcrMessageReply reply(true, m_tcrdm.get()); err = m_tcrdm->sendSyncRequest(request, reply); if (err != GF_NOERR) return err; @@ -966,8 +960,6 @@ GfErrType ThinClientRegion::invalidateNoThrow_remote( break; } case TcrMessage::INVALIDATE_ERROR: { - // LOGERROR("A read error occurred on the endpoint %s", - // m_tcrdm->getActiveEndpoint()->name().c_str()); err = GF_CACHESERVER_EXCEPTION; break; } @@ -1000,19 +992,20 @@ GfErrType ThinClientRegion::putNoThrow_remote( delta = temp && temp->hasDelta(); } TcrMessagePut request(new DataOutput(m_cacheImpl->createDataOutput()), this, - keyPtr, valuePtr, aCallbackArgument, delta, m_tcrdm); - TcrMessageReply* reply = new TcrMessageReply(true, m_tcrdm); + keyPtr, valuePtr, aCallbackArgument, delta, + m_tcrdm.get()); + TcrMessageReply* reply = new TcrMessageReply(true, m_tcrdm.get()); err = m_tcrdm->sendSyncRequest(request, *reply); if (delta) { - m_cacheImpl->getCachePerfStats() - .incDeltaPut(); // Does not chcek whether success of failure.. - if (reply->getMessageType() == - TcrMessage::PUT_DELTA_ERROR) { // Try without delta + // Does not check whether success of failure.. + m_cacheImpl->getCachePerfStats().incDeltaPut(); + if (reply->getMessageType() == TcrMessage::PUT_DELTA_ERROR) { + // Try without delta TcrMessagePut request(new DataOutput(m_cacheImpl->createDataOutput()), this, keyPtr, valuePtr, aCallbackArgument, false, - m_tcrdm, false, true); + m_tcrdm.get(), false, true); delete reply; - reply = new TcrMessageReply(true, m_tcrdm); + reply = new TcrMessageReply(true, m_tcrdm.get()); err = m_tcrdm->sendSyncRequest(request, *reply); } } @@ -1029,8 +1022,6 @@ GfErrType ThinClientRegion::putNoThrow_remote( break; } case TcrMessage::PUT_DATA_ERROR: { - // LOGERROR("A write error occurred on the endpoint %s", - // m_tcrdm->getActiveEndpoint()->name().c_str()); err = GF_CACHESERVER_EXCEPTION; break; } @@ -1062,8 +1053,9 @@ GfErrType ThinClientRegion::destroyNoThrow_remote( // do TCR destroy TcrMessageDestroy request(new DataOutput(m_cacheImpl->createDataOutput()), - this, keyPtr, nullptr, aCallbackArgument, m_tcrdm); - TcrMessageReply reply(true, m_tcrdm); + this, keyPtr, nullptr, aCallbackArgument, + m_tcrdm.get()); + TcrMessageReply reply(true, m_tcrdm.get()); err = m_tcrdm->sendSyncRequest(request, reply); if (err != GF_NOERR) return err; @@ -1105,8 +1097,9 @@ GfErrType ThinClientRegion::removeNoThrow_remote( // do TCR remove TcrMessageDestroy request(new DataOutput(m_cacheImpl->createDataOutput()), - this, keyPtr, cvalue, aCallbackArgument, m_tcrdm); - TcrMessageReply reply(true, m_tcrdm); + this, keyPtr, cvalue, aCallbackArgument, + m_tcrdm.get()); + TcrMessageReply reply(true, m_tcrdm.get()); err = m_tcrdm->sendSyncRequest(request, reply); if (err != GF_NOERR) { return err; @@ -1147,8 +1140,9 @@ GfErrType ThinClientRegion::removeNoThrowEX_remote( // do TCR remove TcrMessageDestroy request(new DataOutput(m_cacheImpl->createDataOutput()), - this, keyPtr, nullptr, aCallbackArgument, m_tcrdm); - TcrMessageReply reply(true, m_tcrdm); + this, keyPtr, nullptr, aCallbackArgument, + m_tcrdm.get()); + TcrMessageReply reply(true, m_tcrdm.get()); err = m_tcrdm->sendSyncRequest(request, reply); if (err != GF_NOERR) { return err; @@ -1208,11 +1202,10 @@ GfErrType ThinClientRegion::getAllNoThrow_remote( } } // create the GET_ALL request - TcrMessageGetAll request( - new DataOutput(m_cacheImpl->createDataOutput()), this, keys, m_tcrdm, - aCallbackArgument); // now we need to initialize later + TcrMessageGetAll request(new DataOutput(m_cacheImpl->createDataOutput()), + this, keys, m_tcrdm.get(), aCallbackArgument); - TcrMessageReply reply(true, m_tcrdm); + TcrMessageReply reply(true, m_tcrdm.get()); std::recursive_mutex responseLock; // need to check TcrChunkedResult* resultCollector(new ChunkedGetAllResponse( @@ -1580,8 +1573,9 @@ GfErrType ThinClientRegion::multiHopPutAllNoThrow_remote( // Construct request/reply for putAll TcrMessagePutAll request(new DataOutput(m_cacheImpl->createDataOutput()), - this, map, timeout, m_tcrdm, aCallbackArgument); - TcrMessageReply reply(true, m_tcrdm); + this, map, timeout, m_tcrdm.get(), + aCallbackArgument); + TcrMessageReply reply(true, m_tcrdm.get()); request.setTimeout(timeout); reply.setTimeout(timeout); @@ -1641,15 +1635,11 @@ GfErrType ThinClientRegion::putAllNoThrow_remote( const std::shared_ptr<Serializable>& aCallbackArgument) { LOGDEBUG("ThinClientRegion::putAllNoThrow_remote"); - auto poolDM = dynamic_cast<ThinClientPoolDM*>(m_tcrdm); - auto txState = TSSTXStateWrapper::get().getTXState(); - - if (poolDM != nullptr) { - if (poolDM->getPRSingleHopEnabled() && - poolDM->getClientMetaDataService() != nullptr && - txState == nullptr /*For Tx use multi-hop*/) { - return singleHopPutAllNoThrow_remote(poolDM, map, versionedObjPartList, - timeout, aCallbackArgument); + if (auto poolDM = std::dynamic_pointer_cast<ThinClientPoolDM>(m_tcrdm)) { + if (poolDM->getPRSingleHopEnabled() && poolDM->getClientMetaDataService() && + !TSSTXStateWrapper::get().getTXState()) { + return singleHopPutAllNoThrow_remote( + poolDM.get(), map, versionedObjPartList, timeout, aCallbackArgument); } else { return multiHopPutAllNoThrow_remote(map, versionedObjPartList, timeout, aCallbackArgument); @@ -1915,8 +1905,8 @@ GfErrType ThinClientRegion::multiHopRemoveAllNoThrow_remote( // Construct request/reply for putAll TcrMessageRemoveAll request(new DataOutput(m_cacheImpl->createDataOutput()), - this, keys, aCallbackArgument, m_tcrdm); - TcrMessageReply reply(true, m_tcrdm); + this, keys, aCallbackArgument, m_tcrdm.get()); + TcrMessageReply reply(true, m_tcrdm.get()); std::recursive_mutex responseLock; versionedObjPartList = @@ -1966,15 +1956,11 @@ GfErrType ThinClientRegion::removeAllNoThrow_remote( const std::shared_ptr<Serializable>& aCallbackArgument) { LOGDEBUG("ThinClientRegion::removeAllNoThrow_remote"); - ThinClientPoolDM* poolDM = dynamic_cast<ThinClientPoolDM*>(m_tcrdm); - auto txState = TSSTXStateWrapper::get().getTXState(); - - if (poolDM != nullptr) { - if (poolDM->getPRSingleHopEnabled() && - poolDM->getClientMetaDataService() != nullptr && - txState == nullptr /*For Tx use multi-hop*/) { + if (auto poolDM = std::dynamic_pointer_cast<ThinClientPoolDM>(m_tcrdm)) { + if (poolDM->getPRSingleHopEnabled() && poolDM->getClientMetaDataService() && + !TSSTXStateWrapper::get().getTXState()) { return singleHopRemoveAllNoThrow_remote( - poolDM, keys, versionedObjPartList, aCallbackArgument); + poolDM.get(), keys, versionedObjPartList, aCallbackArgument); } else { return multiHopRemoveAllNoThrow_remote(keys, versionedObjPartList, aCallbackArgument); @@ -1993,7 +1979,7 @@ uint32_t ThinClientRegion::size_remote() { // do TCR size TcrMessageSize request(new DataOutput(m_cacheImpl->createDataOutput()), m_fullPath.c_str()); - TcrMessageReply reply(true, m_tcrdm); + TcrMessageReply reply(true, m_tcrdm.get()); err = m_tcrdm->sendSyncRequest(request, reply); if (err != GF_NOERR) { @@ -2197,8 +2183,8 @@ GfErrType ThinClientRegion::destroyRegionNoThrow_remote( // do TCR destroyRegion TcrMessageDestroyRegion request( new DataOutput(m_cacheImpl->createDataOutput()), this, aCallbackArgument, - std::chrono::milliseconds(-1), m_tcrdm); - TcrMessageReply reply(true, m_tcrdm); + std::chrono::milliseconds(-1), m_tcrdm.get()); + TcrMessageReply reply(true, m_tcrdm.get()); err = m_tcrdm->sendSyncRequest(request, reply); if (err != GF_NOERR) return err; @@ -2241,7 +2227,7 @@ GfErrType ThinClientRegion::registerKeysNoThrow( return err; } - TcrMessageReply replyLocal(true, m_tcrdm); + TcrMessageReply replyLocal(true, m_tcrdm.get()); bool needToCreateRC = true; if (reply == nullptr) { reply = &replyLocal; @@ -2255,7 +2241,7 @@ GfErrType ThinClientRegion::registerKeysNoThrow( TcrMessageRegisterInterestList request( new DataOutput(m_cacheImpl->createDataOutput()), this, keys, isDurable, getAttributes().getCachingEnabled(), receiveValues, interestPolicy, - m_tcrdm); + m_tcrdm.get()); std::recursive_mutex responseLock; TcrChunkedResult* resultCollector = nullptr; if (interestPolicy.ordinal == InterestResultPolicy::KEYS_VALUES.ordinal) { @@ -2308,7 +2294,7 @@ GfErrType ThinClientRegion::unregisterKeysNoThrow( CHECK_DESTROY_PENDING_NOTHROW(TryReadGuard); GfErrType err = GF_NOERR; std::lock_guard<decltype(m_keysLock)> keysGuard(m_keysLock); - TcrMessageReply reply(true, m_tcrdm); + TcrMessageReply reply(true, m_tcrdm.get()); if (keys.empty()) { return err; } @@ -2322,7 +2308,7 @@ GfErrType ThinClientRegion::unregisterKeysNoThrow( TcrMessageUnregisterInterestList request( new DataOutput(m_cacheImpl->createDataOutput()), this, keys, false, true, - InterestResultPolicy::NONE, m_tcrdm); + InterestResultPolicy::NONE, m_tcrdm.get()); err = m_tcrdm->sendSyncRequestRegisterInterest(request, reply); if (err == GF_NOERR /*|| err == GF_CACHE_REDUNDANCY_FAILURE*/) { if (attemptFailover) { @@ -2344,7 +2330,7 @@ GfErrType ThinClientRegion::unregisterKeysNoThrowLocalDestroy( RegionGlobalLocks acquireLocksFailover(this); GfErrType err = GF_NOERR; std::lock_guard<decltype(m_keysLock)> keysGuard(m_keysLock); - TcrMessageReply reply(true, m_tcrdm); + TcrMessageReply reply(true, m_tcrdm.get()); if (keys.empty()) { return err; } @@ -2358,7 +2344,7 @@ GfErrType ThinClientRegion::unregisterKeysNoThrowLocalDestroy( TcrMessageUnregisterInterestList request( new DataOutput(m_cacheImpl->createDataOutput()), this, keys, false, true, - InterestResultPolicy::NONE, m_tcrdm); + InterestResultPolicy::NONE, m_tcrdm.get()); err = m_tcrdm->sendSyncRequestRegisterInterest(request, reply); if (err == GF_NOERR) { if (attemptFailover) { @@ -2433,10 +2419,10 @@ GfErrType ThinClientRegion::registerRegexNoThrow( TcrMessageRegisterInterest request( new DataOutput(m_cacheImpl->createDataOutput()), m_fullPath, regex.c_str(), interestPolicy, isDurable, - getAttributes().getCachingEnabled(), receiveValues, m_tcrdm); + getAttributes().getCachingEnabled(), receiveValues, m_tcrdm.get()); std::recursive_mutex responseLock; if (reply == nullptr) { - TcrMessageReply replyLocal(true, m_tcrdm); + TcrMessageReply replyLocal(true, m_tcrdm.get()); auto values = std::make_shared<HashMapOfCacheable>(); auto exceptions = std::make_shared<HashMapOfException>(); @@ -2510,10 +2496,10 @@ GfErrType ThinClientRegion::unregisterRegexNoThrow(const std::string& regex, err = findRegex(regex); if (err == GF_NOERR) { - TcrMessageReply reply(false, m_tcrdm); + TcrMessageReply reply(false, m_tcrdm.get()); TcrMessageUnregisterInterest request( new DataOutput(m_cacheImpl->createDataOutput()), m_fullPath, regex, - InterestResultPolicy::NONE, false, true, m_tcrdm); + InterestResultPolicy::NONE, false, true, m_tcrdm.get()); err = m_tcrdm->sendSyncRequestRegisterInterest(request, reply); if (err == GF_NOERR /*|| err == GF_CACHE_REDUNDANCY_FAILURE*/) { if (attemptFailover) { @@ -2556,10 +2542,10 @@ GfErrType ThinClientRegion::unregisterRegexNoThrowLocalDestroy( err = findRegex(regex); if (err == GF_NOERR) { - TcrMessageReply reply(false, m_tcrdm); + TcrMessageReply reply(false, m_tcrdm.get()); TcrMessageUnregisterInterest request( new DataOutput(m_cacheImpl->createDataOutput()), m_fullPath, regex, - InterestResultPolicy::NONE, false, true, m_tcrdm); + InterestResultPolicy::NONE, false, true, m_tcrdm.get()); err = m_tcrdm->sendSyncRequestRegisterInterest(request, reply); if (err == GF_NOERR) { if (attemptFailover) { @@ -2935,12 +2921,11 @@ void ThinClientRegion::release(bool invokeCallbacks) { LocalRegion::release(invokeCallbacks); } -ThinClientRegion::~ThinClientRegion() { +ThinClientRegion::~ThinClientRegion() noexcept { TryWriteGuard guard(m_rwLock, m_destroyPending); if (!m_destroyPending) { release(false); } - _GEODE_SAFE_DELETE(m_tcrdm); } void ThinClientRegion::acquireGlobals(bool isFailover) { @@ -2976,15 +2961,15 @@ void ThinClientRegion::executeFunction( if (reExecuteForServ) { msg = new TcrMessageExecuteRegionFunction( new DataOutput(m_cacheImpl->createDataOutput()), func, this, args, - routingObj, getResult, failedNodes, timeout, m_tcrdm, + routingObj, getResult, failedNodes, timeout, m_tcrdm.get(), static_cast<int8_t>(1)); } else { msg = new TcrMessageExecuteRegionFunction( new DataOutput(m_cacheImpl->createDataOutput()), func, this, args, - routingObj, getResult, failedNodes, timeout, m_tcrdm, + routingObj, getResult, failedNodes, timeout, m_tcrdm.get(), static_cast<int8_t>(0)); } - TcrMessageReply reply(true, m_tcrdm); + TcrMessageReply reply(true, m_tcrdm.get()); // need to check ChunkedFunctionExecutionResponse* resultCollector( new ChunkedFunctionExecutionResponse(reply, (getResult & 2) == 2, rc)); @@ -3076,9 +3061,9 @@ std::shared_ptr<CacheableVector> ThinClientRegion::reExecuteFunction( reExecute = false; TcrMessageExecuteRegionFunction msg( new DataOutput(m_cacheImpl->createDataOutput()), func, this, args, - routingObj, getResult, failedNodes, timeout, m_tcrdm, + routingObj, getResult, failedNodes, timeout, m_tcrdm.get(), static_cast<int8_t>(1)); - TcrMessageReply reply(true, m_tcrdm); + TcrMessageReply reply(true, m_tcrdm.get()); // need to check ChunkedFunctionExecutionResponse* resultCollector( new ChunkedFunctionExecutionResponse(reply, (getResult & 2) == 2, rc)); @@ -3154,7 +3139,7 @@ bool ThinClientRegion::executeFunctionSH( const auto& routingObj = locationIter.second; auto worker = std::make_shared<OnRegionFunctionExecution>( func, this, args, routingObj, getResult, timeout, - dynamic_cast<ThinClientPoolDM*>(m_tcrdm), resultCollectorLock, rc, + dynamic_cast<ThinClientPoolDM*>(m_tcrdm.get()), resultCollectorLock, rc, userAttr, false, serverLocation, allBuckets); threadPool.perform(worker); feWorkers.push_back(worker); @@ -3177,7 +3162,8 @@ bool ThinClientRegion::executeFunctionSH( if (err != GF_NOERR) { if (err == GF_FUNCTION_EXCEPTION) { reExecute = true; - if (auto poolDM = dynamic_cast<ThinClientPoolDM*>(m_tcrdm)) { + if (auto poolDM = + std::dynamic_pointer_cast<ThinClientPoolDM>(m_tcrdm)) { if (poolDM->getClientMetaDataService()) { poolDM->getClientMetaDataService()->enqueueForMetadataRefresh( this->getFullPath(), 0); @@ -3204,7 +3190,8 @@ bool ThinClientRegion::executeFunctionSH( LOGINFO( "ThinClientRegion::executeFunctionSH with GF_NOTCON or " "GF_CLIENT_WAIT_TIMEOUT "); - if (auto poolDM = dynamic_cast<ThinClientPoolDM*>(m_tcrdm)) { + if (auto poolDM = + std::dynamic_pointer_cast<ThinClientPoolDM>(m_tcrdm)) { if (poolDM->getClientMetaDataService()) { poolDM->getClientMetaDataService()->enqueueForMetadataRefresh( this->getFullPath(), 0); @@ -3243,8 +3230,8 @@ GfErrType ThinClientRegion::getFuncAttributes(const std::string& func, // do TCR GET_FUNCTION_ATTRIBUTES LOGDEBUG("Tcrmessage request GET_FUNCTION_ATTRIBUTES "); TcrMessageGetFunctionAttributes request( - new DataOutput(m_cacheImpl->createDataOutput()), func, m_tcrdm); - TcrMessageReply reply(true, m_tcrdm); + new DataOutput(m_cacheImpl->createDataOutput()), func, m_tcrdm.get()); + TcrMessageReply reply(true, m_tcrdm.get()); err = m_tcrdm->sendSyncRequest(request, reply); if (err != GF_NOERR) { return err; diff --git a/cppcache/src/ThinClientRegion.hpp b/cppcache/src/ThinClientRegion.hpp index a7ec893..1da5bce 100644 --- a/cppcache/src/ThinClientRegion.hpp +++ b/cppcache/src/ThinClientRegion.hpp @@ -61,41 +61,43 @@ class APACHE_GEODE_EXPORT ThinClientRegion : public LocalRegion { RegionAttributes attributes, const std::shared_ptr<CacheStatistics>& stats, bool shared = false); + + ThinClientRegion(const ThinClientRegion&) = delete; + ThinClientRegion& operator=(const ThinClientRegion&) = delete; + virtual void initTCR(); - virtual ~ThinClientRegion() override; + ~ThinClientRegion() noexcept override; /** @brief Public Methods from Region */ // Unhide function to prevent SunPro Warnings using RegionInternal::registerKeys; - virtual void registerKeys( - const std::vector<std::shared_ptr<CacheableKey>>& keys, - bool isDurable = false, bool getInitialValues = false, - bool receiveValues = true) override; - virtual void unregisterKeys( + void registerKeys(const std::vector<std::shared_ptr<CacheableKey>>& keys, + bool isDurable = false, bool getInitialValues = false, + bool receiveValues = true) override; + void unregisterKeys( const std::vector<std::shared_ptr<CacheableKey>>& keys) override; - virtual void registerAllKeys(bool isDurable = false, - bool getInitialValues = false, - bool receiveValues = true) override; - virtual void unregisterAllKeys() override; - virtual void registerRegex(const std::string& regex, bool isDurable = false, - bool getInitialValues = false, - bool receiveValues = true) override; - virtual void unregisterRegex(const std::string& regex) override; - virtual std::vector<std::shared_ptr<CacheableKey>> serverKeys() override; - virtual void clear(const std::shared_ptr<Serializable>& aCallbackArgument = - nullptr) override; - - virtual std::shared_ptr<SelectResults> query( + void registerAllKeys(bool isDurable = false, bool getInitialValues = false, + bool receiveValues = true) override; + void unregisterAllKeys() override; + void registerRegex(const std::string& regex, bool isDurable = false, + bool getInitialValues = false, + bool receiveValues = true) override; + void unregisterRegex(const std::string& regex) override; + std::vector<std::shared_ptr<CacheableKey>> serverKeys() override; + void clear(const std::shared_ptr<Serializable>& aCallbackArgument = + nullptr) override; + + std::shared_ptr<SelectResults> query( const std::string& predicate, std::chrono::milliseconds timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT) override; - virtual bool existsValue(const std::string& predicate, - std::chrono::milliseconds timeout = - DEFAULT_QUERY_RESPONSE_TIMEOUT) override; + bool existsValue(const std::string& predicate, + std::chrono::milliseconds timeout = + DEFAULT_QUERY_RESPONSE_TIMEOUT) override; - virtual std::shared_ptr<Serializable> selectValue( + std::shared_ptr<Serializable> selectValue( const std::string& predicate, std::chrono::milliseconds timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT) override; @@ -128,28 +130,23 @@ class APACHE_GEODE_EXPORT ThinClientRegion : public LocalRegion { bool containsKeyOnServer( const std::shared_ptr<CacheableKey>& keyPtr) const override; - virtual bool containsValueForKey_remote( + bool containsValueForKey_remote( const std::shared_ptr<CacheableKey>& keyPtr) const override; - virtual std::vector<std::shared_ptr<CacheableKey>> getInterestList() - const override; - virtual std::vector<std::shared_ptr<CacheableString>> getInterestListRegex() + std::vector<std::shared_ptr<CacheableKey>> getInterestList() const override; + std::vector<std::shared_ptr<CacheableString>> getInterestListRegex() const override; - /** @brief Public Methods from RegionInternal - * These are all virtual methods - */ void receiveNotification(TcrMessage* msg); - /** @brief Misc utility methods. */ static GfErrType handleServerException(const char* func, const char* exceptionMsg); - virtual void acquireGlobals(bool failover) override; - virtual void releaseGlobals(bool failover) override; + void acquireGlobals(bool failover) override; + void releaseGlobals(bool failover) override; void localInvalidateFailover(); - inline ThinClientBaseDM* getDistMgr() const { return m_tcrdm; } + inline ThinClientBaseDM* getDistMgr() const { return m_tcrdm.get(); } std::shared_ptr<CacheableVector> reExecuteFunction( const std::string& func, const std::shared_ptr<Cacheable>& args, @@ -186,20 +183,18 @@ class APACHE_GEODE_EXPORT ThinClientRegion : public LocalRegion { uint32_t size_remote() override; - virtual void txDestroy(const std::shared_ptr<CacheableKey>& key, - const std::shared_ptr<Serializable>& callBack, - std::shared_ptr<VersionTag> versionTag) override; - virtual void txInvalidate(const std::shared_ptr<CacheableKey>& key, - const std::shared_ptr<Serializable>& callBack, - std::shared_ptr<VersionTag> versionTag) override; - virtual void txPut(const std::shared_ptr<CacheableKey>& key, - const std::shared_ptr<Cacheable>& value, - const std::shared_ptr<Serializable>& callBack, - std::shared_ptr<VersionTag> versionTag) override; + void txDestroy(const std::shared_ptr<CacheableKey>& key, + const std::shared_ptr<Serializable>& callBack, + std::shared_ptr<VersionTag> versionTag) override; + void txInvalidate(const std::shared_ptr<CacheableKey>& key, + const std::shared_ptr<Serializable>& callBack, + std::shared_ptr<VersionTag> versionTag) override; + void txPut(const std::shared_ptr<CacheableKey>& key, + const std::shared_ptr<Cacheable>& value, + const std::shared_ptr<Serializable>& callBack, + std::shared_ptr<VersionTag> versionTag) override; protected: - /** @brief the methods need to be overloaded in TCR - */ GfErrType getNoThrow_remote( const std::shared_ptr<CacheableKey>& keyPtr, std::shared_ptr<Cacheable>& valPtr, @@ -276,13 +271,12 @@ class APACHE_GEODE_EXPORT ThinClientRegion : public LocalRegion { std::vector<std::shared_ptr<CacheableKey>>& keysVector, std::unordered_map<std::shared_ptr<CacheableKey>, InterestResultPolicy>& interestList) const; - virtual void release(bool invokeCallbacks = true) override; + void release(bool invokeCallbacks = true) override; GfErrType unregisterKeysBeforeDestroyRegion() override; bool isDurableClient() { return m_isDurableClnt; } - /** @brief Protected fields. */ - ThinClientBaseDM* m_tcrdm; + std::shared_ptr<ThinClientBaseDM> m_tcrdm; std::recursive_mutex m_keysLock; mutable ACE_RW_Thread_Mutex m_rwDestroyLock; std::unordered_map<std::shared_ptr<CacheableKey>, InterestResultPolicy> @@ -340,9 +334,6 @@ class APACHE_GEODE_EXPORT ThinClientRegion : public LocalRegion { std::shared_ptr<EventId> eventId, std::shared_ptr<Cacheable>& fullObject, std::shared_ptr<VersionTag>& versionTag) override; - // Disallow copy constructor and assignment operator. - ThinClientRegion(const ThinClientRegion&); - ThinClientRegion& operator=(const ThinClientRegion&); GfErrType singleHopPutAllNoThrow_remote( ThinClientPoolDM* tcrdm, const HashMapOfCacheable& map, std::shared_ptr<VersionedCacheableObjectPartList>& versionedObjPartList,