From 1263b5d4addbc8bbe13452cb49070fcb7b64bf4a Mon Sep 17 00:00:00 2001 From: Jacob Barrett Date: Thu, 31 Dec 2020 00:01:10 -0800 Subject: [PATCH] clang-tidy. --- .clang-tidy | 6 +- .../benchmark/SerializationRegistryBM.cpp | 19 +-- cppcache/include/geode/Cache.hpp | 11 +- .../include/geode/CqServiceStatistics.hpp | 4 +- cppcache/include/geode/FunctionService.hpp | 2 +- cppcache/include/geode/PdxInstance.hpp | 2 +- cppcache/include/geode/PdxUnreadFields.hpp | 4 +- cppcache/include/geode/Properties.hpp | 2 +- .../include/geode/WritablePdxInstance.hpp | 5 +- .../include/geode/internal/geode_base.hpp | 4 +- cppcache/integration-test/.clang-tidy | 20 +-- cppcache/integration-test/BBNamingContext.cpp | 1 + .../BuiltinCacheableWrappers.hpp | 139 +++++---------- cppcache/integration-test/QueryHelper.hpp | 4 +- cppcache/integration-test/TallyListener.hpp | 43 +---- cppcache/integration-test/TallyLoader.hpp | 24 +-- .../ThinClientListenerInit.hpp | 6 +- .../ThinClientLocalCacheLoader.hpp | 8 +- .../ThinClientSecurityHelper.hpp | 4 +- .../ThinClientTransactions.hpp | 21 ++- .../ThinClientTransactionsXA.hpp | 32 ++-- cppcache/integration-test/TimeBomb.hpp | 4 +- cppcache/integration-test/fw_dunit.cpp | 7 +- cppcache/integration-test/fw_dunit.hpp | 36 ++-- cppcache/integration-test/fw_helper.hpp | 2 +- cppcache/integration-test/fw_perf.hpp | 46 +---- cppcache/integration-test/fw_spawn.hpp | 8 +- cppcache/integration-test/testFwPerf.cpp | 6 +- cppcache/integration-test/testLogger.cpp | 5 +- .../testOverflowPutGetSqLite.cpp | 2 +- .../testRegionAccessThreadSafe.cpp | 2 +- cppcache/integration-test/testSpinLock.cpp | 4 +- .../testThinClientConflation.cpp | 6 +- .../integration-test/testThinClientCq.cpp | 22 ++- .../testThinClientCqDelta.cpp | 2 +- .../testThinClientCqFailover.cpp | 2 +- .../testThinClientCqHAFailover.cpp | 2 +- .../testThinClientHAQueryFailover.cpp | 2 +- .../testThinClientInterest1Cacheless.cpp | 4 +- .../testThinClientInterestNotify.cpp | 11 +- .../testThinClientListenerCallbackArgTest.cpp | 20 +-- .../testThinClientPRSingleHop.cpp | 2 +- .../testThinClientPoolAttrTest.cpp | 2 +- ...ientPoolExecuteFunctionThrowsException.cpp | 1 - .../testThinClientPoolExecuteHAFunction.cpp | 1 - .../testThinClientPoolServer.cpp | 1 - .../testThinClientRemoteQueryFailover.cpp | 2 +- .../testThinClientRemoteQueryFailoverPdx.cpp | 2 +- .../testThinClientTicket304.cpp | 2 - .../integration-test/testTimedSemaphore.cpp | 3 +- cppcache/integration/framework/.clang-tidy | 15 -- cppcache/integration/framework/Cluster.cpp | 67 ++++---- .../integration/test/AuthInitializeTest.cpp | 8 +- .../test/CqPlusAuthInitializeTest.cpp | 2 +- .../test/PartitionRegionOpsTest.cpp | 4 +- .../integration/test/TransactionsTest.cpp | 8 +- cppcache/src/AdminRegion.cpp | 9 +- cppcache/src/AuthenticatedView.cpp | 2 - cppcache/src/CacheXmlParser.hpp | 20 ++- cppcache/src/ConcurrentEntriesMap.cpp | 3 +- cppcache/src/ConcurrentEntriesMap.hpp | 125 +++++++------- cppcache/src/ConnectionQueue.hpp | 2 +- cppcache/src/CqEventImpl.hpp | 15 +- cppcache/src/CqQueryImpl.cpp | 9 +- cppcache/src/CqQueryVsdStats.cpp | 2 +- cppcache/src/CqQueryVsdStats.hpp | 12 +- cppcache/src/CqService.cpp | 8 +- cppcache/src/CqServiceVsdStats.cpp | 2 +- cppcache/src/CqServiceVsdStats.hpp | 25 +-- cppcache/src/EntryExpiryHandler.hpp | 26 ++- cppcache/src/ExpMapEntry.hpp | 40 ++--- cppcache/src/ExpiryTaskManager.cpp | 10 +- cppcache/src/ExpiryTaskManager.hpp | 18 +- cppcache/src/FunctionServiceImpl.cpp | 39 ----- cppcache/src/FunctionServiceImpl.hpp | 60 ------- cppcache/src/LRUAction.hpp | 38 ++--- cppcache/src/LRUEntriesMap.cpp | 13 +- cppcache/src/LRUEntriesMap.hpp | 84 ++++----- cppcache/src/LRUExpMapEntry.hpp | 47 +++-- cppcache/src/LRULocalDestroyAction.hpp | 17 +- cppcache/src/LRUMapEntry.hpp | 54 +++--- cppcache/src/LocalRegion.cpp | 6 +- cppcache/src/LocalRegion.hpp | 34 ++-- cppcache/src/MapEntry.hpp | 30 ++-- cppcache/src/PdxRemotePreservedData.hpp | 31 ++-- cppcache/src/RemoteQuery.cpp | 7 +- cppcache/src/SerializationRegistry.cpp | 1 - cppcache/src/ServerLocation.hpp | 7 +- cppcache/src/SystemProperties.cpp | 13 +- cppcache/src/TXId.cpp | 8 +- cppcache/src/TXId.hpp | 18 +- cppcache/src/TcrChunkedContext.hpp | 2 +- cppcache/src/TcrConnection.cpp | 38 +---- cppcache/src/TcrConnection.hpp | 12 -- cppcache/src/TcrConnectionManager.cpp | 29 +--- cppcache/src/TcrConnectionManager.hpp | 2 - cppcache/src/TcrDistributionManager.hpp | 31 ++-- cppcache/src/TcrEndpoint.cpp | 2 + cppcache/src/ThinClientBaseDM.cpp | 11 +- cppcache/src/ThinClientBaseDM.hpp | 2 +- .../ThinClientCacheDistributionManager.hpp | 37 ++-- .../src/ThinClientDistributionManager.hpp | 3 +- cppcache/src/ThinClientPoolDM.cpp | 11 +- cppcache/src/ThinClientPoolDM.hpp | 8 +- cppcache/src/ThinClientPoolHADM.cpp | 24 +-- cppcache/src/ThinClientPoolStickyHADM.hpp | 15 +- cppcache/src/ThinClientRedundancyManager.cpp | 10 +- cppcache/src/ThinClientRegion.cpp | 66 ++------ cppcache/src/ThinClientRegion.hpp | 160 ++++++++---------- cppcache/src/ThreadPool.hpp | 2 +- cppcache/src/TrackedMapEntry.hpp | 2 +- cppcache/src/VersionStamp.hpp | 5 +- .../src/VersionedCacheableObjectPartList.cpp | 3 +- cppcache/src/statistics/OsStatisticsImpl.cpp | 32 ++-- cppcache/test/CacheableDateTest.cpp | 8 +- cppcache/test/CacheableKeyCreateTests.cpp | 36 ++-- cppcache/test/CacheableKeysTest.cpp | 8 +- cppcache/test/ChunkedHeaderTest.cpp | 2 +- cppcache/test/DataInputTest.cpp | 87 ++++++---- cppcache/test/DataOutputTest.cpp | 25 +-- cppcache/test/PdxInstanceImplTest.cpp | 4 +- cppcache/test/SerializableCreateTests.cpp | 28 +-- cppcache/test/TcrMessageTest.cpp | 72 ++++---- cppcache/test/ThreadPoolTest.cpp | 2 +- cppcache/test/util/chrono/durationTest.cpp | 12 +- cppcache/test/util/functionalTests.cpp | 2 +- cppcache/test/util/queueTest.cpp | 2 +- cppcache/test/util/synchronized_mapTest.cpp | 36 ++-- cppcache/test/util/synchronized_setTest.cpp | 42 ++--- tests/cpp/.clang-tidy | 4 + tests/cpp/fwklib/FwkBBServer.hpp | 8 +- tests/cpp/fwklib/FwkLog.hpp | 43 ++--- tests/cpp/fwklib/Service.hpp | 7 +- tests/cpp/fwklib/TimeBomb.hpp | 4 +- tests/cpp/fwklib/UDPIpc.hpp | 43 ++--- .../cpp/security/DummyCredentialGenerator.hpp | 5 +- .../security/XmlAuthzCredentialGenerator.hpp | 12 +- tests/cpp/testobject/VariousPdxTypes.cpp | 1 - 138 files changed, 1005 insertions(+), 1504 deletions(-) delete mode 100644 cppcache/integration/framework/.clang-tidy delete mode 100644 cppcache/src/FunctionServiceImpl.cpp delete mode 100644 cppcache/src/FunctionServiceImpl.hpp create mode 100644 tests/cpp/.clang-tidy diff --git a/.clang-tidy b/.clang-tidy index 6d39dedd8e..1019b3c688 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,8 +1,8 @@ --- -Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references,-google-default-arguments,-clang-analyzer-core.uninitialized.UndefReturn,-clang-analyzer-core.UndefinedBinaryOperatorResult,-clang-analyzer-optin.cplusplus.VirtualCall' +Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references,-google-default-arguments' WarningsAsErrors: '*' HeaderFilterRegex: '.*' -FormatStyle: file +FormatStyle: file ... # Disable Checks @@ -14,5 +14,3 @@ FormatStyle: file # clang-analyzer-core.uninitialized.UndefReturn - Generates errors in ACE, how do we ignore? # clang-analyzer-core.UndefinedBinaryOperatorResult - Generates errors in ACE, how do we ignore? -# TEMP -# clang-analyzer-optin.cplusplus.VirtualCall \ No newline at end of file diff --git a/cppcache/benchmark/SerializationRegistryBM.cpp b/cppcache/benchmark/SerializationRegistryBM.cpp index 89be4ccabc..bf14d85787 100644 --- a/cppcache/benchmark/SerializationRegistryBM.cpp +++ b/cppcache/benchmark/SerializationRegistryBM.cpp @@ -36,12 +36,13 @@ using apache::geode::client::internal::DSFid; class TestPdxClass : public PdxSerializable { public: - TestPdxClass() {} - void fromData(PdxReader&) {} + TestPdxClass() = default; - void toData(PdxWriter&) const {} + void fromData(PdxReader&) override {} - const std::string& getClassName() const { return className; } + void toData(PdxWriter&) const override {} + + const std::string& getClassName() const override { return className; } static std::shared_ptr createDeserializable() { return std::make_shared(); @@ -53,19 +54,15 @@ class TestPdxClass : public PdxSerializable { class TestDataSerializableClass : public DataSerializable { public: - TestDataSerializableClass() {} - void fromData(DataInput&) {} + TestDataSerializableClass() = default; - void toData(DataOutput&) const {} + void fromData(DataInput&) override {} - const std::string& getClassName() const { return className; } + void toData(DataOutput&) const override {} static std::shared_ptr createInstance() { return std::make_shared(); } - - private: - std::string className = "myserializableclass"; }; static void SerializationRegistryBM_findDataSerializablePrimitive( diff --git a/cppcache/include/geode/Cache.hpp b/cppcache/include/geode/Cache.hpp index 0ed5985ebd..15ea3aa036 100644 --- a/cppcache/include/geode/Cache.hpp +++ b/cppcache/include/geode/Cache.hpp @@ -27,10 +27,6 @@ #include "GeodeCache.hpp" #include "internal/geode_globals.hpp" -/** - * @file - */ - namespace apache { namespace geode { namespace client { @@ -67,9 +63,6 @@ enum class RegionShortcut; * */ class APACHE_GEODE_EXPORT Cache : public GeodeCache { - /** - * @brief public methods - */ public: /** * Returns the {@link RegionFactory} to create the region. @@ -268,9 +261,6 @@ class APACHE_GEODE_EXPORT Cache : public GeodeCache { Cache& operator=(Cache&& other) noexcept; private: - /** - * @brief constructors - */ Cache(const std::shared_ptr& dsProp, bool ignorePdxUnreadFields, bool readPdxSerialized, const std::shared_ptr& authInitialize); @@ -284,6 +274,7 @@ class APACHE_GEODE_EXPORT Cache : public GeodeCache { friend class CacheXmlCreation; friend class RegionXmlCreation; }; + } // namespace client } // namespace geode } // namespace apache diff --git a/cppcache/include/geode/CqServiceStatistics.hpp b/cppcache/include/geode/CqServiceStatistics.hpp index 5582dc2c8a..0957e9586e 100644 --- a/cppcache/include/geode/CqServiceStatistics.hpp +++ b/cppcache/include/geode/CqServiceStatistics.hpp @@ -38,8 +38,10 @@ namespace client { */ class APACHE_GEODE_EXPORT CqServiceStatistics { public: + virtual ~CqServiceStatistics() noexcept = default; + /** - * Get the number of CQs currently active. + * Get the number of CQs currently active.c * Active CQs are those which are executing (in running state). * @return number of CQs */ diff --git a/cppcache/include/geode/FunctionService.hpp b/cppcache/include/geode/FunctionService.hpp index 43a9519f17..8dbb10ae55 100644 --- a/cppcache/include/geode/FunctionService.hpp +++ b/cppcache/include/geode/FunctionService.hpp @@ -134,7 +134,7 @@ class APACHE_GEODE_EXPORT FunctionService { return onServersWithCache(regionService); } - virtual ~FunctionService() {} + virtual ~FunctionService() noexcept = default; private: static Execution onServerWithPool(const std::shared_ptr& pool); diff --git a/cppcache/include/geode/PdxInstance.hpp b/cppcache/include/geode/PdxInstance.hpp index a2758d4eef..2ac3a908ab 100644 --- a/cppcache/include/geode/PdxInstance.hpp +++ b/cppcache/include/geode/PdxInstance.hpp @@ -53,7 +53,7 @@ class APACHE_GEODE_EXPORT PdxInstance : public PdxSerializable { /** * @brief destructor */ - ~PdxInstance() override = default; + ~PdxInstance() noexcept override = default; /** * Deserializes and returns the domain object that this instance represents. diff --git a/cppcache/include/geode/PdxUnreadFields.hpp b/cppcache/include/geode/PdxUnreadFields.hpp index 38541eb6f4..8d5f827755 100644 --- a/cppcache/include/geode/PdxUnreadFields.hpp +++ b/cppcache/include/geode/PdxUnreadFields.hpp @@ -42,8 +42,8 @@ namespace client { **/ class APACHE_GEODE_EXPORT PdxUnreadFields { public: - PdxUnreadFields() {} - virtual ~PdxUnreadFields() {} + PdxUnreadFields() = default; + virtual ~PdxUnreadFields() = default; }; } // namespace client } // namespace geode diff --git a/cppcache/include/geode/Properties.hpp b/cppcache/include/geode/Properties.hpp index 375670c933..40077d71b1 100644 --- a/cppcache/include/geode/Properties.hpp +++ b/cppcache/include/geode/Properties.hpp @@ -55,7 +55,7 @@ class APACHE_GEODE_EXPORT Properties public: virtual void visit(const std::shared_ptr& key, const std::shared_ptr& value) = 0; - virtual ~Visitor() {} + virtual ~Visitor() noexcept = default; }; Properties() = default; diff --git a/cppcache/include/geode/WritablePdxInstance.hpp b/cppcache/include/geode/WritablePdxInstance.hpp index 71d232e7b5..6341c977e0 100644 --- a/cppcache/include/geode/WritablePdxInstance.hpp +++ b/cppcache/include/geode/WritablePdxInstance.hpp @@ -39,10 +39,7 @@ class CacheableObjectArray; */ class APACHE_GEODE_EXPORT WritablePdxInstance : public PdxInstance { public: - /** - * @brief destructor - */ - virtual ~WritablePdxInstance() = default; + ~WritablePdxInstance() noexcept override = default; /** * Set the existing named field to the given value. diff --git a/cppcache/include/geode/internal/geode_base.hpp b/cppcache/include/geode/internal/geode_base.hpp index 26bf2650b5..c253e2bb3c 100644 --- a/cppcache/include/geode/internal/geode_base.hpp +++ b/cppcache/include/geode/internal/geode_base.hpp @@ -62,10 +62,10 @@ /** Deletes array x only if it exists */ #define _GEODE_SAFE_DELETE_ARRAY(x) \ - { \ + do { \ delete[] x; \ x = nullptr; \ - } + } while (0) #include #include diff --git a/cppcache/integration-test/.clang-tidy b/cppcache/integration-test/.clang-tidy index a3b1d36c53..910b72624f 100644 --- a/cppcache/integration-test/.clang-tidy +++ b/cppcache/integration-test/.clang-tidy @@ -1,19 +1,7 @@ --- -Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references,-google-default-arguments,-clang-analyzer-core.uninitialized.UndefReturn,-clang-analyzer-core.UndefinedBinaryOperatorResult,-clang-analyzer-optin.cplusplus.VirtualCall,-clang-analyzer-cplusplus.NewDeleteLeaks,-google-readability-function-size' -WarningsAsErrors: '*' -HeaderFilterRegex: '.*' -FormatStyle: file +InheritParentConfig: true +Checks: '-google-readability-function-size' ... -# Disable Checks -# google-runtime-references - We have diverged from this rule due to both legacy and disagreement with the rule. -# google-readability-todo - Adds current user name when fix applied. -# clang-analyzer-cplusplus.NewDeleteLeaks - Fundamental design flaw in dunit::Task - -# TODO - Fix these checks -# google-default-arguments -# clang-analyzer-core.uninitialized.UndefReturn - Generates errors in ACE, how do we ignore? -# clang-analyzer-core.UndefinedBinaryOperatorResult - Generates errors in ACE, how do we ignore? - -# TEMP -# clang-analyzer-optin.cplusplus.VirtualCall +# google-readability-function-size +# Some tests have large bodies that cause this rule to fail. diff --git a/cppcache/integration-test/BBNamingContext.cpp b/cppcache/integration-test/BBNamingContext.cpp index 0de09f7c82..fa707ef27a 100644 --- a/cppcache/integration-test/BBNamingContext.cpp +++ b/cppcache/integration-test/BBNamingContext.cpp @@ -283,6 +283,7 @@ BBNamingContextServer::BBNamingContextServer() { m_impl = new BBNamingContextServerImpl(); } BBNamingContextServer::~BBNamingContextServer() { + // NOLINTNEXTLINE(clang-analyzer-unix.Malloc): ACE if (m_impl != nullptr) { delete m_impl; m_impl = nullptr; diff --git a/cppcache/integration-test/BuiltinCacheableWrappers.hpp b/cppcache/integration-test/BuiltinCacheableWrappers.hpp index a68f674473..1efa2a1a5e 100644 --- a/cppcache/integration-test/BuiltinCacheableWrappers.hpp +++ b/cppcache/integration-test/BuiltinCacheableWrappers.hpp @@ -334,11 +334,10 @@ class CacheableDateWrapper : public CacheableWrapper { } void initRandomValue(int32_t) override { - int32_t rnd = CacheableHelper::random(INT_MAX); - time_t timeofday = 0; + auto rnd = CacheableHelper::random(INT_MAX); const ACE_Time_Value currentTime = ACE_OS::gettimeofday(); - timeofday = currentTime.sec(); + auto timeofday = currentTime.sec(); time_t epoctime = static_cast(timeofday + (rnd * (rnd % 2 == 0 ? 1 : -1))); @@ -362,9 +361,9 @@ class CacheableFileNameWrapper : public CacheableWrapper { // CacheableWrapper members - virtual int32_t maxKeys() const { return INT_MAX; } + int32_t maxKeys() const override { return INT_MAX; } - virtual void initKey(int32_t keyIndex, int32_t maxSize) { + void initKey(int32_t keyIndex, int32_t maxSize) override { maxSize %= (0xFFFF + 1); if (maxSize < 11) { maxSize = 11; @@ -385,7 +384,7 @@ class CacheableFileNameWrapper : public CacheableWrapper { m_cacheableObject = CacheableFileName::create(baseStr); } - virtual void initRandomValue(int32_t maxSize) { + void initRandomValue(int32_t maxSize) override { maxSize %= (0xFFFF + 1); std::string randStr; CacheableHelper::randomString(maxSize, randStr); @@ -395,7 +394,7 @@ class CacheableFileNameWrapper : public CacheableWrapper { m_cacheableObject = CacheableFileName::create(randStr); } - virtual uint32_t getCheckSum(const std::shared_ptr object) const { + uint32_t getCheckSum(const std::shared_ptr object) const override { auto&& obj = std::dynamic_pointer_cast(object); return (obj ? CacheableHelper::crc32( reinterpret_cast(obj->value().c_str()), @@ -531,9 +530,9 @@ class CacheableStringWrapper : public CacheableWrapper { // CacheableWrapper members - virtual int32_t maxKeys() const { return INT_MAX; } + int32_t maxKeys() const override { return INT_MAX; } - virtual void initKey(int32_t keyIndex, int32_t maxSize) { + void initKey(int32_t keyIndex, int32_t maxSize) override { maxSize %= (0xFFFF + 1); if (maxSize < 11) { maxSize = 11; @@ -545,14 +544,14 @@ class CacheableStringWrapper : public CacheableWrapper { m_cacheableObject = CacheableString::create(baseStr); } - virtual void initRandomValue(int32_t maxSize) { + void initRandomValue(int32_t maxSize) override { maxSize %= (0xFFFF + 1); std::string randStr; CacheableHelper::randomString(maxSize, randStr); m_cacheableObject = CacheableString::create(randStr); } - virtual uint32_t getCheckSum(const std::shared_ptr object) const { + uint32_t getCheckSum(const std::shared_ptr object) const override { const CacheableString* obj = dynamic_cast(object.get()); return (obj != nullptr @@ -573,9 +572,9 @@ class CacheableHugeStringWrapper : public CacheableWrapper { // CacheableWrapper members - virtual int32_t maxKeys() const { return INT_MAX; } + int32_t maxKeys() const override { return INT_MAX; } - virtual void initKey(int32_t keyIndex, int32_t maxSize) { + void initKey(int32_t keyIndex, int32_t maxSize) override { if (maxSize <= 0xFFFF) // ensure its larger than 64k { maxSize += (0xFFFF + 1); @@ -587,7 +586,7 @@ class CacheableHugeStringWrapper : public CacheableWrapper { m_cacheableObject = CacheableString::create(baseStr); } - virtual void initRandomValue(int32_t maxSize) { + void initRandomValue(int32_t maxSize) override { if (maxSize <= 0xFFFF) // ensure its larger than 64k { maxSize += (0xFFFF + 1); @@ -597,7 +596,7 @@ class CacheableHugeStringWrapper : public CacheableWrapper { m_cacheableObject = CacheableString::create(randStr); } - virtual uint32_t getCheckSum(const std::shared_ptr object) const { + uint32_t getCheckSum(const std::shared_ptr object) const override { const CacheableString* obj = dynamic_cast(object.get()); ASSERT(obj != nullptr, "getCheckSum: null object."); @@ -608,19 +607,15 @@ class CacheableHugeStringWrapper : public CacheableWrapper { class CacheableHugeUnicodeStringWrapper : public CacheableWrapper { public: - // Constructor and factory function - CacheableHugeUnicodeStringWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableHugeUnicodeStringWrapper(); } - // CacheableWrapper members - - virtual int32_t maxKeys() const { return INT_MAX; } + int32_t maxKeys() const override { return INT_MAX; } - virtual void initKey(int32_t keyIndex, int32_t maxSize) { + void initKey(int32_t keyIndex, int32_t maxSize) override { if (maxSize <= 0xFFFF) // ensure its larger than 64k { maxSize += (0xFFFF + 1); @@ -632,7 +627,7 @@ class CacheableHugeUnicodeStringWrapper : public CacheableWrapper { m_cacheableObject = CacheableString::create(baseStr); } - virtual void initRandomValue(int32_t maxSize) { + void initRandomValue(int32_t maxSize) override { if (maxSize <= 0xFFFF) // ensure its larger than 64k { maxSize += (0xFFFF + 1); @@ -642,7 +637,7 @@ class CacheableHugeUnicodeStringWrapper : public CacheableWrapper { m_cacheableObject = CacheableString::create(randStr); } - virtual uint32_t getCheckSum(const std::shared_ptr object) const { + uint32_t getCheckSum(const std::shared_ptr object) const override { auto&& obj = std::dynamic_pointer_cast(object); ASSERT(obj != nullptr, "getCheckSum: null object."); return CacheableHelper::crc32( @@ -663,9 +658,9 @@ class CacheableUnicodeStringWrapper : public CacheableWrapper { // CacheableWrapper members - virtual int32_t maxKeys() const { return INT_MAX; } + int32_t maxKeys() const override { return INT_MAX; } - virtual void initKey(int32_t keyIndex, int32_t maxSize) { + void initKey(int32_t keyIndex, int32_t maxSize) override { maxSize %= 21800; // so that encoded length is within 64k if (maxSize < 11) { maxSize = 11; @@ -677,14 +672,14 @@ class CacheableUnicodeStringWrapper : public CacheableWrapper { m_cacheableObject = CacheableString::create(baseStr); } - virtual void initRandomValue(int32_t maxSize) { + void initRandomValue(int32_t maxSize) override { maxSize %= 21800; // so that encoded length is within 64k std::wstring randStr; CacheableHelper::randomString(maxSize, randStr); m_cacheableObject = CacheableString::create(randStr); } - virtual uint32_t getCheckSum(const std::shared_ptr object) const { + uint32_t getCheckSum(const std::shared_ptr object) const override { auto&& obj = std::dynamic_pointer_cast(object); ASSERT(obj != nullptr, "getCheckSum: null object."); return CacheableHelper::crc32( @@ -886,15 +881,13 @@ class CacheableBytesWrapper : public CacheableWrapper { static CacheableWrapper* create() { return new CacheableBytesWrapper(); } - // CacheableWrapper members - - virtual void initRandomValue(int32_t maxSize) { + void initRandomValue(int32_t maxSize) override { auto randArr = CacheableHelper::randomArray(maxSize, UCHAR_MAX); m_cacheableObject = CacheableBytes::create( std::vector(std::begin(randArr), std::end(randArr))); } - virtual uint32_t getCheckSum(const std::shared_ptr object) const { + uint32_t getCheckSum(const std::shared_ptr object) const override { const CacheableBytes* obj = dynamic_cast(object.get()); ASSERT(obj != nullptr, "getCheckSum: null object."); @@ -904,24 +897,20 @@ class CacheableBytesWrapper : public CacheableWrapper { class CacheableDoubleArrayWrapper : public CacheableWrapper { public: - // Constructor and factory function - CacheableDoubleArrayWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableDoubleArrayWrapper(); } - // CacheableWrapper members - - virtual void initRandomValue(int32_t maxSize) { + void initRandomValue(int32_t maxSize) override { maxSize = maxSize / sizeof(double) + 1; auto randArr = CacheableHelper::randomArray(maxSize, static_cast(INT_MAX)); m_cacheableObject = CacheableDoubleArray::create(randArr); } - virtual uint32_t getCheckSum(const std::shared_ptr object) const { + uint32_t getCheckSum(const std::shared_ptr object) const override { const auto obj = std::dynamic_pointer_cast(object); ASSERT(obj != nullptr, "getCheckSum: null object."); @@ -931,22 +920,18 @@ class CacheableDoubleArrayWrapper : public CacheableWrapper { class CacheableFloatArrayWrapper : public CacheableWrapper { public: - // Constructor and factory function - CacheableFloatArrayWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableFloatArrayWrapper(); } - // CacheableWrapper members - - virtual void initRandomValue(int32_t maxSize) { + void initRandomValue(int32_t maxSize) override { maxSize = maxSize / sizeof(float) + 1; auto randArr = CacheableHelper::randomArray(maxSize, static_cast(INT_MAX)); m_cacheableObject = CacheableFloatArray::create(randArr); } - virtual uint32_t getCheckSum(const std::shared_ptr object) const { + uint32_t getCheckSum(const std::shared_ptr object) const override { const auto obj = std::dynamic_pointer_cast(object); ASSERT(obj != nullptr, "getCheckSum: null object."); @@ -956,21 +941,17 @@ class CacheableFloatArrayWrapper : public CacheableWrapper { class CacheableInt16ArrayWrapper : public CacheableWrapper { public: - // Constructor and factory function - CacheableInt16ArrayWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableInt16ArrayWrapper(); } - // CacheableWrapper members - - virtual void initRandomValue(int32_t maxSize) { + void initRandomValue(int32_t maxSize) override { maxSize = maxSize / sizeof(int16_t) + 1; auto randArr = CacheableHelper::randomArray(maxSize, SHRT_MAX); m_cacheableObject = CacheableInt16Array::create(randArr); } - virtual uint32_t getCheckSum(const std::shared_ptr object) const { + uint32_t getCheckSum(const std::shared_ptr object) const override { const auto obj = std::dynamic_pointer_cast(object); ASSERT(obj != nullptr, "getCheckSum: null object."); @@ -980,21 +961,17 @@ class CacheableInt16ArrayWrapper : public CacheableWrapper { class CacheableInt32ArrayWrapper : public CacheableWrapper { public: - // Constructor and factory function - CacheableInt32ArrayWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableInt32ArrayWrapper(); } - // CacheableWrapper members - - virtual void initRandomValue(int32_t maxSize) { + void initRandomValue(int32_t maxSize) override { maxSize = maxSize / sizeof(int32_t) + 1; auto randArr = CacheableHelper::randomArray(maxSize, INT_MAX); m_cacheableObject = CacheableInt32Array::create(randArr); } - virtual uint32_t getCheckSum(const std::shared_ptr object) const { + uint32_t getCheckSum(const std::shared_ptr object) const override { const auto obj = std::dynamic_pointer_cast(object); ASSERT(obj != nullptr, "getCheckSum: null object."); @@ -1004,21 +981,17 @@ class CacheableInt32ArrayWrapper : public CacheableWrapper { class CacheableInt64ArrayWrapper : public CacheableWrapper { public: - // Constructor and factory function - CacheableInt64ArrayWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableInt64ArrayWrapper(); } - // CacheableWrapper members - - virtual void initRandomValue(int32_t maxSize) { + void initRandomValue(int32_t maxSize) override { maxSize = maxSize / sizeof(int64_t) + 1; auto randArr = CacheableHelper::randomArray(maxSize, INT_MAX); m_cacheableObject = CacheableInt64Array::create(randArr); } - virtual uint32_t getCheckSum(const std::shared_ptr object) const { + uint32_t getCheckSum(const std::shared_ptr object) const override { const auto obj = std::dynamic_pointer_cast(object); ASSERT(obj != nullptr, "getCheckSum: null object."); @@ -1028,14 +1001,10 @@ class CacheableInt64ArrayWrapper : public CacheableWrapper { class CacheableNullStringWrapper : public CacheableWrapper { public: - // Constructor and factory function - CacheableNullStringWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableNullStringWrapper(); } - // CacheableWrapper members - void initRandomValue(int32_t) override { m_cacheableObject = CacheableString::create(static_cast(nullptr)); } @@ -1048,17 +1017,13 @@ class CacheableNullStringWrapper : public CacheableWrapper { class CacheableStringArrayWrapper : public CacheableWrapper { public: - // Constructor and factory function - CacheableStringArrayWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableStringArrayWrapper(); } - // CacheableWrapper members - - virtual void initRandomValue(int32_t maxSize) { + void initRandomValue(int32_t maxSize) override { int32_t arraySize = 16; maxSize = maxSize / arraySize; if (maxSize < 2) { @@ -1083,7 +1048,7 @@ class CacheableStringArrayWrapper : public CacheableWrapper { randArr + arraySize)); } - virtual uint32_t getCheckSum(const std::shared_ptr object) const { + uint32_t getCheckSum(const std::shared_ptr object) const override { auto&& obj = std::dynamic_pointer_cast(object); ASSERT(obj != nullptr, "getCheckSum: null object."); uint32_t checkSum = 0; @@ -1098,40 +1063,16 @@ class CacheableStringArrayWrapper : public CacheableWrapper { } }; -class CacheableUndefinedWrapper : public CacheableWrapper { - public: - // Constructor and factory function - - CacheableUndefinedWrapper() : CacheableWrapper(nullptr) {} - - static CacheableWrapper* create() { return new CacheableUndefinedWrapper(); } - - // CacheableWrapper members - - void initRandomValue(int32_t) override { - m_cacheableObject = std::shared_ptr( - CacheableUndefined::createDeserializable()); - } - - uint32_t getCheckSum(const std::shared_ptr) const override { - return 0; - } -}; - template class CacheableVectorTypeWrapper : public CacheableWrapper { public: - // Constructor and factory function - CacheableVectorTypeWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableVectorTypeWrapper(); } - // CacheableWrapper members - - virtual void initRandomValue(int32_t maxSize) { + void initRandomValue(int32_t maxSize) override { auto vec = std::dynamic_pointer_cast(VECTTYPE::createDeserializable()); auto valueTypeIds = CacheableWrapperFactory::getRegisteredValueTypes(); @@ -1150,7 +1091,7 @@ class CacheableVectorTypeWrapper : public CacheableWrapper { m_cacheableObject = vec; } - virtual uint32_t getCheckSum(const std::shared_ptr object) const { + uint32_t getCheckSum(const std::shared_ptr object) const override { auto vec = std::dynamic_pointer_cast(object); ASSERT(vec != nullptr, "getCheckSum: null object."); uint32_t checkSum = 0; @@ -1189,7 +1130,7 @@ class CacheableObjectArrayWrapper : public CacheableWrapper { // CacheableWrapper members - virtual void initRandomValue(int32_t maxSize) { + void initRandomValue(int32_t maxSize) override { auto arr = std::dynamic_pointer_cast( CacheableObjectArray::createDeserializable()); auto valueTypeIds = CacheableWrapperFactory::getRegisteredValueTypes(); @@ -1208,7 +1149,7 @@ class CacheableObjectArrayWrapper : public CacheableWrapper { m_cacheableObject = arr; } - virtual uint32_t getCheckSum(const std::shared_ptr object) const { + uint32_t getCheckSum(const std::shared_ptr object) const override { auto&& arr = std::dynamic_pointer_cast(object); ASSERT(arr != nullptr, "getCheckSum: null object."); uint32_t checkSum = 0; diff --git a/cppcache/integration-test/QueryHelper.hpp b/cppcache/integration-test/QueryHelper.hpp index efe3fd9de0..072581060e 100644 --- a/cppcache/integration-test/QueryHelper.hpp +++ b/cppcache/integration-test/QueryHelper.hpp @@ -51,7 +51,7 @@ #define ROOT_SCOPE LOCAL #endif -namespace { // NOLINT(google-build-namespaces) +namespace { // NOLINT(google-build-namespaces) using apache::geode::client::CacheableKey; using apache::geode::client::CacheableStringArray; @@ -88,7 +88,7 @@ class QueryHelper { positionNumSets = 1; } - virtual ~QueryHelper() { ; } + virtual ~QueryHelper() {} virtual void populatePortfolioData( std::shared_ptr& pregion, size_t setSize, size_t numSets, diff --git a/cppcache/integration-test/TallyListener.hpp b/cppcache/integration-test/TallyListener.hpp index f0285aef65..c486a2ed52 100644 --- a/cppcache/integration-test/TallyListener.hpp +++ b/cppcache/integration-test/TallyListener.hpp @@ -69,12 +69,10 @@ class TallyListener : public CacheListener { LOG("TallyListener contructor called"); } - virtual ~TallyListener() {} + ~TallyListener() noexcept override = default; void beQuiet(bool v) { m_quiet = v; } - void ignoreTimeouts(bool ignore) { m_ignoreTimeout = ignore; } - int expectCreates(int expected) { int tries = 0; while ((m_creates < expected) && (tries < 200)) { @@ -99,24 +97,6 @@ class TallyListener : public CacheListener { isCallbackCalled = false; } int getUpdates() { return m_updates; } - int expectInvalidates(int expected) { - LOG("calling expectInvalidates "); - int tries = 0; - while ((m_invalidates < expected) && (tries < 200)) { - SLEEP(100); - tries++; - } - return m_invalidates; - } - int expectDestroys(int expected) { - LOG("calling expectDestroys "); - int tries = 0; - while ((m_destroys < expected) && (tries < 200)) { - SLEEP(100); - tries++; - } - return m_destroys; - } int getInvalidates() { return m_invalidates; } int getDestroys() { return m_destroys; } @@ -142,23 +122,21 @@ class TallyListener : public CacheListener { int getClears() { return m_clears; } - virtual void afterCreate(const EntryEvent& event); + void afterCreate(const EntryEvent& event) override; - virtual void afterUpdate(const EntryEvent& event); + void afterUpdate(const EntryEvent& event) override; - virtual void afterInvalidate(const EntryEvent& event); + void afterInvalidate(const EntryEvent& event) override; - virtual void afterDestroy(const EntryEvent& event); + void afterDestroy(const EntryEvent& event) override; - virtual void afterRegionClear(const RegionEvent& event) { + void afterRegionClear(const RegionEvent& event) override { CacheListener::afterRegionClear(event); } - virtual void afterRegionClear(const EntryEvent& event); + void afterRegionInvalidate(const RegionEvent&) override {} - virtual void afterRegionInvalidate(const RegionEvent&) {} - - virtual void afterRegionDestroy(const RegionEvent&) {} + void afterRegionDestroy(const RegionEvent&) override {} void showTallies() { char buf[1024]; @@ -220,11 +198,6 @@ void TallyListener::afterDestroy(const EntryEvent& event) { m_destroys++; checkcallbackArg(event); } -void TallyListener::afterRegionClear(const EntryEvent& event) { - m_clears++; - LOGINFO("TallyListener::afterRegionClear m_clears = %d", m_clears); - checkcallbackArg(event); -} } // namespace testing } // namespace client diff --git a/cppcache/integration-test/TallyLoader.hpp b/cppcache/integration-test/TallyLoader.hpp index 95818492ce..3b932b1700 100644 --- a/cppcache/integration-test/TallyLoader.hpp +++ b/cppcache/integration-test/TallyLoader.hpp @@ -38,10 +38,11 @@ class TallyLoader : virtual public CacheLoader { public: TallyLoader() : CacheLoader(), m_loads(0) {} - virtual ~TallyLoader() = default; + ~TallyLoader() noexcept override = default; - std::shared_ptr load(Region&, const std::shared_ptr&, - const std::shared_ptr&) { + std::shared_ptr load( + Region&, const std::shared_ptr&, + const std::shared_ptr&) override { LOGDEBUG("TallyLoader::load invoked for %d.", m_loads); char buf[1024]; sprintf(buf, "TallyLoader state: (loads = %d)", m_loads); @@ -49,26 +50,11 @@ class TallyLoader : virtual public CacheLoader { return CacheableInt32::create(m_loads++); } - virtual void close(Region&) { LOG("TallyLoader::close"); } - - int expectLoads(int expected) { - int tries = 0; - while ((m_loads < expected) && (tries < 200)) { - SLEEP(100); - tries++; - } - return m_loads; - } + virtual void close(Region&) override { LOG("TallyLoader::close"); } int getLoads() { return m_loads; } void reset() { m_loads = 0; } - - void showTallies() { - char buf[1024]; - sprintf(buf, "TallyLoader state: (loads = %d)", getLoads()); - LOG(buf); - } }; } // namespace testing diff --git a/cppcache/integration-test/ThinClientListenerInit.hpp b/cppcache/integration-test/ThinClientListenerInit.hpp index 9c27983343..046cc6b068 100644 --- a/cppcache/integration-test/ThinClientListenerInit.hpp +++ b/cppcache/integration-test/ThinClientListenerInit.hpp @@ -30,7 +30,7 @@ #define CLIENT2 s1p2 #define SERVER1 s2p1 -namespace { // NOLINT(google-build-namespaces) +namespace { // NOLINT(google-build-namespaces) using apache::geode::client::Cacheable; @@ -57,11 +57,11 @@ class ThinClientTallyLoader : public TallyLoader { public: ThinClientTallyLoader() : TallyLoader() {} - virtual ~ThinClientTallyLoader() = default; + ~ThinClientTallyLoader() noexcept override = default; std::shared_ptr load( Region& rp, const std::shared_ptr& key, - const std::shared_ptr& aCallbackArgument) { + const std::shared_ptr& aCallbackArgument) override { int32_t loadValue = std::dynamic_pointer_cast( TallyLoader::load(rp, key, aCallbackArgument)) ->value(); diff --git a/cppcache/integration-test/ThinClientLocalCacheLoader.hpp b/cppcache/integration-test/ThinClientLocalCacheLoader.hpp index 9969ca5686..b74e38a3c0 100644 --- a/cppcache/integration-test/ThinClientLocalCacheLoader.hpp +++ b/cppcache/integration-test/ThinClientLocalCacheLoader.hpp @@ -28,7 +28,7 @@ #define CLIENT1 s1p1 #define SERVER1 s2p1 -namespace { // NOLINT(google-build-namespaces) +namespace { // NOLINT(google-build-namespaces) using apache::geode::client::Cacheable; using apache::geode::client::CacheFactory; @@ -44,11 +44,11 @@ class ThinClientTallyLoader : public TallyLoader { public: ThinClientTallyLoader() : TallyLoader() {} - virtual ~ThinClientTallyLoader() = default; + ~ThinClientTallyLoader() noexcept override = default; std::shared_ptr load( Region& rp, const std::shared_ptr& key, - const std::shared_ptr& aCallbackArgument) { + const std::shared_ptr& aCallbackArgument) override { int32_t loadValue = std::dynamic_pointer_cast( TallyLoader::load(rp, key, aCallbackArgument)) ->value(); @@ -64,7 +64,7 @@ class ThinClientTallyLoader : public TallyLoader { return std::move(lreturnValue); } - void close(Region& region) { + void close(Region& region) override { LOG(" ThinClientTallyLoader::close() called"); LOGINFO(" Region %s is Destroyed = %d ", region.getName().c_str(), region.isDestroyed()); diff --git a/cppcache/integration-test/ThinClientSecurityHelper.hpp b/cppcache/integration-test/ThinClientSecurityHelper.hpp index 973ee8cccd..de43ce57b3 100644 --- a/cppcache/integration-test/ThinClientSecurityHelper.hpp +++ b/cppcache/integration-test/ThinClientSecurityHelper.hpp @@ -26,7 +26,7 @@ #include "ThinClientHelper.hpp" #include "hacks/AceThreadId.h" -namespace { // NOLINT(google-build-namespaces) +namespace { // NOLINT(google-build-namespaces) using apache::geode::client::CacheableBoolean; using apache::geode::client::Exception; @@ -215,7 +215,7 @@ class putThread : public ACE_Task_Base { } } - int svc(void) { + int svc(void) override { int ops = 0; auto pid = ACE_OS::getpid(); std::shared_ptr key; diff --git a/cppcache/integration-test/ThinClientTransactions.hpp b/cppcache/integration-test/ThinClientTransactions.hpp index 2e4bec6489..7ef5c157ea 100644 --- a/cppcache/integration-test/ThinClientTransactions.hpp +++ b/cppcache/integration-test/ThinClientTransactions.hpp @@ -34,7 +34,7 @@ #include "CacheHelper.hpp" -namespace { // NOLINT(google-build-namespaces) +namespace { // NOLINT(google-build-namespaces) using apache::geode::client::CacheableKey; using apache::geode::client::CacheableString; @@ -144,7 +144,8 @@ void _verifyEntry(const char* name, const char* key, const char* val, std::dynamic_pointer_cast(regPtr->get(keyPtr)); ASSERT(checkPtr != nullptr, "Value Ptr should not be null."); - LOG("In verify loop, get returned " + checkPtr->value() + " for key " + key); + LOG("In verify loop, get returned " + checkPtr->value() + " for key " + + key); if (strcmp(checkPtr->value().c_str(), value) != 0) { testValueCnt++; @@ -360,11 +361,13 @@ const bool USE_ACK = true; const bool NO_ACK = false; #include "LocatorHelper.hpp" #define THREADERRORCHECK(x, y) \ - if (!(x)) { \ - m_isFailed = true; \ - sprintf(m_error, y); \ - return -1; \ - } + do { \ + if (!(x)) { \ + m_isFailed = true; \ + sprintf(m_error, y); \ + return -1; \ + } \ + } while (0) class SuspendTransactionThread : public ACE_Task_Base { private: @@ -376,7 +379,7 @@ class SuspendTransactionThread : public ACE_Task_Base { SuspendTransactionThread(bool sleep, ACE_Auto_Event* txEvent) : m_suspendedTransaction(nullptr), m_sleep(sleep), m_txEvent(txEvent) {} - int svc(void) { + int svc(void) override { char buf[1024]; sprintf(buf, " In SuspendTransactionThread"); LOG(buf); @@ -429,7 +432,7 @@ class ResumeTransactionThread : public ACE_Task_Base { m_isFailed(false), m_txEvent(txEvent) {} - int svc(void) { + int svc(void) override { char buf[1024]; sprintf(buf, "In ResumeTransactionThread"); LOG(buf); diff --git a/cppcache/integration-test/ThinClientTransactionsXA.hpp b/cppcache/integration-test/ThinClientTransactionsXA.hpp index 84fa7845b9..4594775892 100644 --- a/cppcache/integration-test/ThinClientTransactionsXA.hpp +++ b/cppcache/integration-test/ThinClientTransactionsXA.hpp @@ -34,16 +34,16 @@ #include "CacheHelper.hpp" -namespace { // NOLINT(google-build-namespaces) +namespace { // NOLINT(google-build-namespaces) using apache::geode::client::CacheableKey; using apache::geode::client::CacheableString; using apache::geode::client::CacheHelper; using apache::geode::client::CacheServerException; +using apache::geode::client::CacheTransactionManager; using apache::geode::client::EntryExistsException; using apache::geode::client::EntryNotFoundException; using apache::geode::client::IllegalStateException; -using apache::geode::client::CacheTransactionManager; using apache::geode::client::Properties; using apache::geode::client::TransactionException; using apache::geode::client::TransactionId; @@ -145,7 +145,8 @@ void _verifyEntry(const char* name, const char* key, const char* val, std::dynamic_pointer_cast(regPtr->get(keyPtr)); ASSERT(checkPtr != nullptr, "Value Ptr should not be null."); - LOG("In verify loop, get returned " + checkPtr->value() + " for key " + key); + LOG("In verify loop, get returned " + checkPtr->value() + " for key " + + key); if (strcmp(checkPtr->value().c_str(), value) != 0) { testValueCnt++; @@ -361,11 +362,13 @@ const bool USE_ACK = true; const bool NO_ACK = false; #include "LocatorHelper.hpp" #define THREADERRORCHECK(x, y) \ - if (!(x)) { \ - m_isFailed = true; \ - sprintf(m_error, y); \ - return -1; \ - } + do { \ + if (!(x)) { \ + m_isFailed = true; \ + sprintf(m_error, y); \ + return -1; \ + } \ + } while (0) class SuspendTransactionThread : public ACE_Task_Base { private: @@ -377,7 +380,7 @@ class SuspendTransactionThread : public ACE_Task_Base { SuspendTransactionThread(bool sleep, ACE_Auto_Event* txEvent) : m_suspendedTransaction(nullptr), m_sleep(sleep), m_txEvent(txEvent) {} - int svc(void) { + int svc(void) override { char buf[1024]; sprintf(buf, " In SuspendTransactionThread"); LOG(buf); @@ -410,9 +413,7 @@ class SuspendTransactionThread : public ACE_Task_Base { } void start() { activate(); } void stop() { wait(); } - TransactionId& getSuspendedTx() { - return *m_suspendedTransaction; - } + TransactionId& getSuspendedTx() { return *m_suspendedTransaction; } }; class ResumeTransactionThread : public ACE_Task_Base { private: @@ -424,16 +425,15 @@ class ResumeTransactionThread : public ACE_Task_Base { ACE_Auto_Event* m_txEvent; public: - ResumeTransactionThread(TransactionId& suspendedTransaction, - bool commit, bool tryResumeWithSleep, - ACE_Auto_Event* txEvent) + ResumeTransactionThread(TransactionId& suspendedTransaction, bool commit, + bool tryResumeWithSleep, ACE_Auto_Event* txEvent) : m_suspendedTransaction(suspendedTransaction), m_commit(commit), m_tryResumeWithSleep(tryResumeWithSleep), m_isFailed(false), m_txEvent(txEvent) {} - int svc(void) { + int svc(void) override { char buf[1024]; sprintf(buf, "In ResumeTransactionThread"); LOG(buf); diff --git a/cppcache/integration-test/TimeBomb.hpp b/cppcache/integration-test/TimeBomb.hpp index 97d58f5f25..07ef80074b 100644 --- a/cppcache/integration-test/TimeBomb.hpp +++ b/cppcache/integration-test/TimeBomb.hpp @@ -87,7 +87,7 @@ class TimeBomb : public ACE_Task_Base { return activate(thrAttrs, 1); } - int svc() { + int svc() override { if (m_sleep == ACE_Time_Value(0)) { printf("###### TIMEBOMB Disabled. ######\n"); fflush(stdout); @@ -108,7 +108,7 @@ class TimeBomb : public ACE_Task_Base { return 0; } - ~TimeBomb() {} + ~TimeBomb() noexcept override = default; }; #endif // GEODE_INTEGRATION_TEST_TIMEBOMB_H_ diff --git a/cppcache/integration-test/fw_dunit.cpp b/cppcache/integration-test/fw_dunit.cpp index 257a1f2a3d..fa1350abd5 100644 --- a/cppcache/integration-test/fw_dunit.cpp +++ b/cppcache/integration-test/fw_dunit.cpp @@ -508,7 +508,7 @@ class TestProcess : virtual public dunit::Manager { protected: public: - virtual ~TestProcess() {} + ~TestProcess() noexcept override = default; }; /** @@ -1031,7 +1031,6 @@ PerfSuite::PerfSuite(const char *suiteName) : m_suiteName(suiteName) {} void PerfSuite::addRecord(std::string testName, int64_t ops, const TimeStamp &start, const TimeStamp &stop) { Record tmp(testName, ops, start, stop); - m_records[testName] = tmp; fprintf(stdout, "[PerfSuite] %s\n", tmp.asString().c_str()); fflush(stdout); } @@ -1129,10 +1128,6 @@ ThreadLauncher::~ThreadLauncher() { } } -Thread::Thread() : ACE_Task_Base(), m_launcher(nullptr), m_used(false) {} - -Thread::~Thread() {} - int Thread::svc() { m_used = true; int res = 0; diff --git a/cppcache/integration-test/fw_dunit.hpp b/cppcache/integration-test/fw_dunit.hpp index 59904f8e79..7b39479861 100644 --- a/cppcache/integration-test/fw_dunit.hpp +++ b/cppcache/integration-test/fw_dunit.hpp @@ -120,18 +120,18 @@ END_TASK(validate) #include #include -#define ASSERT(x, y) \ - do { \ - if (!(x)) { \ - throw dunit::TestException(y, __LINE__, __FILE__); \ - } \ - } while(false) -#define XASSERT(x) \ - do { \ - if (!(x)) { \ - throw dunit::TestException(#x, __LINE__, __FILE__); \ - } \ - } while(false) +#define ASSERT(x, y) \ + do { \ + if (!(x)) { \ + throw dunit::TestException(y, __LINE__, __FILE__); \ + } \ + } while (false) +#define XASSERT(x) \ + do { \ + if (!(x)) { \ + throw dunit::TestException(#x, __LINE__, __FILE__); \ + } \ + } while (false) #define FAIL(y) throw dunit::TestException(y, __LINE__, __FILE__) #define LOG(y) dunit::log(y, __LINE__, __FILE__) #define LOGCOORDINATOR(y) dunit::logCoordinator(y, __LINE__, __FILE__) @@ -155,7 +155,7 @@ END_TASK(validate) DCLASSNAME(y)() { init(x); } \ \ public: \ - virtual void doTask() { \ + void doTask() override { \ static const char* fwtest_Name = DTASKDESC(y, __LINE__); \ try { // Close the class definition produced by DUNIT_TASK macro. @@ -200,10 +200,10 @@ END_TASK(validate) #define DUNIT_TASK_DEFINITION(x, y) \ class DCLASSDEF(y) : virtual public dunit::Task { \ public: \ - DCLASSDEF(y)() { init(x, true); } \ + DCLASSDEF(y)() { init(x, true); } \ \ public: \ - virtual void doTask() { \ + void doTask() override { \ static const char* fwtest_Name = DTASKDESC(y, __LINE__); \ try { #define END_TASK_DEFINITION \ @@ -224,7 +224,9 @@ END_TASK(validate) } \ } \ ; -#define CALL_TASK(y); DCLASSDEF(y) * DVARNAME(y) = new DCLASSDEF(y)() +#define CALL_TASK(y) \ + ; \ + DCLASSDEF(y) * DVARNAME(y) = new DCLASSDEF(y)() #define DUNIT_MAIN \ class DCLASSNAME(Main) { \ @@ -277,7 +279,7 @@ class Task { bool m_isHeapAllocated; Task() {} - virtual ~Task() { } + virtual ~Task() {} /** register task with worker. */ void init(int sId); diff --git a/cppcache/integration-test/fw_helper.hpp b/cppcache/integration-test/fw_helper.hpp index 11d0ace623..59e942a200 100644 --- a/cppcache/integration-test/fw_helper.hpp +++ b/cppcache/integration-test/fw_helper.hpp @@ -236,7 +236,7 @@ int main(int /*argc*/, char** /*argv*/) Test_##x() { init(); } \ \ public: \ - virtual void doTest() { \ + void doTest() override { \ static const char* fwtest_Name = #x; #define END_TEST(x) \ } \ diff --git a/cppcache/integration-test/fw_perf.hpp b/cppcache/integration-test/fw_perf.hpp index af019e6534..a952301808 100644 --- a/cppcache/integration-test/fw_perf.hpp +++ b/cppcache/integration-test/fw_perf.hpp @@ -70,15 +70,14 @@ class Semaphore { volatile int m_count; public: + Semaphore() = delete; explicit Semaphore(int count); ~Semaphore(); + Semaphore(const Semaphore& other) = delete; + Semaphore& operator=(const Semaphore& other) = delete; + void acquire(int t = 1); void release(int t = 1); - - private: - Semaphore(); - Semaphore(const Semaphore& other); - Semaphore& operator=(const Semaphore& other); }; class TimeStamp { @@ -125,12 +124,9 @@ class Record { ~Record(); }; -typedef std::map RecordMap; - class PerfSuite { private: std::string m_suiteName; - RecordMap m_records; public: explicit PerfSuite(const char* suiteName); @@ -193,7 +189,8 @@ class Thread : public ACE_Task_Base { bool m_used; public: - Thread(); + Thread() : ACE_Task_Base(), m_launcher(nullptr), m_used(false) {} + // Unhide function to prevent SunPro Warnings using ACE_Shared_Object::init; void init(ThreadLauncher* l) { @@ -201,7 +198,7 @@ class Thread : public ACE_Task_Base { m_launcher = l; } - ~Thread(); + ~Thread() noexcept override = default; /** called before measurement begins. override to do per thread setup. */ virtual void setup() {} @@ -213,36 +210,9 @@ class Thread : public ACE_Task_Base { */ virtual void cleanup() {} - virtual int svc(); + int svc() override; }; -// class NamingServiceThread -//: public ACE_Task_Base -//{ -// private: -// uint32_t m_port; -// -// void namingService() -// { -// char * argsv[2]; -// char pbuf[32]; -// sprintf( pbuf, "-p %d", 12321 ); -// -// argsv[0] = strdup( pbuf ); -// argsv[1] = 0; -// auto svcObj = ACE_SVC_INVOKE( ACE_Name_Acceptor ); -// -// if ( svcObj->init( 1, argsv ) == -1 ) { -// fprintf( stdout, "Failed to construct the Naming Service." ); -// fflush( stdout ); -// } -// ACE_Reactor::run_event_loop(); -// } -// -// public: -// NamingServiceThread( uint32_t port ) : m_port( port ) {} -// virtual int svc() { };//namingService(); } -//}; } // namespace perf #endif // GEODE_INTEGRATION_TEST_FW_PERF_H_ diff --git a/cppcache/integration-test/fw_spawn.hpp b/cppcache/integration-test/fw_spawn.hpp index e49da7dc49..16ba989fde 100644 --- a/cppcache/integration-test/fw_spawn.hpp +++ b/cppcache/integration-test/fw_spawn.hpp @@ -32,14 +32,14 @@ #if defined(_WIN32) #if (FD_SETSIZE != 1024) -++ + bad fdsetsize... ++++bad fdsetsize... #endif #endif #include #include - namespace dunit { + namespace dunit { // Listing 1 code/ch10 class Manager : virtual public ACE_Process { @@ -95,7 +95,7 @@ // Listing 2 code/ch10 // prepare() is inherited from ACE_Process. - virtual int prepare(ACE_Process_Options &options) { + int prepare(ACE_Process_Options &options) override { options.command_line("%s", this->programName_); if (this->setStdHandles(options) == -1 || this->setEnvVariable(options) == -1) { @@ -117,7 +117,7 @@ private: protected: - virtual ~Manager() {} + ~Manager() noexcept override = default; private: ACE_HANDLE outputfd_; diff --git a/cppcache/integration-test/testFwPerf.cpp b/cppcache/integration-test/testFwPerf.cpp index 8615b944f4..e5304e17af 100644 --- a/cppcache/integration-test/testFwPerf.cpp +++ b/cppcache/integration-test/testFwPerf.cpp @@ -24,18 +24,18 @@ class LocalPutTask : public perf::Thread { public: LocalPutTask() : Thread() {} - virtual void setup() { + void setup() override { fprintf(stdout, "performed my setup...\n"); fflush(stdout); } - virtual void perftask() { + void perftask() override { ACE_OS::sleep(1); fprintf(stdout, "perffunc done.\n"); fflush(stdout); } - virtual void cleanup() { + void cleanup() override { fprintf(stdout, "performed my cleanup...\n"); fflush(stdout); } diff --git a/cppcache/integration-test/testLogger.cpp b/cppcache/integration-test/testLogger.cpp index 5645db4835..f3a245d9a7 100644 --- a/cppcache/integration-test/testLogger.cpp +++ b/cppcache/integration-test/testLogger.cpp @@ -31,13 +31,12 @@ using apache::geode::client::LogLevel; int numOfLinesInFile(const char *fname) { char line[2048]; - char *read; int ln_cnt = 0; - FILE *fp = fopen(fname, "r"); + auto fp = fopen(fname, "r"); if (fp == nullptr) { return -1; } - while (!!(read = fgets(line, sizeof line, fp))) { + while (!!(fgets(line, sizeof line, fp))) { printf("%d:%s", ++ln_cnt, line); } diff --git a/cppcache/integration-test/testOverflowPutGetSqLite.cpp b/cppcache/integration-test/testOverflowPutGetSqLite.cpp index 594d0d98ae..6e353598e0 100644 --- a/cppcache/integration-test/testOverflowPutGetSqLite.cpp +++ b/cppcache/integration-test/testOverflowPutGetSqLite.cpp @@ -288,7 +288,7 @@ class PutThread : public ACE_Task_Base { PutThread(std::shared_ptr ®Ptr, int min, int max) : m_regPtr(regPtr), m_min(min), m_max(max) {} - int svc(void) { + int svc(void) override { /** put some values into the cache. */ doNput(m_regPtr, m_max, m_min); /** do some gets... printing what we find in the cache. */ diff --git a/cppcache/integration-test/testRegionAccessThreadSafe.cpp b/cppcache/integration-test/testRegionAccessThreadSafe.cpp index cc0530ec26..e9e973c80d 100644 --- a/cppcache/integration-test/testRegionAccessThreadSafe.cpp +++ b/cppcache/integration-test/testRegionAccessThreadSafe.cpp @@ -36,7 +36,7 @@ class GetRegionThread : public ACE_Task_Base { m_regionCreateDone(false), m_subRegionCreateDone(false), m_mutex() {} - int svc(void) { + int svc(void) override { while (m_running == true) { SLEEP(40); try { diff --git a/cppcache/integration-test/testSpinLock.cpp b/cppcache/integration-test/testSpinLock.cpp index ec9306062b..1e99257ff0 100644 --- a/cppcache/integration-test/testSpinLock.cpp +++ b/cppcache/integration-test/testSpinLock.cpp @@ -46,7 +46,7 @@ class ThreadA : public ACE_Task_Base { public: ThreadA() : ACE_Task_Base() {} - int svc() { + int svc() override { { std::lock_guard lk(lock); LOG("ThreadA: Acquired lock x."); @@ -62,7 +62,7 @@ class ThreadB : public ACE_Task_Base { public: ThreadB() : ACE_Task_Base() {} - int svc() { + int svc() override { triggerB->acquire(); { std::lock_guard lk(lock); diff --git a/cppcache/integration-test/testThinClientConflation.cpp b/cppcache/integration-test/testThinClientConflation.cpp index 17954d5f33..b9a7bafa2e 100644 --- a/cppcache/integration-test/testThinClientConflation.cpp +++ b/cppcache/integration-test/testThinClientConflation.cpp @@ -61,11 +61,11 @@ class OperMonitor : public CacheListener { public: OperMonitor() : m_events(0), m_value(0) {} - ~OperMonitor() {} + ~OperMonitor() noexcept override = default; - virtual void afterCreate(const EntryEvent &event) { check(event); } + void afterCreate(const EntryEvent &event) override { check(event); } - virtual void afterUpdate(const EntryEvent &event) { check(event); } + void afterUpdate(const EntryEvent &event) override { check(event); } void validate(bool conflation) { LOG("validate called"); diff --git a/cppcache/integration-test/testThinClientCq.cpp b/cppcache/integration-test/testThinClientCq.cpp index 7a32dd3f5a..fbfe4092c9 100644 --- a/cppcache/integration-test/testThinClientCq.cpp +++ b/cppcache/integration-test/testThinClientCq.cpp @@ -16,13 +16,10 @@ */ #include "fw_dunit.hpp" #include -#include #include #include -#include #include #include -#include #include #define ROOT_NAME "TestThinClientCq" @@ -30,7 +27,6 @@ #include "CacheHelper.hpp" -#include "QueryStrings.hpp" #include "QueryHelper.hpp" #include @@ -161,15 +157,15 @@ class MyCqListener : public CqListener { } } - void onEvent(const CqEvent &cqe) { + void onEvent(const CqEvent &cqe) override { // LOG("MyCqListener::OnEvent called"); updateCount(cqe); } - void onError(const CqEvent &cqe) { + void onError(const CqEvent &cqe) override { updateCount(cqe); // LOG("MyCqListener::OnError called"); } - void close() { + void close() override { // LOG("MyCqListener::close called"); } }; @@ -225,20 +221,22 @@ class MyCqStatusListener : public CqStatusListener { } } - void onEvent(const CqEvent &cqe) { + void onEvent(const CqEvent &cqe) override { LOGINFO("MyCqStatusListener::OnEvent %d called", m_id); updateCount(cqe); } - void onError(const CqEvent &cqe) { + void onError(const CqEvent &cqe) override { updateCount(cqe); LOGINFO("MyCqStatusListener::OnError %d called", m_id); } - void close() { LOGINFO("MyCqStatusListener::close %d called", m_id); } - void onCqDisconnected() { + void close() override { + LOGINFO("MyCqStatusListener::close %d called", m_id); + } + void onCqDisconnected() override { LOGINFO("MyCqStatusListener %d got onCqDisconnected", m_id); m_cqsDisconnectedCount++; } - void onCqConnected() { + void onCqConnected() override { LOGINFO("MyCqStatusListener %d got onCqConnected", m_id); m_cqsConnectedCount++; } diff --git a/cppcache/integration-test/testThinClientCqDelta.cpp b/cppcache/integration-test/testThinClientCqDelta.cpp index b5577cc3c5..eb3eaea491 100644 --- a/cppcache/integration-test/testThinClientCqDelta.cpp +++ b/cppcache/integration-test/testThinClientCqDelta.cpp @@ -60,7 +60,7 @@ class CqDeltaListener : public CqListener { public: CqDeltaListener() : m_deltaCount(0), m_valueCount(0) {} - virtual void onEvent(const CqEvent &aCqEvent) { + void onEvent(const CqEvent &aCqEvent) override { auto deltaValue = aCqEvent.getDeltaValue(); DeltaTestImpl newValue; auto input = getHelper()->getCache()->createDataInput( diff --git a/cppcache/integration-test/testThinClientCqFailover.cpp b/cppcache/integration-test/testThinClientCqFailover.cpp index 09f56ddc02..fcf7662d72 100644 --- a/cppcache/integration-test/testThinClientCqFailover.cpp +++ b/cppcache/integration-test/testThinClientCqFailover.cpp @@ -94,7 +94,7 @@ class KillServerThread : public ACE_Task_Base { MyCqListener *m_listener; explicit KillServerThread(MyCqListener *listener) : m_running(false), m_listener(listener) {} - int svc(void) { + int svc(void) override { while (m_running == true) { CacheHelper::closeServer(1); LOG("THREAD CLOSED SERVER 1"); diff --git a/cppcache/integration-test/testThinClientCqHAFailover.cpp b/cppcache/integration-test/testThinClientCqHAFailover.cpp index 790f9a699b..d5bebbc453 100644 --- a/cppcache/integration-test/testThinClientCqHAFailover.cpp +++ b/cppcache/integration-test/testThinClientCqHAFailover.cpp @@ -93,7 +93,7 @@ class KillServerThread : public ACE_Task_Base { MyCqListener *m_listener; explicit KillServerThread(MyCqListener *listener) : m_running(false), m_listener(listener) {} - int svc(void) { + int svc(void) override { while (m_running == true) { CacheHelper::closeServer(1); LOG("THREAD CLOSED SERVER 1"); diff --git a/cppcache/integration-test/testThinClientHAQueryFailover.cpp b/cppcache/integration-test/testThinClientHAQueryFailover.cpp index 25e46d6f5b..f71c43ebda 100644 --- a/cppcache/integration-test/testThinClientHAQueryFailover.cpp +++ b/cppcache/integration-test/testThinClientHAQueryFailover.cpp @@ -62,7 +62,7 @@ class KillServerThread : public ACE_Task_Base { public: bool m_running; KillServerThread() : m_running(false) {} - int svc(void) { + int svc(void) override { while (m_running == true) { // CacheHelper::initServer( 2, "cacheserver_remoteoql2.xml"); // LOG("THREAD STARTED SERVER 2"); diff --git a/cppcache/integration-test/testThinClientInterest1Cacheless.cpp b/cppcache/integration-test/testThinClientInterest1Cacheless.cpp index 31819a7a63..fee5666270 100644 --- a/cppcache/integration-test/testThinClientInterest1Cacheless.cpp +++ b/cppcache/integration-test/testThinClientInterest1Cacheless.cpp @@ -46,8 +46,8 @@ class MyListener : public CacheListener { } } } - virtual void afterCreate(const EntryEvent &event) { checkEntry(event); } - virtual void afterUpdate(const EntryEvent &event) { checkEntry(event); } + void afterCreate(const EntryEvent &event) override { checkEntry(event); } + void afterUpdate(const EntryEvent &event) override { checkEntry(event); } inline bool gotAll() { for (int i = 0; i < 5; i++) { if (m_gotit[i] == 0) return false; diff --git a/cppcache/integration-test/testThinClientInterestNotify.cpp b/cppcache/integration-test/testThinClientInterestNotify.cpp index 9f8673b3d8..1fc0af2025 100644 --- a/cppcache/integration-test/testThinClientInterestNotify.cpp +++ b/cppcache/integration-test/testThinClientInterestNotify.cpp @@ -76,24 +76,24 @@ class EventListener : public CacheListener { m_destroys(0), m_name(name) {} - ~EventListener() {} + ~EventListener() noexcept override = default; - virtual void afterCreate(const EntryEvent &event) { + void afterCreate(const EntryEvent &event) override { check(event, "afterCreate"); m_creates++; } - virtual void afterUpdate(const EntryEvent &event) { + void afterUpdate(const EntryEvent &event) override { check(event, "afterUpdate"); m_updates++; } - virtual void afterInvalidate(const EntryEvent &event) { + void afterInvalidate(const EntryEvent &event) override { check(event, "afterInvalidate"); m_invalidates++; } - virtual void afterDestroy(const EntryEvent &event) { + void afterDestroy(const EntryEvent &event) override { check(event, "afterDestroy"); m_destroys++; } @@ -147,7 +147,6 @@ const char *keysForRegex[] = {"key-regex-1", "key-regex-2", "key-regex-3"}; #include "ThinClientDurableInit.hpp" #include "ThinClientTasks_C2S2.hpp" -#include "LocatorHelper.hpp" void initClientForInterestNotify(std::shared_ptr &mon1, std::shared_ptr &mon2, diff --git a/cppcache/integration-test/testThinClientListenerCallbackArgTest.cpp b/cppcache/integration-test/testThinClientListenerCallbackArgTest.cpp index 5f294ce6d2..5a0d854aa6 100644 --- a/cppcache/integration-test/testThinClientListenerCallbackArgTest.cpp +++ b/cppcache/integration-test/testThinClientListenerCallbackArgTest.cpp @@ -21,12 +21,9 @@ #include "ThinClientHelper.hpp" #include "TallyListener.hpp" #include "TallyWriter.hpp" -#include "testobject/PdxType.hpp" #include "testobject/VariousPdxTypes.hpp" -#include "SerializationRegistry.hpp" #include "CacheRegionHelper.hpp" -#include "CacheImpl.hpp" #define CLIENT1 s1p1 #define CLIENT2 s1p2 @@ -77,7 +74,7 @@ class CallbackListener : public CacheListener { LOG("CallbackListener contructor called"); } - virtual ~CallbackListener() {} + ~CallbackListener() noexcept override = default; int getCreates() { return m_creates; } @@ -142,30 +139,31 @@ class CallbackListener : public CacheListener { check(event.getCallbackArgument(), updateEvent); } - virtual void afterCreate(const EntryEvent &event) { + void afterCreate(const EntryEvent &event) override { checkcallbackArg(event, m_creates); } - virtual void afterUpdate(const EntryEvent &event) { + void afterUpdate(const EntryEvent &event) override { checkcallbackArg(event, m_updates); } - virtual void afterInvalidate(const EntryEvent &event) { + void afterInvalidate(const EntryEvent &event) override { checkcallbackArg(event, m_invalidates); } - virtual void afterDestroy(const EntryEvent &event) { + void afterDestroy(const EntryEvent &event) override { checkcallbackArg(event, m_destroys); } - virtual void afterRegionInvalidate(const RegionEvent &event) { + void afterRegionInvalidate(const RegionEvent &event) override { checkcallbackArg(event, m_regionInvalidate); } - virtual void afterRegionDestroy(const RegionEvent &event) { + void afterRegionDestroy(const RegionEvent &event) override { checkcallbackArg(event, m_regionDestroy); } - virtual void afterRegionClear(const RegionEvent &event) { + + void afterRegionClear(const RegionEvent &event) override { checkcallbackArg(event, m_regionClear); } }; diff --git a/cppcache/integration-test/testThinClientPRSingleHop.cpp b/cppcache/integration-test/testThinClientPRSingleHop.cpp index db00235084..4d71a66804 100644 --- a/cppcache/integration-test/testThinClientPRSingleHop.cpp +++ b/cppcache/integration-test/testThinClientPRSingleHop.cpp @@ -125,7 +125,7 @@ class putThread : public ACE_Task_Base { int getFailureCount() { return m_failureCount; } - int svc(void) { + int svc(void) override { std::shared_ptr keyPtr; for (int i = m_min; i < m_max; i++) { if (!m_isWarmUpTask) { diff --git a/cppcache/integration-test/testThinClientPoolAttrTest.cpp b/cppcache/integration-test/testThinClientPoolAttrTest.cpp index 1ea7eadd0e..d57f67ce4e 100644 --- a/cppcache/integration-test/testThinClientPoolAttrTest.cpp +++ b/cppcache/integration-test/testThinClientPoolAttrTest.cpp @@ -51,7 +51,7 @@ class putThread : public ACE_Task_Base { public: explicit putThread(const char *name) : regPtr(getHelper()->getRegion(name)) {} - int svc(void) { + int svc(void) override { // TODO: No. of connection should be = minConnection for (int i = 0; i < 10000; i++) { diff --git a/cppcache/integration-test/testThinClientPoolExecuteFunctionThrowsException.cpp b/cppcache/integration-test/testThinClientPoolExecuteFunctionThrowsException.cpp index 50e0727a80..3516783e9f 100644 --- a/cppcache/integration-test/testThinClientPoolExecuteFunctionThrowsException.cpp +++ b/cppcache/integration-test/testThinClientPoolExecuteFunctionThrowsException.cpp @@ -140,7 +140,6 @@ DUNIT_TASK_DEFINITION(CLIENT1, StartC1) // createRegionAndAttachPool(poolRegNames[0],USE_ACK, poolName); auto regPtr0 = createRegionAndAttachPool(poolRegNames[0], USE_ACK); - ; // getHelper()->createRegion( poolRegNames[0], USE_ACK); regPtr0->registerAllKeys(); LOG("Clnt1Init complete."); diff --git a/cppcache/integration-test/testThinClientPoolExecuteHAFunction.cpp b/cppcache/integration-test/testThinClientPoolExecuteHAFunction.cpp index e63bbb6093..76c019acec 100644 --- a/cppcache/integration-test/testThinClientPoolExecuteHAFunction.cpp +++ b/cppcache/integration-test/testThinClientPoolExecuteHAFunction.cpp @@ -151,7 +151,6 @@ DUNIT_TASK_DEFINITION(CLIENT1, StartC1) // createRegionAndAttachPool(poolRegNames[0],USE_ACK, poolName); auto regPtr0 = createRegionAndAttachPool(poolRegNames[0], USE_ACK); - ; // getHelper()->createRegion( poolRegNames[0], USE_ACK); regPtr0->registerAllKeys(); LOG("Clnt1Init complete."); diff --git a/cppcache/integration-test/testThinClientPoolServer.cpp b/cppcache/integration-test/testThinClientPoolServer.cpp index 65c1a2d6ce..f28590b158 100644 --- a/cppcache/integration-test/testThinClientPoolServer.cpp +++ b/cppcache/integration-test/testThinClientPoolServer.cpp @@ -187,7 +187,6 @@ DUNIT_MAIN { CALL_TASK(StartLocator1); CALL_TASK(StartServers); - ; CALL_TASK(StartClient1); CALL_TASK(StartClient2); CALL_TASK(CreateClient1Entries); diff --git a/cppcache/integration-test/testThinClientRemoteQueryFailover.cpp b/cppcache/integration-test/testThinClientRemoteQueryFailover.cpp index cae59fa032..7c899913bb 100644 --- a/cppcache/integration-test/testThinClientRemoteQueryFailover.cpp +++ b/cppcache/integration-test/testThinClientRemoteQueryFailover.cpp @@ -57,7 +57,7 @@ class KillServerThread : public ACE_Task_Base { public: bool m_running; KillServerThread() : m_running(false) {} - int svc(void) { + int svc(void) override { while (m_running == true) { CacheHelper::closeServer(1); LOG("THREAD CLOSED SERVER 1"); diff --git a/cppcache/integration-test/testThinClientRemoteQueryFailoverPdx.cpp b/cppcache/integration-test/testThinClientRemoteQueryFailoverPdx.cpp index eb486ac33e..8d09b94a1b 100644 --- a/cppcache/integration-test/testThinClientRemoteQueryFailoverPdx.cpp +++ b/cppcache/integration-test/testThinClientRemoteQueryFailoverPdx.cpp @@ -54,7 +54,7 @@ class KillServerThread : public ACE_Task_Base { public: bool m_running; KillServerThread() : m_running(false) {} - int svc(void) { + int svc(void) override { while (m_running == true) { CacheHelper::closeServer(1); LOG("THREAD CLOSED SERVER 1"); diff --git a/cppcache/integration-test/testThinClientTicket304.cpp b/cppcache/integration-test/testThinClientTicket304.cpp index 69531166ca..14370f2492 100644 --- a/cppcache/integration-test/testThinClientTicket304.cpp +++ b/cppcache/integration-test/testThinClientTicket304.cpp @@ -138,7 +138,6 @@ DUNIT_TASK_DEFINITION(CLIENT2, RegisterRegexClient2) } END_TASK_DEFINITION DUNIT_TASK_DEFINITION(CLIENT1, CreateRegionOnClient1) - ; { auto rptr = getHelper()->getRegion(regionNamesAuth[0]); rptr->localDestroyRegion(); @@ -147,7 +146,6 @@ DUNIT_TASK_DEFINITION(CLIENT1, CreateRegionOnClient1) } END_TASK_DEFINITION DUNIT_TASK_DEFINITION(CLIENT2, CreateRegionOnClient2) - ; { SLEEP(10000); createRegion(regionNamesAuth[0], false, true); diff --git a/cppcache/integration-test/testTimedSemaphore.cpp b/cppcache/integration-test/testTimedSemaphore.cpp index f559e59c23..0c8f5421e9 100644 --- a/cppcache/integration-test/testTimedSemaphore.cpp +++ b/cppcache/integration-test/testTimedSemaphore.cpp @@ -26,7 +26,7 @@ class ThreadAcquire : public ACE_Task_Base { m_acquireSecs(acquireSecs), m_status(0) {} - int svc() { + int svc() override { ACE_Time_Value start = ACE_OS::gettimeofday(); ACE_Time_Value interval(m_acquireSecs, 0); // 10 seconds ACE_Time_Value expireAt = start + interval; @@ -122,7 +122,6 @@ BEGIN_TEST(CheckResetAndTimedAcquire) sema.release(); sema.release(); while (sema.tryacquire() != -1) { - ; } thread->activate(); diff --git a/cppcache/integration/framework/.clang-tidy b/cppcache/integration/framework/.clang-tidy deleted file mode 100644 index 7346c5983b..0000000000 --- a/cppcache/integration/framework/.clang-tidy +++ /dev/null @@ -1,15 +0,0 @@ ---- -Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references,-google-default-arguments,-clang-analyzer-unix.cstring.NullArg,-clang-analyzer-optin.cplusplus.VirtualCall' -WarningsAsErrors: '*' -HeaderFilterRegex: '.*' -FormatStyle: file -... - -# Disable Checks -# google-runtime-references - We have diverged from this rule due to both legacy and disagreement with the rule. -# google-readability-todo - Adds current user name when fix applied. - -# TODO - Fix these checks -# google-default-arguments -# clang-analyzer-unix.cstring.NullArg - Generates errors in Boost, how do we ignore? -# clang-analyzer-optin.cplusplus.VirtualCall - Boost.Process diff --git a/cppcache/integration/framework/Cluster.cpp b/cppcache/integration/framework/Cluster.cpp index f5105c8843..d53126dc35 100644 --- a/cppcache/integration/framework/Cluster.cpp +++ b/cppcache/integration/framework/Cluster.cpp @@ -17,8 +17,6 @@ #include "Cluster.h" -#include - #include #include @@ -47,14 +45,14 @@ Locator::Locator(Cluster &cluster, std::vector &locators, name_(std::move(name)), locators_(locators), jmxManagerPort_(jmxManagerPort), - distributedSystemId_(distributedSystemId){ + distributedSystemId_(distributedSystemId) { auto hostname = "localhost"; if (useIPv6) { hostname = "ip6-localhost"; } locatorAddress_ = LocatorAddress{hostname, port}; - for (uint16_t remotePort : remotePorts){ + for (uint16_t remotePort : remotePorts) { remoteLocatorsPorts_.push_back(remotePort); } } @@ -76,7 +74,7 @@ Locator::Locator(Locator &&move) remoteLocatorsPorts_(move.remoteLocatorsPorts_), jmxManagerPort_(move.jmxManagerPort_), started_(move.started_), - distributedSystemId_(move.distributedSystemId_){ + distributedSystemId_(move.distributedSystemId_) { move.started_ = false; } @@ -232,21 +230,26 @@ void Server::stop() { } Cluster::Cluster(LocatorCount initialLocators, ServerCount initialServers, - std::vector &locatorPorts, std::vector &remoteLocatorPort, - uint16_t distributedSystemId) : Cluster( - Name(std::string(::testing::UnitTest::GetInstance() - ->current_test_info() - ->test_case_name()) + - "/DS" + std::to_string(distributedSystemId) + "/" + - ::testing::UnitTest::GetInstance()->current_test_info()->name()), Classpath(""), - SecurityManager(""), User(""), Password(""), initialLocators, initialServers, - CacheXMLFiles({}), locatorPorts, remoteLocatorPort, distributedSystemId) {} + std::vector &locatorPorts, + std::vector &remoteLocatorPort, + uint16_t distributedSystemId) + : Cluster( + Name(std::string(::testing::UnitTest::GetInstance() + ->current_test_info() + ->test_suite_name()) + + "/DS" + std::to_string(distributedSystemId) + "/" + + ::testing::UnitTest::GetInstance()->current_test_info()->name()), + Classpath(""), SecurityManager(""), User(""), Password(""), + initialLocators, initialServers, CacheXMLFiles({}), locatorPorts, + remoteLocatorPort, distributedSystemId) {} Cluster::Cluster(Name name, Classpath classpath, SecurityManager securityManager, User user, Password password, LocatorCount initialLocators, ServerCount initialServers, - CacheXMLFiles cacheXMLFiles, std::vector &locatorPorts, - std::vector &remoteLocatorPort, uint16_t distributedSystemId) + CacheXMLFiles cacheXMLFiles, + std::vector &locatorPorts, + std::vector &remoteLocatorPort, + uint16_t distributedSystemId) : name_(name.get()), classpath_(classpath.get()), securityManager_(securityManager.get()), @@ -255,15 +258,14 @@ Cluster::Cluster(Name name, Classpath classpath, initialLocators_(initialLocators.get()), initialServers_(initialServers.get()), jmxManagerPort_(Framework::getAvailablePort()), - distributedSystemId_(distributedSystemId) - { + distributedSystemId_(distributedSystemId) { cacheXMLFiles_ = cacheXMLFiles.get(); useIPv6_ = false; - for(uint16_t port : locatorPorts){ + for (uint16_t port : locatorPorts) { locatorsPorts_.push_back(port); } - for(uint16_t port : remoteLocatorPort){ + for (uint16_t port : remoteLocatorPort) { remoteLocatorsPorts_.push_back(port); } removeServerDirectory(); @@ -274,7 +276,7 @@ Cluster::Cluster(LocatorCount initialLocators, ServerCount initialServers, : Cluster( Name(std::string(::testing::UnitTest::GetInstance() ->current_test_info() - ->test_case_name()) + + ->test_suite_name()) + "/" + ::testing::UnitTest::GetInstance()->current_test_info()->name()), initialLocators, initialServers, useIPv6) {} @@ -286,7 +288,7 @@ Cluster::Cluster(LocatorCount initialLocators, ServerCount initialServers, CacheXMLFiles cacheXMLFiles) : name_(std::string(::testing::UnitTest::GetInstance() ->current_test_info() - ->test_case_name()) + + ->test_suite_name()) + "/" + ::testing::UnitTest::GetInstance()->current_test_info()->name()), initialLocators_(initialLocators.get()), @@ -417,10 +419,10 @@ void Cluster::start(std::function extraGfshCommands) { locators_.reserve(initialLocators_); for (size_t i = 0; i < initialLocators_; i++) { uint16_t port; - if(locatorsPorts_.empty()){ - port=Framework::getAvailablePort(); - }else{ - port=locatorsPorts_.at(i); + if (locatorsPorts_.empty()) { + port = Framework::getAvailablePort(); + } else { + port = locatorsPorts_.at(i); } locators_.push_back({*this, locators_, @@ -432,10 +434,9 @@ void Cluster::start(std::function extraGfshCommands) { servers_.reserve(initialServers_); std::string xmlFile; for (size_t i = 0; i < initialServers_; i++) { - xmlFile = (cacheXMLFiles_.size() == 0) - ? "" - : cacheXMLFiles_.size() == 1 ? cacheXMLFiles_[0] - : cacheXMLFiles_[i]; + xmlFile = (cacheXMLFiles_.size() == 0) ? "" + : cacheXMLFiles_.size() == 1 ? cacheXMLFiles_[0] + : cacheXMLFiles_[i]; servers_.push_back({*this, locators_, name_ + "/server/" + std::to_string(i), xmlFile, @@ -524,13 +525,13 @@ void Cluster::usePropertiesFile(const std::string propertiesFile) { propertiesFile_ = propertiesFile; } -void Cluster::useSecurityPropertiesFile(const std::string securityPropertiesFile) { +void Cluster::useSecurityPropertiesFile( + const std::string securityPropertiesFile) { useSecurityPropertiesFile_ = true; securityPropertiesFile_ = securityPropertiesFile; } -void Cluster::useHostNameForClients( - const std::string hostName) { +void Cluster::useHostNameForClients(const std::string hostName) { usePropertiesFile_ = true; hostName_ = hostName; } diff --git a/cppcache/integration/test/AuthInitializeTest.cpp b/cppcache/integration/test/AuthInitializeTest.cpp index af85312b42..0666613302 100644 --- a/cppcache/integration/test/AuthInitializeTest.cpp +++ b/cppcache/integration/test/AuthInitializeTest.cpp @@ -101,7 +101,7 @@ TEST(AuthInitializeTest, putGetWithBasicAuth) { Cluster cluster( Name(std::string(::testing::UnitTest::GetInstance() ->current_test_info() - ->test_case_name()) + + ->test_suite_name()) + "/" + ::testing::UnitTest::GetInstance()->current_test_info()->name()), Classpath{getFrameworkString(FrameworkVariable::JavaObjectJarPath)}, @@ -133,7 +133,7 @@ TEST(AuthInitializeTest, putWithBadUsername) { Cluster cluster( Name(std::string(::testing::UnitTest::GetInstance() ->current_test_info() - ->test_case_name()) + + ->test_suite_name()) + "/" + ::testing::UnitTest::GetInstance()->current_test_info()->name()), Classpath{getFrameworkString(FrameworkVariable::JavaObjectJarPath)}, @@ -169,7 +169,7 @@ TEST(AuthInitializeTest, putWithBadPassword) { Cluster cluster( Name(std::string(::testing::UnitTest::GetInstance() ->current_test_info() - ->test_case_name()) + + ->test_suite_name()) + "/" + ::testing::UnitTest::GetInstance()->current_test_info()->name()), Classpath{getFrameworkString(FrameworkVariable::JavaObjectJarPath)}, @@ -199,7 +199,7 @@ TEST(AuthInitializeTest, badCredentialsWithSubscriptionEnabled) { Cluster cluster( Name(std::string(::testing::UnitTest::GetInstance() ->current_test_info() - ->test_case_name()) + + ->test_suite_name()) + "/" + ::testing::UnitTest::GetInstance()->current_test_info()->name()), Classpath{getFrameworkString(FrameworkVariable::JavaObjectJarPath)}, diff --git a/cppcache/integration/test/CqPlusAuthInitializeTest.cpp b/cppcache/integration/test/CqPlusAuthInitializeTest.cpp index a1358a38c1..0d23bbc2ae 100644 --- a/cppcache/integration/test/CqPlusAuthInitializeTest.cpp +++ b/cppcache/integration/test/CqPlusAuthInitializeTest.cpp @@ -98,7 +98,7 @@ TEST(CqPlusAuthInitializeTest, putInALoopWhileSubscribedAndAuthenticated) { Cluster cluster( Name(std::string(::testing::UnitTest::GetInstance() ->current_test_info() - ->test_case_name()) + + ->test_suite_name()) + "/" + ::testing::UnitTest::GetInstance()->current_test_info()->name()), Classpath{getFrameworkString(FrameworkVariable::JavaObjectJarPath)}, diff --git a/cppcache/integration/test/PartitionRegionOpsTest.cpp b/cppcache/integration/test/PartitionRegionOpsTest.cpp index 8c9e6cdfc2..4801604d9a 100644 --- a/cppcache/integration/test/PartitionRegionOpsTest.cpp +++ b/cppcache/integration/test/PartitionRegionOpsTest.cpp @@ -50,7 +50,7 @@ using std::chrono::minutes; std::string getClientLogName() { std::string testSuiteName(::testing::UnitTest::GetInstance() ->current_test_info() - ->test_case_name()); + ->test_suite_name()); std::string testCaseName( ::testing::UnitTest::GetInstance()->current_test_info()->name()); std::string logFileName(testSuiteName + "/" + testCaseName + "/client.log"); @@ -61,7 +61,7 @@ Cache createCache() { using apache::geode::client::CacheFactory; auto cache = CacheFactory() - .set("log-level", "none") + .set("log-level", "debug") // needed for log checking .set("log-file", getClientLogName()) .set("statistic-sampling-enabled", "false") .create(); diff --git a/cppcache/integration/test/TransactionsTest.cpp b/cppcache/integration/test/TransactionsTest.cpp index eacaa040e0..da37c2f8d8 100644 --- a/cppcache/integration/test/TransactionsTest.cpp +++ b/cppcache/integration/test/TransactionsTest.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -52,10 +53,15 @@ std::shared_ptr createPool(Cluster& cluster, void runClientOperations(std::shared_ptr cache, std::shared_ptr region, int minEntryKey, int maxEntryKey, int numTx) { + std::random_device randomDevice; + std::default_random_engine randomEngine(randomDevice()); + std::uniform_int_distribution distribution( + minEntryKey, maxEntryKey); + auto transactionManager = cache->getCacheTransactionManager(); for (int i = 0; i < numTx; i++) { - auto theKey = (rand() % (maxEntryKey - minEntryKey)) + minEntryKey; + auto theKey = distribution(randomEngine); std::string theValue = "theValue"; try { transactionManager->begin(); diff --git a/cppcache/src/AdminRegion.cpp b/cppcache/src/AdminRegion.cpp index 7c774f416a..4f217a5127 100644 --- a/cppcache/src/AdminRegion.cpp +++ b/cppcache/src/AdminRegion.cpp @@ -23,7 +23,6 @@ #include "TcrConnectionManager.hpp" #include "ThinClientPoolDM.hpp" #include "ThinClientRegion.hpp" -#include "statistics/StatisticsManager.hpp" #include "util/exception.hpp" namespace apache { @@ -51,14 +50,8 @@ std::shared_ptr AdminRegion::create(CacheImpl* cache, } void AdminRegion::init() { - /*TryWriteGuard _guard(m_rwLock, m_destroyPending); - if (m_destroyPending) { - return; - } - */ // Init distribution manager if it is not a pool - ThinClientPoolDM* pool = dynamic_cast(m_distMngr); - if (pool == nullptr) { + if (m_distMngr && !dynamic_cast(m_distMngr)) { m_distMngr->init(); } } diff --git a/cppcache/src/AuthenticatedView.cpp b/cppcache/src/AuthenticatedView.cpp index 35e6a55c15..888e68c712 100644 --- a/cppcache/src/AuthenticatedView.cpp +++ b/cppcache/src/AuthenticatedView.cpp @@ -22,13 +22,11 @@ #include #include #include -#include #include "CacheImpl.hpp" #include "CacheRegionHelper.hpp" #include "CacheXmlParser.hpp" #include "DistributedSystemImpl.hpp" -#include "FunctionServiceImpl.hpp" #include "ProxyRegion.hpp" #include "ProxyRemoteQueryService.hpp" #include "ThinClientPoolDM.hpp" diff --git a/cppcache/src/CacheXmlParser.hpp b/cppcache/src/CacheXmlParser.hpp index 439a00d283..c57289dc16 100644 --- a/cppcache/src/CacheXmlParser.hpp +++ b/cppcache/src/CacheXmlParser.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_CACHEXMLPARSER_H_ -#define GEODE_CACHEXMLPARSER_H_ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,6 +15,11 @@ * limitations under the License. */ +#pragma once + +#ifndef GEODE_CACHEXMLPARSER_H_ +#define GEODE_CACHEXMLPARSER_H_ + #include #include #include @@ -53,10 +53,11 @@ using FactoryLoaderFn = std::function; class CacheXmlParser : public xercesc::DefaultHandler { void startElement(const XMLCh* const uri, const XMLCh* const localname, - const XMLCh* const qname, const xercesc::Attributes& attrs); + const XMLCh* const qname, + const xercesc::Attributes& attrs) override; void endElement(const XMLCh* const uri, const XMLCh* const localname, - const XMLCh* const qname); - void fatalError(const xercesc::SAXParseException&); + const XMLCh* const qname) override; + void fatalError(const xercesc::SAXParseException&) override; std::map> @@ -80,7 +81,7 @@ class CacheXmlParser : public xercesc::DefaultHandler { public: explicit CacheXmlParser(Cache* cache); - ~CacheXmlParser(); + ~CacheXmlParser() override; static CacheXmlParser* parse(const char* cachexml, Cache* cache); void parseFile(const char* filename); void parseMemory(const char* buffer, int size); @@ -170,6 +171,7 @@ class CacheXmlParser : public xercesc::DefaultHandler { } } }; + } // namespace client } // namespace geode } // namespace apache diff --git a/cppcache/src/ConcurrentEntriesMap.cpp b/cppcache/src/ConcurrentEntriesMap.cpp index b1983f4142..cea4e8b0a8 100644 --- a/cppcache/src/ConcurrentEntriesMap.cpp +++ b/cppcache/src/ConcurrentEntriesMap.cpp @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "ConcurrentEntriesMap.hpp" #include @@ -69,7 +70,7 @@ void ConcurrentEntriesMap::clear() { m_size = 0; } -ConcurrentEntriesMap::~ConcurrentEntriesMap() { delete[] m_segments; } +ConcurrentEntriesMap::~ConcurrentEntriesMap() noexcept { delete[] m_segments; } GfErrType ConcurrentEntriesMap::create( const std::shared_ptr& key, diff --git a/cppcache/src/ConcurrentEntriesMap.hpp b/cppcache/src/ConcurrentEntriesMap.hpp index 353d92efa2..bcd0cd56ac 100644 --- a/cppcache/src/ConcurrentEntriesMap.hpp +++ b/cppcache/src/ConcurrentEntriesMap.hpp @@ -19,6 +19,7 @@ #ifndef GEODE_CONCURRENTENTRIESMAP_H_ #define GEODE_CONCURRENTENTRIESMAP_H_ + #include #include @@ -31,12 +32,13 @@ namespace apache { namespace geode { namespace client { + class RegionInternal; /** * @brief Concurrent entries map. */ -class APACHE_GEODE_EXPORT ConcurrentEntriesMap : public EntriesMap { +class ConcurrentEntriesMap : public EntriesMap { protected: ExpiryTaskManager* m_expiryTaskManager; uint8_t m_concurrency; @@ -45,14 +47,13 @@ class APACHE_GEODE_EXPORT ConcurrentEntriesMap : public EntriesMap { RegionInternal* m_region; std::atomic m_numDestroyTrackers; bool m_concurrencyChecksEnabled; - // TODO: hashcode() is invoked 3-4 times -- need a better - // implementation (STLport hash_map?) that will invoke it only once + /** * Return a reference to the segment for which the given key would * be stored. */ - virtual MapSegment* segmentFor( - const std::shared_ptr& key) const { + MapSegment* segmentFor( + const std::shared_ptr& key) const override { return &(m_segments[segmentIdx(key)]); } @@ -80,101 +81,100 @@ class APACHE_GEODE_EXPORT ConcurrentEntriesMap : public EntriesMap { /** * Initialize segments with proper EntryFactory. */ - virtual void open(uint32_t initialCapacity); - - virtual void close(); - - virtual ~ConcurrentEntriesMap(); - - virtual void clear(); - - virtual GfErrType put(const std::shared_ptr& key, - const std::shared_ptr& newValue, - std::shared_ptr& me, - std::shared_ptr& oldValue, int updateCount, - int destroyTracker, - std::shared_ptr versionTag, - bool& isUpdate = EntriesMap::boolVal, - DataInput* delta = nullptr); - virtual GfErrType invalidate(const std::shared_ptr& key, - std::shared_ptr& me, - std::shared_ptr& oldValue, - std::shared_ptr versionTag); - virtual GfErrType create(const std::shared_ptr& key, - const std::shared_ptr& newValue, - std::shared_ptr& me, - std::shared_ptr& oldValue, - int updateCount, int destroyTracker, - std::shared_ptr versionTag); - virtual bool get(const std::shared_ptr& key, - std::shared_ptr& value, - std::shared_ptr& me); + void open(uint32_t initialCapacity) override; + + void close() override; + + ~ConcurrentEntriesMap() noexcept override; + + void clear() override; + + GfErrType put(const std::shared_ptr& key, + const std::shared_ptr& newValue, + std::shared_ptr& me, + std::shared_ptr& oldValue, int updateCount, + int destroyTracker, std::shared_ptr versionTag, + bool& isUpdate = EntriesMap::boolVal, + DataInput* delta = nullptr) override; + GfErrType invalidate(const std::shared_ptr& key, + std::shared_ptr& me, + std::shared_ptr& oldValue, + std::shared_ptr versionTag) override; + GfErrType create(const std::shared_ptr& key, + const std::shared_ptr& newValue, + std::shared_ptr& me, + std::shared_ptr& oldValue, int updateCount, + int destroyTracker, + std::shared_ptr versionTag) override; + bool get(const std::shared_ptr& key, + std::shared_ptr& value, + std::shared_ptr& me) override; /** * @brief get MapEntry for key. * TODO: return GfErrType like other methods */ - virtual void getEntry(const std::shared_ptr& key, - std::shared_ptr& result, - std::shared_ptr& value) const; + void getEntry(const std::shared_ptr& key, + std::shared_ptr& result, + std::shared_ptr& value) const override; /** * @brief remove the entry for key from the map. */ - virtual GfErrType remove(const std::shared_ptr& key, - std::shared_ptr& result, - std::shared_ptr& me, int updateCount, - std::shared_ptr versionTag, - bool afterRemote); + GfErrType remove(const std::shared_ptr& key, + std::shared_ptr& result, + std::shared_ptr& me, int updateCount, + std::shared_ptr versionTag, + bool afterRemote) override; /** * @brief return true if there exists an entry for the key. */ - virtual bool containsKey(const std::shared_ptr& key) const; + bool containsKey(const std::shared_ptr& key) const override; /** * @brief return the all the keys in a list. */ - virtual void getKeys( - std::vector>& result) const; + void getKeys( + std::vector>& result) const override; /** * @brief return all the entries in a list. */ - virtual void getEntries( - std::vector>& result) const; + void getEntries( + std::vector>& result) const override; /** * @brief return all values in a list. */ - virtual void getValues(std::vector>& result) const; + void getValues( + std::vector>& result) const override; /** * @brief return the number of entries in the map. */ - virtual uint32_t size() const; + uint32_t size() const override; - virtual int addTrackerForEntry(const std::shared_ptr& key, - std::shared_ptr& oldValue, - bool addIfAbsent, bool failIfPresent, - bool incUpdateCount); + int addTrackerForEntry(const std::shared_ptr& key, + std::shared_ptr& oldValue, bool addIfAbsent, + bool failIfPresent, bool incUpdateCount) override; - virtual void removeTrackerForEntry(const std::shared_ptr& key); + void removeTrackerForEntry(const std::shared_ptr& key) override; - virtual int addTrackerForAllEntries(MapOfUpdateCounters& updateCounterMap, - bool addDestroyTracking); + int addTrackerForAllEntries(MapOfUpdateCounters& updateCounterMap, + bool addDestroyTracking) override; - virtual void removeDestroyTracking(); - virtual void reapTombstones(std::map& gcVersions); + void removeDestroyTracking() override; + void reapTombstones(std::map& gcVersions) override; - virtual void reapTombstones(std::shared_ptr removedKeys); + void reapTombstones(std::shared_ptr removedKeys) override; /** * for internal testing, returns if an entry is a tombstone */ - virtual GfErrType isTombstone(std::shared_ptr& key, - std::shared_ptr& me, - bool& result); + GfErrType isTombstone(std::shared_ptr& key, + std::shared_ptr& me, + bool& result) override; /** * for internal testing, return the number of times any segment @@ -182,6 +182,7 @@ class APACHE_GEODE_EXPORT ConcurrentEntriesMap : public EntriesMap { */ uint32_t totalSegmentRehashes() const; }; // class EntriesMap + } // namespace client } // namespace geode } // namespace apache diff --git a/cppcache/src/ConnectionQueue.hpp b/cppcache/src/ConnectionQueue.hpp index 66a6efa8d1..1467a0ece5 100644 --- a/cppcache/src/ConnectionQueue.hpp +++ b/cppcache/src/ConnectionQueue.hpp @@ -68,7 +68,7 @@ class ConnectionQueue { } condition_.notify_one(); } - if (delMp) { + if (delMp && mp) { mp->close(); delete mp; } diff --git a/cppcache/src/CqEventImpl.hpp b/cppcache/src/CqEventImpl.hpp index 2303ebd358..571f4f8c8d 100644 --- a/cppcache/src/CqEventImpl.hpp +++ b/cppcache/src/CqEventImpl.hpp @@ -45,46 +45,47 @@ class ThinClientBaseDM; class EventId; class CqEventImpl : public CqEvent { public: + CqEventImpl() = delete; CqEventImpl(std::shared_ptr& cQuery, CqOperation baseOp, CqOperation cqOp, std::shared_ptr& key, std::shared_ptr& value, ThinClientBaseDM* tcrdm, std::shared_ptr deltaBytes, std::shared_ptr eventId); + ~CqEventImpl() override = default; - std::shared_ptr getCq() const; + std::shared_ptr getCq() const override; /** * Get the operation on the base region that triggered this event. */ - CqOperation getBaseOperation() const; + CqOperation getBaseOperation() const override; /** * Get the the operation on the query results. Supported operations include * update, create, and destroy. */ - CqOperation getQueryOperation() const; + CqOperation getQueryOperation() const override; /** * Get the key relating to the event. * @return Object key. */ - std::shared_ptr getKey() const; + std::shared_ptr getKey() const override; /** * Get the new value of the modification. * If there is no new value because this is a delete, then * return null. */ - std::shared_ptr getNewValue() const; + std::shared_ptr getNewValue() const override; bool getError(); std::string toString(); - std::shared_ptr getDeltaValue() const; + std::shared_ptr getDeltaValue() const override; private: - CqEventImpl(); std::shared_ptr m_cQuery; CqOperation m_baseOp; CqOperation m_queryOp; diff --git a/cppcache/src/CqQueryImpl.cpp b/cppcache/src/CqQueryImpl.cpp index eec3da418f..2a5ddc094e 100644 --- a/cppcache/src/CqQueryImpl.cpp +++ b/cppcache/src/CqQueryImpl.cpp @@ -123,14 +123,7 @@ void CqQueryImpl::close(bool sendRequestToServer) { // Stat update. auto& stats = m_cqService->getCqServiceVsdStats(); - /* - if (isRunning()) { - stats.decNumCqsActive(); - } - else if (isStopped()) { - stats.decNumCqsStopped(); - } - */ + setCqState(CqState::CLOSING); if (sendRequestToServer == true) { try { diff --git a/cppcache/src/CqQueryVsdStats.cpp b/cppcache/src/CqQueryVsdStats.cpp index 54840abbbc..b7bdfe629e 100644 --- a/cppcache/src/CqQueryVsdStats.cpp +++ b/cppcache/src/CqQueryVsdStats.cpp @@ -62,7 +62,7 @@ CqQueryVsdStats::CqQueryVsdStats(StatisticsFactory* factory, m_cqQueryVsdStats->setInt(m_numEventsId, 0); } -CqQueryVsdStats::~CqQueryVsdStats() { +CqQueryVsdStats::~CqQueryVsdStats() noexcept { if (m_cqQueryVsdStats != nullptr) { // Don't Delete, Already closed, Just set nullptr // delete m_CqQueryVsdStats; diff --git a/cppcache/src/CqQueryVsdStats.hpp b/cppcache/src/CqQueryVsdStats.hpp index 715862d42a..3dda95e5b2 100644 --- a/cppcache/src/CqQueryVsdStats.hpp +++ b/cppcache/src/CqQueryVsdStats.hpp @@ -36,14 +36,14 @@ using statistics::StatisticDescriptor; using statistics::Statistics; using statistics::StatisticsType; -class APACHE_GEODE_EXPORT CqQueryVsdStats : public CqStatistics { +class CqQueryVsdStats : public CqStatistics { public: /** hold statistics for a cq. */ CqQueryVsdStats(statistics::StatisticsFactory* factory, const std::string& cqqueryName); /** disable stat collection for this item. */ - virtual ~CqQueryVsdStats(); + virtual ~CqQueryVsdStats() noexcept; void close() { m_cqQueryVsdStats->close(); } @@ -55,16 +55,16 @@ class APACHE_GEODE_EXPORT CqQueryVsdStats : public CqStatistics { inline void incNumEvents() { m_cqQueryVsdStats->incInt(m_numEventsId, 1); } - inline uint32_t numInserts() const { + uint32_t numInserts() const override { return m_cqQueryVsdStats->getInt(m_numInsertsId); } - inline uint32_t numUpdates() const { + uint32_t numUpdates() const override { return m_cqQueryVsdStats->getInt(m_numUpdatesId); } - inline uint32_t numDeletes() const { + uint32_t numDeletes() const override { return m_cqQueryVsdStats->getInt(m_numDeletesId); } - inline uint32_t numEvents() const { + uint32_t numEvents() const override { return m_cqQueryVsdStats->getInt(m_numEventsId); } diff --git a/cppcache/src/CqService.cpp b/cppcache/src/CqService.cpp index 57403e9fcf..d85c2ee5c2 100644 --- a/cppcache/src/CqService.cpp +++ b/cppcache/src/CqService.cpp @@ -26,8 +26,6 @@ #include "CqEventImpl.hpp" #include "CqQueryImpl.hpp" -#include "DistributedSystem.hpp" -#include "ReadWriteLock.hpp" #include "TcrConnectionManager.hpp" #include "ThinClientPoolDM.hpp" #include "util/exception.hpp" @@ -42,6 +40,8 @@ CqService::CqService(ThinClientBaseDM* tccdm, m_statisticsFactory(statisticsFactory), m_notificationSema(1), m_stats(std::make_shared(m_statisticsFactory)) { + assert(nullptr != m_tccdm); + m_running = true; LOGDEBUG("CqService Started"); } @@ -99,7 +99,7 @@ std::shared_ptr CqService::newCq( // Check if the subscription is enabled on the pool auto pool = dynamic_cast(m_tccdm); - if (pool != nullptr && !pool->getSubscriptionEnabled()) { + if (pool && !pool->getSubscriptionEnabled()) { LOGERROR( "Cannot create CQ because subscription is not enabled on the pool."); throw IllegalStateException( @@ -107,7 +107,7 @@ std::shared_ptr CqService::newCq( } // check for durable client - if (isDurable) { + if (isDurable && m_tccdm) { auto&& durableID = m_tccdm->getConnectionManager() .getCacheImpl() ->getDistributedSystem() diff --git a/cppcache/src/CqServiceVsdStats.cpp b/cppcache/src/CqServiceVsdStats.cpp index 397434b4bf..6a623a2588 100644 --- a/cppcache/src/CqServiceVsdStats.cpp +++ b/cppcache/src/CqServiceVsdStats.cpp @@ -68,7 +68,7 @@ CqServiceVsdStats::CqServiceVsdStats(StatisticsFactory* factory, m_cqServiceVsdStats->setInt(m_numCqsStoppedId, 0); } -CqServiceVsdStats::~CqServiceVsdStats() { +CqServiceVsdStats::~CqServiceVsdStats() noexcept { if (m_cqServiceVsdStats != nullptr) { // Don't Delete, Already closed, Just set nullptr // delete m_CqServiceVsdStats; diff --git a/cppcache/src/CqServiceVsdStats.hpp b/cppcache/src/CqServiceVsdStats.hpp index 5272ff10c2..3b324c406b 100644 --- a/cppcache/src/CqServiceVsdStats.hpp +++ b/cppcache/src/CqServiceVsdStats.hpp @@ -36,52 +36,47 @@ using statistics::StatisticDescriptor; using statistics::Statistics; using statistics::StatisticsType; -class APACHE_GEODE_EXPORT CqServiceVsdStats : public CqServiceStatistics { +class CqServiceVsdStats : public CqServiceStatistics { public: /** hold statistics for a cq. */ explicit CqServiceVsdStats(statistics::StatisticsFactory* factory, const std::string& cqName = "CqServiceVsdStats"); /** disable stat collection for this item. */ - virtual ~CqServiceVsdStats(); + ~CqServiceVsdStats() noexcept override; void close() { m_cqServiceVsdStats->close(); } - inline void decNumCqsActive() { - m_cqServiceVsdStats->incInt(m_numCqsActiveId, -1); - } inline void incNumCqsActive() const { m_cqServiceVsdStats->incInt(m_numCqsActiveId, 1); } - inline uint32_t numCqsActive() const { + inline uint32_t numCqsActive() const override { return m_cqServiceVsdStats->getInt(m_numCqsActiveId); } inline void incNumCqsCreated() { m_cqServiceVsdStats->incInt(m_numCqsCreatedId, 1); } - inline uint32_t numCqsCreated() const { + inline uint32_t numCqsCreated() const override { return m_cqServiceVsdStats->getInt(m_numCqsCreatedId); } - inline uint32_t numCqsOnClient() const { + inline uint32_t numCqsOnClient() const override { return m_cqServiceVsdStats->getInt(m_numCqsOnClientId); } inline void incNumCqsClosed() { m_cqServiceVsdStats->incInt(m_numCqsClosedId, 1); } - inline uint32_t numCqsClosed() const { + inline uint32_t numCqsClosed() const override { return m_cqServiceVsdStats->getInt(m_numCqsClosedId); } inline void incNumCqsStopped() { m_cqServiceVsdStats->incInt(m_numCqsStoppedId, 1); } - inline void decNumCqsStopped() { - m_cqServiceVsdStats->incInt(m_numCqsStoppedId, -1); - } - inline uint32_t numCqsStopped() const { + + inline uint32_t numCqsStopped() const override { return m_cqServiceVsdStats->getInt(m_numCqsStoppedId); } @@ -93,10 +88,6 @@ class APACHE_GEODE_EXPORT CqServiceVsdStats : public CqServiceStatistics { m_cqServiceVsdStats->setInt(m_numCqsOnClientId, value); } - inline void setNumCqsClosed(uint32_t value) { - m_cqServiceVsdStats->setInt(m_numCqsClosedId, value); - } - inline void setNumCqsStopped(uint32_t value) { m_cqServiceVsdStats->setInt(m_numCqsStoppedId, value); } diff --git a/cppcache/src/EntryExpiryHandler.hpp b/cppcache/src/EntryExpiryHandler.hpp index 5af8a866d0..2cb9c19e28 100644 --- a/cppcache/src/EntryExpiryHandler.hpp +++ b/cppcache/src/EntryExpiryHandler.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_ENTRYEXPIRYHANDLER_H_ -#define GEODE_ENTRYEXPIRYHANDLER_H_ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,6 +15,11 @@ * limitations under the License. */ +#pragma once + +#ifndef GEODE_ENTRYEXPIRYHANDLER_H_ +#define GEODE_ENTRYEXPIRYHANDLER_H_ + #include #include #include @@ -28,13 +28,10 @@ #include "ExpMapEntry.hpp" #include "RegionInternal.hpp" -/** - * @file - */ - namespace apache { namespace geode { namespace client { + /** * @class EntryExpiryTask EntryExpiryTask.hpp * @@ -44,11 +41,8 @@ namespace client { * TODO: TODO: cleanup region entry nodes and handlers from expiry task * manager when region is destroyed */ -class APACHE_GEODE_EXPORT EntryExpiryHandler : public ACE_Event_Handler { +class EntryExpiryHandler : public ACE_Event_Handler { public: - /** - * Constructor - */ EntryExpiryHandler(std::shared_ptr& rptr, std::shared_ptr& entryPtr, ExpirationAction action, std::chrono::seconds duration); @@ -56,11 +50,12 @@ class APACHE_GEODE_EXPORT EntryExpiryHandler : public ACE_Event_Handler { /** This task object will be registered with the Timer Queue. * When the timer expires the handle_timeout is invoked. */ - int handle_timeout(const ACE_Time_Value& current_time, const void* arg); + int handle_timeout(const ACE_Time_Value& current_time, + const void* arg) override; /** * This is called when the task object needs to be cleaned up.. */ - int handle_close(ACE_HANDLE handle, ACE_Reactor_Mask close_mask); + int handle_close(ACE_HANDLE handle, ACE_Reactor_Mask close_mask) override; private: // The region which contains the entry @@ -75,6 +70,7 @@ class APACHE_GEODE_EXPORT EntryExpiryHandler : public ACE_Event_Handler { // perform the actual expiration action void DoTheExpirationAction(const std::shared_ptr& key); }; + } // namespace client } // namespace geode } // namespace apache diff --git a/cppcache/src/ExpMapEntry.hpp b/cppcache/src/ExpMapEntry.hpp index f58a33ffb9..d532089d42 100644 --- a/cppcache/src/ExpMapEntry.hpp +++ b/cppcache/src/ExpMapEntry.hpp @@ -32,14 +32,16 @@ namespace client { * @brief Hold region mapped entry value. * This subclass adds expiration times. */ -class APACHE_GEODE_EXPORT ExpMapEntry : public MapEntryImpl, - public ExpEntryProperties { +class ExpMapEntry : public MapEntryImpl, public ExpEntryProperties { public: - virtual ~ExpMapEntry() {} + ~ExpMapEntry() noexcept override = default; - virtual ExpEntryProperties& getExpProperties() { return *this; } + ExpMapEntry(const ExpMapEntry&) = delete; + ExpMapEntry& operator=(const ExpMapEntry&) = delete; - virtual void cleanup(const CacheEventFlags eventFlags) { + ExpEntryProperties& getExpProperties() override { return *this; } + + virtual void cleanup(const CacheEventFlags eventFlags) override { if (!eventFlags.isExpiration()) { cancelExpiryTaskId(m_key); } @@ -52,15 +54,9 @@ class APACHE_GEODE_EXPORT ExpMapEntry : public MapEntryImpl, inline ExpMapEntry(ExpiryTaskManager* expiryTaskManager, const std::shared_ptr& key) : MapEntryImpl(key), ExpEntryProperties(expiryTaskManager) {} - - private: - // disabled - ExpMapEntry(const ExpMapEntry&); - ExpMapEntry& operator=(const ExpMapEntry&); }; -class APACHE_GEODE_EXPORT VersionedExpMapEntry : public ExpMapEntry, - public VersionStamp { +class VersionedExpMapEntry : public ExpMapEntry, public VersionStamp { public: inline VersionedExpMapEntry(ExpiryTaskManager* expiryTaskManager, const std::shared_ptr& key) @@ -68,25 +64,23 @@ class APACHE_GEODE_EXPORT VersionedExpMapEntry : public ExpMapEntry, inline explicit VersionedExpMapEntry(bool) : ExpMapEntry(true) {} - virtual ~VersionedExpMapEntry() {} + ~VersionedExpMapEntry() noexcept override {} - virtual VersionStamp& getVersionStamp() { return *this; } + VersionedExpMapEntry(const VersionedExpMapEntry&) = delete; + VersionedExpMapEntry& operator=(const VersionedExpMapEntry&) = delete; - private: - // disabled - VersionedExpMapEntry(const VersionedExpMapEntry&); - VersionedExpMapEntry& operator=(const VersionedExpMapEntry&); + VersionStamp& getVersionStamp() override { return *this; } }; -class APACHE_GEODE_EXPORT ExpEntryFactory : public EntryFactory { +class ExpEntryFactory : public EntryFactory { public: using EntryFactory::EntryFactory; - virtual ~ExpEntryFactory() {} + ~ExpEntryFactory() noexcept override {} - virtual void newMapEntry(ExpiryTaskManager* expiryTaskManager, - const std::shared_ptr& key, - std::shared_ptr& result) const; + void newMapEntry(ExpiryTaskManager* expiryTaskManager, + const std::shared_ptr& key, + std::shared_ptr& result) const override; }; } // namespace client } // namespace geode diff --git a/cppcache/src/ExpiryTaskManager.cpp b/cppcache/src/ExpiryTaskManager.cpp index 1e1cb5960c..bced26e201 100644 --- a/cppcache/src/ExpiryTaskManager.cpp +++ b/cppcache/src/ExpiryTaskManager.cpp @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "ExpiryTaskManager.hpp" #include "DistributedSystem.hpp" @@ -37,13 +38,16 @@ namespace client { const char* ExpiryTaskManager::NC_ETM_Thread = "NC ETM Thread"; ExpiryTaskManager::ExpiryTaskManager() : m_reactorEventLoopRunning(false) { + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall): ACE auto timer = new GF_Timer_Heap_ImmediateReset(); m_timer = std::unique_ptr(timer); #if defined(_WIN32) m_reactor = new ACE_Reactor(new ACE_WFMO_Reactor(nullptr, m_timer.get()), 1); #elif defined(WITH_ACE_Select_Reactor) - m_reactor = - new ACE_Reactor(new ACE_Select_Reactor(nullptr, m_timer.get()), 1); + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall): ACE + auto aceSelectReactor = new ACE_Select_Reactor(nullptr, m_timer.get()); + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall): ACE + m_reactor = new ACE_Reactor(aceSelectReactor, 1); #else m_reactor = new ACE_Reactor(new ACE_Dev_Poll_Reactor(nullptr, m_timer.get()) 1); @@ -95,6 +99,8 @@ ExpiryTaskManager::~ExpiryTaskManager() { delete m_reactor; m_reactor = nullptr; + + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall): ACE } } // namespace client diff --git a/cppcache/src/ExpiryTaskManager.hpp b/cppcache/src/ExpiryTaskManager.hpp index ca99032bc6..bbce064afa 100644 --- a/cppcache/src/ExpiryTaskManager.hpp +++ b/cppcache/src/ExpiryTaskManager.hpp @@ -46,7 +46,7 @@ namespace client { * This class starts a reactor's event loop for taking care of expiry * tasks. The scheduling of event also happens through this manager. */ -class APACHE_GEODE_EXPORT ExpiryTaskManager : public ACE_Task_Base { +class ExpiryTaskManager : public ACE_Task_Base { public: typedef decltype(std::declval().schedule_timer( nullptr, nullptr, std::declval())) id_type; @@ -85,7 +85,7 @@ class APACHE_GEODE_EXPORT ExpiryTaskManager : public ACE_Task_Base { class GF_Timer_Heap_ImmediateReset_T : public ACE_Timer_Heap_T { public: - virtual int expire_single(ACE_Command_Base& pre_dispatch_command) { + int expire_single(ACE_Command_Base& pre_dispatch_command) override { ACE_TRACE("GF_Timer_Heap_ImmediateReset_T::expire_single"); ACE_Timer_Node_Dispatch_Info_T info; ACE_Time_Value cur_time; @@ -93,7 +93,7 @@ class APACHE_GEODE_EXPORT ExpiryTaskManager : public ACE_Task_Base { // Create a scope for the lock ... { - ACE_MT(ACE_GUARD_RETURN(ACE_LOCK, ace_mon, this->mutex_, -1)); + ACE_MT(ACE_GUARD_RETURN(ACE_LOCK, ace_mon, this->mutex_, -1)) if (this->is_empty()) return 0; @@ -121,7 +121,7 @@ class APACHE_GEODE_EXPORT ExpiryTaskManager : public ACE_Task_Base { // Create a scope for the lock ... { - ACE_MT(ACE_GUARD_RETURN(ACE_LOCK, ace_mon, this->mutex_, -1)); + ACE_MT(ACE_GUARD_RETURN(ACE_LOCK, ace_mon, this->mutex_, -1)) // Reschedule after doing the upcall in expire method // to let updated expiry interval, if any, take effect correctly @@ -147,13 +147,13 @@ class APACHE_GEODE_EXPORT ExpiryTaskManager : public ACE_Task_Base { return 1; } - virtual int expire() { + int expire() override { return ACE_Timer_Queue_T::expire(); } - virtual int expire(const ACE_Time_Value& cur_time) { + int expire(const ACE_Time_Value& cur_time) override { ACE_TRACE("GF_Timer_Heap_ImmediateReset_T::expire"); - ACE_MT(ACE_GUARD_RETURN(ACE_LOCK, ace_mon, this->mutex_, -1)); + ACE_MT(ACE_GUARD_RETURN(ACE_LOCK, ace_mon, this->mutex_, -1)) // Keep looping while there are timers remaining and the earliest // timer is <= the passed in to the method. @@ -230,7 +230,7 @@ class APACHE_GEODE_EXPORT ExpiryTaskManager : public ACE_Task_Base { * Destructor. Stops the reactors event loop if it is not running * and then exits. */ - ~ExpiryTaskManager(); + ~ExpiryTaskManager() override; /** * For scheduling a task for expiration. @@ -285,7 +285,7 @@ class APACHE_GEODE_EXPORT ExpiryTaskManager : public ACE_Task_Base { * is kept running unless explicitly stopped or when this object * goes out of scope. */ - int svc(); + int svc() override; /** * For explicitly stopping the reactor's event loop. diff --git a/cppcache/src/FunctionServiceImpl.cpp b/cppcache/src/FunctionServiceImpl.cpp deleted file mode 100644 index 1f91209412..0000000000 --- a/cppcache/src/FunctionServiceImpl.cpp +++ /dev/null @@ -1,39 +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 "FunctionServiceImpl.hpp" - -#include - -#include "ExecutionImpl.hpp" - -namespace apache { -namespace geode { -namespace client { - -FunctionServiceImpl::FunctionServiceImpl(AuthenticatedView* authenticatedView) { - m_authenticatedView = authenticatedView; -} - -std::shared_ptr FunctionServiceImpl::getFunctionService( - AuthenticatedView* authenticatedView) { - return std::make_shared(authenticatedView); -} - -} // namespace client -} // namespace geode -} // namespace apache diff --git a/cppcache/src/FunctionServiceImpl.hpp b/cppcache/src/FunctionServiceImpl.hpp deleted file mode 100644 index 8c6e51aa71..0000000000 --- a/cppcache/src/FunctionServiceImpl.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once - -#ifndef GEODE_FUNCTIONSERVICEIMPL_H_ -#define GEODE_FUNCTIONSERVICEIMPL_H_ - -/* - * 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 -#include -#include -/** - * @file - */ - -namespace apache { -namespace geode { -namespace client { -/** - * @class FunctionService FunctionService.hpp - * entry point for function execution - * @see Execution - */ - -class APACHE_GEODE_EXPORT FunctionServiceImpl : public FunctionService { - public: - explicit FunctionServiceImpl(AuthenticatedView* authenticatedView); - - virtual ~FunctionServiceImpl() {} - - private: - explicit FunctionServiceImpl(const FunctionService&); - FunctionServiceImpl& operator=(const FunctionService&); - - static std::shared_ptr getFunctionService( - AuthenticatedView* authenticatedView); - - AuthenticatedView* m_authenticatedView; - - friend class AuthenticatedView; -}; -} // namespace client -} // namespace geode -} // namespace apache - -#endif // GEODE_FUNCTIONSERVICEIMPL_H_ diff --git a/cppcache/src/LRUAction.hpp b/cppcache/src/LRUAction.hpp index 24142c4216..58434b2c83 100644 --- a/cppcache/src/LRUAction.hpp +++ b/cppcache/src/LRUAction.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_LRUACTION_H_ -#define GEODE_LRUACTION_H_ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,6 +15,11 @@ * limitations under the License. */ +#pragma once + +#ifndef GEODE_LRUACTION_H_ +#define GEODE_LRUACTION_H_ + #include #include #include @@ -37,7 +37,7 @@ namespace client { * @brief abstract behavior for different eviction actions. */ class LRUEntriesMap; -class APACHE_GEODE_EXPORT LRUAction { +class LRUAction { protected: bool m_invalidates; bool m_destroys; @@ -77,7 +77,7 @@ class APACHE_GEODE_EXPORT LRUAction { RegionInternal* regionPtr, LRUEntriesMap* entriesMapPtr); - virtual ~LRUAction() {} + virtual ~LRUAction() noexcept = default; virtual bool evict(const std::shared_ptr& mePtr) = 0; @@ -95,7 +95,7 @@ class APACHE_GEODE_EXPORT LRUAction { /** * @brief LRUAction for destroy (distributed) */ -class APACHE_GEODE_EXPORT LRUDestroyAction : public virtual LRUAction { +class LRUDestroyAction : public virtual LRUAction { private: RegionInternal* m_regionPtr; @@ -106,9 +106,9 @@ class APACHE_GEODE_EXPORT LRUDestroyAction : public virtual LRUAction { } public: - virtual ~LRUDestroyAction() = default; + ~LRUDestroyAction() noexcept override = default; - virtual bool evict(const std::shared_ptr& mePtr) { + bool evict(const std::shared_ptr& mePtr) override { std::shared_ptr keyPtr; mePtr->getKeyI(keyPtr); std::shared_ptr versionTag; @@ -124,7 +124,7 @@ class APACHE_GEODE_EXPORT LRUDestroyAction : public virtual LRUAction { return (err == GF_NOERR); } - virtual LRUAction::Action getType() { return LRUAction::DESTROY; } + LRUAction::Action getType() override { return LRUAction::DESTROY; } friend class LRUAction; }; @@ -132,7 +132,7 @@ class APACHE_GEODE_EXPORT LRUDestroyAction : public virtual LRUAction { /** * @brief LRUAction for invalidate. */ -class APACHE_GEODE_EXPORT LRULocalInvalidateAction : public virtual LRUAction { +class LRULocalInvalidateAction : public virtual LRUAction { private: RegionInternal* m_regionPtr; @@ -142,11 +142,11 @@ class APACHE_GEODE_EXPORT LRULocalInvalidateAction : public virtual LRUAction { } public: - virtual ~LRULocalInvalidateAction() = default; + ~LRULocalInvalidateAction() noexcept override = default; - virtual bool evict(const std::shared_ptr& mePtr); + bool evict(const std::shared_ptr& mePtr) override; - virtual LRUAction::Action getType() { return LRUAction::LOCAL_INVALIDATE; } + LRUAction::Action getType() override { return LRUAction::LOCAL_INVALIDATE; } friend class LRUAction; }; @@ -154,7 +154,7 @@ class APACHE_GEODE_EXPORT LRULocalInvalidateAction : public virtual LRUAction { /** * @brief LRUAction for invalidate. */ -class APACHE_GEODE_EXPORT LRUOverFlowToDiskAction : public virtual LRUAction { +class LRUOverFlowToDiskAction : public virtual LRUAction { private: RegionInternal* m_regionPtr; LRUEntriesMap* m_entriesMapPtr; @@ -166,11 +166,11 @@ class APACHE_GEODE_EXPORT LRUOverFlowToDiskAction : public virtual LRUAction { } public: - virtual ~LRUOverFlowToDiskAction() {} + ~LRUOverFlowToDiskAction() noexcept override {} - virtual bool evict(const std::shared_ptr& mePtr); + bool evict(const std::shared_ptr& mePtr) override; - virtual LRUAction::Action getType() { return LRUAction::OVERFLOW_TO_DISK; } + LRUAction::Action getType() override { return LRUAction::OVERFLOW_TO_DISK; } friend class LRUAction; }; diff --git a/cppcache/src/LRUEntriesMap.cpp b/cppcache/src/LRUEntriesMap.cpp index 6b25985d69..2e9413f028 100644 --- a/cppcache/src/LRUEntriesMap.cpp +++ b/cppcache/src/LRUEntriesMap.cpp @@ -33,16 +33,16 @@ namespace client { /** * @brief LRUAction for testing map outside of a region.... */ -class APACHE_GEODE_EXPORT TestMapAction : public virtual LRUAction { +class TestMapAction : public virtual LRUAction { private: EntriesMap* m_eMap; public: explicit TestMapAction(EntriesMap* eMap) : m_eMap(eMap) { m_destroys = true; } - virtual ~TestMapAction() {} + ~TestMapAction() noexcept override = default; - virtual bool evict(const std::shared_ptr& mePtr) { + bool evict(const std::shared_ptr& mePtr) override { std::shared_ptr keyPtr; mePtr->getKeyI(keyPtr); /** @TODO try catch.... return true or false. */ @@ -52,7 +52,7 @@ class APACHE_GEODE_EXPORT TestMapAction : public virtual LRUAction { return (m_eMap->remove(keyPtr, cPtr, me, 0, versionTag, false) == GF_NOERR); } - virtual LRUAction::Action getType() { return LRUAction::LOCAL_DESTROY; } + LRUAction::Action getType() override { return LRUAction::LOCAL_DESTROY; } friend class LRUAction; }; @@ -104,7 +104,7 @@ void LRUEntriesMap::clear() { ConcurrentEntriesMap::clear(); } -LRUEntriesMap::~LRUEntriesMap() { delete m_action; } +LRUEntriesMap::~LRUEntriesMap() noexcept { delete m_action; } /** * @brief put an item in the map... if it is a new entry, then the LRU may @@ -201,7 +201,6 @@ GfErrType LRUEntriesMap::invalidate(const std::shared_ptr& key, std::shared_ptr& me, std::shared_ptr& oldValue, std::shared_ptr versionTag) { - int64_t newSize = 0; MapSegment* segmentRPtr = segmentFor(key); bool isTokenAdded = false; GfErrType err = @@ -236,7 +235,7 @@ GfErrType LRUEntriesMap::invalidate(const std::shared_ptr& key, if (!isOldValueToken) { --m_validEntries; lru_queue_.remove(me); - newSize = CacheableToken::invalid()->objectSize(); + auto newSize = CacheableToken::invalid()->objectSize(); if (oldValue != nullptr) { newSize -= oldValue->objectSize(); } else { diff --git a/cppcache/src/LRUEntriesMap.hpp b/cppcache/src/LRUEntriesMap.hpp index 2c7f0e916f..f04c0a7fd0 100644 --- a/cppcache/src/LRUEntriesMap.hpp +++ b/cppcache/src/LRUEntriesMap.hpp @@ -35,27 +35,13 @@ namespace apache { namespace geode { namespace client { + class EvictionController; /** * @brief Concurrent entries map with LRU behavior. * Not designed for subclassing... */ - -/* adongre - * CID 28728: Other violation (MISSING_COPY) - * Class "apache::geode::client::LRUEntriesMap" owns resources that are managed - * in its - * constructor and destructor but has no user-written copy constructor. - * - * FIX : Make the class non copyable - * - * CID 28714: Other violation (MISSING_ASSIGN) - * Class "apache::geode::client::LRUEntriesMap" owns resources that are managed - * in - * its constructor and destructor but has no user-written assignment operator. - * Fix : Make the class Non Assinable - */ class APACHE_GEODE_EXPORT LRUEntriesMap : public ConcurrentEntriesMap { protected: using spinlock_mutex = ::apache::geode::util::concurrent::spinlock_mutex; @@ -80,32 +66,31 @@ class APACHE_GEODE_EXPORT LRUEntriesMap : public ConcurrentEntriesMap { const uint32_t limit, bool concurrencyChecksEnabled, const uint8_t concurrency = 16, bool heapLRUEnabled = false); - virtual ~LRUEntriesMap(); - - virtual GfErrType put(const std::shared_ptr& key, - const std::shared_ptr& newValue, - std::shared_ptr& me, - std::shared_ptr& oldValue, int updateCount, - int destroyTracker, - std::shared_ptr versionTag, - bool& isUpdate = EntriesMap::boolVal, - DataInput* delta = nullptr); - virtual GfErrType invalidate(const std::shared_ptr& key, - std::shared_ptr& me, - std::shared_ptr& oldValue, - std::shared_ptr versionTag); - virtual GfErrType create(const std::shared_ptr& key, - const std::shared_ptr& newValue, - std::shared_ptr& me, - std::shared_ptr& oldValue, - int updateCount, int destroyTracker, - std::shared_ptr versionTag); - virtual bool get(const std::shared_ptr& key, - std::shared_ptr& value, - std::shared_ptr& me); - virtual std::shared_ptr getFromDisk( + ~LRUEntriesMap() noexcept override; + + GfErrType put(const std::shared_ptr& key, + const std::shared_ptr& newValue, + std::shared_ptr& me, + std::shared_ptr& oldValue, int updateCount, + int destroyTracker, std::shared_ptr versionTag, + bool& isUpdate = EntriesMap::boolVal, + DataInput* delta = nullptr) override; + GfErrType invalidate(const std::shared_ptr& key, + std::shared_ptr& me, + std::shared_ptr& oldValue, + std::shared_ptr versionTag) override; + GfErrType create(const std::shared_ptr& key, + const std::shared_ptr& newValue, + std::shared_ptr& me, + std::shared_ptr& oldValue, int updateCount, + int destroyTracker, + std::shared_ptr versionTag) override; + bool get(const std::shared_ptr& key, + std::shared_ptr& value, + std::shared_ptr& me) override; + std::shared_ptr getFromDisk( const std::shared_ptr& key, - std::shared_ptr& me) const; + std::shared_ptr& me) const override; GfErrType processLRU(); void processLRU(int32_t numEntriesToEvict); GfErrType evictionHelper(); @@ -115,16 +100,12 @@ class APACHE_GEODE_EXPORT LRUEntriesMap : public ConcurrentEntriesMap { m_pmPtr = pmPtr; } - /** - * @brief remove an entry, marking it evicted for LRUList maintainance. - */ - virtual GfErrType remove(const std::shared_ptr& key, - std::shared_ptr& result, - std::shared_ptr& me, int updateCount, - std::shared_ptr versionTag, - bool afterRemote); - - virtual void close(); + GfErrType remove(const std::shared_ptr& key, + std::shared_ptr& result, + std::shared_ptr& me, int updateCount, + std::shared_ptr versionTag, + bool afterRemote) override; + void close() override; inline bool mustEvict() const { if (m_action == nullptr) { @@ -144,9 +125,10 @@ class APACHE_GEODE_EXPORT LRUEntriesMap : public ConcurrentEntriesMap { inline void adjustLimit(uint32_t limit) { m_limit = limit; } - virtual void clear(); + void clear() override; }; // class LRUEntriesMap + } // namespace client } // namespace geode } // namespace apache diff --git a/cppcache/src/LRUExpMapEntry.hpp b/cppcache/src/LRUExpMapEntry.hpp index d462bc72e3..ebf5685fa6 100644 --- a/cppcache/src/LRUExpMapEntry.hpp +++ b/cppcache/src/LRUExpMapEntry.hpp @@ -32,17 +32,20 @@ namespace client { /** * @brief Hold region mapped entry value and lru information. */ -class APACHE_GEODE_EXPORT LRUExpMapEntry : public MapEntryImpl, - public LRUEntryProperties, - public ExpEntryProperties { +class LRUExpMapEntry : public MapEntryImpl, + public LRUEntryProperties, + public ExpEntryProperties { public: - virtual ~LRUExpMapEntry() {} + LRUExpMapEntry(const LRUExpMapEntry&) = delete; + LRUExpMapEntry& operator=(const LRUExpMapEntry&) = delete; - virtual LRUEntryProperties& getLRUProperties() { return *this; } + ~LRUExpMapEntry() noexcept override = default; - virtual ExpEntryProperties& getExpProperties() { return *this; } + LRUEntryProperties& getLRUProperties() override { return *this; } - virtual void cleanup(const CacheEventFlags eventFlags) { + ExpEntryProperties& getExpProperties() override { return *this; } + + void cleanup(const CacheEventFlags eventFlags) override { if (!eventFlags.isExpiration()) { cancelExpiryTaskId(m_key); } @@ -57,19 +60,16 @@ class APACHE_GEODE_EXPORT LRUExpMapEntry : public MapEntryImpl, inline LRUExpMapEntry(ExpiryTaskManager* expiryTaskManager, const std::shared_ptr& key) : MapEntryImpl(key), ExpEntryProperties(expiryTaskManager) {} - - private: - // disabled - LRUExpMapEntry(const LRUExpMapEntry&); - LRUExpMapEntry& operator=(const LRUExpMapEntry&); }; -class APACHE_GEODE_EXPORT VersionedLRUExpMapEntry : public LRUExpMapEntry, - public VersionStamp { +class VersionedLRUExpMapEntry : public LRUExpMapEntry, public VersionStamp { public: - virtual ~VersionedLRUExpMapEntry() {} + VersionedLRUExpMapEntry(const VersionedLRUExpMapEntry&) = delete; + VersionedLRUExpMapEntry& operator=(const VersionedLRUExpMapEntry&) = delete; - virtual VersionStamp& getVersionStamp() { return *this; } + ~VersionedLRUExpMapEntry() noexcept override = default; + + VersionStamp& getVersionStamp() override { return *this; } protected: inline explicit VersionedLRUExpMapEntry(bool) : LRUExpMapEntry(true) {} @@ -77,22 +77,17 @@ class APACHE_GEODE_EXPORT VersionedLRUExpMapEntry : public LRUExpMapEntry, inline VersionedLRUExpMapEntry(ExpiryTaskManager* expiryTaskManager, const std::shared_ptr& key) : LRUExpMapEntry(expiryTaskManager, key) {} - - private: - // disabled - VersionedLRUExpMapEntry(const VersionedLRUExpMapEntry&); - VersionedLRUExpMapEntry& operator=(const VersionedLRUExpMapEntry&); }; -class APACHE_GEODE_EXPORT LRUExpEntryFactory : public EntryFactory { +class LRUExpEntryFactory : public EntryFactory { public: using EntryFactory::EntryFactory; - virtual ~LRUExpEntryFactory() {} + ~LRUExpEntryFactory() noexcept override = default; - virtual void newMapEntry(ExpiryTaskManager* expiryTaskManager, - const std::shared_ptr& key, - std::shared_ptr& result) const; + void newMapEntry(ExpiryTaskManager* expiryTaskManager, + const std::shared_ptr& key, + std::shared_ptr& result) const override; }; } // namespace client } // namespace geode diff --git a/cppcache/src/LRULocalDestroyAction.hpp b/cppcache/src/LRULocalDestroyAction.hpp index 4ce209d825..d42f2364ca 100644 --- a/cppcache/src/LRULocalDestroyAction.hpp +++ b/cppcache/src/LRULocalDestroyAction.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_LRULOCALDESTROYACTION_H_ -#define GEODE_LRULOCALDESTROYACTION_H_ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,6 +15,11 @@ * limitations under the License. */ +#pragma once + +#ifndef GEODE_LRULOCALDESTROYACTION_H_ +#define GEODE_LRULOCALDESTROYACTION_H_ + #include #include @@ -46,13 +46,14 @@ class APACHE_GEODE_EXPORT LRULocalDestroyAction : public virtual LRUAction { } public: - virtual ~LRULocalDestroyAction() {} + ~LRULocalDestroyAction() noexcept override = default; - virtual bool evict(const std::shared_ptr& mePtr); + bool evict(const std::shared_ptr& mePtr) override; - virtual LRUAction::Action getType() { return LRUAction::LOCAL_DESTROY; } + LRUAction::Action getType() override { return LRUAction::LOCAL_DESTROY; } friend class LRUAction; }; + } // namespace client } // namespace geode } // namespace apache diff --git a/cppcache/src/LRUMapEntry.hpp b/cppcache/src/LRUMapEntry.hpp index bd16b56925..a9bc1f6659 100644 --- a/cppcache/src/LRUMapEntry.hpp +++ b/cppcache/src/LRUMapEntry.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_LRUMAPENTRY_H_ -#define GEODE_LRUMAPENTRY_H_ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,6 +15,11 @@ * limitations under the License. */ +#pragma once + +#ifndef GEODE_LRUMAPENTRY_H_ +#define GEODE_LRUMAPENTRY_H_ + #include #include @@ -30,6 +30,7 @@ namespace apache { namespace geode { namespace client { + /** * This template class adds the recently used, eviction bits and persistence * info to the MapEntry class. The earlier design looked like below: @@ -60,14 +61,16 @@ namespace client { * * */ -class APACHE_GEODE_EXPORT LRUMapEntry : public MapEntryImpl, - public LRUEntryProperties { +class LRUMapEntry : public MapEntryImpl, public LRUEntryProperties { public: - virtual ~LRUMapEntry() {} + LRUMapEntry(const LRUMapEntry&) = delete; + LRUMapEntry& operator=(const LRUMapEntry&) = delete; + + ~LRUMapEntry() noexcept override = default; - virtual LRUEntryProperties& getLRUProperties() { return *this; } + LRUEntryProperties& getLRUProperties() override { return *this; } - virtual void cleanup(const CacheEventFlags eventFlags) { + void cleanup(const CacheEventFlags eventFlags) override { if (!eventFlags.isEviction()) { // TODO: this needs an implementation of doubly-linked list // to remove from the list; also add this to LRUExpMapEntry since MI @@ -81,42 +84,35 @@ class APACHE_GEODE_EXPORT LRUMapEntry : public MapEntryImpl, inline explicit LRUMapEntry(const std::shared_ptr& key) : MapEntryImpl(key) {} - - private: - // disabled - LRUMapEntry(const LRUMapEntry&); - LRUMapEntry& operator=(const LRUMapEntry&); }; -class APACHE_GEODE_EXPORT VersionedLRUMapEntry : public LRUMapEntry, - public VersionStamp { +class VersionedLRUMapEntry : public LRUMapEntry, public VersionStamp { public: - virtual ~VersionedLRUMapEntry() {} + VersionedLRUMapEntry(const VersionedLRUMapEntry&) = delete; + VersionedLRUMapEntry& operator=(const VersionedLRUMapEntry&) = delete; + + ~VersionedLRUMapEntry() noexcept override = default; - virtual VersionStamp& getVersionStamp() { return *this; } + VersionStamp& getVersionStamp() override { return *this; } protected: inline explicit VersionedLRUMapEntry(bool) : LRUMapEntry(true) {} inline explicit VersionedLRUMapEntry(const std::shared_ptr& key) : LRUMapEntry(key) {} - - private: - // disabled - VersionedLRUMapEntry(const VersionedLRUMapEntry&); - VersionedLRUMapEntry& operator=(const VersionedLRUMapEntry&); }; -class APACHE_GEODE_EXPORT LRUEntryFactory : public EntryFactory { +class LRUEntryFactory : public EntryFactory { public: using EntryFactory::EntryFactory; - virtual ~LRUEntryFactory() {} + ~LRUEntryFactory() noexcept override = default; - virtual void newMapEntry(ExpiryTaskManager* expiryTaskManager, - const std::shared_ptr& key, - std::shared_ptr& result) const; + void newMapEntry(ExpiryTaskManager* expiryTaskManager, + const std::shared_ptr& key, + std::shared_ptr& result) const override; }; + } // namespace client } // namespace geode } // namespace apache diff --git a/cppcache/src/LocalRegion.cpp b/cppcache/src/LocalRegion.cpp index 8ce50d89e0..13267ebb54 100644 --- a/cppcache/src/LocalRegion.cpp +++ b/cppcache/src/LocalRegion.cpp @@ -17,7 +17,6 @@ #include "LocalRegion.hpp" -#include #include #include @@ -26,6 +25,7 @@ #include "CacheImpl.hpp" #include "CacheRegionHelper.hpp" #include "CacheableToken.hpp" +#include "EntriesMapFactory.hpp" #include "EntryExpiryHandler.hpp" #include "ExpiryTaskManager.hpp" #include "LRUEntriesMap.hpp" @@ -93,7 +93,7 @@ LocalRegion::LocalRegion(const std::string& name, CacheImpl* cacheImpl, m_regionStats = new RegionStats( cacheImpl->getStatisticsManager().getStatisticsFactory(), m_fullPath); - auto p = cacheImpl->getPoolManager().find(getAttributes().getPoolName()); + auto p = cacheImpl->getPoolManager().find(m_regionAttributes.getPoolName()); setPool(p); } @@ -733,6 +733,8 @@ void LocalRegion::registerEntryExpiryTask( LocalRegion::~LocalRegion() noexcept { TryWriteGuard guard(m_rwLock, m_destroyPending); if (!m_destroyPending) { + // TODO suspect + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) release(false); } m_listener = nullptr; diff --git a/cppcache/src/LocalRegion.hpp b/cppcache/src/LocalRegion.hpp index 1076d0acf3..057276b0ad 100644 --- a/cppcache/src/LocalRegion.hpp +++ b/cppcache/src/LocalRegion.hpp @@ -33,19 +33,15 @@ #include #include #include -#include #include #include #include #include -#include "CacheableToken.hpp" -#include "EntriesMapFactory.hpp" +#include "EntriesMap.hpp" #include "EventType.hpp" -#include "ExpMapEntry.hpp" #include "RegionInternal.hpp" #include "RegionStats.hpp" -#include "SerializationRegistry.hpp" #include "TSSTXStateWrapper.hpp" #include "TombstoneList.hpp" #include "util/synchronized_map.hpp" @@ -55,21 +51,25 @@ namespace geode { namespace client { #ifndef CHECK_DESTROY_PENDING -#define CHECK_DESTROY_PENDING(lock, function) \ - lock checkGuard(m_rwLock, m_destroyPending); \ - if (m_destroyPending) { \ - std::string err_msg = #function; \ - err_msg += ": region " + m_fullPath + " destroyed"; \ - throw RegionDestroyedException(err_msg.c_str()); \ - } +#define CHECK_DESTROY_PENDING(lock, function) \ + lock checkGuard(m_rwLock, m_destroyPending); \ + do { \ + if (m_destroyPending) { \ + std::string err_msg = #function; \ + err_msg += ": region " + m_fullPath + " destroyed"; \ + throw RegionDestroyedException(err_msg.c_str()); \ + } \ + } while (0) #endif #ifndef CHECK_DESTROY_PENDING_NOTHROW -#define CHECK_DESTROY_PENDING_NOTHROW(lock) \ - lock checkGuard(m_rwLock, m_destroyPending); \ - if (m_destroyPending) { \ - return GF_CACHE_REGION_DESTROYED_EXCEPTION; \ - } +#define CHECK_DESTROY_PENDING_NOTHROW(lock) \ + lock checkGuard(m_rwLock, m_destroyPending); \ + do { \ + if (m_destroyPending) { \ + return GF_CACHE_REGION_DESTROYED_EXCEPTION; \ + } \ + } while (0) #endif class PutActions; diff --git a/cppcache/src/MapEntry.hpp b/cppcache/src/MapEntry.hpp index 14bec140f0..76b0690acb 100644 --- a/cppcache/src/MapEntry.hpp +++ b/cppcache/src/MapEntry.hpp @@ -48,8 +48,10 @@ class CacheImpl; * @brief This class encapsulates expiration specific properties for * a MapEntry. */ -class APACHE_GEODE_EXPORT ExpEntryProperties { +class ExpEntryProperties { public: + ~ExpEntryProperties() noexcept = default; + typedef std::chrono::system_clock::time_point time_point; inline explicit ExpEntryProperties(ExpiryTaskManager* expiryTaskManager) @@ -122,7 +124,7 @@ class APACHE_GEODE_EXPORT ExpEntryProperties { */ class APACHE_GEODE_EXPORT MapEntry { public: - virtual ~MapEntry() {} + virtual ~MapEntry() noexcept = default; virtual void getKey(std::shared_ptr& result) const = 0; virtual void getValue(std::shared_ptr& result) const = 0; @@ -191,7 +193,7 @@ class APACHE_GEODE_EXPORT MapEntry { virtual void cleanup(const CacheEventFlags eventFlags) = 0; protected: - inline MapEntry() {} + inline MapEntry() = default; inline explicit MapEntry(bool) {} }; @@ -203,7 +205,7 @@ class APACHE_GEODE_EXPORT MapEntry { class MapEntryImpl : public MapEntry, public std::enable_shared_from_this { public: - ~MapEntryImpl() override = default; + ~MapEntryImpl() noexcept override = default; MapEntryImpl(const MapEntryImpl&) = delete; MapEntryImpl& operator=(const MapEntryImpl&) = delete; @@ -270,12 +272,14 @@ class MapEntryImpl : public MapEntry, std::shared_ptr m_key; }; -class APACHE_GEODE_EXPORT VersionedMapEntryImpl : public MapEntryImpl, - public VersionStamp { +class VersionedMapEntryImpl : public MapEntryImpl, public VersionStamp { public: - virtual ~VersionedMapEntryImpl() {} + ~VersionedMapEntryImpl() noexcept override = default; + + VersionedMapEntryImpl(const VersionedMapEntryImpl&) = delete; + VersionedMapEntryImpl& operator=(const VersionedMapEntryImpl&) = delete; - virtual VersionStamp& getVersionStamp() { return *this; } + VersionStamp& getVersionStamp() override { return *this; } protected: inline explicit VersionedMapEntryImpl(bool) : MapEntryImpl(true) {} @@ -283,19 +287,14 @@ class APACHE_GEODE_EXPORT VersionedMapEntryImpl : public MapEntryImpl, inline explicit VersionedMapEntryImpl( const std::shared_ptr& key) : MapEntryImpl(key) {} - - private: - // disabled - VersionedMapEntryImpl(const VersionedMapEntryImpl&); - VersionedMapEntryImpl& operator=(const VersionedMapEntryImpl&); }; -class APACHE_GEODE_EXPORT EntryFactory { +class EntryFactory { public: explicit EntryFactory(const bool concurrencyChecksEnabled) : m_concurrencyChecksEnabled(concurrencyChecksEnabled) {} - virtual ~EntryFactory() {} + virtual ~EntryFactory() noexcept = default; virtual void newMapEntry(ExpiryTaskManager* expiryTaskManager, const std::shared_ptr& key, @@ -304,6 +303,7 @@ class APACHE_GEODE_EXPORT EntryFactory { protected: bool m_concurrencyChecksEnabled; }; + } // namespace client } // namespace geode } // namespace apache diff --git a/cppcache/src/PdxRemotePreservedData.hpp b/cppcache/src/PdxRemotePreservedData.hpp index 5b39819e30..711b694c47 100644 --- a/cppcache/src/PdxRemotePreservedData.hpp +++ b/cppcache/src/PdxRemotePreservedData.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_PDXREMOTEPRESERVEDDATA_H_ -#define GEODE_PDXREMOTEPRESERVEDDATA_H_ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,6 +15,11 @@ * limitations under the License. */ +#pragma once + +#ifndef GEODE_PDXREMOTEPRESERVEDDATA_H_ +#define GEODE_PDXREMOTEPRESERVEDDATA_H_ + #include #include @@ -30,6 +30,7 @@ namespace apache { namespace geode { namespace client { + class PdxRemotePreservedData; class PdxRemotePreservedData : public PdxUnreadFields { @@ -38,25 +39,15 @@ class PdxRemotePreservedData : public PdxUnreadFields { int32_t m_typeId; int32_t m_mergedTypeId; int32_t m_currentIndex; - std::shared_ptr /*Object^*/ m_owner; + std::shared_ptr m_owner; ExpiryTaskManager::id_type m_expiryTakId; public: PdxRemotePreservedData() - : /* adongre - Coverity II - * CID 29283: Uninitialized scalar field (UNINIT_CTOR) - */ - m_typeId(0), - m_mergedTypeId(0), - m_currentIndex(0), - m_expiryTakId(0) {} - - virtual ~PdxRemotePreservedData() { - /*for(int i=0;i owner) { m_typeId = typeId; diff --git a/cppcache/src/RemoteQuery.cpp b/cppcache/src/RemoteQuery.cpp index a29f80ca8b..a1e3e203f4 100644 --- a/cppcache/src/RemoteQuery.cpp +++ b/cppcache/src/RemoteQuery.cpp @@ -70,6 +70,7 @@ std::shared_ptr RemoteQuery::execute( pool->getStats().incQueryExecutionId(); } /*get the start time for QueryExecutionTime stat*/ + // NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) bool enableTimeStatistics = tcdm->getConnectionManager() .getCacheImpl() ->getDistributedSystem() @@ -140,12 +141,11 @@ GfErrType RemoteQuery::executeNoThrow( msg.setTimeout(timeout); reply.setTimeout(timeout); - GfErrType err = GF_NOERR; LOGFINEST("%s: sending request for query: %s", func, m_queryString.c_str()); if (tcdm == nullptr) { tcdm = m_tccdm; } - err = tcdm->sendSyncRequest(msg, reply); + auto err = tcdm->sendSyncRequest(msg, reply); if (err != GF_NOERR) { return err; } @@ -164,12 +164,11 @@ GfErrType RemoteQuery::executeNoThrow( msg.setTimeout(timeout); reply.setTimeout(timeout); - GfErrType err = GF_NOERR; LOGFINEST("%s: sending request for query: %s", func, m_queryString.c_str()); if (tcdm == nullptr) { tcdm = m_tccdm; } - err = tcdm->sendSyncRequest(msg, reply); + auto err = tcdm->sendSyncRequest(msg, reply); if (err != GF_NOERR) { return err; } diff --git a/cppcache/src/SerializationRegistry.cpp b/cppcache/src/SerializationRegistry.cpp index 151a643e4e..a6d81c784d 100644 --- a/cppcache/src/SerializationRegistry.cpp +++ b/cppcache/src/SerializationRegistry.cpp @@ -680,7 +680,6 @@ void DataSerializableHandler::serialize( ptr->toDelta(dataOutput); } else { dataSerializable->toData(dataOutput); - ; } } diff --git a/cppcache/src/ServerLocation.hpp b/cppcache/src/ServerLocation.hpp index 91cd670ac4..46097abeca 100644 --- a/cppcache/src/ServerLocation.hpp +++ b/cppcache/src/ServerLocation.hpp @@ -42,7 +42,7 @@ class APACHE_GEODE_EXPORT ServerLocation : Serializable(), m_serverName(std::move(serverName)), m_port(port) { LOGDEBUG( "ServerLocation::ServerLocation(): creating ServerLocation for %s:%d", - serverName.c_str(), port); + m_serverName.c_str(), port); makeEpString(); } @@ -64,11 +64,6 @@ class APACHE_GEODE_EXPORT ServerLocation const std::string& getServerName() const { return m_serverName; } - void setServername(std::string serverName) { - m_serverName = std::move(serverName); - makeEpString(); - } - int getPort() const { return m_port; } void toData(DataOutput& output) const override { diff --git a/cppcache/src/SystemProperties.cpp b/cppcache/src/SystemProperties.cpp index a3184c9832..ec8e4f0ab7 100644 --- a/cppcache/src/SystemProperties.cpp +++ b/cppcache/src/SystemProperties.cpp @@ -23,15 +23,12 @@ #include #include #include -#include #include "CppCacheLibrary.hpp" #include "util/Log.hpp" #if defined(_WIN32) #include -#else -#include #endif namespace { @@ -134,12 +131,6 @@ namespace apache { namespace geode { namespace client { -namespace impl { - -void* getFactoryFunc(const char* lib, const char* funcName); - -} // namespace impl - SystemProperties::SystemProperties( const std::shared_ptr& propertiesPtr, const std::string& configFile) @@ -191,8 +182,10 @@ SystemProperties::SystemProperties( public: explicit ProcessPropsVisitor(SystemProperties* sysProps) : m_sysProps(sysProps) {} + ~ProcessPropsVisitor() noexcept override = default; + void visit(const std::shared_ptr& key, - const std::shared_ptr& value) { + const std::shared_ptr& value) override { auto property = key->toString(); std::string val; if (value != nullptr) { diff --git a/cppcache/src/TXId.cpp b/cppcache/src/TXId.cpp index 3b8cc9008c..869395107e 100644 --- a/cppcache/src/TXId.cpp +++ b/cppcache/src/TXId.cpp @@ -14,12 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* - * TXId.cpp - * - * Created on: 07-Feb-2011 - * Author: ankurs - */ #include "TXId.hpp" @@ -36,7 +30,7 @@ TXId& TXId::operator=(const TXId& other) { return *this; } -TXId::~TXId() {} +TXId::~TXId() noexcept = default; int32_t TXId::getId() { return m_TXId; } } // namespace client diff --git a/cppcache/src/TXId.hpp b/cppcache/src/TXId.hpp index 2f2d280e78..1cb13e9381 100644 --- a/cppcache/src/TXId.hpp +++ b/cppcache/src/TXId.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_TXID_H_ -#define GEODE_TXID_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. */ -/* - * TXId.h - * - * Created on: 07-Feb-2011 - * Author: ankurs - */ + +#pragma once + +#ifndef GEODE_TXID_H_ +#define GEODE_TXID_H_ #include @@ -41,7 +35,7 @@ class TXId : public apache::geode::client::TransactionId { TXId& operator=(const TXId&); - virtual ~TXId(); + ~TXId() noexcept override; int32_t getId(); diff --git a/cppcache/src/TcrChunkedContext.hpp b/cppcache/src/TcrChunkedContext.hpp index 17b42c6c5a..00e22d13f7 100644 --- a/cppcache/src/TcrChunkedContext.hpp +++ b/cppcache/src/TcrChunkedContext.hpp @@ -56,7 +56,7 @@ class TcrChunkedResult { m_ex(nullptr), m_inSameThread(false), m_dsmemId(0) {} - virtual ~TcrChunkedResult() {} + virtual ~TcrChunkedResult() noexcept {} void setFinalizeSemaphore(ACE_Semaphore* finalizeSema) { m_finalizeSema = finalizeSema; } diff --git a/cppcache/src/TcrConnection.cpp b/cppcache/src/TcrConnection.cpp index 40d123840b..f73707e70e 100644 --- a/cppcache/src/TcrConnection.cpp +++ b/cppcache/src/TcrConnection.cpp @@ -69,6 +69,7 @@ int expiryTimeVariancePercentage() { srand(static_cast((now_s * 1000) + (now_ms / 1000))); const int numbers = 21; + // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.rand): TODO replace int random = rand() % numbers + 1; if (random > 10) { @@ -989,12 +990,6 @@ std::shared_ptr TcrConnection::readHandshakeRawData( } } -std::shared_ptr TcrConnection::readHandshakeByteArray( - std::chrono::microseconds connectTimeout) { - uint32_t arraySize = readHandshakeArraySize(connectTimeout); - return readHandshakeRawData(arraySize, connectTimeout); -} - // read a byte array int32_t TcrConnection::readHandshakeArraySize( std::chrono::microseconds connectTimeout) { @@ -1073,37 +1068,6 @@ void TcrConnection::readHandShakeBytes( _GEODE_SAFE_DELETE_ARRAY(recvMessage); } -int32_t TcrConnection::readHandShakeInt( - std::chrono::microseconds connectTimeout) { - ConnErrType error = CONN_NOERR; - uint8_t* recvMessage; - _GEODE_NEW(recvMessage, uint8_t[4]); - - if ((error = receiveData(reinterpret_cast(recvMessage), 4, - connectTimeout)) != CONN_NOERR) { - if (error & CONN_TIMEOUT) { - _GEODE_SAFE_DELETE_ARRAY(recvMessage); - m_conn.reset(); - throwException( - TimeoutException("TcrConnection::TcrConnection: " - "Timeout in handshake")); - } else { - _GEODE_SAFE_DELETE_ARRAY(recvMessage); - m_conn.reset(); - throwException( - GeodeIOException("TcrConnection::TcrConnection: " - "Handshake failure")); - } - } - - auto di = m_connectionManager.getCacheImpl()->createDataInput(recvMessage, 4); - int32_t val = di.readInt32(); - - _GEODE_SAFE_DELETE_ARRAY(recvMessage); - - return val; -} - std::shared_ptr TcrConnection::readHandshakeString( std::chrono::microseconds connectTimeout) { ConnErrType error = CONN_NOERR; diff --git a/cppcache/src/TcrConnection.hpp b/cppcache/src/TcrConnection.hpp index 857ff0df4c..acb974e9b8 100644 --- a/cppcache/src/TcrConnection.hpp +++ b/cppcache/src/TcrConnection.hpp @@ -300,11 +300,6 @@ class TcrConnection { */ uint8_t getOverrides(const SystemProperties* props); - /** - * To read the from stream - */ - int32_t readHandShakeInt(std::chrono::microseconds connectTimeout); - /* * To read the arraysize */ @@ -341,13 +336,6 @@ class TcrConnection { std::shared_ptr readHandshakeString( std::chrono::microseconds connectTimeout); - /** - * Reads a byte array (using initial length) from socket and handles error - * conditions in case of Handshake. - */ - std::shared_ptr readHandshakeByteArray( - std::chrono::microseconds connectTimeout); - /** * Send data to the connection till sendTimeout */ diff --git a/cppcache/src/TcrConnectionManager.cpp b/cppcache/src/TcrConnectionManager.cpp index 7159a30171..7e7adeb691 100644 --- a/cppcache/src/TcrConnectionManager.cpp +++ b/cppcache/src/TcrConnectionManager.cpp @@ -26,15 +26,11 @@ #include "CacheImpl.hpp" #include "ExpiryHandler_T.hpp" #include "ExpiryTaskManager.hpp" -#include "RemoteQueryService.hpp" -#include "ServerLocation.hpp" #include "TcrConnection.hpp" #include "TcrEndpoint.hpp" #include "TcrHADistributionManager.hpp" #include "ThinClientBaseDM.hpp" -#include "ThinClientCacheDistributionManager.hpp" #include "ThinClientHARegion.hpp" -#include "ThinClientLocatorHelper.hpp" #include "ThinClientRedundancyManager.hpp" #include "ThinClientRegion.hpp" #include "Utils.hpp" @@ -46,7 +42,6 @@ namespace client { volatile bool TcrConnectionManager::TEST_DURABLE_CLIENT_CRASH = false; -const char *TcrConnectionManager::NC_Redundancy = "NC Redundancy"; const char *TcrConnectionManager::NC_Failover = "NC Failover"; const char *TcrConnectionManager::NC_CleanUp = "NC CleanUp"; @@ -69,9 +64,6 @@ TcrConnectionManager::TcrConnectionManager(CacheImpl *cache) new ThinClientRedundancyManager(this)); } -ExpiryTaskManager::id_type TcrConnectionManager::getPingTaskId() { - return m_pingTaskId; -} void TcrConnectionManager::init(bool isPool) { if (!m_initGuard) { m_initGuard = true; @@ -299,7 +291,6 @@ void TcrConnectionManager::failover(std::atomic &isRunning) { it->failover(); } while (m_failoverSema.tryacquire() != -1) { - ; } } catch (const Exception &e) { LOGERROR(e.what()); @@ -334,19 +325,13 @@ GfErrType TcrConnectionManager::registerInterestAllRegions( // TcrHADistributionManagers). GfErrType err = GF_NOERR; - GfErrType opErr = GF_NOERR; std::lock_guard guard(m_distMngrsLock); - std::list::iterator begin = m_distMngrs.begin(); - std::list::iterator end = m_distMngrs.end(); - for (std::list::iterator it = begin; it != end; ++it) { - TcrHADistributionManager *tcrHADM = - dynamic_cast(*it); - if (tcrHADM != nullptr) { - if ((opErr = tcrHADM->registerInterestForRegion(ep, request, reply)) != - GF_NOERR) { - if (err == GF_NOERR) { - err = opErr; - } + + for (const auto &it : m_distMngrs) { + if (auto tcrHADM = dynamic_cast(it)) { + auto opErr = tcrHADM->registerInterestForRegion(ep, request, reply); + if (err == GF_NOERR) { + err = opErr; } } } @@ -429,7 +414,6 @@ void TcrConnectionManager::redundancy(std::atomic &isRunning) { if (isRunning && !m_isNetDown) { m_redundancyManager->maintainRedundancyLevel(); while (m_redundancySema.tryacquire() != -1) { - ; } } } @@ -458,7 +442,6 @@ void TcrConnectionManager::cleanup(std::atomic &isRunning) { cleanNotificationLists(); while (m_cleanupSema.tryacquire() != -1) { - ; } } while (isRunning); diff --git a/cppcache/src/TcrConnectionManager.hpp b/cppcache/src/TcrConnectionManager.hpp index 682e090db1..393d472eb5 100644 --- a/cppcache/src/TcrConnectionManager.hpp +++ b/cppcache/src/TcrConnectionManager.hpp @@ -66,7 +66,6 @@ class TcrConnectionManager { int checkConnection(const ACE_Time_Value&, const void*); int checkRedundancy(const ACE_Time_Value&, const void*); int processEventIdMap(const ACE_Time_Value&, const void*); - ExpiryTaskManager::id_type getPingTaskId(); void close(); void readyForEvents(); @@ -185,7 +184,6 @@ class TcrConnectionManager { friend class DistManagersLockGuard; friend class ThinClientPoolDM; friend class ThinClientPoolHADM; - static const char* NC_Redundancy; static const char* NC_Failover; static const char* NC_CleanUp; }; diff --git a/cppcache/src/TcrDistributionManager.hpp b/cppcache/src/TcrDistributionManager.hpp index 2a7907d79e..56b525daee 100644 --- a/cppcache/src/TcrDistributionManager.hpp +++ b/cppcache/src/TcrDistributionManager.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_TCRDISTRIBUTIONMANAGER_H_ -#define GEODE_TCRDISTRIBUTIONMANAGER_H_ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,6 +15,11 @@ * limitations under the License. */ +#pragma once + +#ifndef GEODE_TCRDISTRIBUTIONMANAGER_H_ +#define GEODE_TCRDISTRIBUTIONMANAGER_H_ + #include #include "ThinClientDistributionManager.hpp" @@ -29,6 +29,7 @@ namespace geode { namespace client { class ThinClientRegion; + /** * @brief Distribute data between caches */ @@ -36,23 +37,23 @@ class TcrDistributionManager : public ThinClientDistributionManager { public: TcrDistributionManager(ThinClientRegion* region, TcrConnectionManager& connManager); + TcrDistributionManager(const TcrDistributionManager&) = delete; + TcrDistributionManager& operator=(const TcrDistributionManager&) = delete; + ~TcrDistributionManager() noexcept override = default; protected: - virtual void getEndpointNames(std::unordered_set& endpointNames); - - virtual void postUnregisterAction(); + void getEndpointNames( + std::unordered_set& endpointNames) override; - virtual bool preFailoverAction(); + void postUnregisterAction() override; - virtual bool postFailoverAction(TcrEndpoint* endpoint); + bool preFailoverAction() override; - virtual void destroyAction(); + bool postFailoverAction(TcrEndpoint* endpoint) override; - private: - // Disallow copy constructor and assignment operator. - TcrDistributionManager(const TcrDistributionManager&); - TcrDistributionManager& operator=(const TcrDistributionManager&); + void destroyAction() override; }; + } // namespace client } // namespace geode } // namespace apache diff --git a/cppcache/src/TcrEndpoint.cpp b/cppcache/src/TcrEndpoint.cpp index 0ef91e2fb7..dce9b7da97 100644 --- a/cppcache/src/TcrEndpoint.cpp +++ b/cppcache/src/TcrEndpoint.cpp @@ -94,6 +94,8 @@ TcrEndpoint::~TcrEndpoint() { m_name.c_str()); // fail in dev build to track #295 better in regressions m_numRegionListener = 0; + // TODO suspect + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) closeNotification(); } } diff --git a/cppcache/src/ThinClientBaseDM.cpp b/cppcache/src/ThinClientBaseDM.cpp index 4acc0d234d..a47be6d98e 100644 --- a/cppcache/src/ThinClientBaseDM.cpp +++ b/cppcache/src/ThinClientBaseDM.cpp @@ -41,7 +41,7 @@ ThinClientBaseDM::ThinClientBaseDM(TcrConnectionManager& connManager, m_chunks(true), m_chunkProcessor(nullptr) {} -ThinClientBaseDM::~ThinClientBaseDM() = default; +ThinClientBaseDM::~ThinClientBaseDM() noexcept = default; void ThinClientBaseDM::init() { const auto& systemProperties = m_connManager.getCacheImpl() @@ -72,8 +72,7 @@ void ThinClientBaseDM::destroy(bool) { GfErrType ThinClientBaseDM::sendSyncRequestRegisterInterest( TcrMessage& request, TcrMessageReply& reply, bool attemptFailover, ThinClientRegion*, TcrEndpoint* endpoint) { - GfErrType err = GF_NOERR; - + GfErrType err; if (endpoint == nullptr) { err = sendSyncRequest(request, reply, attemptFailover); } else { @@ -150,10 +149,9 @@ GfErrType ThinClientBaseDM::handleEPError(TcrEndpoint* ep, GfErrType ThinClientBaseDM::sendRequestToEndPoint(const TcrMessage& request, TcrMessageReply& reply, TcrEndpoint* ep) { - GfErrType error = GF_NOERR; LOGDEBUG("ThinClientBaseDM::sendRequestToEP: invoking endpoint send for: %s", ep->name().c_str()); - error = ep->send(request, reply); + auto error = ep->send(request, reply); LOGDEBUG( "ThinClientBaseDM::sendRequestToEP: completed endpoint send for: %s " "[error:%d]", @@ -262,9 +260,8 @@ void ThinClientBaseDM::beforeSendingRequest(const TcrMessage& request, this->isSecurityOn(), this->isMultiUserMode(), request.getMessageType()); if (!(request.isMetaRegion()) && TcrMessage::isUserInitiativeOps(request) && (this->isSecurityOn() || this->isMultiUserMode())) { - int64_t connId = 0; + int64_t connId; int64_t uniqueId = 0; - if (!this->isMultiUserMode()) { connId = conn->getConnectionId(); uniqueId = conn->getEndpointObject()->getUniqueId(); diff --git a/cppcache/src/ThinClientBaseDM.hpp b/cppcache/src/ThinClientBaseDM.hpp index 61c3fe32ce..57ae3b67c4 100644 --- a/cppcache/src/ThinClientBaseDM.hpp +++ b/cppcache/src/ThinClientBaseDM.hpp @@ -49,7 +49,7 @@ class EventId; class ThinClientBaseDM { public: ThinClientBaseDM(TcrConnectionManager& connManager, ThinClientRegion* region); - virtual ~ThinClientBaseDM() = 0; + virtual ~ThinClientBaseDM() noexcept; virtual void init(); virtual void destroy(bool keepalive = false); diff --git a/cppcache/src/ThinClientCacheDistributionManager.hpp b/cppcache/src/ThinClientCacheDistributionManager.hpp index 29898e8465..d6edc9263c 100644 --- a/cppcache/src/ThinClientCacheDistributionManager.hpp +++ b/cppcache/src/ThinClientCacheDistributionManager.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_THINCLIENTCACHEDISTRIBUTIONMANAGER_H_ -#define GEODE_THINCLIENTCACHEDISTRIBUTIONMANAGER_H_ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,6 +15,11 @@ * limitations under the License. */ +#pragma once + +#ifndef GEODE_THINCLIENTCACHEDISTRIBUTIONMANAGER_H_ +#define GEODE_THINCLIENTCACHEDISTRIBUTIONMANAGER_H_ + #include #include @@ -29,37 +29,38 @@ namespace apache { namespace geode { namespace client { -/** - * @brief Distribute data between caches - */ + class TcrMessage; class TcrConnection; +/** + * @brief Distribute data between caches + */ class ThinClientCacheDistributionManager : public ThinClientDistributionManager { public: explicit ThinClientCacheDistributionManager( TcrConnectionManager& connManager); - ~ThinClientCacheDistributionManager() {} + ~ThinClientCacheDistributionManager() override {} - void init(); + void init() override; virtual GfErrType sendSyncRequest(TcrMessage& request, TcrMessageReply& reply, bool attemptFailover = true, - bool isBGThread = false); + bool isBGThread = false) override; GfErrType sendSyncRequestCq(TcrMessage& request, TcrMessageReply& reply); GfErrType sendRequestToPrimary(TcrMessage& request, TcrMessageReply& reply); protected: - virtual bool preFailoverAction(); - virtual bool postFailoverAction(TcrEndpoint* endpoint); + bool preFailoverAction() override; + bool postFailoverAction(TcrEndpoint* endpoint) override; - private: - // Disallow default/copy constructor and assignment operator. - ThinClientCacheDistributionManager(); - ThinClientCacheDistributionManager(const ThinClientCacheDistributionManager&); + public: + ThinClientCacheDistributionManager() = delete; + ThinClientCacheDistributionManager( + const ThinClientCacheDistributionManager&) = delete; ThinClientCacheDistributionManager& operator=( - const ThinClientCacheDistributionManager&); + const ThinClientCacheDistributionManager&) = delete; }; } // namespace client diff --git a/cppcache/src/ThinClientDistributionManager.hpp b/cppcache/src/ThinClientDistributionManager.hpp index b1657e1526..a00b64d9b1 100644 --- a/cppcache/src/ThinClientDistributionManager.hpp +++ b/cppcache/src/ThinClientDistributionManager.hpp @@ -32,7 +32,7 @@ class ThinClientDistributionManager : public ThinClientBaseDM { public: ThinClientDistributionManager(TcrConnectionManager& connManager, ThinClientRegion* region); - ~ThinClientDistributionManager() override = default; + ~ThinClientDistributionManager() noexcept override = default; void init() override; void destroy(bool keepalive = false) override; @@ -81,6 +81,7 @@ class ThinClientDistributionManager : public ThinClientBaseDM { std::vector m_endpoints; std::recursive_mutex m_endpointsLock; }; + } // namespace client } // namespace geode } // namespace apache diff --git a/cppcache/src/ThinClientPoolDM.cpp b/cppcache/src/ThinClientPoolDM.cpp index 52eca1e84a..aaccde25cb 100644 --- a/cppcache/src/ThinClientPoolDM.cpp +++ b/cppcache/src/ThinClientPoolDM.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include @@ -237,6 +236,8 @@ void ThinClientPoolDM::init() { } ThinClientPoolDM::~ThinClientPoolDM() { + // TODO suspect + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) destroy(); _GEODE_SAFE_DELETE(m_locHelper); _GEODE_SAFE_DELETE(m_stats); @@ -817,6 +818,8 @@ void ThinClientPoolDM::destroy(bool keepAlive) { m_PoolStatsSampler = nullptr; } LOGDEBUG("PoolStatsSampler thread closed ."); + // TODO suspect + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) stopCliCallbackThread(); LOGDEBUG("ThinClientPoolDM::destroy( ): Closing connection manager."); auto cacheImpl = m_connManager.getCacheImpl(); @@ -831,7 +834,11 @@ void ThinClientPoolDM::destroy(bool keepAlive) { } LOGDEBUG("Closing PoolStatsSampler thread."); + // TODO suspect + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) stopPingThread(); + // TODO suspect + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) stopUpdateLocatorListThread(); if (m_clientMetadataService) { @@ -847,6 +854,8 @@ void ThinClientPoolDM::destroy(bool keepAlive) { LOGDEBUG("ThinClientPoolDM::destroy( ): after close "); // Close Stats + // TODO suspect + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) getStats().close(); cacheImpl->getStatisticsManager().forceSample(); diff --git a/cppcache/src/ThinClientPoolDM.hpp b/cppcache/src/ThinClientPoolDM.hpp index 4e063992a4..ce1f8d83ee 100644 --- a/cppcache/src/ThinClientPoolDM.hpp +++ b/cppcache/src/ThinClientPoolDM.hpp @@ -342,7 +342,7 @@ class FunctionExecution : public PooledWork { m_userAttr = nullptr; } - ~FunctionExecution() {} + ~FunctionExecution() noexcept override = default; std::shared_ptr getException() { return exceptionPtr; } @@ -366,7 +366,7 @@ class FunctionExecution : public PooledWork { m_userAttr = userAttr; } - GfErrType execute(void); + GfErrType execute(void) override; }; class OnRegionFunctionExecution : public PooledWork { @@ -398,7 +398,7 @@ class OnRegionFunctionExecution : public PooledWork { const std::shared_ptr& serverLocation, bool allBuckets); - ~OnRegionFunctionExecution() { + ~OnRegionFunctionExecution() noexcept override { delete m_request; delete m_reply; delete m_resultCollector; @@ -414,7 +414,7 @@ class OnRegionFunctionExecution : public PooledWork { return static_cast(m_resultCollector); } - GfErrType execute(void) { + GfErrType execute(void) override { GuardUserAttributes gua; if (m_userAttr) { diff --git a/cppcache/src/ThinClientPoolHADM.cpp b/cppcache/src/ThinClientPoolHADM.cpp index 7f162a82a8..b940569aa5 100644 --- a/cppcache/src/ThinClientPoolHADM.cpp +++ b/cppcache/src/ThinClientPoolHADM.cpp @@ -26,6 +26,7 @@ namespace apache { namespace geode { namespace client { + const char* ThinClientPoolHADM::NC_Redundancy = "NC Redundancy"; ThinClientPoolHADM::ThinClientPoolHADM(const char* name, std::shared_ptr poolAttr, @@ -92,10 +93,7 @@ GfErrType ThinClientPoolHADM::sendSyncRequest(TcrMessage& request, TcrMessageReply& reply, bool attemptFailover, bool isBGThread) { - GfErrType err = GF_NOERR; - int32_t type = request.getMessageType(); - if ((type == TcrMessage::EXECUTECQ_MSG_TYPE || type == TcrMessage::STOPCQ_MSG_TYPE || type == TcrMessage::CLOSECQ_MSG_TYPE || @@ -106,12 +104,11 @@ GfErrType ThinClientPoolHADM::sendSyncRequest(TcrMessage& request, type == TcrMessage::GETDURABLECQS_MSG_TYPE)) { if (m_destroyPending) return GF_NOERR; reply.setDM(this); - err = sendSyncRequestCq(request, reply); + return sendSyncRequestCq(request, reply); } else { - err = ThinClientPoolDM::sendSyncRequest(request, reply, attemptFailover, - isBGThread); + return ThinClientPoolDM::sendSyncRequest(request, reply, attemptFailover, + isBGThread); } - return err; } bool ThinClientPoolHADM::registerInterestForHARegion( @@ -152,7 +149,6 @@ void ThinClientPoolHADM::redundancy(std::atomic& isRunning) { if (isRunning && !m_connManager.isNetDown()) { m_redundancyManager->maintainRedundancyLevel(); while (m_redundancySema.tryacquire() != -1) { - ; } } } @@ -202,17 +198,15 @@ void ThinClientPoolHADM::sendNotificationCloseMsgs() { GfErrType ThinClientPoolHADM::registerInterestAllRegions( TcrEndpoint* ep, const TcrMessage* request, TcrMessageReply* reply) { GfErrType err = GF_NOERR; - GfErrType opErr = GF_NOERR; std::lock_guard guard(m_regionsLock); - for (std::list::iterator itr = m_regions.begin(); - itr != m_regions.end(); itr++) { - if ((opErr = (*itr)->registerKeys(ep, request, reply)) != GF_NOERR) { - if (err == GF_NOERR) { - err = opErr; - } + for (const auto& region : m_regions) { + auto opErr = region->registerKeys(ep, request, reply); + if (err == GF_NOERR) { + err = opErr; } } + return err; } diff --git a/cppcache/src/ThinClientPoolStickyHADM.hpp b/cppcache/src/ThinClientPoolStickyHADM.hpp index 3c7566b4b4..2cbbd014dc 100644 --- a/cppcache/src/ThinClientPoolStickyHADM.hpp +++ b/cppcache/src/ThinClientPoolStickyHADM.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_THINCLIENTPOOLSTICKYHADM_H_ -#define GEODE_THINCLIENTPOOLSTICKYHADM_H_ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -19,11 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#pragma once + +#ifndef GEODE_THINCLIENTPOOLSTICKYHADM_H_ +#define GEODE_THINCLIENTPOOLSTICKYHADM_H_ + #include "ThinClientPoolHADM.hpp" namespace apache { namespace geode { namespace client { + class ThinClientPoolStickyHADM : public ThinClientPoolHADM { public: ThinClientPoolStickyHADM(const char* name, @@ -32,8 +34,9 @@ class ThinClientPoolStickyHADM : public ThinClientPoolHADM { : ThinClientPoolHADM(name, poolAttrs, connManager) { m_sticky = true; } - virtual ~ThinClientPoolStickyHADM() {} + ~ThinClientPoolStickyHADM() override = default; }; + } // namespace client } // namespace geode } // namespace apache diff --git a/cppcache/src/ThinClientRedundancyManager.cpp b/cppcache/src/ThinClientRedundancyManager.cpp index 03ac35474c..432cc4b000 100644 --- a/cppcache/src/ThinClientRedundancyManager.cpp +++ b/cppcache/src/ThinClientRedundancyManager.cpp @@ -14,12 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* - * ThinClientRedundancyManager.cpp - * - * Created on: Dec 1, 2008 - * Author: abhaware - */ #include "ThinClientRedundancyManager.hpp" @@ -35,7 +29,6 @@ #include "RemoteQueryService.hpp" #include "ServerLocation.hpp" #include "TcrHADistributionManager.hpp" -#include "ThinClientLocatorHelper.hpp" #include "ThinClientPoolHADM.hpp" #include "ThinClientRegion.hpp" #include "UserAttributes.hpp" @@ -1133,7 +1126,6 @@ void ThinClientRedundancyManager::periodicAck(std::atomic& isRunning) { if (isRunning) { doPeriodicAck(); while (m_periodicAckSema.tryacquire() != -1) { - ; } } } @@ -1169,7 +1161,7 @@ void ThinClientRedundancyManager::doPeriodicAck() { result = m_poolHADM->sendRequestToEP(request, reply, *endpoint); } else { result = (*endpoint)->send(request, reply); - }; + } if (result == GF_NOERR && reply.getMessageType() == TcrMessage::REPLY) { LOGFINE( diff --git a/cppcache/src/ThinClientRegion.cpp b/cppcache/src/ThinClientRegion.cpp index d49b1ac053..4fa88ba83d 100644 --- a/cppcache/src/ThinClientRegion.cpp +++ b/cppcache/src/ThinClientRegion.cpp @@ -18,7 +18,6 @@ #include "ThinClientRegion.hpp" #include -#include #include #include @@ -59,19 +58,15 @@ class PutAllWork : public PooledWork { std::shared_ptr m_serverLocation; TcrMessage* m_request; TcrMessageReply* m_reply; - MapOfUpdateCounters m_mapOfUpdateCounters; bool m_attemptFailover; bool m_isBGThread; std::shared_ptr m_userAttribute; const std::shared_ptr m_region; - std::shared_ptr>> m_keys; std::shared_ptr m_map; std::shared_ptr m_verObjPartListPtr; std::chrono::milliseconds m_timeout; std::shared_ptr m_papException; - bool m_isPapeReceived; ChunkedPutAllResponse* m_resultCollector; - // UNUSED const std::shared_ptr& m_aCallbackArgument; public: PutAllWork(const PutAllWork&) = delete; @@ -90,13 +85,9 @@ class PutAllWork : public PooledWork { m_isBGThread(isBGThread), m_userAttribute(nullptr), m_region(region), - m_keys(keys), m_map(map), m_timeout(timeout), - m_papException(nullptr), - m_isPapeReceived(false) - // UNUSED , m_aCallbackArgument(aCallbackArgument) - { + m_papException(nullptr) { m_request = new TcrMessagePutAll( new DataOutput(m_region->getCache().createDataOutput()), m_region.get(), *m_map, m_timeout, m_poolDM, aCallbackArgument); @@ -118,20 +109,14 @@ class PutAllWork : public PooledWork { m_reply->setChunkedResultHandler(m_resultCollector); } - ~PutAllWork() { + ~PutAllWork() noexcept override { delete m_request; delete m_reply; delete m_resultCollector; } - TcrMessage* getReply() { return m_reply; } - std::shared_ptr getPutAllMap() { return m_map; } - std::shared_ptr getVerObjPartList() { - return m_verObjPartListPtr; - } - ChunkedPutAllResponse* getResultCollector() { return m_resultCollector; } std::shared_ptr getServerLocation() { @@ -143,7 +128,7 @@ class PutAllWork : public PooledWork { } void init() {} - GfErrType execute(void) { + GfErrType execute(void) override { GuardUserAttributes gua; if (m_userAttribute != nullptr) { @@ -175,7 +160,6 @@ class PutAllWork : public PooledWork { // TODO::Check for the PAPException and READ // PutAllPartialResultServerException and set its member for later use. // set m_papException and m_isPapeReceived - m_isPapeReceived = true; if (m_poolDM->isNotAuthorizedException(m_reply->getException())) { LOGDEBUG("received NotAuthorizedException"); err = GF_AUTHENTICATION_FAILED_EXCEPTION; @@ -208,16 +192,13 @@ class RemoveAllWork : public PooledWork { std::shared_ptr m_serverLocation; TcrMessage* m_request; TcrMessageReply* m_reply; - MapOfUpdateCounters m_mapOfUpdateCounters; bool m_attemptFailover; bool m_isBGThread; std::shared_ptr m_userAttribute; const std::shared_ptr m_region; const std::shared_ptr& m_aCallbackArgument; - std::shared_ptr>> m_keys; std::shared_ptr m_verObjPartListPtr; std::shared_ptr m_papException; - bool m_isPapeReceived; ChunkedRemoveAllResponse* m_resultCollector; public: @@ -237,9 +218,7 @@ class RemoveAllWork : public PooledWork { m_userAttribute(nullptr), m_region(region), m_aCallbackArgument(aCallbackArgument), - m_keys(keys), - m_papException(nullptr), - m_isPapeReceived(false) { + m_papException(nullptr) { m_request = new TcrMessageRemoveAll( new DataOutput(m_region->getCache().createDataOutput()), m_region.get(), *keys, m_aCallbackArgument, m_poolDM); @@ -253,23 +232,17 @@ class RemoveAllWork : public PooledWork { m_userAttribute = UserAttributes::threadLocalUserAttributes; } - m_resultCollector = new ChunkedRemoveAllResponse( - m_region, *m_reply, responseLock, m_verObjPartListPtr); + m_resultCollector = + new ChunkedRemoveAllResponse(m_region, *m_reply, m_verObjPartListPtr); m_reply->setChunkedResultHandler(m_resultCollector); } - ~RemoveAllWork() { + ~RemoveAllWork() noexcept override { delete m_request; delete m_reply; delete m_resultCollector; } - TcrMessage* getReply() { return m_reply; } - - std::shared_ptr getVerObjPartList() { - return m_verObjPartListPtr; - } - ChunkedRemoveAllResponse* getResultCollector() { return m_resultCollector; } std::shared_ptr getServerLocation() { @@ -281,7 +254,7 @@ class RemoveAllWork : public PooledWork { } void init() {} - GfErrType execute(void) { + GfErrType execute(void) override { GuardUserAttributes gua; if (m_userAttribute != nullptr) { @@ -313,7 +286,6 @@ class RemoveAllWork : public PooledWork { // TODO::Check for the PAPException and READ // PutAllPartialResultServerException and set its member for later use. // set m_papException and m_isPapeReceived - m_isPapeReceived = true; if (m_poolDM->isNotAuthorizedException(m_reply->getException())) { LOGDEBUG("received NotAuthorizedException"); err = GF_AUTHENTICATION_FAILED_EXCEPTION; @@ -1913,7 +1885,7 @@ GfErrType ThinClientRegion::multiHopRemoveAllNoThrow_remote( std::make_shared(this, responseLock); // need to check ChunkedRemoveAllResponse* resultCollector(new ChunkedRemoveAllResponse( - shared_from_this(), reply, responseLock, versionedObjPartList)); + shared_from_this(), reply, versionedObjPartList)); reply.setChunkedResultHandler(resultCollector); err = m_tcrdm->sendSyncRequest(request, reply); @@ -2878,22 +2850,6 @@ InterestResultPolicy ThinClientRegion::copyInterestList( return interestPolicy; } -void ThinClientRegion::registerInterestGetValues( - const char* method, const std::vector>* keys, - const std::shared_ptr>>& - resultKeys) { - auto exceptions = std::make_shared(); - auto err = getAllNoThrow_remote(keys, nullptr, exceptions, resultKeys, true, - nullptr); - throwExceptionIfError(method, err); - // log any exceptions here - for (const auto& iter : *exceptions) { - LOGWARN("%s Exception for key %s:: %s: %s", method, - Utils::nullSafeToString(iter.first).c_str(), - iter.second->getName().c_str(), iter.second->what()); - } -} - void ThinClientRegion::destroyDM(bool keepEndpoints) { if (m_tcrdm != nullptr) { m_tcrdm->destroy(keepEndpoints); @@ -2910,6 +2866,8 @@ void ThinClientRegion::release(bool invokeCallbacks) { lock.lock(); } + // TODO suspect + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) destroyDM(invokeCallbacks); m_interestList.clear(); @@ -2928,6 +2886,8 @@ void ThinClientRegion::release(bool invokeCallbacks) { ThinClientRegion::~ThinClientRegion() noexcept { TryWriteGuard guard(m_rwLock, m_destroyPending); if (!m_destroyPending) { + // TODO suspect + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) release(false); } } diff --git a/cppcache/src/ThinClientRegion.hpp b/cppcache/src/ThinClientRegion.hpp index f62bee935c..03d02665a2 100644 --- a/cppcache/src/ThinClientRegion.hpp +++ b/cppcache/src/ThinClientRegion.hpp @@ -321,12 +321,6 @@ class APACHE_GEODE_EXPORT ThinClientRegion : public LocalRegion { const std::shared_ptr& keyPtr, const std::shared_ptr& cvalue, const std::shared_ptr& aCallbackArgument); - // method to get the values for a register interest - void registerInterestGetValues( - const char* method, - const std::vector>* keys, - const std::shared_ptr>>& - resultKeys); GfErrType getNoThrow_FullObject( std::shared_ptr eventId, std::shared_ptr& fullObject, std::shared_ptr& versionTag) override; @@ -380,10 +374,6 @@ class ChunkedInterestResponse : public TcrChunkedResult { TcrMessage& m_replyMsg; std::shared_ptr>> m_resultKeys; - // disabled - ChunkedInterestResponse(const ChunkedInterestResponse&); - ChunkedInterestResponse& operator=(const ChunkedInterestResponse&); - public: inline ChunkedInterestResponse( TcrMessage& msg, @@ -395,15 +385,20 @@ class ChunkedInterestResponse : public TcrChunkedResult { m_replyMsg(replyMsg), m_resultKeys(resultKeys) {} + ChunkedInterestResponse(const ChunkedInterestResponse&) = delete; + ChunkedInterestResponse& operator=(const ChunkedInterestResponse&) = delete; + + ~ChunkedInterestResponse() noexcept override = default; + inline const std::shared_ptr>>& getResultKeys() const { return m_resultKeys; } - virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen, - uint8_t isLastChunkWithSecurity, - const CacheImpl* cacheImpl); - virtual void reset(); + void handleChunk(const uint8_t* chunk, int32_t chunkLen, + uint8_t isLastChunkWithSecurity, + const CacheImpl* cacheImpl) override; + virtual void reset() override; }; /** @@ -419,16 +414,17 @@ class ChunkedQueryResponse : public TcrChunkedResult { void skipClass(DataInput& input); - // disabled - ChunkedQueryResponse(const ChunkedQueryResponse&); - ChunkedQueryResponse& operator=(const ChunkedQueryResponse&); - public: inline explicit ChunkedQueryResponse(TcrMessage& msg) : TcrChunkedResult(), m_msg(msg), m_queryResults(CacheableVector::create()) {} + ChunkedQueryResponse(const ChunkedQueryResponse&) = delete; + ChunkedQueryResponse& operator=(const ChunkedQueryResponse&) = delete; + + ~ChunkedQueryResponse() noexcept override = default; + inline const std::shared_ptr& getQueryResults() const { return m_queryResults; } @@ -437,10 +433,10 @@ class ChunkedQueryResponse : public TcrChunkedResult { return m_structFieldNames; } - virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen, - uint8_t isLastChunkWithSecurity, - const CacheImpl* cacheImpl); - virtual void reset(); + void handleChunk(const uint8_t* chunk, int32_t chunkLen, + uint8_t isLastChunkWithSecurity, + const CacheImpl* cacheImpl) override; + void reset() override; void readObjectPartList(DataInput& input, bool isResultSet); }; @@ -458,11 +454,6 @@ class ChunkedFunctionExecutionResponse : public TcrChunkedResult { std::shared_ptr m_rc; std::shared_ptr m_resultCollectorLock; - // disabled - ChunkedFunctionExecutionResponse(const ChunkedFunctionExecutionResponse&); - ChunkedFunctionExecutionResponse& operator=( - const ChunkedFunctionExecutionResponse&); - public: inline ChunkedFunctionExecutionResponse(TcrMessage& msg, bool getResult, std::shared_ptr rc) @@ -477,22 +468,19 @@ class ChunkedFunctionExecutionResponse : public TcrChunkedResult { m_rc(rc), m_resultCollectorLock(resultCollectorLock) {} - /* inline const std::shared_ptr& - getFunctionExecutionResults() const - { - return m_functionExecutionResults; - }*/ + ChunkedFunctionExecutionResponse(const ChunkedFunctionExecutionResponse&) = + delete; + ChunkedFunctionExecutionResponse& operator=( + const ChunkedFunctionExecutionResponse&) = delete; + + ~ChunkedFunctionExecutionResponse() noexcept override = default; - /* adongre - * CID 28805: Parse warning (PW.USELESS_TYPE_QUALIFIER_ON_RETURN_TYPE) - */ - // inline const bool getResult() const inline bool getResult() const { return m_getResult; } - virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen, - uint8_t isLastChunkWithSecurity, - const CacheImpl* cacheImpl); - virtual void reset(); + void handleChunk(const uint8_t* chunk, int32_t chunkLen, + uint8_t isLastChunkWithSecurity, + const CacheImpl* cacheImpl) override; + void reset() override; }; /** @@ -513,9 +501,6 @@ class ChunkedGetAllResponse : public TcrChunkedResult { bool m_addToLocalCache; uint32_t m_keysOffset; std::recursive_mutex& m_responseLock; - // disabled - ChunkedGetAllResponse(const ChunkedGetAllResponse&); - ChunkedGetAllResponse& operator=(const ChunkedGetAllResponse&); public: inline ChunkedGetAllResponse( @@ -540,10 +525,15 @@ class ChunkedGetAllResponse : public TcrChunkedResult { m_keysOffset(0), m_responseLock(responseLock) {} - virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen, - uint8_t isLastChunkWithSecurity, - const CacheImpl* cacheImpl); - virtual void reset(); + ChunkedGetAllResponse(const ChunkedGetAllResponse&) = delete; + ChunkedGetAllResponse& operator=(const ChunkedGetAllResponse&) = delete; + + ~ChunkedGetAllResponse() noexcept override = default; + + void handleChunk(const uint8_t* chunk, int32_t chunkLen, + uint8_t isLastChunkWithSecurity, + const CacheImpl* cacheImpl) override; + void reset() override; void add(const ChunkedGetAllResponse* other); bool getAddToLocalCache() { return m_addToLocalCache; } @@ -565,9 +555,6 @@ class ChunkedPutAllResponse : public TcrChunkedResult { const std::shared_ptr m_region; std::recursive_mutex& m_responseLock; std::shared_ptr m_list; - // disabled - ChunkedPutAllResponse(const ChunkedPutAllResponse&); - ChunkedPutAllResponse& operator=(const ChunkedPutAllResponse&); public: inline ChunkedPutAllResponse( @@ -580,10 +567,15 @@ class ChunkedPutAllResponse : public TcrChunkedResult { m_responseLock(responseLock), m_list(list) {} - virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen, - uint8_t isLastChunkWithSecurity, - const CacheImpl* cacheImpl); - virtual void reset(); + ChunkedPutAllResponse(const ChunkedPutAllResponse&) = delete; + ChunkedPutAllResponse& operator=(const ChunkedPutAllResponse&) = delete; + + ~ChunkedPutAllResponse() noexcept override = default; + + void handleChunk(const uint8_t* chunk, int32_t chunkLen, + uint8_t isLastChunkWithSecurity, + const CacheImpl* cacheImpl) override; + void reset() override; std::shared_ptr getList() { return m_list; } std::recursive_mutex& getResponseLock() { return m_responseLock; } }; @@ -595,29 +587,24 @@ class ChunkedRemoveAllResponse : public TcrChunkedResult { private: TcrMessage& m_msg; const std::shared_ptr m_region; - std::recursive_mutex& m_responseLock; std::shared_ptr m_list; - // disabled - ChunkedRemoveAllResponse(const ChunkedRemoveAllResponse&); - ChunkedRemoveAllResponse& operator=(const ChunkedRemoveAllResponse&); public: inline ChunkedRemoveAllResponse( const std::shared_ptr& region, TcrMessage& msg, - std::recursive_mutex& responseLock, std::shared_ptr& list) - : TcrChunkedResult(), - m_msg(msg), - m_region(region), - m_responseLock(responseLock), - m_list(list) {} + : TcrChunkedResult(), m_msg(msg), m_region(region), m_list(list) {} + + ChunkedRemoveAllResponse(const ChunkedRemoveAllResponse&) = delete; + ChunkedRemoveAllResponse& operator=(const ChunkedRemoveAllResponse&) = delete; - virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen, - uint8_t isLastChunkWithSecurity, - const CacheImpl* cacheImpl); - virtual void reset(); + ~ChunkedRemoveAllResponse() noexcept override = default; + + void handleChunk(const uint8_t* chunk, int32_t chunkLen, + uint8_t isLastChunkWithSecurity, + const CacheImpl* cacheImpl) override; + void reset() override; std::shared_ptr getList() { return m_list; } - std::recursive_mutex& getResponseLock() { return m_responseLock; } }; /** @@ -631,10 +618,6 @@ class ChunkedKeySetResponse : public TcrChunkedResult { TcrMessage& m_replyMsg; std::vector>& m_resultKeys; - // disabled - ChunkedKeySetResponse(const ChunkedKeySetResponse&); - ChunkedKeySetResponse& operator=(const ChunkedKeySetResponse&); - public: inline ChunkedKeySetResponse( TcrMessage& msg, std::vector>& resultKeys, @@ -644,10 +627,15 @@ class ChunkedKeySetResponse : public TcrChunkedResult { m_replyMsg(replyMsg), m_resultKeys(resultKeys) {} - virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen, - uint8_t isLastChunkWithSecurity, - const CacheImpl* cacheImpl); - virtual void reset(); + ChunkedKeySetResponse(const ChunkedKeySetResponse&) = delete; + ChunkedKeySetResponse& operator=(const ChunkedKeySetResponse&) = delete; + + ~ChunkedKeySetResponse() noexcept override = default; + + void handleChunk(const uint8_t* chunk, int32_t chunkLen, + uint8_t isLastChunkWithSecurity, + const CacheImpl* cacheImpl) override; + void reset() override; }; class ChunkedDurableCQListResponse : public TcrChunkedResult { @@ -655,10 +643,6 @@ class ChunkedDurableCQListResponse : public TcrChunkedResult { TcrMessage& m_msg; std::shared_ptr m_resultList; - // disabled - ChunkedDurableCQListResponse(const ChunkedDurableCQListResponse&); - ChunkedDurableCQListResponse& operator=(const ChunkedDurableCQListResponse&); - public: inline explicit ChunkedDurableCQListResponse(TcrMessage& msg) : TcrChunkedResult(), @@ -668,10 +652,16 @@ class ChunkedDurableCQListResponse : public TcrChunkedResult { return m_resultList; } - virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen, - uint8_t isLastChunkWithSecurity, - const CacheImpl* cacheImpl); - virtual void reset(); + ChunkedDurableCQListResponse(const ChunkedDurableCQListResponse&) = delete; + ChunkedDurableCQListResponse& operator=(const ChunkedDurableCQListResponse&) = + delete; + + ~ChunkedDurableCQListResponse() noexcept override = default; + + void handleChunk(const uint8_t* chunk, int32_t chunkLen, + uint8_t isLastChunkWithSecurity, + const CacheImpl* cacheImpl) override; + void reset() override; }; } // namespace client diff --git a/cppcache/src/ThreadPool.hpp b/cppcache/src/ThreadPool.hpp index d72f12a786..a534bb0ed4 100644 --- a/cppcache/src/ThreadPool.hpp +++ b/cppcache/src/ThreadPool.hpp @@ -50,7 +50,7 @@ class PooledWork : public Callable { public: PooledWork() : m_mutex(), m_cond(), m_done(false) {} - ~PooledWork() override {} + ~PooledWork() noexcept override = default; void call() override { T res = execute(); diff --git a/cppcache/src/TrackedMapEntry.hpp b/cppcache/src/TrackedMapEntry.hpp index 7767b7e293..42fb357e89 100644 --- a/cppcache/src/TrackedMapEntry.hpp +++ b/cppcache/src/TrackedMapEntry.hpp @@ -36,7 +36,7 @@ class TrackedMapEntry final : public MapEntry { m_trackingNumber(trackingNumber), m_updateCount(updateCount) {} - virtual ~TrackedMapEntry() {} + ~TrackedMapEntry() noexcept override = default; std::shared_ptr getImplPtr() final { return m_entry; } diff --git a/cppcache/src/VersionStamp.hpp b/cppcache/src/VersionStamp.hpp index 211641379b..47ee64709c 100644 --- a/cppcache/src/VersionStamp.hpp +++ b/cppcache/src/VersionStamp.hpp @@ -31,10 +31,11 @@ namespace apache { namespace geode { namespace client { + /** * @brief This class encapsulates Version Stamp for map entries. */ -class APACHE_GEODE_EXPORT VersionStamp { +class VersionStamp { public: VersionStamp() : m_memberID(0), @@ -50,7 +51,7 @@ class APACHE_GEODE_EXPORT VersionStamp { m_regionVersionHighBytes(rhs.m_regionVersionHighBytes), m_regionVersionLowBytes(rhs.m_regionVersionLowBytes) {} - virtual ~VersionStamp() {} + virtual ~VersionStamp() noexcept = default; void setVersions(std::shared_ptr versionTag); void setVersions(VersionStamp& versionStamp); int32_t getEntryVersion() const; diff --git a/cppcache/src/VersionedCacheableObjectPartList.cpp b/cppcache/src/VersionedCacheableObjectPartList.cpp index 15b8ea3f39..7190424cfc 100644 --- a/cppcache/src/VersionedCacheableObjectPartList.cpp +++ b/cppcache/src/VersionedCacheableObjectPartList.cpp @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "VersionedCacheableObjectPartList.hpp" #include @@ -23,6 +24,7 @@ #include "DiskStoreId.hpp" #include "DiskVersionTag.hpp" #include "ThinClientRegion.hpp" + namespace apache { namespace geode { namespace client { @@ -181,7 +183,6 @@ void VersionedCacheableObjectPartList::fromData(DataInput& input) { if (m_hasTags) { len = static_cast(input.readUnsignedVL()); - ; m_versionTags.resize(len); std::vector ids; MemberListForVersionStamp& memberListForVersionStamp = diff --git a/cppcache/src/statistics/OsStatisticsImpl.cpp b/cppcache/src/statistics/OsStatisticsImpl.cpp index 63f3ca3444..a55b780998 100644 --- a/cppcache/src/statistics/OsStatisticsImpl.cpp +++ b/cppcache/src/statistics/OsStatisticsImpl.cpp @@ -85,10 +85,6 @@ OsStatisticsImpl::OsStatisticsImpl(StatisticsType* typeArg, this->numericId = calcNumericId(system, numericIdArg); this->uniqueId = uniqueIdArg; this->closed = false; - ; - /* adongre - * CID 28981: Uninitialized pointer field (UNINIT_CTOR) - */ doubleStorage = nullptr; intStorage = nullptr; longStorage = nullptr; @@ -125,22 +121,18 @@ OsStatisticsImpl::OsStatisticsImpl(StatisticsType* typeArg, } OsStatisticsImpl::~OsStatisticsImpl() noexcept { - try { - statsType = nullptr; - if (intStorage != nullptr) { - delete[] intStorage; - intStorage = nullptr; - } - if (longStorage != nullptr) { - delete[] longStorage; - longStorage = nullptr; - } - if (doubleStorage != nullptr) { - delete[] doubleStorage; - doubleStorage = nullptr; - } - } catch (...) { - LOGERROR("Exception in ~OsStatisticsImpl"); + statsType = nullptr; + if (intStorage != nullptr) { + delete[] intStorage; + intStorage = nullptr; + } + if (longStorage != nullptr) { + delete[] longStorage; + longStorage = nullptr; + } + if (doubleStorage != nullptr) { + delete[] doubleStorage; + doubleStorage = nullptr; } } diff --git a/cppcache/test/CacheableDateTest.cpp b/cppcache/test/CacheableDateTest.cpp index a22774e141..e133551a27 100644 --- a/cppcache/test/CacheableDateTest.cpp +++ b/cppcache/test/CacheableDateTest.cpp @@ -26,14 +26,14 @@ using apache::geode::client::CacheableDate; -TEST(CacheableDateTest, constructFrom_time_t_WithDefault) { +TEST(CacheableDateTest, constructFromTimeTWithDefault) { const CacheableDate cacheableDate; EXPECT_EQ(0, cacheableDate.milliseconds()); EXPECT_EQ(0, static_cast(cacheableDate)); } -TEST(CacheableDateTest, constructFrom_time_t) { +TEST(CacheableDateTest, constructFromTimeT) { time_t time = 0; std::time(&time); CacheableDate cacheableDate(time); @@ -42,7 +42,7 @@ TEST(CacheableDateTest, constructFrom_time_t) { EXPECT_EQ(time, static_cast(cacheableDate)); } -TEST(CacheableDateTest, constructFrom_time_point) { +TEST(CacheableDateTest, constructFromTimePoint) { const auto timePoint = CacheableDate::clock::now(); const CacheableDate cacheableDate(timePoint); @@ -61,7 +61,7 @@ TEST(CacheableDateTest, constructFrom_time_point) { EXPECT_EQ(time, static_cast(cacheableDate)); } -TEST(CacheableDateTest, constructFrom_duration) { +TEST(CacheableDateTest, constructFromDuration) { const auto duration = CacheableDate::duration(1000); const CacheableDate cacheableDate(duration); diff --git a/cppcache/test/CacheableKeyCreateTests.cpp b/cppcache/test/CacheableKeyCreateTests.cpp index 901671fdf1..6216e97c86 100644 --- a/cppcache/test/CacheableKeyCreateTests.cpp +++ b/cppcache/test/CacheableKeyCreateTests.cpp @@ -36,7 +36,7 @@ using apache::geode::client::CacheableInt64; using apache::geode::client::CacheableKey; using apache::geode::client::CacheableString; -TEST(CacheableKeyCreateTests, forArrayOf_constchar) { +TEST(CacheableKeyCreateTests, forArrayOfConstChar) { const auto cacheableKey = CacheableKey::create("test"); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableString = @@ -45,7 +45,7 @@ TEST(CacheableKeyCreateTests, forArrayOf_constchar) { EXPECT_EQ(cacheableString->value(), "test"); } -TEST(CacheableKeyCreateTests, forArrayOf_char) { +TEST(CacheableKeyCreateTests, forArrayOfChar) { char* test = new char[5]{'t', 'e', 's', 't', '\0'}; const auto cacheableKey = CacheableKey::create(test); ASSERT_TRUE(nullptr != cacheableKey); @@ -55,7 +55,7 @@ TEST(CacheableKeyCreateTests, forArrayOf_char) { EXPECT_EQ(cacheableString->value(), "test"); } -TEST(CacheableKeyCreateTests, forArrayOf_char16_t) { +TEST(CacheableKeyCreateTests, forArrayOfChar16) { const auto cacheableKey = CacheableKey::create(u"test"); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableString = @@ -64,7 +64,7 @@ TEST(CacheableKeyCreateTests, forArrayOf_char16_t) { EXPECT_EQ(cacheableString->value(), "test"); } -TEST(CacheableKeyCreateTests, forArrayOf_char32_t) { +TEST(CacheableKeyCreateTests, forArrayOfChar32) { const auto cacheableKey = CacheableKey::create(U"test"); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableString = @@ -73,7 +73,7 @@ TEST(CacheableKeyCreateTests, forArrayOf_char32_t) { ASSERT_EQ(cacheableString->value(), "test"); } -TEST(CacheableKeyCreateTests, forArrayOf_wchar_t) { +TEST(CacheableKeyCreateTests, forArrayOfWchar) { const auto cacheableKey = CacheableKey::create(L"test"); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableString = @@ -82,7 +82,7 @@ TEST(CacheableKeyCreateTests, forArrayOf_wchar_t) { EXPECT_EQ(cacheableString->value(), "test"); } -TEST(CacheableKeyCreateTests, for_string) { +TEST(CacheableKeyCreateTests, forString) { const auto cacheableKey = CacheableKey::create(std::string("test")); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableString = @@ -91,7 +91,7 @@ TEST(CacheableKeyCreateTests, for_string) { EXPECT_EQ(cacheableString->value(), "test"); } -TEST(CacheableKeyCreateTests, for_u16string) { +TEST(CacheableKeyCreateTests, forU16string) { const auto cacheableKey = CacheableKey::create(std::u16string(u"test")); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableString = @@ -100,7 +100,7 @@ TEST(CacheableKeyCreateTests, for_u16string) { EXPECT_EQ(cacheableString->value(), "test"); } -TEST(CacheableKeyCreateTests, for_u32string) { +TEST(CacheableKeyCreateTests, forU32string) { const auto cacheableKey = CacheableKey::create(std::u32string(U"test")); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableString = @@ -109,7 +109,7 @@ TEST(CacheableKeyCreateTests, for_u32string) { EXPECT_EQ(cacheableString->value(), "test"); } -TEST(CacheableKeyCreateTests, for_wstring) { +TEST(CacheableKeyCreateTests, forWstring) { const auto cacheableKey = CacheableKey::create(std::wstring(L"test")); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableString = @@ -118,7 +118,7 @@ TEST(CacheableKeyCreateTests, for_wstring) { EXPECT_EQ(cacheableString->value(), "test"); } -TEST(CacheableKeyCreateTests, for_int8_t) { +TEST(CacheableKeyCreateTests, forInt8) { const auto cacheableKey = CacheableKey::create(static_cast(1)); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableByte = std::dynamic_pointer_cast(cacheableKey); @@ -126,7 +126,7 @@ TEST(CacheableKeyCreateTests, for_int8_t) { EXPECT_EQ(cacheableByte->value(), 1); } -TEST(CacheableKeyCreateTests, for_int16_t) { +TEST(CacheableKeyCreateTests, forInt16) { const auto cacheableKey = CacheableKey::create(static_cast(1)); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableInt16 = @@ -135,7 +135,7 @@ TEST(CacheableKeyCreateTests, for_int16_t) { ASSERT_EQ(cacheableInt16->value(), 1); } -TEST(CacheableKeyCreateTests, for_int32_t) { +TEST(CacheableKeyCreateTests, forInt32) { const auto cacheableKey = CacheableKey::create(static_cast(1)); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableInt32 = @@ -144,7 +144,7 @@ TEST(CacheableKeyCreateTests, for_int32_t) { ASSERT_EQ(cacheableInt32->value(), 1); } -TEST(CacheableKeyCreateTests, for_int64_t) { +TEST(CacheableKeyCreateTests, forInt64) { const auto cacheableKey = CacheableKey::create(static_cast(1)); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableInt64 = @@ -153,7 +153,7 @@ TEST(CacheableKeyCreateTests, for_int64_t) { EXPECT_EQ(cacheableInt64->value(), 1); } -TEST(CacheableKeyCreateTests, for_char16_t) { +TEST(CacheableKeyCreateTests, forChar16) { const auto cacheableKey = CacheableKey::create(u'a'); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableCharacter = @@ -162,7 +162,7 @@ TEST(CacheableKeyCreateTests, for_char16_t) { EXPECT_EQ(cacheableCharacter->value(), u'a'); } -TEST(CacheableKeyCreateTests, for_float) { +TEST(CacheableKeyCreateTests, forFloat) { const auto cacheableKey = CacheableKey::create(1.1f); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableFloat = @@ -171,7 +171,7 @@ TEST(CacheableKeyCreateTests, for_float) { EXPECT_EQ(cacheableFloat->value(), 1.1f); } -TEST(CacheableKeyCreateTests, for_double) { +TEST(CacheableKeyCreateTests, forDouble) { const auto cacheableKey = CacheableKey::create(1.1); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableDouble = @@ -180,7 +180,7 @@ TEST(CacheableKeyCreateTests, for_double) { EXPECT_EQ(cacheableDouble->value(), 1.1); } -TEST(CacheableKeyCreateTests, for_bool) { +TEST(CacheableKeyCreateTests, forBool) { const auto cacheableKey = CacheableKey::create(true); ASSERT_TRUE(nullptr != cacheableKey); auto&& cacheableBoolean = @@ -189,7 +189,7 @@ TEST(CacheableKeyCreateTests, for_bool) { EXPECT_EQ(cacheableBoolean->value(), true); } -TEST(CacheableKeyCreateTests, for_timepoint) { +TEST(CacheableKeyCreateTests, forTimepoint) { auto time = std::chrono::system_clock::now(); const auto cacheableKey = CacheableKey::create(time); ASSERT_TRUE(nullptr != cacheableKey); diff --git a/cppcache/test/CacheableKeysTest.cpp b/cppcache/test/CacheableKeysTest.cpp index 58167d9608..1b5a1cac8f 100644 --- a/cppcache/test/CacheableKeysTest.cpp +++ b/cppcache/test/CacheableKeysTest.cpp @@ -26,25 +26,25 @@ TEST(CacheableKeysTest, boolDifferentHashCodes) { << "Two different bool values have different hashcodes"; } -TEST(CacheableKeysTest, int8_tDifferentHashCodes) { +TEST(CacheableKeysTest, int8DifferentHashCodes) { EXPECT_NE(hashcode(static_cast(37)), hashcode(static_cast(42))) << "Two different int8_t values have different hashcodes"; } -TEST(CacheableKeysTest, int16_tDifferentHashCodes) { +TEST(CacheableKeysTest, int16DifferentHashCodes) { EXPECT_NE(hashcode(static_cast(37)), hashcode(static_cast(42))) << "Two different int16_t values have different hashcodes"; } -TEST(CacheableKeysTest, int32_tDifferentHashCodes) { +TEST(CacheableKeysTest, int32DifferentHashCodes) { EXPECT_NE(hashcode(static_cast(37)), hashcode(static_cast(42))) << "Two different int32_t values have different hashcodes"; } -TEST(CacheableKeysTest, int64_tDifferentHashCodes) { +TEST(CacheableKeysTest, int64DifferentHashCodes) { EXPECT_NE(hashcode(static_cast(37)), hashcode(static_cast(42))) << "Two different int64_t values have different hashcodes"; diff --git a/cppcache/test/ChunkedHeaderTest.cpp b/cppcache/test/ChunkedHeaderTest.cpp index 767c8fcb3e..a1280e9233 100644 --- a/cppcache/test/ChunkedHeaderTest.cpp +++ b/cppcache/test/ChunkedHeaderTest.cpp @@ -34,7 +34,7 @@ namespace { class TcrMessageTestFixture : public TcrMessage { public: TcrMessageTestFixture() : TcrMessage() {} - virtual ~TcrMessageTestFixture() {} + ~TcrMessageTestFixture() noexcept override = default; }; } // namespace diff --git a/cppcache/test/DataInputTest.cpp b/cppcache/test/DataInputTest.cpp index 27d22e83d3..1ac81cca35 100644 --- a/cppcache/test/DataInputTest.cpp +++ b/cppcache/test/DataInputTest.cpp @@ -62,9 +62,7 @@ class TestDataInput { public: explicit TestDataInput(const char *str) : m_byteArray(ByteArray::fromString(str)), - m_dataInput(m_byteArray.get(), m_byteArray.size()) { - // NOP - } + m_dataInput(m_byteArray.get(), m_byteArray.size()) {} void read(uint8_t *value) { *value = m_dataInput.read(); } @@ -258,8 +256,16 @@ TEST_F(DataInputTest, CanReadUTFWithAnUTFStringInput) { DataOutputInternal stream; stream.writeUTF(expectedString); - DataInputUnderTest dataInput(stream.getBufferCopy(), - stream.getBufferLength()); + size_t outputBufferSize; + auto outputBuffer = stream.getBuffer(&outputBufferSize); + + auto buffer = std::unique_ptr{ + reinterpret_cast( + std::malloc(sizeof(uint8_t) * outputBufferSize)), + std::free}; + std::memcpy(buffer.get(), outputBuffer, outputBufferSize); + + DataInputUnderTest dataInput(buffer.get(), stream.getBufferLength()); auto actualString = dataInput.readUTF(); EXPECT_TRUE(expectedString == actualString); @@ -315,7 +321,7 @@ TEST_F(DataInputTest, TestReadBoolean) { EXPECT_EQ(true, value) << "Correct bool"; } -TEST_F(DataInputTest, TestReadUint8_tBytesOnly) { +TEST_F(DataInputTest, TestReadUint8BytesOnly) { TestDataInput dataInput("BABEFACE"); uint8_t buffer[4]; ::memset(buffer, 0U, 4 * sizeof(uint8_t)); @@ -326,7 +332,7 @@ TEST_F(DataInputTest, TestReadUint8_tBytesOnly) { EXPECT_EQ(static_cast(206U), buffer[3]) << "Correct third uint8_t"; } -TEST_F(DataInputTest, TestReadInt8_tBytesOnly) { +TEST_F(DataInputTest, TestReadInt8BytesOnly) { TestDataInput dataInput("DEADBEEF"); int8_t buffer[4]; ::memset(buffer, 0, 4 * sizeof(int8_t)); @@ -337,32 +343,38 @@ TEST_F(DataInputTest, TestReadInt8_tBytesOnly) { EXPECT_EQ(static_cast(-17), buffer[3]) << "Correct third int8_t"; } -TEST_F(DataInputTest, TestReadUint8_tBytes) { +TEST_F(DataInputTest, TestReadUint8Bytes) { TestDataInput dataInput("04BABEFACE"); uint8_t *buffer = nullptr; int32_t len = 0; dataInput.readBytes(&buffer, &len); - EXPECT_NE(static_cast(nullptr), buffer) << "Non-null buffer"; + auto bufferGuard = std::unique_ptr{buffer}; + ASSERT_NE(nullptr, buffer) << "Non-null buffer"; ASSERT_EQ(4, len) << "Correct length"; - EXPECT_EQ(static_cast(186U), buffer[0]) << "Correct zeroth uint8_t"; - EXPECT_EQ(static_cast(190U), buffer[1]) << "Correct first uint8_t"; - EXPECT_EQ(static_cast(250U), buffer[2]) << "Correct second uint8_t"; - EXPECT_EQ(static_cast(206U), buffer[3]) << "Correct third uint8_t"; - _GEODE_SAFE_DELETE_ARRAY(buffer); + if (buffer) { + EXPECT_EQ(static_cast(186U), buffer[0]) + << "Correct zeroth uint8_t"; + EXPECT_EQ(static_cast(190U), buffer[1]) << "Correct first uint8_t"; + EXPECT_EQ(static_cast(250U), buffer[2]) + << "Correct second uint8_t"; + EXPECT_EQ(static_cast(206U), buffer[3]) << "Correct third uint8_t"; + } } -TEST_F(DataInputTest, TestReadInt8_tBytes) { +TEST_F(DataInputTest, TestReadInt8Bytes) { TestDataInput dataInput("04DEADBEEF"); int8_t *buffer = nullptr; int32_t len = 0; dataInput.readBytes(&buffer, &len); - EXPECT_NE(static_cast(nullptr), buffer) << "Non-null buffer"; + auto bufferGuard = std::unique_ptr{buffer}; + ASSERT_NE(nullptr, buffer) << "Non-null buffer"; ASSERT_EQ(4, len) << "Correct length"; - EXPECT_EQ(static_cast(-34), buffer[0]) << "Correct zeroth int8_t"; - EXPECT_EQ(static_cast(-83), buffer[1]) << "Correct first int8_t"; - EXPECT_EQ(static_cast(-66), buffer[2]) << "Correct second int8_t"; - EXPECT_EQ(static_cast(-17), buffer[3]) << "Correct third int8_t"; - _GEODE_SAFE_DELETE_ARRAY(buffer); + if (buffer) { + EXPECT_EQ(static_cast(-34), buffer[0]) << "Correct zeroth int8_t"; + EXPECT_EQ(static_cast(-83), buffer[1]) << "Correct first int8_t"; + EXPECT_EQ(static_cast(-66), buffer[2]) << "Correct second int8_t"; + EXPECT_EQ(static_cast(-17), buffer[3]) << "Correct third int8_t"; + } } TEST_F(DataInputTest, TestReadIntUint16) { @@ -590,22 +602,25 @@ TEST_F(DataInputTest, TestReadArrayOfByteArrays) { int32_t *elementLength = nullptr; dataInput.readArrayOfByteArrays(&arrayOfByteArrays, arrayLength, &elementLength); - EXPECT_NE(static_cast(nullptr), arrayOfByteArrays) - << "Non-null array of byte arrays"; + auto arrayOfByteArraysGuard = + std::unique_ptr { arrayOfByteArrays }; + auto elementLengthGuard = std::unique_ptr{elementLength}; + + ASSERT_NE(nullptr, arrayOfByteArrays) << "Non-null array of byte arrays"; ASSERT_EQ(1, arrayLength) << "Correct array length"; - EXPECT_NE(static_cast(nullptr), arrayOfByteArrays[0]) - << "Non-null first byte array"; - ASSERT_EQ(4, elementLength[0]) << "Correct length"; - EXPECT_EQ(static_cast(-34), arrayOfByteArrays[0][0]) - << "Correct zeroth int8_t"; - EXPECT_EQ(static_cast(-83), arrayOfByteArrays[0][1]) - << "Correct first int8_t"; - EXPECT_EQ(static_cast(-66), arrayOfByteArrays[0][2]) - << "Correct second int8_t"; - EXPECT_EQ(static_cast(-17), arrayOfByteArrays[0][3]) - << "Correct third int8_t"; - _GEODE_SAFE_DELETE_ARRAY(elementLength); - _GEODE_SAFE_DELETE_ARRAY(arrayOfByteArrays); + if (arrayOfByteArrays) { + EXPECT_NE(static_cast(nullptr), arrayOfByteArrays[0]) + << "Non-null first byte array"; + ASSERT_EQ(4, elementLength[0]) << "Correct length"; + EXPECT_EQ(static_cast(-34), arrayOfByteArrays[0][0]) + << "Correct zeroth int8_t"; + EXPECT_EQ(static_cast(-83), arrayOfByteArrays[0][1]) + << "Correct first int8_t"; + EXPECT_EQ(static_cast(-66), arrayOfByteArrays[0][2]) + << "Correct second int8_t"; + EXPECT_EQ(static_cast(-17), arrayOfByteArrays[0][3]) + << "Correct third int8_t"; + } } TEST_F(DataInputTest, TestGetBytesRead) { diff --git a/cppcache/test/DataOutputTest.cpp b/cppcache/test/DataOutputTest.cpp index f3017d5b01..29e3982eab 100644 --- a/cppcache/test/DataOutputTest.cpp +++ b/cppcache/test/DataOutputTest.cpp @@ -71,29 +71,16 @@ class TestDataOutput : public DataOutputInternal { class DataOutputTest : public ::testing::Test, public ByteArrayFixture { public: - DataOutputTest() : m_mersennesTwister(m_randomDevice()) { - // NOP - } - - virtual ~DataOutputTest() { - // NOP - } + DataOutputTest() : randomEngine_(randomDevice_()) {} + ~DataOutputTest() noexcept override = default; protected: - std::random_device m_randomDevice; - std::mt19937 m_mersennesTwister; + std::random_device randomDevice_; + std::default_random_engine randomEngine_; + std::uniform_int_distribution random_; int32_t getRandomSequenceNumber() { - // One would normally just use std::uniform_int_distribution but gcc 4.4.7 - // is lacking. - const std::mt19937::result_type upperLimit = - static_cast( - std::numeric_limits::max()); - std::mt19937::result_type result; - while (upperLimit < (result = m_mersennesTwister())) { - // Try again. - } - return static_cast(result); + return static_cast(random_(randomEngine_)); } }; diff --git a/cppcache/test/PdxInstanceImplTest.cpp b/cppcache/test/PdxInstanceImplTest.cpp index 604b46f64e..d54f3e7462 100644 --- a/cppcache/test/PdxInstanceImplTest.cpp +++ b/cppcache/test/PdxInstanceImplTest.cpp @@ -51,8 +51,8 @@ using apache::geode::statistics::StatisticsFactory; // TEST(PdxInstanceImplTest, updatePdxStream) { auto properties = std::make_shared(); - CacheFactory cacheFactory; - auto cache = cacheFactory.create(); + properties->insert("log-level", "none"); + auto cache = CacheFactory{}.set("log-level", "none").create(); CacheImpl cacheImpl(&cache, properties, true, false, nullptr); auto buffer = std::vector(__1M__, 0xcc); auto len = static_cast(buffer.size()); diff --git a/cppcache/test/SerializableCreateTests.cpp b/cppcache/test/SerializableCreateTests.cpp index aa171683b9..fcf241e768 100644 --- a/cppcache/test/SerializableCreateTests.cpp +++ b/cppcache/test/SerializableCreateTests.cpp @@ -36,7 +36,7 @@ using apache::geode::client::CacheableInt64; using apache::geode::client::CacheableString; using apache::geode::client::Serializable; -TEST(SerializableCreateTests, forArrayOf_constchar) { +TEST(SerializableCreateTests, forArrayOfConstChar) { const auto serializable = Serializable::create("test"); ASSERT_TRUE(nullptr != serializable); auto&& cacheableString = @@ -45,7 +45,7 @@ TEST(SerializableCreateTests, forArrayOf_constchar) { ASSERT_EQ(cacheableString->value(), "test"); } -TEST(SerializableCreateTests, forArrayOf_char) { +TEST(SerializableCreateTests, forArrayOfChar) { char* test = new char[5]{'t', 'e', 's', 't', '\0'}; const auto serializable = Serializable::create(test); ASSERT_TRUE(nullptr != serializable); @@ -55,7 +55,7 @@ TEST(SerializableCreateTests, forArrayOf_char) { ASSERT_EQ(cacheableString->value(), "test"); } -TEST(SerializableCreateTests, forArrayOf_char16_t) { +TEST(SerializableCreateTests, forArrayOfChar16) { const auto serializable = Serializable::create(u"test"); ASSERT_TRUE(nullptr != serializable); auto&& cacheableString = @@ -64,7 +64,7 @@ TEST(SerializableCreateTests, forArrayOf_char16_t) { ASSERT_EQ(cacheableString->value(), "test"); } -TEST(SerializableCreateTests, forArrayOf_char32_t) { +TEST(SerializableCreateTests, forArrayOfChar32) { const auto serializable = Serializable::create(U"test"); ASSERT_TRUE(nullptr != serializable); auto&& cacheableString = @@ -73,7 +73,7 @@ TEST(SerializableCreateTests, forArrayOf_char32_t) { ASSERT_EQ(cacheableString->value(), "test"); } -TEST(SerializableCreateTests, forArrayOf_wchar_t) { +TEST(SerializableCreateTests, forArrayOfWchar) { const auto serializable = Serializable::create(L"test"); ASSERT_TRUE(nullptr != serializable); auto&& cacheableString = @@ -82,7 +82,7 @@ TEST(SerializableCreateTests, forArrayOf_wchar_t) { ASSERT_EQ(cacheableString->value(), "test"); } -TEST(SerializableCreateTests, for_int8_t) { +TEST(SerializableCreateTests, forInt8) { const auto serializable = Serializable::create(static_cast(1)); ASSERT_TRUE(nullptr != serializable); auto&& cacheableByte = std::dynamic_pointer_cast(serializable); @@ -90,7 +90,7 @@ TEST(SerializableCreateTests, for_int8_t) { ASSERT_EQ(cacheableByte->value(), 1); } -TEST(SerializableCreateTests, for_int16_t) { +TEST(SerializableCreateTests, forInt16) { const auto serializable = Serializable::create(static_cast(1)); ASSERT_TRUE(nullptr != serializable); auto&& cacheableInt16 = @@ -99,7 +99,7 @@ TEST(SerializableCreateTests, for_int16_t) { ASSERT_EQ(cacheableInt16->value(), 1); } -TEST(SerializableCreateTests, for_int32_t) { +TEST(SerializableCreateTests, forInt32) { const auto serializable = Serializable::create(static_cast(1)); ASSERT_TRUE(nullptr != serializable); auto&& cacheableInt32 = @@ -108,7 +108,7 @@ TEST(SerializableCreateTests, for_int32_t) { ASSERT_EQ(cacheableInt32->value(), 1); } -TEST(SerializableCreateTests, for_int64_t) { +TEST(SerializableCreateTests, forInt64) { const auto serializable = Serializable::create(static_cast(1)); ASSERT_TRUE(nullptr != serializable); auto&& cacheableInt64 = @@ -117,7 +117,7 @@ TEST(SerializableCreateTests, for_int64_t) { ASSERT_EQ(cacheableInt64->value(), 1); } -TEST(SerializableCreateTests, for_char16_t) { +TEST(SerializableCreateTests, forCr16) { const auto serializable = Serializable::create(u'a'); ASSERT_TRUE(nullptr != serializable); auto&& cacheableCharacter = @@ -126,7 +126,7 @@ TEST(SerializableCreateTests, for_char16_t) { ASSERT_EQ(cacheableCharacter->value(), u'a'); } -TEST(SerializableCreateTests, for_float) { +TEST(SerializableCreateTests, forFloat) { const auto serializable = Serializable::create(1.1f); ASSERT_TRUE(nullptr != serializable); auto&& cacheableFloat = @@ -135,7 +135,7 @@ TEST(SerializableCreateTests, for_float) { ASSERT_EQ(cacheableFloat->value(), 1.1f); } -TEST(SerializableCreateTests, for_double) { +TEST(SerializableCreateTests, forDouble) { const auto serializable = Serializable::create(1.1); ASSERT_TRUE(nullptr != serializable); auto&& cacheableDouble = @@ -144,7 +144,7 @@ TEST(SerializableCreateTests, for_double) { ASSERT_EQ(cacheableDouble->value(), 1.1); } -TEST(SerializableCreateTests, for_bool) { +TEST(SerializableCreateTests, forBool) { const auto serializable = Serializable::create(true); ASSERT_TRUE(nullptr != serializable); auto&& cacheableBoolean = @@ -153,7 +153,7 @@ TEST(SerializableCreateTests, for_bool) { ASSERT_EQ(cacheableBoolean->value(), true); } -TEST(SerializableCreateTests, for_timepoint) { +TEST(SerializableCreateTests, forTimepoint) { auto time = std::chrono::system_clock::now(); const auto serializable = Serializable::create(time); ASSERT_TRUE(nullptr != serializable); diff --git a/cppcache/test/TcrMessageTest.cpp b/cppcache/test/TcrMessageTest.cpp index cfe200411d..1f811bd165 100644 --- a/cppcache/test/TcrMessageTest.cpp +++ b/cppcache/test/TcrMessageTest.cpp @@ -78,7 +78,7 @@ TEST_F(TcrMessageTest, intializeDefaultConstructor) { EXPECT_EQ(TcrMessage::INVALID, message.getMessageType()); } -TEST_F(TcrMessageTest, testConstructor1MessageDataContentWithDESTROY_REGION) { +TEST_F(TcrMessageTest, testConstructor1MessageDataContentWithDestoryRegion) { using apache::geode::client::TcrMessageDestroyRegion; const Region *region = nullptr; @@ -99,7 +99,7 @@ TEST_F(TcrMessageTest, testConstructor1MessageDataContentWithDESTROY_REGION) { message); } -TEST_F(TcrMessageTest, testConstructor1MessageDataContentWithCLEAR_REGION) { +TEST_F(TcrMessageTest, testConstructor1MessageDataContentWithClearRegion) { using apache::geode::client::TcrMessageClearRegion; const Region *region = nullptr; @@ -135,7 +135,7 @@ TEST_F(TcrMessageTest, testQueryConstructorMessageDataContent) { message); } -TEST_F(TcrMessageTest, testQueryConstructorWithQUERY) { +TEST_F(TcrMessageTest, testQueryConstructorWithQuery) { using apache::geode::client::TcrMessageQuery; std::chrono::milliseconds messageResponseTimeout{1000}; @@ -152,7 +152,7 @@ TEST_F(TcrMessageTest, testQueryConstructorWithQUERY) { message); } -TEST_F(TcrMessageTest, testQueryConstructorWithSTOPCQ_MSG_TYPE) { +TEST_F(TcrMessageTest, testQueryConstructorWithStopCq) { using apache::geode::client::TcrMessageStopCQ; std::chrono::milliseconds messageResponseTimeout{1000}; @@ -169,7 +169,7 @@ TEST_F(TcrMessageTest, testQueryConstructorWithSTOPCQ_MSG_TYPE) { message); } -TEST_F(TcrMessageTest, testQueryConstructorWithCLOSECQ_MSG_TYPE) { +TEST_F(TcrMessageTest, testQueryConstructorWithCloseCq) { using apache::geode::client::TcrMessageCloseCQ; std::chrono::milliseconds messageResponseTimeout{1000}; @@ -187,7 +187,7 @@ TEST_F(TcrMessageTest, testQueryConstructorWithCLOSECQ_MSG_TYPE) { } TEST_F(TcrMessageTest, - testParameterizedQueryConstructorWithQUERY_WITH_PARAMETERS) { + testParameterizedQueryConstructorWithQueryWithParameters) { using apache::geode::client::TcrMessageQueryWithParameters; std::chrono::milliseconds messageResponseTimeout{1000}; @@ -207,7 +207,7 @@ TEST_F(TcrMessageTest, message); } -TEST_F(TcrMessageTest, testConstructorWithCONTAINS_KEY) { +TEST_F(TcrMessageTest, testConstructorWithContainsKey) { using apache::geode::client::TcrMessageContainsKey; TcrMessageContainsKey message( @@ -226,7 +226,7 @@ TEST_F(TcrMessageTest, testConstructorWithCONTAINS_KEY) { message); } -TEST_F(TcrMessageTest, testConstructorWithGETDURABLECQS_MSG_TYPE) { +TEST_F(TcrMessageTest, testConstructorWithGetDurableCqs) { using apache::geode::client::TcrMessageGetDurableCqs; TcrMessageGetDurableCqs message(new DataOutputUnderTest(), @@ -256,7 +256,7 @@ TEST_F(TcrMessageTest, testConstructor2WithREQUEST) { message); } -TEST_F(TcrMessageTest, testConstructor2WithDESTROY) { +TEST_F(TcrMessageTest, testConstructor2WithDestroy) { using apache::geode::client::TcrMessageDestroy; TcrMessageDestroy message( @@ -275,7 +275,7 @@ TEST_F(TcrMessageTest, testConstructor2WithDESTROY) { message); } -TEST_F(TcrMessageTest, testConstructor2WithINVALIDATE) { +TEST_F(TcrMessageTest, testConstructor2WithInvalidate) { using apache::geode::client::TcrMessageInvalidate; TcrMessageInvalidate message( @@ -295,7 +295,7 @@ TEST_F(TcrMessageTest, testConstructor2WithINVALIDATE) { message); } -TEST_F(TcrMessageTest, testConstructor3WithPUT) { +TEST_F(TcrMessageTest, testConstructor3WithPut) { using apache::geode::client::TcrMessagePut; TcrMessagePut message( @@ -373,7 +373,7 @@ TEST_F(TcrMessageTest, TcrMessageRegisterInterestListWithManyKeys) { message); } -TEST_F(TcrMessageTest, testConstructor5WithUNREGISTER_INTERST_LIST) { +TEST_F(TcrMessageTest, testConstructor5WithUnregisterInteresetList) { using apache::geode::client::TcrMessageUnregisterInterestList; std::vector> keys; @@ -394,7 +394,7 @@ TEST_F(TcrMessageTest, testConstructor5WithUNREGISTER_INTERST_LIST) { message); } -TEST_F(TcrMessageTest, testConstructorGET_FUNCTION_ATTRIBUTES) { +TEST_F(TcrMessageTest, testConstructorGetFunctionAttributes) { using apache::geode::client::TcrMessageGetFunctionAttributes; TcrMessageGetFunctionAttributes message( @@ -408,7 +408,7 @@ TEST_F(TcrMessageTest, testConstructorGET_FUNCTION_ATTRIBUTES) { message); } -TEST_F(TcrMessageTest, testConstructorKEY_SET) { +TEST_F(TcrMessageTest, testConstructorKeySet) { using apache::geode::client::TcrMessageKeySet; TcrMessageKeySet message(new DataOutputUnderTest(), @@ -423,7 +423,7 @@ TEST_F(TcrMessageTest, testConstructorKEY_SET) { message); } -TEST_F(TcrMessageTest, testConstructor6WithCREATE_REGION) { +TEST_F(TcrMessageTest, testConstructor6WithCreateRegion) { using apache::geode::client::TcrMessageCreateRegion; TcrMessageCreateRegion message(new DataOutputUnderTest(), @@ -440,7 +440,7 @@ TEST_F(TcrMessageTest, testConstructor6WithCREATE_REGION) { message); } -TEST_F(TcrMessageTest, testConstructor6WithREGISTER_INTEREST) { +TEST_F(TcrMessageTest, testConstructor6WithRegisterInterest) { using apache::geode::client::TcrMessageRegisterInterest; TcrMessageRegisterInterest message( @@ -461,7 +461,7 @@ TEST_F(TcrMessageTest, testConstructor6WithREGISTER_INTEREST) { message); } -TEST_F(TcrMessageTest, testConstructor6WithUNREGISTER_INTEREST) { +TEST_F(TcrMessageTest, testConstructor6WithUnregisterInterest) { using apache::geode::client::TcrMessageUnregisterInterest; TcrMessageUnregisterInterest message( @@ -481,7 +481,7 @@ TEST_F(TcrMessageTest, testConstructor6WithUNREGISTER_INTEREST) { message); } -TEST_F(TcrMessageTest, testConstructorGET_PDX_TYPE_BY_ID) { +TEST_F(TcrMessageTest, testConstructorGetPdxTypeById) { using apache::geode::client::TcrMessageGetPdxTypeById; TcrMessageGetPdxTypeById message(new DataOutputUnderTest(), 42, @@ -493,7 +493,7 @@ TEST_F(TcrMessageTest, testConstructorGET_PDX_TYPE_BY_ID) { message); } -TEST_F(TcrMessageTest, testConstructorGET_PDX_ENUM_BY_ID) { +TEST_F(TcrMessageTest, testConstructorGetPdxEnumById) { using apache::geode::client::TcrMessageGetPdxEnumById; TcrMessageGetPdxEnumById message(new DataOutputUnderTest(), 42, @@ -505,7 +505,7 @@ TEST_F(TcrMessageTest, testConstructorGET_PDX_ENUM_BY_ID) { message); } -TEST_F(TcrMessageTest, testConstructorGET_PDX_ID_FOR_TYPE) { +TEST_F(TcrMessageTest, testConstructorGetPdxIdForType) { using apache::geode::client::TcrMessageGetPdxIdForType; std::shared_ptr myPtr(CacheableString::createDeserializable()); @@ -518,7 +518,7 @@ TEST_F(TcrMessageTest, testConstructorGET_PDX_ID_FOR_TYPE) { message); } -TEST_F(TcrMessageTest, testConstructorADD_PDX_TYPE) { +TEST_F(TcrMessageTest, testConstructorAddPdxType) { using apache::geode::client::TcrMessageAddPdxType; std::shared_ptr myPtr(CacheableString::createDeserializable()); @@ -532,7 +532,7 @@ TEST_F(TcrMessageTest, testConstructorADD_PDX_TYPE) { message); } -TEST_F(TcrMessageTest, testConstructorGET_PDX_ID_FOR_ENUM) { +TEST_F(TcrMessageTest, testConstructorGetPdxIdForEnum) { using apache::geode::client::TcrMessageGetPdxIdForEnum; TcrMessageGetPdxIdForEnum message( @@ -545,7 +545,7 @@ TEST_F(TcrMessageTest, testConstructorGET_PDX_ID_FOR_ENUM) { EXPECT_MESSAGE_EQ("000000610000000600000001FFFFFFFF00000000010129", message); } -TEST_F(TcrMessageTest, testConstructorADD_PDX_ENUM) { +TEST_F(TcrMessageTest, testConstructorAddPdxEnum) { using apache::geode::client::TcrMessageAddPdxEnum; std::shared_ptr myPtr(CacheableString::createDeserializable()); @@ -574,7 +574,7 @@ TEST_F(TcrMessageTest, testConstructorEventId) { EXPECT_MESSAGE_EQ("000000440000000600000001FFFFFFFF00000000010129", message); } -TEST_F(TcrMessageTest, testConstructorREMOVE_USER_AUTH) { +TEST_F(TcrMessageTest, testConstructorRemoveUserAuth) { using apache::geode::client::TcrMessageRemoveUserAuth; TcrMessageRemoveUserAuth message(new DataOutputUnderTest(), true, @@ -592,7 +592,7 @@ TEST_F(TcrMessageTest, testConstructorREMOVE_USER_AUTH) { EXPECT_MESSAGE_EQ("0000004E0000000600000001FFFFFFFF00000000010000", message2); } -TEST_F(TcrMessageTest, testConstructorUSER_CREDENTIAL_MESSAGE) { +TEST_F(TcrMessageTest, testConstructorUserCredential) { using apache::geode::client::Properties; using apache::geode::client::TcrMessageUserCredential; @@ -607,7 +607,7 @@ TEST_F(TcrMessageTest, testConstructorUSER_CREDENTIAL_MESSAGE) { EXPECT_MESSAGE_EQ("", message); } -TEST_F(TcrMessageTest, testConstructorGET_CLIENT_PARTITION_ATTRIBUTES) { +TEST_F(TcrMessageTest, testConstructorGetClientPartitionAttributes) { using apache::geode::client::TcrMessageGetClientPartitionAttributes; TcrMessageGetClientPartitionAttributes message(new DataOutputUnderTest(), @@ -622,7 +622,7 @@ TEST_F(TcrMessageTest, testConstructorGET_CLIENT_PARTITION_ATTRIBUTES) { message); } -TEST_F(TcrMessageTest, testConstructorGET_CLIENT_PR_METADATA) { +TEST_F(TcrMessageTest, testConstructorGetClientPrMetadata) { using apache::geode::client::TcrMessageGetClientPrMetadata; TcrMessageGetClientPrMetadata message(new DataOutputUnderTest(), @@ -635,7 +635,7 @@ TEST_F(TcrMessageTest, testConstructorGET_CLIENT_PR_METADATA) { "6F6E50524D455441", message); } -TEST_F(TcrMessageTest, testConstructorSIZE) { +TEST_F(TcrMessageTest, testConstructorSize) { using apache::geode::client::TcrMessageSize; TcrMessageSize message(new DataOutputUnderTest(), "testClientRegionSIZE"); @@ -648,7 +648,7 @@ TEST_F(TcrMessageTest, testConstructorSIZE) { message); } -TEST_F(TcrMessageTest, testConstructorEXECUTE_REGION_FUNCTION_SINGLE_HOP) { +TEST_F(TcrMessageTest, testConstructorExecuteRegionFunctionSingleHop) { using apache::geode::client::TcrMessageExecuteRegionFunctionSingleHop; const Region *region = nullptr; @@ -676,7 +676,7 @@ TEST_F(TcrMessageTest, testConstructorEXECUTE_REGION_FUNCTION_SINGLE_HOP) { EXPECT_TRUE(message.hasResult()); } -TEST_F(TcrMessageTest, testConstructorEXECUTE_REGION_FUNCTION) { +TEST_F(TcrMessageTest, testConstructorExecuteRegionFunction) { using apache::geode::client::TcrMessageExecuteRegionFunction; const Region *region = nullptr; @@ -705,7 +705,7 @@ TEST_F(TcrMessageTest, testConstructorEXECUTE_REGION_FUNCTION) { EXPECT_TRUE(testMessage.hasResult()); } -TEST_F(TcrMessageTest, DISABLED_testConstructorEXECUTE_FUNCTION) { +TEST_F(TcrMessageTest, DISABLED_testConstructorExecuteFunction) { using apache::geode::client::TcrMessageExecuteFunction; std::shared_ptr myCacheablePtr( @@ -725,7 +725,7 @@ TEST_F(TcrMessageTest, DISABLED_testConstructorEXECUTE_FUNCTION) { testMessage); } -TEST_F(TcrMessageTest, testConstructorEXECUTECQ_MSG_TYPE) { +TEST_F(TcrMessageTest, testConstructorExecuteCq) { using apache::geode::client::TcrMessageExecuteCq; std::shared_ptr myCacheablePtr( @@ -744,7 +744,7 @@ TEST_F(TcrMessageTest, testConstructorEXECUTECQ_MSG_TYPE) { testMessage); } -TEST_F(TcrMessageTest, testConstructorWithGinormousQueryEXECUTECQ_MSG_TYPE) { +TEST_F(TcrMessageTest, testConstructorWithGinormousQueryExecuteCq) { using apache::geode::client::TcrMessageExecuteCq; std::shared_ptr myCacheablePtr( @@ -778,7 +778,7 @@ TEST_F(TcrMessageTest, testConstructorWithGinormousQueryEXECUTECQ_MSG_TYPE) { testMessage); } -TEST_F(TcrMessageTest, testConstructorEXECUTECQ_WITH_IR_MSG_TYPE) { +TEST_F(TcrMessageTest, testConstructorExecuteCqWithIr) { using apache::geode::client::TcrMessageExecuteCqWithIr; std::shared_ptr myCacheablePtr( @@ -798,7 +798,7 @@ TEST_F(TcrMessageTest, testConstructorEXECUTECQ_WITH_IR_MSG_TYPE) { testMessage); } -TEST_F(TcrMessageTest, testConstructorPING) { +TEST_F(TcrMessageTest, testConstructorPing) { using apache::geode::client::TcrMessagePing; std::shared_ptr myCacheablePtr( @@ -811,7 +811,7 @@ TEST_F(TcrMessageTest, testConstructorPING) { EXPECT_MESSAGE_EQ("000000050000000000000000FFFFFFFF00", testMessage); } -TEST_F(TcrMessageTest, testConstructorCLOSE_CONNECTION) { +TEST_F(TcrMessageTest, testConstructorCloseConnection) { using apache::geode::client::TcrMessageCloseConnection; std::shared_ptr myCacheablePtr( diff --git a/cppcache/test/ThreadPoolTest.cpp b/cppcache/test/ThreadPoolTest.cpp index f62bf61cfc..3f0bb24b51 100644 --- a/cppcache/test/ThreadPoolTest.cpp +++ b/cppcache/test/ThreadPoolTest.cpp @@ -33,7 +33,7 @@ class TestCallable : public Callable { public: TestCallable() : called_(0) {} - void call() { + void call() override { std::lock_guard lock(mutex_); called_++; condition_.notify_all(); diff --git a/cppcache/test/util/chrono/durationTest.cpp b/cppcache/test/util/chrono/durationTest.cpp index 80e766e138..26f95c91f2 100644 --- a/cppcache/test/util/chrono/durationTest.cpp +++ b/cppcache/test/util/chrono/durationTest.cpp @@ -29,7 +29,7 @@ using apache::geode::internal::chrono::duration::from_string; using apache::geode::internal::chrono::duration::to_string; using apache::geode::util::chrono::duration::assert_bounds; -TEST(util_chrono_durationTest, ceil) { +TEST(durationTest, ceil) { EXPECT_EQ(std::chrono::seconds(1), _ceil(std::chrono::milliseconds(1))); EXPECT_EQ(std::chrono::milliseconds(1), @@ -38,7 +38,7 @@ TEST(util_chrono_durationTest, ceil) { _ceil(std::chrono::milliseconds(1))); } -TEST(util_chrono_durationTest, to_string) { +TEST(durationTest, toString) { EXPECT_EQ("42h", to_string(std::chrono::hours(42))); EXPECT_EQ("42min", to_string(std::chrono::minutes(42))); EXPECT_EQ("42s", to_string(std::chrono::seconds(42))); @@ -52,7 +52,7 @@ TEST(util_chrono_durationTest, to_string) { to_string(std::chrono::duration>(100))); } -TEST(util_chrono_durationTest, from_string) { +TEST(durationTest, fromString) { EXPECT_EQ(std::chrono::hours(42), from_string("42h")); EXPECT_EQ(std::chrono::minutes(42), from_string("42min")); EXPECT_EQ(std::chrono::seconds(42), from_string("42s")); @@ -63,7 +63,7 @@ TEST(util_chrono_durationTest, from_string) { EXPECT_EQ(std::chrono::nanoseconds(-42), from_string("-42ns")); } -TEST(util_chrono_durationTest, from_stringWithCeil) { +TEST(durationTest, fromStringWithCeil) { EXPECT_EQ(std::chrono::hours(42), from_string("42h")); EXPECT_EQ(std::chrono::hours(1), from_string("42min")); EXPECT_EQ(std::chrono::minutes(1), from_string("42s")); @@ -76,11 +76,11 @@ TEST(util_chrono_durationTest, from_stringWithCeil) { from_string("2000ms")); } -TEST(util_chrono_durationTest, from_stringException) { +TEST(durationTest, fromStringException) { ASSERT_THROW(from_string("42"), std::invalid_argument); } -TEST(util_chrono_durationTest, assert_bounds) { +TEST(durationTest, assertBounds) { auto protocolTimeoutLimit = assert_bounds{}; ASSERT_NO_THROW(protocolTimeoutLimit(std::chrono::milliseconds(2147483647))); diff --git a/cppcache/test/util/functionalTests.cpp b/cppcache/test/util/functionalTests.cpp index 1cd483ca70..eee02695e4 100644 --- a/cppcache/test/util/functionalTests.cpp +++ b/cppcache/test/util/functionalTests.cpp @@ -23,7 +23,7 @@ using apache::geode::client::internal::geode_hash; -TEST(string, geode_hash) { +TEST(string, geodeHash) { auto&& hash = geode_hash{}; EXPECT_EQ(0, hash("")); diff --git a/cppcache/test/util/queueTest.cpp b/cppcache/test/util/queueTest.cpp index b5d68617aa..c31a3b3b2b 100644 --- a/cppcache/test/util/queueTest.cpp +++ b/cppcache/test/util/queueTest.cpp @@ -23,7 +23,7 @@ using apache::geode::client::queue::coalesce; -TEST(util_queueTest, coalesce) { +TEST(queueTest, coalesce) { auto queue = std::deque({1, 1, 1, 2, 3, 4}); coalesce(queue, 1); diff --git a/cppcache/test/util/synchronized_mapTest.cpp b/cppcache/test/util/synchronized_mapTest.cpp index 2a6f79c206..272b4b81f0 100644 --- a/cppcache/test/util/synchronized_mapTest.cpp +++ b/cppcache/test/util/synchronized_mapTest.cpp @@ -26,7 +26,7 @@ using apache::geode::client::synchronized_map; -TEST(synchronized_mapTest, emplaceLocks) { +TEST(SynchronizedMapTest, emplaceLocks) { synchronized_map, TestableRecursiveMutex> map; @@ -48,7 +48,7 @@ TEST(synchronized_mapTest, emplaceLocks) { EXPECT_EQ(2, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, eraseKeyLocks) { +TEST(SynchronizedMapTest, eraseKeyLocks) { synchronized_map, TestableRecursiveMutex> map; @@ -63,7 +63,7 @@ TEST(synchronized_mapTest, eraseKeyLocks) { EXPECT_EQ(1, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, beginLocks) { +TEST(SynchronizedMapTest, beginLocks) { synchronized_map, TestableRecursiveMutex> map; @@ -80,7 +80,7 @@ TEST(synchronized_mapTest, beginLocks) { EXPECT_EQ(0, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, beginConstLocks) { +TEST(SynchronizedMapTest, beginConstLocks) { synchronized_map, TestableRecursiveMutex> map; @@ -98,7 +98,7 @@ TEST(synchronized_mapTest, beginConstLocks) { EXPECT_EQ(0, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, cbeginLocks) { +TEST(SynchronizedMapTest, cbeginLocks) { synchronized_map, TestableRecursiveMutex> map; @@ -115,7 +115,7 @@ TEST(synchronized_mapTest, cbeginLocks) { EXPECT_EQ(0, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, endLocks) { +TEST(SynchronizedMapTest, endLocks) { synchronized_map, TestableRecursiveMutex> map; @@ -133,7 +133,7 @@ TEST(synchronized_mapTest, endLocks) { EXPECT_EQ(0, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, endConsLocks) { +TEST(SynchronizedMapTest, endConsLocks) { synchronized_map, TestableRecursiveMutex> map; @@ -152,7 +152,7 @@ TEST(synchronized_mapTest, endConsLocks) { EXPECT_EQ(0, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, cendLocks) { +TEST(SynchronizedMapTest, cendLocks) { synchronized_map, TestableRecursiveMutex> map; @@ -170,7 +170,7 @@ TEST(synchronized_mapTest, cendLocks) { EXPECT_EQ(0, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, emptyLocks) { +TEST(SynchronizedMapTest, emptyLocks) { synchronized_map, TestableRecursiveMutex> map; @@ -189,7 +189,7 @@ TEST(synchronized_mapTest, emptyLocks) { EXPECT_EQ(1, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, sizeLocks) { +TEST(SynchronizedMapTest, sizeLocks) { synchronized_map, TestableRecursiveMutex> map; @@ -208,7 +208,7 @@ TEST(synchronized_mapTest, sizeLocks) { EXPECT_EQ(1, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, clearLocks) { +TEST(SynchronizedMapTest, clearLocks) { synchronized_map, TestableRecursiveMutex> map; @@ -223,7 +223,7 @@ TEST(synchronized_mapTest, clearLocks) { EXPECT_TRUE(map.empty()); } -TEST(synchronized_mapTest, findNotLocked) { +TEST(SynchronizedMapTest, findNotLocked) { synchronized_map, TestableRecursiveMutex> map; @@ -244,7 +244,7 @@ TEST(synchronized_mapTest, findNotLocked) { EXPECT_EQ(1, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, findConstNotLocked) { +TEST(SynchronizedMapTest, findConstNotLocked) { synchronized_map, TestableRecursiveMutex> map; @@ -266,7 +266,7 @@ TEST(synchronized_mapTest, findConstNotLocked) { EXPECT_EQ(1, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, iteratorNotLocked) { +TEST(SynchronizedMapTest, iteratorNotLocked) { synchronized_map, TestableRecursiveMutex> map; @@ -305,7 +305,7 @@ TEST(synchronized_mapTest, iteratorNotLocked) { EXPECT_EQ(1, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, make_lockDefault) { +TEST(SynchronizedMapTest, makeLockDefault) { synchronized_map, TestableRecursiveMutex> map; @@ -321,7 +321,7 @@ TEST(synchronized_mapTest, make_lockDefault) { EXPECT_EQ(1, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, make_lock_WithUniqueLock) { +TEST(SynchronizedMapTest, makeLockWithUniqueLock) { synchronized_map, TestableRecursiveMutex> map; @@ -337,7 +337,7 @@ TEST(synchronized_mapTest, make_lock_WithUniqueLock) { EXPECT_EQ(1, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, make_lock_WithUniqueLockDefered) { +TEST(SynchronizedMapTest, makeLockWithUniqueLockDefered) { synchronized_map, TestableRecursiveMutex> map; @@ -357,7 +357,7 @@ TEST(synchronized_mapTest, make_lock_WithUniqueLockDefered) { EXPECT_EQ(1, map.mutex().unlock_count_); } -TEST(synchronized_mapTest, insertIteratorIteratorLocks) { +TEST(SynchronizedMapTest, insertIteratorIteratorLocks) { std::unordered_map source = {{"a", "A"}, {"b", "B"}}; diff --git a/cppcache/test/util/synchronized_setTest.cpp b/cppcache/test/util/synchronized_setTest.cpp index 98f8563210..005aa21f91 100644 --- a/cppcache/test/util/synchronized_setTest.cpp +++ b/cppcache/test/util/synchronized_setTest.cpp @@ -26,7 +26,7 @@ using apache::geode::client::synchronized_set; -TEST(synchronized_setTest, emplaceLocks) { +TEST(SynchronizedSetTest, emplaceLocks) { synchronized_set, TestableRecursiveMutex> set; auto result = set.emplace("a"); @@ -44,7 +44,7 @@ TEST(synchronized_setTest, emplaceLocks) { EXPECT_EQ(2, set.mutex().unlock_count_); } -TEST(synchronized_setTest, eraseKeyLocks) { +TEST(SynchronizedSetTest, eraseKeyLocks) { synchronized_set, TestableRecursiveMutex> set; set.emplace("a"); @@ -57,7 +57,7 @@ TEST(synchronized_setTest, eraseKeyLocks) { EXPECT_EQ(1, set.mutex().unlock_count_); } -TEST(synchronized_setTest, beginLocks) { +TEST(SynchronizedSetTest, beginLocks) { synchronized_set, TestableRecursiveMutex> set; set.emplace("a"); @@ -72,7 +72,7 @@ TEST(synchronized_setTest, beginLocks) { EXPECT_EQ(0, set.mutex().unlock_count_); } -TEST(synchronized_setTest, beginConstLocks) { +TEST(SynchronizedSetTest, beginConstLocks) { synchronized_set, TestableRecursiveMutex> set; set.emplace("a"); @@ -88,7 +88,7 @@ TEST(synchronized_setTest, beginConstLocks) { EXPECT_EQ(0, set.mutex().unlock_count_); } -TEST(synchronized_setTest, cbeginLocks) { +TEST(SynchronizedSetTest, cbeginLocks) { synchronized_set, TestableRecursiveMutex> set; set.emplace("a"); @@ -103,7 +103,7 @@ TEST(synchronized_setTest, cbeginLocks) { EXPECT_EQ(0, set.mutex().unlock_count_); } -TEST(synchronized_setTest, endLocks) { +TEST(SynchronizedSetTest, endLocks) { synchronized_set, TestableRecursiveMutex> set; set.emplace("a"); @@ -119,7 +119,7 @@ TEST(synchronized_setTest, endLocks) { EXPECT_EQ(0, set.mutex().unlock_count_); } -TEST(synchronized_setTest, endConsLocks) { +TEST(SynchronizedSetTest, endConsLocks) { synchronized_set, TestableRecursiveMutex> set; set.emplace("a"); @@ -136,7 +136,7 @@ TEST(synchronized_setTest, endConsLocks) { EXPECT_EQ(0, set.mutex().unlock_count_); } -TEST(synchronized_setTest, cendLocks) { +TEST(SynchronizedSetTest, cendLocks) { synchronized_set, TestableRecursiveMutex> set; set.emplace("a"); @@ -152,7 +152,7 @@ TEST(synchronized_setTest, cendLocks) { EXPECT_EQ(0, set.mutex().unlock_count_); } -TEST(synchronized_setTest, emptyLocks) { +TEST(SynchronizedSetTest, emptyLocks) { synchronized_set, TestableRecursiveMutex> set; ASSERT_TRUE(set.empty()); @@ -169,7 +169,7 @@ TEST(synchronized_setTest, emptyLocks) { EXPECT_EQ(1, set.mutex().unlock_count_); } -TEST(synchronized_setTest, sizeLocks) { +TEST(SynchronizedSetTest, sizeLocks) { synchronized_set, TestableRecursiveMutex> set; ASSERT_EQ(0, set.size()); @@ -186,7 +186,7 @@ TEST(synchronized_setTest, sizeLocks) { EXPECT_EQ(1, set.mutex().unlock_count_); } -TEST(synchronized_setTest, clearLocks) { +TEST(SynchronizedSetTest, clearLocks) { synchronized_set, TestableRecursiveMutex> set; set.emplace("a"); @@ -199,7 +199,7 @@ TEST(synchronized_setTest, clearLocks) { EXPECT_TRUE(set.empty()); } -TEST(synchronized_setTest, findNotLocked) { +TEST(SynchronizedSetTest, findNotLocked) { synchronized_set, TestableRecursiveMutex> set; set.emplace("a"); @@ -218,7 +218,7 @@ TEST(synchronized_setTest, findNotLocked) { EXPECT_EQ(1, set.mutex().unlock_count_); } -TEST(synchronized_setTest, findConstNotLocked) { +TEST(SynchronizedSetTest, findConstNotLocked) { synchronized_set, TestableRecursiveMutex> set; set.emplace("a"); @@ -238,7 +238,7 @@ TEST(synchronized_setTest, findConstNotLocked) { EXPECT_EQ(1, set.mutex().unlock_count_); } -TEST(synchronized_setTest, iteratorNotLocked) { +TEST(SynchronizedSetTest, iteratorNotLocked) { synchronized_set, TestableRecursiveMutex> set; set.emplace("a"); @@ -275,7 +275,7 @@ TEST(synchronized_setTest, iteratorNotLocked) { EXPECT_EQ(1, set.mutex().unlock_count_); } -TEST(synchronized_setTest, make_lockDefault) { +TEST(SynchronizedSetTest, makeLockDefault) { synchronized_set, TestableRecursiveMutex> set; { @@ -289,7 +289,7 @@ TEST(synchronized_setTest, make_lockDefault) { EXPECT_EQ(1, set.mutex().unlock_count_); } -TEST(synchronized_setTest, make_lock_WithUniqueLock) { +TEST(SynchronizedSetTest, makeLockWithUniqueLock) { synchronized_set, TestableRecursiveMutex> set; { @@ -303,7 +303,7 @@ TEST(synchronized_setTest, make_lock_WithUniqueLock) { EXPECT_EQ(1, set.mutex().unlock_count_); } -TEST(synchronized_setTest, make_lock_WithUniqueLockDefered) { +TEST(SynchronizedSetTest, makeLockWithUniqueLockDefered) { synchronized_set, TestableRecursiveMutex> set; { @@ -321,7 +321,7 @@ TEST(synchronized_setTest, make_lock_WithUniqueLockDefered) { EXPECT_EQ(1, set.mutex().unlock_count_); } -TEST(synchronized_setTest, insertIteratorIteratorLocks) { +TEST(SynchronizedSetTest, insertIteratorIteratorLocks) { std::unordered_set source = {"a", "b"}; synchronized_set, TestableRecursiveMutex> set; @@ -333,7 +333,7 @@ TEST(synchronized_setTest, insertIteratorIteratorLocks) { EXPECT_EQ(2, set.size()); } -TEST(synchronized_setTest, insertRvalue) { +TEST(SynchronizedSetTest, insertRvalue) { synchronized_set, TestableRecursiveMutex> set; set.insert("a"); @@ -343,7 +343,7 @@ TEST(synchronized_setTest, insertRvalue) { EXPECT_EQ(1, set.size()); } -TEST(synchronized_setTest, insertLvalue) { +TEST(SynchronizedSetTest, insertLvalue) { synchronized_set, TestableRecursiveMutex> set; std::string value = "a"; @@ -354,7 +354,7 @@ TEST(synchronized_setTest, insertLvalue) { EXPECT_EQ(1, set.size()); } -TEST(synchronized_setTest, compilesWithStdSet) { +TEST(SynchronizedSetTest, compilesWithStdSet) { synchronized_set, TestableRecursiveMutex> set; auto result = set.emplace("a"); diff --git a/tests/cpp/.clang-tidy b/tests/cpp/.clang-tidy new file mode 100644 index 0000000000..6f51aee50b --- /dev/null +++ b/tests/cpp/.clang-tidy @@ -0,0 +1,4 @@ +--- +InheritParentConfig: true +Checks: '' +... diff --git a/tests/cpp/fwklib/FwkBBServer.hpp b/tests/cpp/fwklib/FwkBBServer.hpp index 0404f430ce..64bc845a30 100644 --- a/tests/cpp/fwklib/FwkBBServer.hpp +++ b/tests/cpp/fwklib/FwkBBServer.hpp @@ -151,9 +151,9 @@ class BBProcessor : public ServiceTask { BBProcessor(UDPMessageQueues* shared, FwkBBServer* server) : ServiceTask(shared), m_queues(shared), m_server(server) {} - virtual ~BBProcessor() {} + ~BBProcessor() noexcept override = default; - virtual int doTask() { + int doTask() override { while (*m_run) { try { UDPMessage* msg = m_queues->getInbound(); @@ -214,8 +214,8 @@ class BBProcessor : public ServiceTask { } return 0; } - virtual void initialize() {} - virtual void finalize() {} + void initialize() override {} + void finalize() override {} }; } // namespace testframework diff --git a/tests/cpp/fwklib/FwkLog.hpp b/tests/cpp/fwklib/FwkLog.hpp index cd34892310..1ceb490a05 100644 --- a/tests/cpp/fwklib/FwkLog.hpp +++ b/tests/cpp/fwklib/FwkLog.hpp @@ -51,72 +51,53 @@ const char* getNodeName(); #ifdef DEBUG #define FWKDEBUG(x) \ - { \ + do { \ std::ostringstream os; \ os << x; \ plog("Debug", os.str().c_str(), __FILE__, __LINE__); \ - } - -#define FWKSLEEP(x) \ - { ACE_OS::sleep(ACE_Time_Value(x, 0)); } + } while (0) #else #define FWKDEBUG(x) -#define FWKSLEEP(x) \ - { ACE_OS::sleep(ACE_Time_Value(x, 0)); } - #endif #define FWKINFO(x) \ - { \ + do { \ std::ostringstream os; \ os << x; \ apache::geode::client::testframework::plog("Info", os.str().c_str(), \ __FILE__, __LINE__); \ - } + } while (0) #define FWKWARN(x) \ - { \ + do { \ std::ostringstream os; \ os << x; \ apache::geode::client::testframework::plog("Warn", os.str().c_str(), \ __FILE__, __LINE__); \ - } + } while (0) #define FWKERROR(x) \ - { \ + do { \ std::ostringstream os; \ os << x; \ apache::geode::client::testframework::plog("Error", os.str().c_str(), \ __FILE__, __LINE__); \ - } + } while (0) #define FWKSEVERE(x) \ - { \ + do { \ std::ostringstream os; \ os << x; \ apache::geode::client::testframework::plog("Severe", os.str().c_str(), \ __FILE__, __LINE__); \ - } + } while (0) #define FWKEXCEPTION(x) \ - { \ + do { \ std::ostringstream os; \ os << x << " In file: " << __FILE__ << " at line: " << __LINE__; \ throw apache::geode::client::testframework::FwkException( \ os.str().c_str()); \ - } - -#define WAITFORDEBUGGER(x) \ - { \ - apache::geode::client::testframework::plog( \ - "Info", "Waiting for debugger ...", __FILE__, __LINE__); \ - for (int32_t i = x; i > 0; i--) ACE_OS::sleep(ACE_Time_Value(1, 0)); \ - } - -#define DUMPSTACK(x) \ - { \ - FWKSEVERE(x); \ - apache::geode::client::testframework::dumpStack(); \ - } + } while (0) } // namespace testframework } // namespace client diff --git a/tests/cpp/fwklib/Service.hpp b/tests/cpp/fwklib/Service.hpp index fea7d71d63..ecb0817f93 100644 --- a/tests/cpp/fwklib/Service.hpp +++ b/tests/cpp/fwklib/Service.hpp @@ -69,7 +69,7 @@ class Service : public ACE_Task_Base { ACE_Thread_Mutex m_Mutex; ACE_DLList m_TaskQueue; - int32_t svc(); + int32_t svc() override; inline void putQ(ServiceTask* task, uint32_t cnt = 1) { ACE_Guard guard(m_Mutex); @@ -85,7 +85,7 @@ class Service : public ACE_Task_Base { public: explicit Service(int32_t threadCnt); - inline ~Service() { stopThreads(); } + ~Service() override { stopThreads(); } int32_t runThreaded(ServiceTask* task, uint32_t threads); @@ -119,8 +119,7 @@ class SafeQueue { if (m_queue.size() == 0) { ACE_Time_Value until(2); until += ACE_OS::gettimeofday(); - ; - int32_t res = m_cond.wait(&until); + auto res = m_cond.wait(&until); if (res == -1) return nullptr; } return m_queue.delete_head(); diff --git a/tests/cpp/fwklib/TimeBomb.hpp b/tests/cpp/fwklib/TimeBomb.hpp index bfb9650638..7171db01e3 100644 --- a/tests/cpp/fwklib/TimeBomb.hpp +++ b/tests/cpp/fwklib/TimeBomb.hpp @@ -40,7 +40,7 @@ class TimeBomb : public ACE_Task_Base { int32_t m_exitCode; std::string m_msg; - int32_t svc(); + int32_t svc() override; public: inline TimeBomb(uint32_t seconds, int32_t exitCode, const std::string& msg) @@ -52,7 +52,7 @@ class TimeBomb : public ACE_Task_Base { inline TimeBomb() : m_stop(false), m_armed(false), m_seconds(0), m_exitCode(-1) {} - inline ~TimeBomb() { + ~TimeBomb() override { m_armed = false; m_stop = true; wait(); diff --git a/tests/cpp/fwklib/UDPIpc.hpp b/tests/cpp/fwklib/UDPIpc.hpp index b4201fe088..a8cd9be9fb 100644 --- a/tests/cpp/fwklib/UDPIpc.hpp +++ b/tests/cpp/fwklib/UDPIpc.hpp @@ -89,7 +89,7 @@ class UDPMessage : public IPCMessage { setCmd(msg.getCmd()); } - virtual ~UDPMessage() {} + ~UDPMessage() noexcept override = default; void setCmd(UdpCmds cmd) { m_hdr.cmd = cmd; } @@ -127,7 +127,7 @@ class UDPMessage : public IPCMessage { m_hdr.length = 0; } - virtual void clear() { + virtual void clear() override { clearHdr(); m_msg.clear(); } @@ -162,7 +162,7 @@ class UDPMessageQueues : public SharedTaskObject { public: explicit UDPMessageQueues(std::string label) : m_cntInbound(), m_cntOutbound(0), m_cntProcessed(0), m_label(label) {} - ~UDPMessageQueues() { + ~UDPMessageQueues() noexcept override { FWKINFO(m_label << "MessageQueues::Inbound count: " << m_cntInbound); FWKINFO(m_label << "MessageQueues::Processed count: " << m_cntProcessed); FWKINFO(m_label << "MessageQueues::Outbound count: " << m_cntOutbound); @@ -192,8 +192,8 @@ class UDPMessageQueues : public SharedTaskObject { return msg; } - virtual void initialize() {} - virtual void finalize() {} + void initialize() override {} + void finalize() override {} }; class Receiver : public ServiceTask { @@ -213,15 +213,15 @@ class Receiver : public ServiceTask { m_queues = dynamic_cast(m_shared); } - virtual ~Receiver() {} + virtual ~Receiver() noexcept override = default; bool isListener() { return (m_listener == ACE_Thread::self()); } - int32_t doTask(); + int32_t doTask() override; - void initialize(); + void initialize() override; - void finalize() { m_io->close(); } + void finalize() override { m_io->close(); } }; class STReceiver : public ServiceTask { @@ -237,13 +237,13 @@ class STReceiver : public ServiceTask { m_queues = dynamic_cast(m_shared); } - virtual ~STReceiver() {} + ~STReceiver() noexcept override = default; - int32_t doTask(); + int32_t doTask() override; - void initialize(); + void initialize() override; - void finalize() { m_io.close(); } + void finalize() override { m_io.close(); } }; class Processor : public ServiceTask { @@ -256,9 +256,9 @@ class Processor : public ServiceTask { m_queues = dynamic_cast(m_shared); } - virtual ~Processor() {} + ~Processor() noexcept override = default; - int32_t doTask() { + int32_t doTask() override { while (*m_run) { UDPMessage* msg = m_queues->getInbound(); if (msg) { @@ -267,8 +267,8 @@ class Processor : public ServiceTask { } return 0; } - void initialize() {} - void finalize() {} + void initialize() override {} + void finalize() override {} }; class Responder : public ServiceTask { @@ -284,14 +284,15 @@ class Responder : public ServiceTask { m_queues = dynamic_cast(m_shared); } - virtual ~Responder() {} + ~Responder() noexcept override = default; - int32_t doTask(); + int32_t doTask() override; - void initialize(); + void initialize() override; - void finalize() { m_io->close(); } + void finalize() override { m_io->close(); } }; + } // namespace testframework } // namespace client } // namespace geode diff --git a/tests/cpp/security/DummyCredentialGenerator.hpp b/tests/cpp/security/DummyCredentialGenerator.hpp index ac9e2588a5..a81ac58830 100644 --- a/tests/cpp/security/DummyCredentialGenerator.hpp +++ b/tests/cpp/security/DummyCredentialGenerator.hpp @@ -31,10 +31,7 @@ namespace security { class DummyCredentialGenerator : public CredentialGenerator { public: - DummyCredentialGenerator() : CredentialGenerator(ID_DUMMY, "DUMMY") { - ; - ; - } + DummyCredentialGenerator() : CredentialGenerator(ID_DUMMY, "DUMMY") {} std::string getInitArgs(std::string workingDir, bool userMode) override { std::string additionalArgs; diff --git a/tests/cpp/security/XmlAuthzCredentialGenerator.hpp b/tests/cpp/security/XmlAuthzCredentialGenerator.hpp index 5b120a29c5..c951689edd 100644 --- a/tests/cpp/security/XmlAuthzCredentialGenerator.hpp +++ b/tests/cpp/security/XmlAuthzCredentialGenerator.hpp @@ -84,7 +84,7 @@ class XmlAuthzCredentialGenerator { /* initialize random seed: */ srand(static_cast(time(nullptr))); } - virtual ~XmlAuthzCredentialGenerator() { ; } + virtual ~XmlAuthzCredentialGenerator() {} virtual void getAllowedCredentials(opCodeList& opCode, std::shared_ptr& prop, @@ -109,7 +109,7 @@ class XmlAuthzCredentialGenerator { case ID_DUMMY2: case ID_DUMMY3: break; - }; + } } catch (...) { reset(); @@ -147,7 +147,7 @@ class XmlAuthzCredentialGenerator { break; case NO_ROLE: /* UNNECESSARY role = role*/ break; - }; + } switch (m_id) { case ID_DUMMY: @@ -164,7 +164,7 @@ class XmlAuthzCredentialGenerator { case ID_DUMMY2: case ID_DUMMY3: break; - }; + } } catch (...) { reset(); @@ -200,7 +200,7 @@ class XmlAuthzCredentialGenerator { case NO_ROLE: sprintf(userName, kPRiUsername, "user", randomValue(2)); break; - }; + } (*m_prop)->insert("security-username", userName); (*m_prop)->insert("security-password", userName); @@ -250,7 +250,7 @@ class XmlAuthzCredentialGenerator { sprintf(userName, kPRiUsername, userPrefix.c_str(), adminIndices[randomValue(adminIndSz)]); break; - }; + } FWKINFO("inserted " << validity << " username " << userName); return std::string(userName); } diff --git a/tests/cpp/testobject/VariousPdxTypes.cpp b/tests/cpp/testobject/VariousPdxTypes.cpp index a0a6007fa9..a3f9ede8e7 100644 --- a/tests/cpp/testobject/VariousPdxTypes.cpp +++ b/tests/cpp/testobject/VariousPdxTypes.cpp @@ -334,7 +334,6 @@ PdxTypes6::PdxTypes6() { m_s2 = "two"; bytes128 = std::vector(2); bytes128[0] = 0x34; - ; bytes128[1] = 0x64; m_i1 = 34324; m_i2 = 2144;