You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2018/11/07 21:58:45 UTC
[geode-native] branch develop updated: GEODE-2484: Removes most
usage of ACE (#379)
This is an automated email from the ASF dual-hosted git repository.
jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push:
new 9b4c572 GEODE-2484: Removes most usage of ACE (#379)
9b4c572 is described below
commit 9b4c572ac0c63854641410a49521625c29a75bae
Author: Jacob Barrett <jb...@pivotal.io>
AuthorDate: Wed Nov 7 13:58:40 2018 -0800
GEODE-2484: Removes most usage of ACE (#379)
* Replaces warm spin lock with std::condition.
* Replaces ACE_OS:Sleep with std::this_thread::sleep_for
* Replaces ACE_OS:gettimeofday with std::choro::time_point
* Removes ACE_OS:gettimeofday
* No need to initialize the ACE PRNG since we don't use it.
* Unused code removed
* Fixes inclusion of <mutex> in C++/CLR.
* Replaces ACE_OS:gettimeofday with std::chrono::steady_clock
* Replaces ACE mutex with std::mutex.
* Replaces ACE::gettimeofday with std::chrono::duration.
* Replaces ACE_OS::localtime usage.
* Add thread safe wrapper around localtime, similar to ACE_OS::localtime.
* Update date formatting to use C++11 formatting functions.
* Refactor ACE_OS::snprintf to std::snprintf.
* Replace ACE_OS::strcasecmp with STL algorithm.
* Remove ACE_OS::time
* Replace ACE_OS::itoa with std::to_string.
* Replace ACE_OS::getcwd with boost::filesystem.
* Replace ACE_OS::getenv with std::getenv.
* Replace ACE_OS::memcpy with std::memcpy.
* Replace ACE_OS::strcmp with std::strcmp or std::string.
* Replace ACE_OS::atoi with std::stoi
* Replace ACE_OS::strlen with std::strlen
* Replace ACE_OS::num_processors with std::thread::hardware_concurrency()
* Replace ACE_OS::getpagesize() with boost::interprocess::mapped_region::get_page_size()
* Remove ACE_OS::memset
* Replace ACE_OS::strstr with std::string::find.
* Replace ACE_OS::getpid with boost::this_process::get_id
* Remove unused ACE headers.
* Replace htonl with boost::endian
* Replace ACE TSS with thread_local in DataOutput
---
clicache/src/Cache.hpp | 4 +
clicache/src/CacheableHashMap.hpp | 6 +-
clicache/src/CacheableObject.hpp | 4 +
clicache/src/CacheableObjectArray.hpp | 4 +
clicache/src/CacheableObjectXml.hpp | 4 +
clicache/src/CacheableUndefined.hpp | 6 +-
clicache/src/CacheableVector.hpp | 3 +
clicache/src/GeodeClassIds.hpp | 1 +
clicache/src/Log.cpp | 11 +-
clicache/src/Log.hpp | 7 -
clicache/src/begin_native.hpp | 3 +
clicache/src/end_native.hpp | 3 +-
clicache/src/geode_includes.hpp | 12 +-
clicache/src/impl/EnumInfo.hpp | 6 +-
clicache/src/impl/ManagedCacheableDelta.hpp | 3 +
clicache/src/impl/ManagedCacheableKey.hpp | 14 +-
clicache/src/impl/PdxFieldType.cpp | 1 +
clicache/src/impl/PdxManagedCacheableKey.hpp | 1 +
clicache/src/impl/PdxType.hpp | 4 +
cppcache/CMakeLists.txt | 3 +-
cppcache/integration-test/fw_spawn.hpp | 18 +-
cppcache/integration-test/testSpinLock.cpp | 36 ---
.../testThinClientSSLWithSecurityAuthz.cpp | 2 +-
.../testThinClientSecurityAuthorization.cpp | 2 +-
.../testThinClientSecurityAuthorizationMU.cpp | 2 +-
.../testThinClientSecurityCQAuthorizationMU.cpp | 2 +-
...tThinClientSecurityDurableCQAuthorizationMU.cpp | 2 +-
.../testThinClientWriterException.cpp | 2 +-
cppcache/src/CacheFactory.cpp | 3 -
cppcache/src/CacheImpl.cpp | 9 +-
cppcache/src/CacheImpl.hpp | 11 +-
cppcache/src/CacheTransactionManagerImpl.cpp | 312 ++-------------------
cppcache/src/CacheTransactionManagerImpl.hpp | 11 +-
cppcache/src/CacheXmlParser.cpp | 16 +-
cppcache/src/CacheableDate.cpp | 12 +-
cppcache/src/CacheableFileName.cpp | 2 -
cppcache/src/CacheableString.cpp | 3 -
cppcache/src/ClientHealthStats.cpp | 4 +-
cppcache/src/ClientMetadata.cpp | 2 -
cppcache/src/ClientMetadata.hpp | 4 -
cppcache/src/ClientMetadataService.cpp | 3 +-
cppcache/src/ClientMetadataService.hpp | 21 +-
cppcache/src/ClientProxyMembershipID.cpp | 57 +---
cppcache/src/ClientProxyMembershipID.hpp | 6 +-
cppcache/src/ClientProxyMembershipIDFactory.cpp | 4 +-
cppcache/src/Condition.cpp | 49 ----
cppcache/src/Condition.hpp | 81 ------
cppcache/src/CppCacheLibrary.cpp | 1 -
cppcache/src/CqAttributesImpl.cpp | 8 +-
cppcache/src/CqAttributesImpl.hpp | 23 +-
cppcache/src/CqEventImpl.cpp | 2 +-
cppcache/src/CqQueryImpl.cpp | 37 +--
cppcache/src/CqQueryImpl.hpp | 9 +-
cppcache/src/CqService.cpp | 5 +-
cppcache/src/CqService.hpp | 9 +-
cppcache/src/DataOutput.cpp | 17 +-
cppcache/src/DiffieHellman.cpp | 14 +-
cppcache/src/DiffieHellman.hpp | 2 -
cppcache/src/DiskStoreId.cpp | 25 +-
cppcache/src/DistributedSystem.cpp | 4 -
cppcache/src/DistributedSystemImpl.cpp | 31 +-
cppcache/src/DistributedSystemImpl.hpp | 7 +-
cppcache/src/EntryExpiryHandler.cpp | 13 +-
cppcache/src/EventId.cpp | 2 +-
cppcache/src/EventIdMap.cpp | 42 ++-
cppcache/src/EventIdMap.hpp | 24 +-
cppcache/src/EventSource.cpp | 3 +
cppcache/src/EvictionController.cpp | 7 +-
cppcache/src/EvictionController.hpp | 5 +-
cppcache/src/EvictionThread.cpp | 16 +-
cppcache/src/EvictionThread.hpp | 26 +-
cppcache/src/Exception.cpp | 27 +-
cppcache/src/ExceptionTypes.cpp | 225 +++++++--------
cppcache/src/ExecutionImpl.cpp | 7 +-
cppcache/src/ExecutionImpl.hpp | 7 +-
cppcache/src/ExpiryHandler_T.hpp | 3 +-
cppcache/src/ExpiryTaskManager.cpp | 16 +-
cppcache/src/ExpiryTaskManager.hpp | 7 +-
cppcache/src/IntQueue.hpp | 103 +++----
cppcache/src/LRUEntriesMap.cpp | 25 +-
cppcache/src/LocalRegion.hpp | 4 +-
cppcache/src/Log.cpp | 136 ++++-----
cppcache/src/MapSegment.cpp | 34 +--
cppcache/src/MapSegment.hpp | 12 +-
cppcache/src/MapWithLock.hpp | 3 +-
cppcache/src/MemberListForVersionStamp.hpp | 3 +-
cppcache/src/PdxFieldType.cpp | 12 +-
cppcache/src/PdxFieldType.hpp | 4 +-
cppcache/src/PdxInstanceImpl.cpp | 48 +---
cppcache/src/PdxReaderWithTypeCollector.cpp | 2 -
cppcache/src/PdxType.cpp | 2 -
cppcache/src/PdxType.hpp | 3 +-
cppcache/src/PdxTypeRegistry.hpp | 3 +-
cppcache/src/PoolAttributes.hpp | 2 -
cppcache/src/PoolFactory.cpp | 1 -
cppcache/src/PreservedDataExpiryHandler.cpp | 13 +-
cppcache/src/ProxyRemoteQueryService.cpp | 10 +-
cppcache/src/ProxyRemoteQueryService.hpp | 6 +-
cppcache/src/PutAllPartialResult.cpp | 4 +-
cppcache/src/PutAllPartialResult.hpp | 18 +-
.../src/PutAllPartialResultServerException.cpp | 2 +-
cppcache/src/Queue.hpp | 93 +++---
cppcache/src/ReadWriteLock.cpp | 38 ---
cppcache/src/ReadWriteLock.hpp | 27 +-
cppcache/src/RegionAttributes.cpp | 1 -
cppcache/src/RegionExpiryHandler.cpp | 13 +-
cppcache/src/RegionFactory.cpp | 5 +-
cppcache/src/RemoteQuery.cpp | 8 +-
cppcache/src/RemoteQueryService.cpp | 5 +-
cppcache/src/RemoteQueryService.hpp | 2 +-
cppcache/src/ServerLocation.hpp | 7 +-
cppcache/src/SslSockStream.cpp | 8 +-
cppcache/src/SuspendedTxExpiryHandler.cpp | 13 +-
cppcache/src/SystemProperties.cpp | 6 +-
cppcache/src/TcpConn.cpp | 46 ++-
cppcache/src/TcpConn.hpp | 7 +-
cppcache/src/TcpSslConn.cpp | 33 ++-
cppcache/src/TcpSslConn.hpp | 2 +-
cppcache/src/TcrConnection.cpp | 84 +-----
cppcache/src/TcrConnection.hpp | 11 +-
cppcache/src/TcrConnectionManager.cpp | 30 +-
cppcache/src/TcrConnectionManager.hpp | 27 +-
cppcache/src/TcrEndpoint.cpp | 69 +++--
cppcache/src/TcrEndpoint.hpp | 18 +-
cppcache/src/TcrMessage.hpp | 37 ++-
cppcache/src/TcrPoolEndPoint.cpp | 8 +-
cppcache/src/ThinClientBaseDM.cpp | 25 +-
cppcache/src/ThinClientBaseDM.hpp | 2 +-
.../src/ThinClientCacheDistributionManager.cpp | 2 +-
cppcache/src/ThinClientDistributionManager.cpp | 6 +-
cppcache/src/ThinClientDistributionManager.hpp | 19 +-
cppcache/src/ThinClientLocatorHelper.cpp | 10 +-
cppcache/src/ThinClientLocatorHelper.hpp | 5 +-
cppcache/src/ThinClientPoolDM.cpp | 132 ++++-----
cppcache/src/ThinClientPoolDM.hpp | 20 +-
cppcache/src/ThinClientPoolHADM.cpp | 16 +-
cppcache/src/ThinClientPoolHADM.hpp | 21 +-
cppcache/src/ThinClientRedundancyManager.cpp | 60 ++--
cppcache/src/ThinClientRedundancyManager.hpp | 19 +-
cppcache/src/ThinClientRegion.cpp | 68 ++---
cppcache/src/ThinClientRegion.hpp | 31 +-
cppcache/src/ThinClientStickyManager.cpp | 18 +-
cppcache/src/ThinClientStickyManager.hpp | 9 +-
cppcache/src/ThreadPool.cpp | 43 ++-
cppcache/src/ThreadPool.hpp | 50 +---
cppcache/src/TimeoutTimer.hpp | 73 -----
cppcache/src/TombstoneExpiryHandler.cpp | 38 +--
cppcache/src/TombstoneList.cpp | 13 +-
cppcache/src/TombstoneList.hpp | 20 +-
cppcache/src/TssConnectionWrapper.hpp | 2 -
cppcache/src/UserAttributes.cpp | 56 ++--
cppcache/src/UserAttributes.hpp | 39 +--
cppcache/src/Utils.cpp | 51 +---
cppcache/src/Utils.hpp | 2 -
cppcache/src/VersionStamp.cpp | 16 +-
cppcache/src/VersionedCacheableObjectPartList.cpp | 2 +-
cppcache/src/VersionedCacheableObjectPartList.hpp | 33 +--
cppcache/src/dllmain.cpp | 2 -
cppcache/src/internal/{ => chrono}/duration.cpp | 0
cppcache/src/statistics/AtomicStatisticsImpl.cpp | 46 +--
cppcache/src/statistics/GeodeStatisticsFactory.cpp | 18 +-
cppcache/src/statistics/GeodeStatisticsFactory.hpp | 3 +-
cppcache/src/statistics/HostStatSampler.cpp | 94 ++-----
cppcache/src/statistics/HostStatSampler.hpp | 10 +-
cppcache/src/statistics/OsStatisticsImpl.cpp | 44 +--
cppcache/src/statistics/PoolStatsSampler.cpp | 2 +-
cppcache/src/statistics/PoolStatsSampler.hpp | 6 +-
cppcache/src/statistics/StatArchiveWriter.cpp | 17 +-
cppcache/src/statistics/StatisticsManager.cpp | 23 +-
cppcache/src/statistics/StatisticsManager.hpp | 5 +-
cppcache/src/statistics/StatisticsTypeImpl.cpp | 36 +--
cppcache/src/util/Log.hpp | 11 +-
cppcache/src/util/chrono/time_point.hpp | 102 +++++++
cppcache/src/util/string.hpp | 11 +
cppcache/test/CMakeLists.txt | 3 +-
cppcache/test/CacheableDate.cpp | 125 +++++++++
.../test/ClientProxyMembershipIDFactoryTest.cpp | 7 +-
cppcache/test/DataOutputTest.cpp | 2 -
dependencies/boost/CMakeLists.txt | 4 +-
tests/cpp/fwklib/FwkBBClient.cpp | 5 +-
tests/cpp/fwklib/FwkStrCvt.hpp | 4 +-
tests/cpp/fwklib/Service.hpp | 3 +-
tests/cpp/fwklib/TimeBomb.hpp | 3 +-
183 files changed, 1550 insertions(+), 2385 deletions(-)
diff --git a/clicache/src/Cache.hpp b/clicache/src/Cache.hpp
index d45d10d..8766d62 100644
--- a/clicache/src/Cache.hpp
+++ b/clicache/src/Cache.hpp
@@ -22,6 +22,10 @@
#include "IGeodeCache.hpp"
#include "native_shared_ptr.hpp"
+#include "begin_native.hpp"
+#include <geode/Cache.hpp>
+#include "end_native.hpp"
+
using namespace System;
namespace Apache
diff --git a/clicache/src/CacheableHashMap.hpp b/clicache/src/CacheableHashMap.hpp
index f0c9389..702b69a 100644
--- a/clicache/src/CacheableHashMap.hpp
+++ b/clicache/src/CacheableHashMap.hpp
@@ -22,6 +22,10 @@
#include "ISerializable.hpp"
#include "IDataSerializablePrimitive.hpp"
+#include "begin_native.hpp"
+#include <geode/internal/DSCode.hpp>
+#include "end_native.hpp"
+
using namespace System;
using namespace System::Collections::Generic;
@@ -33,7 +37,7 @@ namespace Apache
{
namespace Client
{
- namespace native = apache::geode::client;
+ namespace native = apache::geode::client;
/// <summary>
/// A mutable <c>ICacheableKey</c> to <c>ISerializable</c> hash map
diff --git a/clicache/src/CacheableObject.hpp b/clicache/src/CacheableObject.hpp
index 53edfa1..acfe37b 100644
--- a/clicache/src/CacheableObject.hpp
+++ b/clicache/src/CacheableObject.hpp
@@ -21,6 +21,10 @@
#include "geode_defs.hpp"
#include "IDataSerializablePrimitive.hpp"
+#include "begin_native.hpp"
+#include <geode/internal/InternalId.hpp>
+#include "end_native.hpp"
+
using namespace System;
namespace Apache
diff --git a/clicache/src/CacheableObjectArray.hpp b/clicache/src/CacheableObjectArray.hpp
index 6cce069..e3bcb34 100644
--- a/clicache/src/CacheableObjectArray.hpp
+++ b/clicache/src/CacheableObjectArray.hpp
@@ -20,6 +20,10 @@
#include "geode_defs.hpp"
#include "IDataSerializablePrimitive.hpp"
+#include "begin_native.hpp"
+#include <geode/internal/DSCode.hpp>
+#include "end_native.hpp"
+
using namespace System;
using namespace System::Collections::Generic;
diff --git a/clicache/src/CacheableObjectXml.hpp b/clicache/src/CacheableObjectXml.hpp
index ef7c610..0e4c5e1 100644
--- a/clicache/src/CacheableObjectXml.hpp
+++ b/clicache/src/CacheableObjectXml.hpp
@@ -21,6 +21,10 @@
#include "geode_defs.hpp"
#include "IDataSerializablePrimitive.hpp"
+#include "begin_native.hpp"
+#include <geode/internal/InternalId.hpp>
+#include "end_native.hpp"
+
using namespace System;
namespace Apache
diff --git a/clicache/src/CacheableUndefined.hpp b/clicache/src/CacheableUndefined.hpp
index f4f3a5a..f217911 100644
--- a/clicache/src/CacheableUndefined.hpp
+++ b/clicache/src/CacheableUndefined.hpp
@@ -23,6 +23,10 @@
#include "ISerializable.hpp"
#include "Log.hpp"
+#include "begin_native.hpp"
+#include <geode/internal/DSFixedId.hpp>
+#include "end_native.hpp"
+
using namespace System;
namespace Apache
@@ -92,7 +96,7 @@ namespace Apache
{
virtual Int32 get()
{
- return static_cast<Int32>(native::DSFid::CacheableUndefined);
+ return static_cast<Int32>(native::internal::DSFid::CacheableUndefined);
}
}
diff --git a/clicache/src/CacheableVector.hpp b/clicache/src/CacheableVector.hpp
index bb820aa..c944f0d 100644
--- a/clicache/src/CacheableVector.hpp
+++ b/clicache/src/CacheableVector.hpp
@@ -22,6 +22,9 @@
#include "IDataSerializablePrimitive.hpp"
#include "ISerializable.hpp"
+#include "begin_native.hpp"
+#include <geode/internal/DSCode.hpp>
+#include "end_native.hpp"
using namespace System;
using namespace System::Collections::Generic;
diff --git a/clicache/src/GeodeClassIds.hpp b/clicache/src/GeodeClassIds.hpp
index f28b031..56a1066 100644
--- a/clicache/src/GeodeClassIds.hpp
+++ b/clicache/src/GeodeClassIds.hpp
@@ -19,6 +19,7 @@
#include "geode_defs.hpp"
#include "begin_native.hpp"
+#include <geode/internal/InternalId.hpp>
#include "end_native.hpp"
namespace Apache
diff --git a/clicache/src/Log.cpp b/clicache/src/Log.cpp
index 333f03c..4264fd4 100644
--- a/clicache/src/Log.cpp
+++ b/clicache/src/Log.cpp
@@ -18,9 +18,9 @@
#include "Log.hpp"
+#include "ExceptionTypes.hpp"
#include "impl/ManagedString.hpp"
#include "impl/SafeConvert.hpp"
-#include "ExceptionTypes.hpp"
using namespace System;
@@ -70,15 +70,6 @@ namespace Apache
static_cast<apache::geode::client::LogLevel>(level));
}
- String^ Log::LogFileName()
- {
- _GF_MG_EXCEPTION_TRY2
-
- return ManagedString::Get(apache::geode::client::Log::logFileName());
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
bool Log::Enabled(LogLevel level)
{
return apache::geode::client::Log::enabled(
diff --git a/clicache/src/Log.hpp b/clicache/src/Log.hpp
index 7ac9514..5409646 100644
--- a/clicache/src/Log.hpp
+++ b/clicache/src/Log.hpp
@@ -199,13 +199,6 @@ namespace Apache
static void SetLevel(LogLevel level);
/// <summary>
- /// Returns the name of the current log file.
- /// NOTE: This function is for debugging only, as it is not completely
- /// thread-safe!
- /// </summary>
- static String^ LogFileName();
-
- /// <summary>
/// True if log messages at the given level are enabled.
/// </summary>
static bool Enabled(LogLevel level);
diff --git a/clicache/src/begin_native.hpp b/clicache/src/begin_native.hpp
index 36bf715..7d1d331 100644
--- a/clicache/src/begin_native.hpp
+++ b/clicache/src/begin_native.hpp
@@ -28,6 +28,9 @@
#undef nullptr
#define nullptr __nullptr
+#pragma push_macro("_M_CEE")
+#undef _M_CEE
+
#pragma warning(push)
// Disable XML warnings
diff --git a/clicache/src/end_native.hpp b/clicache/src/end_native.hpp
index 996b31d..b2134df 100644
--- a/clicache/src/end_native.hpp
+++ b/clicache/src/end_native.hpp
@@ -21,7 +21,8 @@
#pragma warning(pop)
+#pragma pop_macro("_M_CEE")
#pragma pop_macro("nullptr")
#pragma pop_macro("_ALLOW_KEYWORD_MACROS")
-#undef __begin_native__hpp__
\ No newline at end of file
+#undef __begin_native__hpp__
diff --git a/clicache/src/geode_includes.hpp b/clicache/src/geode_includes.hpp
index 8ddce3f..49277de 100644
--- a/clicache/src/geode_includes.hpp
+++ b/clicache/src/geode_includes.hpp
@@ -32,10 +32,17 @@
#include "begin_native.hpp"
#include <geode/Cache.hpp>
#include <geode/CacheableBuiltins.hpp>
-#include <geode/CacheLoader.hpp>
#include <geode/CacheListener.hpp>
-#include <geode/FixedPartitionResolver.hpp>
+#include <geode/CacheLoader.hpp>
#include <geode/CacheWriter.hpp>
+#include <geode/DataSerializable.hpp>
+#include <geode/PdxSerializable.hpp>
+#include <geode/FixedPartitionResolver.hpp>
+#include <geode/internal/DataSerializableFixedId.hpp>
+#include <geode/internal/DataSerializablePrimitive.hpp>
+#include <geode/internal/DataSerializableInternal.hpp>
+#include <geode/internal/DSCode.hpp>
+#include <geode/internal/DSFixedId.hpp>
#include <geode/internal/InternalId.hpp>
#include "end_native.hpp"
@@ -43,4 +50,5 @@
#include "begin_native.hpp"
#include <CacheImpl.hpp>
#include <DistributedSystemImpl.hpp>
+#include <PdxFieldType.hpp>
#include "end_native.hpp"
diff --git a/clicache/src/impl/EnumInfo.hpp b/clicache/src/impl/EnumInfo.hpp
index 7cca168..0361543 100755
--- a/clicache/src/impl/EnumInfo.hpp
+++ b/clicache/src/impl/EnumInfo.hpp
@@ -20,6 +20,10 @@
#include "../IDataSerializableFixedId.hpp"
#include "../ISerializable.hpp"
+#include "../begin_native.hpp"
+#include <geode/internal/DSFixedId.hpp>
+#include "../end_native.hpp"
+
using namespace System;
using namespace System::Collections::Generic;
@@ -69,7 +73,7 @@ namespace Apache
property Int32 DSFID
{
- virtual Int32 get() { return static_cast<Int32>(apache::geode::client::DSFid::EnumInfo); }
+ virtual Int32 get() { return static_cast<Int32>(apache::geode::client::internal::DSFid::EnumInfo); }
}
virtual String^ ToString() override
diff --git a/clicache/src/impl/ManagedCacheableDelta.hpp b/clicache/src/impl/ManagedCacheableDelta.hpp
index fb7b193..cd35897 100644
--- a/clicache/src/impl/ManagedCacheableDelta.hpp
+++ b/clicache/src/impl/ManagedCacheableDelta.hpp
@@ -22,6 +22,9 @@
#include "../geode_defs.hpp"
#include "../begin_native.hpp"
+#include <geode/CacheableKey.hpp>
+#include <geode/Delta.hpp>
+#include <geode/DataSerializable.hpp>
#include "../end_native.hpp"
#include "../IDelta.hpp"
#include "../IDataSerializable.hpp"
diff --git a/clicache/src/impl/ManagedCacheableKey.hpp b/clicache/src/impl/ManagedCacheableKey.hpp
index 491c22a..03d87ae 100644
--- a/clicache/src/impl/ManagedCacheableKey.hpp
+++ b/clicache/src/impl/ManagedCacheableKey.hpp
@@ -22,6 +22,10 @@
#include <vcclr.h>
#include "../begin_native.hpp"
#include <geode/CacheableKey.hpp>
+#include <geode/DataSerializable.hpp>
+#include <geode/internal/DataSerializableFixedId.hpp>
+#include <geode/internal/DataSerializablePrimitive.hpp>
+#include <geode/internal/DataSerializableInternal.hpp>
#include "../end_native.hpp"
#include "../IDataSerializable.hpp"
@@ -119,7 +123,7 @@ namespace apache
};
class ManagedDataSerializablePrimitive
- : public native::DataSerializablePrimitive , public native::CacheableKey
+ : public native::internal::DataSerializablePrimitive , public native::CacheableKey
{
public:
@@ -139,7 +143,7 @@ namespace apache
void fromData(DataInput& input) override;
- DSCode getDsCode() const override { return static_cast<DSCode>(m_managedptr->DsCode); }
+ native::internal::DSCode getDsCode() const override { return static_cast<native::internal::DSCode>(m_managedptr->DsCode); }
bool operator == (const CacheableKey& other) const override;
@@ -156,7 +160,7 @@ namespace apache
};
class ManagedDataSerializableInternal
- : public native::DataSerializableInternal
+ : public native::internal::DataSerializableInternal
{
public:
@@ -187,7 +191,7 @@ namespace apache
};
class ManagedDataSerializableFixedId
- : public native::DataSerializableFixedId
+ : public native::internal::DataSerializableFixedId
{
public:
@@ -207,7 +211,7 @@ namespace apache
void fromData(DataInput& input) override;
- DSFid getDSFID() const override { return static_cast<DSFid>(m_managedptr->DSFID); }
+ native::internal::DSFid getDSFID() const override { return static_cast<native::internal::DSFid>(m_managedptr->DSFID); }
inline Apache::Geode::Client::IDataSerializableFixedId^ ptr() const
{
diff --git a/clicache/src/impl/PdxFieldType.cpp b/clicache/src/impl/PdxFieldType.cpp
index 04d8f99..543fcd4 100644
--- a/clicache/src/impl/PdxFieldType.cpp
+++ b/clicache/src/impl/PdxFieldType.cpp
@@ -21,6 +21,7 @@
#include "PdxFieldType.hpp"
#include "../begin_native.hpp"
#include <PdxTypes.hpp>
+#include <PdxFieldType.hpp>
#include "../end_native.hpp"
diff --git a/clicache/src/impl/PdxManagedCacheableKey.hpp b/clicache/src/impl/PdxManagedCacheableKey.hpp
index 12ddcba..b3f14d0 100644
--- a/clicache/src/impl/PdxManagedCacheableKey.hpp
+++ b/clicache/src/impl/PdxManagedCacheableKey.hpp
@@ -22,6 +22,7 @@
#include "../begin_native.hpp"
#include <geode/CacheableKey.hpp>
#include <geode/Delta.hpp>
+#include <geode/PdxSerializable.hpp>
#include "../end_native.hpp"
#include "../geode_defs.hpp"
diff --git a/clicache/src/impl/PdxType.hpp b/clicache/src/impl/PdxType.hpp
index 90c6854..86737e0 100644
--- a/clicache/src/impl/PdxType.hpp
+++ b/clicache/src/impl/PdxType.hpp
@@ -19,6 +19,10 @@
#include "PdxFieldType.hpp"
+#include "../begin_native.hpp"
+#include <PdxFieldType.hpp>
+#include "../end_native.hpp"
+
using namespace System;
using namespace System::Collections::Generic;
diff --git a/cppcache/CMakeLists.txt b/cppcache/CMakeLists.txt
index 5182494..0ad660b 100644
--- a/cppcache/CMakeLists.txt
+++ b/cppcache/CMakeLists.txt
@@ -87,7 +87,8 @@ endif()
target_link_libraries(_apache-geode INTERFACE
ACE
- boost
+ Boost::boost
+ Boost::filesystem
libxml2
)
diff --git a/cppcache/integration-test/fw_spawn.hpp b/cppcache/integration-test/fw_spawn.hpp
index 0411a63..e49da7d 100644
--- a/cppcache/integration-test/fw_spawn.hpp
+++ b/cppcache/integration-test/fw_spawn.hpp
@@ -22,13 +22,13 @@
// Spawn.cpp,v 1.4 2004/01/07 22:40:16 shuston Exp
// @TODO, this out this include list..
-#include "ace/OS_NS_stdio.h"
-#include "ace/OS_NS_fcntl.h"
-#include "ace/OS_NS_pwd.h"
-#include "ace/os_include/os_pwd.h"
-#include "ace/OS_NS_stdlib.h"
-#include "ace/OS_NS_string.h"
-#include "ace/OS_NS_unistd.h"
+#include <ace/OS_NS_stdio.h>
+#include <ace/OS_NS_fcntl.h>
+#include <ace/OS_NS_pwd.h>
+#include <ace/os_include/os_pwd.h>
+#include <ace/OS_NS_stdlib.h>
+#include <ace/OS_NS_string.h>
+#include <ace/OS_NS_unistd.h>
#if defined(_WIN32)
#if (FD_SETSIZE != 1024)
@@ -36,8 +36,8 @@
#endif
#endif
-#include "ace/Process.h"
-#include "ace/Log_Msg.h"
+#include <ace/Process.h>
+#include <ace/Log_Msg.h>
namespace dunit {
diff --git a/cppcache/integration-test/testSpinLock.cpp b/cppcache/integration-test/testSpinLock.cpp
index 348add1..ec93060 100644
--- a/cppcache/integration-test/testSpinLock.cpp
+++ b/cppcache/integration-test/testSpinLock.cpp
@@ -20,8 +20,6 @@
#include <mutex>
#include <util/concurrent/spinlock_mutex.hpp>
-#include <Condition.hpp>
-
#include <ace/Task.h>
#include <ace/Time_Value.h>
#include <ace/Guard_T.h>
@@ -117,38 +115,4 @@ DUNIT_TASK(s1p1, TwoThreads)
}
END_TASK(TwoThreads)
-DUNIT_TASK(s1p1, Cond)
- {
- // Test that the Condtion wrapper times out properly.
- // Does not test signal..
- ACE_Time_Value stopAt = ACE_OS::gettimeofday();
- stopAt -= 10; // Make sure it is in the past.
-
- ACE_Recursive_Thread_Mutex mutex;
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(mutex);
- apache::geode::client::Condition cond(mutex);
- LOG("About to wait on Condition with past time.");
- if (cond.waitUntil(&stopAt) != false) {
- FAIL("Should have timed out immediately.");
- }
-
- stopAt = ACE_OS::gettimeofday();
- LOG("About to wait on Condition with present time.");
- if (cond.waitUntil(&stopAt) != false) {
- FAIL("Should have timed out immediately.");
- }
-
- ACE_Time_Value begin = ACE_OS::gettimeofday();
- stopAt = begin;
- ACE_Time_Value delay(5);
- stopAt += delay;
- if (cond.waitUntil(&stopAt) != false) {
- FAIL("Should have timed out immediately.");
- }
- ACE_Time_Value delta = ACE_OS::gettimeofday();
- delta -= begin;
- printf("delta is %lu, delay is %lu", delta.msec(), delay.msec());
- XASSERT(delta.msec() >= (delay.msec() - 50));
- }
-ENDTASK
} // namespace
diff --git a/cppcache/integration-test/testThinClientSSLWithSecurityAuthz.cpp b/cppcache/integration-test/testThinClientSSLWithSecurityAuthz.cpp
index 81d7cf0..0b68be8 100644
--- a/cppcache/integration-test/testThinClientSSLWithSecurityAuthz.cpp
+++ b/cppcache/integration-test/testThinClientSSLWithSecurityAuthz.cpp
@@ -24,7 +24,7 @@
#include "CacheHelper.hpp"
#include "ThinClientHelper.hpp"
-#include "ace/Process.h"
+#include <ace/Process.h>
#include "ThinClientSecurity.hpp"
diff --git a/cppcache/integration-test/testThinClientSecurityAuthorization.cpp b/cppcache/integration-test/testThinClientSecurityAuthorization.cpp
index 450e840..cc1c8ea 100644
--- a/cppcache/integration-test/testThinClientSecurityAuthorization.cpp
+++ b/cppcache/integration-test/testThinClientSecurityAuthorization.cpp
@@ -23,7 +23,7 @@
#include "CacheHelper.hpp"
#include "ThinClientHelper.hpp"
-#include "ace/Process.h"
+#include <ace/Process.h>
#include "ThinClientSecurity.hpp"
diff --git a/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp b/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
index c20ffd1..5d2d05c 100644
--- a/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
@@ -26,7 +26,7 @@
#include "CacheHelper.hpp"
#include "ThinClientHelper.hpp"
-#include "ace/Process.h"
+#include <ace/Process.h>
#include "ThinClientSecurity.hpp"
diff --git a/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp b/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
index e29691b..e1fef02 100644
--- a/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
@@ -40,7 +40,7 @@
#include "CacheHelper.hpp"
#include "ThinClientHelper.hpp"
-#include "ace/Process.h"
+#include <ace/Process.h>
using apache::geode::client::testframework::security::CredentialGenerator;
diff --git a/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp b/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
index 8754d34..9fa35ab 100644
--- a/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
@@ -40,7 +40,7 @@
#include "CacheHelper.hpp"
#include "ThinClientHelper.hpp"
-#include "ace/Process.h"
+#include <ace/Process.h>
using apache::geode::client::AuthenticatedView;
using apache::geode::client::CqAttributesFactory;
diff --git a/cppcache/integration-test/testThinClientWriterException.cpp b/cppcache/integration-test/testThinClientWriterException.cpp
index 0e8df9c..ea54f5f 100644
--- a/cppcache/integration-test/testThinClientWriterException.cpp
+++ b/cppcache/integration-test/testThinClientWriterException.cpp
@@ -16,7 +16,7 @@
*/
#include "fw_dunit.hpp"
#include "ThinClientHelper.hpp"
-#include "ace/Process.h"
+#include <ace/Process.h>
#include "TallyListener.hpp"
#include "TallyWriter.hpp"
diff --git a/cppcache/src/CacheFactory.cpp b/cppcache/src/CacheFactory.cpp
index 3f368fe..b6ebb8d 100644
--- a/cppcache/src/CacheFactory.cpp
+++ b/cppcache/src/CacheFactory.cpp
@@ -19,9 +19,6 @@
#include <map>
#include <string>
-#include <ace/Guard_T.h>
-#include <ace/Recursive_Thread_Mutex.h>
-
#include <geode/Cache.hpp>
#include <geode/CacheFactory.hpp>
#include <geode/PoolManager.hpp>
diff --git a/cppcache/src/CacheImpl.cpp b/cppcache/src/CacheImpl.cpp
index f18c67d..fab2d60 100644
--- a/cppcache/src/CacheImpl.cpp
+++ b/cppcache/src/CacheImpl.cpp
@@ -14,12 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "CacheImpl.hpp"
#include <string>
-#include <ace/OS.h>
-
#include <geode/CacheStatistics.hpp>
#include <geode/PersistenceManager.hpp>
#include <geode/PoolManager.hpp>
@@ -65,7 +64,6 @@ CacheImpl::CacheImpl(Cache* c, const std::shared_ptr<Properties>& dsProps,
m_distributedSystem(DistributedSystem::create(DEFAULT_DS_NAME, dsProps)),
m_clientProxyMembershipIDFactory(m_distributedSystem.getName()),
m_cache(c),
- m_cond(m_mutex),
m_attributes(nullptr),
m_evictionControllerPtr(nullptr),
m_tcrConnectionManager(nullptr),
@@ -384,7 +382,7 @@ void CacheImpl::createRegion(std::string name,
RegionAttributes regionAttributes,
std::shared_ptr<Region>& regionPtr) {
{
- ACE_Guard<ACE_Thread_Mutex> _guard(m_initDoneLock);
+ std::lock_guard<decltype(m_initDoneLock)> _guard(m_initDoneLock);
if (!m_initDone) {
if (regionAttributes.getPoolName().empty()) {
m_tcrConnectionManager->init();
@@ -706,7 +704,8 @@ bool CacheImpl::getEndpointStatus(const std::string& endpoint) {
const auto firstPool =
std::static_pointer_cast<ThinClientPoolDM>(pools.begin()->second);
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(firstPool->m_endpointsLock);
+ auto& mutex = firstPool->m_endpointsLock;
+ std::lock_guard<decltype(mutex)> guard(mutex);
for (const auto& itr : firstPool->m_endpoints) {
const auto& ep = itr.int_id_;
if (ep->name().find(fullName) != std::string::npos) {
diff --git a/cppcache/src/CacheImpl.hpp b/cppcache/src/CacheImpl.hpp
index f0f6908..f60104c 100644
--- a/cppcache/src/CacheImpl.hpp
+++ b/cppcache/src/CacheImpl.hpp
@@ -22,11 +22,9 @@
#include <atomic>
#include <memory>
+#include <mutex>
-#include <ace/ACE.h>
-#include <ace/Guard_T.h>
-#include <ace/Recursive_Thread_Mutex.h>
-#include <ace/Time_Value.h>
+#include <ace/RW_Thread_Mutex.h>
#include <geode/Cache.hpp>
#include <geode/CacheAttributes.hpp>
@@ -37,7 +35,6 @@
#include "AdminRegion.hpp"
#include "CachePerfStats.hpp"
#include "ClientProxyMembershipIDFactory.hpp"
-#include "Condition.hpp"
#include "DistributedSystem.hpp"
#include "EvictionController.hpp"
#include "MapWithLock.hpp"
@@ -384,8 +381,6 @@ class APACHE_GEODE_EXPORT CacheImpl : private NonCopyable,
ClientProxyMembershipIDFactory m_clientProxyMembershipIDFactory;
MapOfRegionWithLock* m_regions;
Cache* m_cache;
- ACE_Recursive_Thread_Mutex m_mutex;
- Condition m_cond;
std::shared_ptr<CacheAttributes> m_attributes;
EvictionController* m_evictionControllerPtr;
TcrConnectionManager* m_tcrConnectionManager;
@@ -393,7 +388,7 @@ class APACHE_GEODE_EXPORT CacheImpl : private NonCopyable,
ACE_RW_Thread_Mutex m_destroyCacheMutex;
volatile bool m_destroyPending;
volatile bool m_initDone;
- ACE_Thread_Mutex m_initDoneLock;
+ std::mutex m_initDoneLock;
std::shared_ptr<AdminRegion> m_adminRegion;
std::shared_ptr<CacheTransactionManager> m_cacheTXManager;
diff --git a/cppcache/src/CacheTransactionManagerImpl.cpp b/cppcache/src/CacheTransactionManagerImpl.cpp
index 27a5e96..5c74a16 100644
--- a/cppcache/src/CacheTransactionManagerImpl.cpp
+++ b/cppcache/src/CacheTransactionManagerImpl.cpp
@@ -36,7 +36,7 @@ namespace geode {
namespace client {
CacheTransactionManagerImpl::CacheTransactionManagerImpl(CacheImpl* cache)
- : m_cache(cache), m_txCond(m_suspendedTxLock) {}
+ : m_cache(cache) {}
CacheTransactionManagerImpl::~CacheTransactionManagerImpl() {}
@@ -111,140 +111,6 @@ void CacheTransactionManagerImpl::commit() {
auto commit = std::dynamic_pointer_cast<TXCommitMessage>(reply.getValue());
txCleaner.clean();
commit->apply(m_cache->getCache());
-
- /*
- if(m_writer != nullptr)
- {
- try
- {
- std::shared_ptr<TransactionEvent> event(new
- TransactionEvent(txState->getTransactionId(),
- std::shared_ptr<Cache>(m_cache), commit->getEvents(m_cache)));
- m_writer->beforeCommit(event);
- } catch(const TransactionWriterException& ex)
- {
- noteCommitFailure(txState, commit);
- GfErrTypeThrowException(ex.what(),
- GF_COMMIT_CONFLICT_EXCEPTION);
- }
- catch (const Exception& ex)
- {
- noteCommitFailure(txState, commit);
- LOGERROR("Unexpected exception during writer callback
- %s", ex.what());
- throw ex;
- }
- catch (...)
- {
- noteCommitFailure(txState, commit);
- LOGERROR("Unexpected exception during writer
- callback");
- throw;
- }
- }
- */
-
- /*try
- {
- TcrMessage requestCommitBefore(TcrMessage::TX_SYNCHRONIZATION,
-BEFORE_COMMIT, txState->getTransactionId()->getId(), STATUS_COMMITTED);
- TcrMessage replyCommitBefore;
- err = tcr_dm->sendSyncRequest(requestCommitBefore, replyCommitBefore);
- if(err != GF_NOERR)
- {
- GfErrTypeThrowException("Error while committing", err);
- } else {
- switch (replyCommitBefore.getMessageType()) {
- case TcrMessage::REPLY: {
- break;
- }
- case TcrMessage::EXCEPTION: {
- const char* exceptionMsg =
-replyCommitBefore.getException();
- err =
-ThinClientRegion::handleServerException("CacheTransactionManager::commit",
- exceptionMsg);
- GfErrTypeThrowException("Commit
-Failed", err);
- break;
- }
- case TcrMessage::REQUEST_DATA_ERROR: {
- GfErrTypeThrowException("Commit Failed",
-GF_COMMIT_CONFLICT_EXCEPTION);
- break;
- }
- default: {
- LOGERROR("Unknown message type in commit reply %d",
-reply.getMessageType());
- GfErrTypeThrowException("Commit
-Failed", GF_MSG);
- break;
- }
- }
- }
- }
- catch (const Exception& ex)
- {
-// noteCommitFailure(txState, commit);
- LOGERROR("Unexpected exception during commit %s", ex.what());
- throw ex;
- }
- catch (...)
- {
-// noteCommitFailure(txState, commit);
- LOGERROR("Unexpected exception during writer callback");
- throw;
- }
-
- try{
- TcrMessage requestCommitAfter(TcrMessage::TX_SYNCHRONIZATION,
-AFTER_COMMIT, txState->getTransactionId()->getId(), STATUS_COMMITTED);
- TcrMessage replyCommitAfter;
- txCleaner.clean();
- commit->apply(m_cache);
- err = tcr_dm->sendSyncRequest(requestCommitAfter, replyCommitAfter);
-
- if(err != GF_NOERR)
- {
- GfErrTypeThrowException("Error while committing", err);
- } else {
- switch (replyCommitAfter.getMessageType()) {
- case TcrMessage::RESPONSE: {
- //commit = replyCommitAfter.getValue();
- break;
- }
- case TcrMessage::EXCEPTION: {
- const char* exceptionMsg =
-replyCommitAfter.getException();
- err = ThinClientRegion::handleServerException("CacheTransactionManager::commit",
- exceptionMsg);
- GfErrTypeThrowException("Commit Failed", err);
- break;
- }
- case TcrMessage::REQUEST_DATA_ERROR: {
- GfErrTypeThrowException("Commit Failed",
-GF_COMMIT_CONFLICT_EXCEPTION);
- break;
- }
- default: {
- GfErrTypeThrowException("Commit Failed", GF_MSG);
- break;
- }
- }
- }
- }
- catch (const Exception& ex)
- {
-// noteCommitFailure(txState, commit);
- throw ex;
- }
- catch (...)
- {
-// noteCommitFailure(txState, commit);
- throw;
- }*/
-
- // noteCommitSuccess(txState, commit);
}
void CacheTransactionManagerImpl::rollback() {
@@ -482,79 +348,61 @@ bool CacheTransactionManagerImpl::exists() {
}
void CacheTransactionManagerImpl::addTx(int32_t txId) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_txLock);
+ std::unique_lock<decltype(m_txLock)> _guard(m_txLock);
m_TXs.push_back(txId);
}
-bool CacheTransactionManagerImpl::removeTx(int32_t txId) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_txLock);
-
- for (std::vector<int32_t>::iterator iter = m_TXs.begin(); iter != m_TXs.end();
- ++iter) {
- if (*iter == txId) {
- m_TXs.erase(iter);
- return true;
- }
- }
- return false;
+void CacheTransactionManagerImpl::removeTx(int32_t txId) {
+ std::unique_lock<decltype(m_txLock)> _guard(m_txLock);
+ m_TXs.erase(std::remove(m_TXs.begin(), m_TXs.end(), txId), m_TXs.end());
}
bool CacheTransactionManagerImpl::findTx(int32_t txId) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_txLock);
-
- for (std::vector<int32_t>::iterator iter = m_TXs.begin(); iter != m_TXs.end();
- ++iter) {
- if (*iter == txId) return true;
- }
- return false;
+ std::unique_lock<decltype(m_txLock)> _guard(m_txLock);
+ return std::find(m_TXs.begin(), m_TXs.end(), txId) != m_TXs.end();
}
void CacheTransactionManagerImpl::addSuspendedTx(int32_t txId,
TXState* txState) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_suspendedTxLock);
+ std::unique_lock<decltype(m_suspendedTxLock)> _guard(m_suspendedTxLock);
m_suspendedTXs[txId] = txState;
- // signal if some thread is waiting for this transaction to suspend
- m_txCond.broadcast();
+ m_txCond.notify_all();
}
TXState* CacheTransactionManagerImpl::getSuspendedTx(int32_t txId) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_suspendedTxLock);
- std::map<int32_t, TXState*>::iterator it = m_suspendedTXs.find(txId);
+ std::unique_lock<decltype(m_suspendedTxLock)> _guard(m_suspendedTxLock);
+ auto&& it = m_suspendedTXs.find(txId);
if (it == m_suspendedTXs.end()) return nullptr;
- TXState* rettxState = (*it).second;
+ auto rettxState = (*it).second;
return rettxState;
}
TXState* CacheTransactionManagerImpl::removeSuspendedTx(int32_t txId) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_suspendedTxLock);
- std::map<int32_t, TXState*>::iterator it = m_suspendedTXs.find(txId);
+ std::unique_lock<decltype(m_suspendedTxLock)> _guard(m_suspendedTxLock);
+ auto&& it = m_suspendedTXs.find(txId);
if (it == m_suspendedTXs.end()) return nullptr;
- TXState* rettxState = (*it).second;
+ auto rettxState = (*it).second;
m_suspendedTXs.erase(it);
return rettxState;
}
+
TXState* CacheTransactionManagerImpl::removeSuspendedTx(
int32_t txId, std::chrono::milliseconds waitTime) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_suspendedTxLock);
- TXState* txState = nullptr;
- ACE_Time_Value currTime(ACE_OS::gettimeofday());
- ACE_Time_Value stopAt(currTime);
- stopAt += waitTime;
-
- do {
- txState = removeSuspendedTx(txId);
- if (txState == nullptr) {
- LOGFINE("Wait for the connection to get suspended, Tid: %d", txId);
- m_txCond.wait(&stopAt);
- }
+ std::unique_lock<decltype(m_suspendedTxLock)> _guard(m_suspendedTxLock);
+
+ auto txState = removeSuspendedTx(txId);
+ if (txState == nullptr) {
+ LOGFINE("Wait for the connection to get suspended, Tid: %d", txId);
+ m_txCond.wait_for(_guard, waitTime, [this, txId, &txState] {
+ return nullptr != (txState = removeSuspendedTx(txId));
+ });
+ }
- } while (txState == nullptr && findTx(txId) &&
- (currTime = ACE_OS::gettimeofday()) < stopAt);
return txState;
}
bool CacheTransactionManagerImpl::isSuspendedTx(int32_t txId) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_suspendedTxLock);
- std::map<int32_t, TXState*>::iterator it = m_suspendedTXs.find(txId);
+ std::unique_lock<decltype(m_suspendedTxLock)> _guard(m_suspendedTxLock);
+ auto&& it = m_suspendedTXs.find(txId);
if (it == m_suspendedTXs.end()) {
return false;
} else {
@@ -563,114 +411,10 @@ bool CacheTransactionManagerImpl::isSuspendedTx(int32_t txId) {
}
TransactionId& CacheTransactionManagerImpl::getTransactionId() {
- TXState* txState = TSSTXStateWrapper::s_geodeTSSTXState->getTXState();
+ auto txState = TSSTXStateWrapper::s_geodeTSSTXState->getTXState();
return txState->getTransactionId();
}
-/*
-void CacheTransactionManagerImpl::setWriter(std::shared_ptr<TransactionWriter>
-writer)
-{
- m_writer = writer;
-}
- std::shared_ptr<TransactionWriter> CacheTransactionManagerImpl::getWriter()
-{
- return m_writer;
-}
-
-void
-CacheTransactionManagerImpl::addListener(std::shared_ptr<TransactionListener>
-aListener)
-{
- if(aListener == nullptr)
- {
- GfErrTypeThrowException("Trying to add null listener.",
-GF_CACHE_ILLEGAL_ARGUMENT_EXCEPTION);
- }
- if(!m_listeners.contains(aListener))
- {
- m_listeners.insert(aListener);
- }
-}
-
-void
-CacheTransactionManagerImpl::removeListener(std::shared_ptr<TransactionListener>
-aListener)
-{
- if(aListener == nullptr)
- {
- GfErrTypeThrowException("Trying to remove null listener.",
-GF_CACHE_ILLEGAL_ARGUMENT_EXCEPTION);
- }
- if(m_listeners.erase(aListener))
- {
- aListener->close();
- }
-}
-
-void CacheTransactionManagerImpl::noteCommitFailure(TXState* txState, const
-std::shared_ptr<TXCommitMessage>& commitMessage)
-{
- VectorOfEntryEvent events;
- if(commitMessage!= nullptr)
- {
- events = commitMessage->getEvents(m_cache);
- }
- std::shared_ptr<TransactionEvent> event(new
-TransactionEvent(txState->getTransactionId(), std::shared_ptr<Cache>(m_cache),
-events));
-
- for(HashSetOfSharedBase::Iterator iter = m_listeners.begin();
-m_listeners.end() != iter; iter++)
- {
- auto listener =
-std::static_pointer_cast<TransactionListener>(*iter);
- listener->afterFailedCommit(event);
- }
-}
-
-void CacheTransactionManagerImpl::noteCommitSuccess(TXState* txState, const
-std::shared_ptr<TXCommitMessage>& commitMessage)
-{
- VectorOfEntryEvent events;
- if(commitMessage!= nullptr)
- {
- events = commitMessage->getEvents(m_cache);
- }
- std::shared_ptr<TransactionEvent> event(new
-TransactionEvent(txState->getTransactionId(), std::shared_ptr<Cache>(m_cache),
-events));
-
- for(HashSetOfSharedBase::Iterator iter = m_listeners.begin();
-m_listeners.end() != iter; iter++)
- {
- auto listener =
-std::static_pointer_cast<std::shared_ptr<TransactionListener>>(*iter);
- listener->afterCommit(event);
- }
-}
-
-void CacheTransactionManagerImpl::noteRollbackSuccess(TXState* txState, const
-std::shared_ptr<TXCommitMessage>& commitMessage)
-{
- VectorOfEntryEvent events;
- if(commitMessage!= nullptr)
- {
- events = commitMessage->getEvents(m_cache);
- }
- std::shared_ptr<TransactionEvent> event(new
-TransactionEvent(txState->getTransactionId(), std::shared_ptr<Cache>(m_cache),
-events));
-
- for(HashSetOfSharedBase::Iterator iter = m_listeners.begin();
-m_listeners.end() != iter; iter++)
- {
- auto listener =
-std::static_pointer_cast<TransactionListener>(*iter);
- listener->afterRollback(event);
- }
-}
-*/
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/CacheTransactionManagerImpl.hpp b/cppcache/src/CacheTransactionManagerImpl.hpp
index 24f1569..e82edd1 100644
--- a/cppcache/src/CacheTransactionManagerImpl.hpp
+++ b/cppcache/src/CacheTransactionManagerImpl.hpp
@@ -20,6 +20,9 @@
#ifndef GEODE_CACHETRANSACTIONMANAGERIMPL_H_
#define GEODE_CACHETRANSACTIONMANAGERIMPL_H_
+#include <condition_variable>
+#include <mutex>
+
#include <geode/CacheTransactionManager.hpp>
#include "SuspendedTxExpiryHandler.hpp"
@@ -69,14 +72,14 @@ class CacheTransactionManagerImpl : public virtual CacheTransactionManager {
TXState* removeSuspendedTx(int32_t txId, std::chrono::milliseconds waitTime);
bool isSuspendedTx(int32_t txId);
void addTx(int32_t txId);
- bool removeTx(int32_t txId);
+ void removeTx(int32_t txId);
bool findTx(int32_t txId);
std::map<int32_t, TXState*> m_suspendedTXs;
- ACE_Recursive_Thread_Mutex m_suspendedTxLock;
+ std::recursive_mutex m_suspendedTxLock;
std::vector<int32_t> m_TXs;
- ACE_Recursive_Thread_Mutex m_txLock;
- ACE_Condition<ACE_Recursive_Thread_Mutex> m_txCond;
+ std::recursive_mutex m_txLock;
+ std::condition_variable_any m_txCond;
friend class TXCleaner;
};
diff --git a/cppcache/src/CacheXmlParser.cpp b/cppcache/src/CacheXmlParser.cpp
index 81d10b2..1494b53 100644
--- a/cppcache/src/CacheXmlParser.cpp
+++ b/cppcache/src/CacheXmlParser.cpp
@@ -26,6 +26,7 @@
#include "AutoDelete.hpp"
#include "CacheImpl.hpp"
#include "CacheRegionHelper.hpp"
+#include "util/string.hpp"
#if defined(_WIN32)
#include <windows.h>
@@ -347,11 +348,7 @@ void CacheXmlParser::parseMemory(const char* buffer, int size) {
void CacheXmlParser::handleParserErrors(int res) {
if (res != 0) // xml file is not well-formed
{
- char buf[256];
- ACE_OS::snprintf(buf, 256, "Error code returned by xml parser is : %d ",
- res);
- Log::error(buf);
-
+ Log::error("Error code returned by xml parser is : " + std::to_string(res));
throw CacheXmlException("Xml file is not well formed. Error _stack: \n" +
std::string(this->m_parserMessage));
}
@@ -633,13 +630,14 @@ void CacheXmlParser::endPool() {
void CacheXmlParser::setPoolInfo(PoolFactory* factory, const char* name,
const char* value) {
+ using apache::geode::client::equal_ignore_case;
using apache::geode::internal::chrono::duration::from_string;
if (strcmp(name, FREE_CONNECTION_TIMEOUT) == 0) {
factory->setFreeConnectionTimeout(
from_string<std::chrono::milliseconds>(std::string(value)));
} else if (strcmp(name, MULTIUSER_SECURE_MODE) == 0) {
- if (ACE_OS::strcasecmp(value, "true") == 0) {
+ if (equal_ignore_case(value, "true")) {
factory->setMultiuserAuthentication(true);
} else {
factory->setMultiuserAuthentication(false);
@@ -676,7 +674,7 @@ void CacheXmlParser::setPoolInfo(PoolFactory* factory, const char* name,
factory->setSubscriptionAckInterval(
from_string<std::chrono::milliseconds>(std::string(value)));
} else if (strcmp(name, SUBSCRIPTION_ENABLED) == 0) {
- if (ACE_OS::strcasecmp(value, "true") == 0) {
+ if (equal_ignore_case(value, "true")) {
factory->setSubscriptionEnabled(true);
} else {
factory->setSubscriptionEnabled(false);
@@ -687,13 +685,13 @@ void CacheXmlParser::setPoolInfo(PoolFactory* factory, const char* name,
} else if (strcmp(name, SUBSCRIPTION_REDUNDANCY) == 0) {
factory->setSubscriptionRedundancy(atoi(value));
} else if (strcmp(name, THREAD_LOCAL_CONNECTIONS) == 0) {
- if (ACE_OS::strcasecmp(value, "true") == 0) {
+ if (equal_ignore_case(value, "true")) {
factory->setThreadLocalConnections(true);
} else {
factory->setThreadLocalConnections(false);
}
} else if (strcmp(name, PR_SINGLE_HOP_ENABLED) == 0) {
- if (ACE_OS::strcasecmp(value, "true") == 0) {
+ if (equal_ignore_case(value, "true")) {
factory->setPRSingleHopEnabled(true);
} else {
factory->setPRSingleHopEnabled(false);
diff --git a/cppcache/src/CacheableDate.cpp b/cppcache/src/CacheableDate.cpp
index cd0d481..0105b04 100644
--- a/cppcache/src/CacheableDate.cpp
+++ b/cppcache/src/CacheableDate.cpp
@@ -19,8 +19,6 @@
#include <ctime>
#include <cwchar>
-#include <ace/OS.h>
-
#include <geode/CacheableDate.hpp>
#include <geode/DataInput.hpp>
#include <geode/DataOutput.hpp>
@@ -28,6 +26,7 @@
#include <geode/internal/CacheableKeys.hpp>
#include "config.h"
+#include "util/chrono/time_point.hpp"
namespace apache {
namespace geode {
@@ -81,14 +80,7 @@ CacheableDate::CacheableDate(const CacheableDate::duration& value) {
}
std::string CacheableDate::toString() const {
- char buffer[25];
- struct tm date = {};
- time_t sec = m_timevalue / 1000;
- ACE_OS::localtime_r(&sec, &date);
- ACE_OS::snprintf(buffer, 24, "%d/%d/%d %d:%d:%d", date.tm_mon + 1,
- date.tm_mday, date.tm_year + 1900, date.tm_hour, date.tm_min,
- date.tm_sec);
- return std::string(buffer);
+ return apache::geode::util::chrono::to_string(static_cast<time_t>(*this));
}
} // namespace client
diff --git a/cppcache/src/CacheableFileName.cpp b/cppcache/src/CacheableFileName.cpp
index 12afd25..bd1cf99 100644
--- a/cppcache/src/CacheableFileName.cpp
+++ b/cppcache/src/CacheableFileName.cpp
@@ -14,8 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <ace/ACE.h>
-#include <ace/OS.h>
#include <geode/CacheableFileName.hpp>
#include <geode/DataInput.hpp>
diff --git a/cppcache/src/CacheableString.cpp b/cppcache/src/CacheableString.cpp
index 6c6d54b..466566e 100644
--- a/cppcache/src/CacheableString.cpp
+++ b/cppcache/src/CacheableString.cpp
@@ -20,9 +20,6 @@
#include <cwchar>
#include <locale>
-#include <ace/ACE.h>
-#include <ace/OS.h>
-
#include <geode/CacheableString.hpp>
#include <geode/DataInput.hpp>
#include <geode/DataOutput.hpp>
diff --git a/cppcache/src/ClientHealthStats.cpp b/cppcache/src/ClientHealthStats.cpp
index 11b9262..e2c026c 100644
--- a/cppcache/src/ClientHealthStats.cpp
+++ b/cppcache/src/ClientHealthStats.cpp
@@ -56,7 +56,7 @@ ClientHealthStats::ClientHealthStats()
m_numThread(0),
m_processCpuTime(0),
m_cpus(0) {
- m_updateTime = CacheableDate::create(ACE_OS::time(nullptr));
+ m_updateTime = CacheableDate::create();
}
ClientHealthStats::ClientHealthStats(int gets, int puts, int misses,
@@ -69,7 +69,7 @@ ClientHealthStats::ClientHealthStats(int gets, int puts, int misses,
m_numThread(numThreads),
m_processCpuTime(cpuTime),
m_cpus(cpus) {
- m_updateTime = CacheableDate::create(ACE_OS::time(nullptr));
+ m_updateTime = CacheableDate::create();
}
} // namespace client
diff --git a/cppcache/src/ClientMetadata.cpp b/cppcache/src/ClientMetadata.cpp
index 2050fc3..e9acd57 100644
--- a/cppcache/src/ClientMetadata.cpp
+++ b/cppcache/src/ClientMetadata.cpp
@@ -19,8 +19,6 @@
#include <climits>
#include <cstdlib>
-#include <ace/OS.h>
-
#include "ThinClientPoolDM.hpp"
#include "Utils.hpp"
diff --git a/cppcache/src/ClientMetadata.hpp b/cppcache/src/ClientMetadata.hpp
index 5523827..9e3865f 100644
--- a/cppcache/src/ClientMetadata.hpp
+++ b/cppcache/src/ClientMetadata.hpp
@@ -23,9 +23,6 @@
#include <map>
#include <vector>
-#include <ace/ACE.h>
-#include <ace/Recursive_Thread_Mutex.h>
-
#include <geode/PartitionResolver.hpp>
#include "BucketServerLocation.hpp"
@@ -61,7 +58,6 @@ class APACHE_GEODE_EXPORT ClientMetadata : public NonAssignable {
int m_totalNumBuckets;
// std::shared_ptr<PartitionResolver> m_partitionResolver;
std::string m_colocatedWith;
- // ACE_RW_Thread_Mutex m_readWriteLock;
ThinClientPoolDM* m_tcrdm;
FixedMapType m_fpaMap;
inline void checkBucketId(size_t bucketId) {
diff --git a/cppcache/src/ClientMetadataService.cpp b/cppcache/src/ClientMetadataService.cpp
index d5f1c9f..ce57ece 100644
--- a/cppcache/src/ClientMetadataService.cpp
+++ b/cppcache/src/ClientMetadataService.cpp
@@ -31,6 +31,8 @@ namespace apache {
namespace geode {
namespace client {
+const BucketStatus::clock::time_point BucketStatus::m_noTimeout{};
+
const char* ClientMetadataService::NC_CMDSvcThread = "NC CMDSvcThread";
ClientMetadataService::~ClientMetadataService() {
@@ -227,7 +229,6 @@ void ClientMetadataService::getBucketServerLocation(
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument, bool isPrimary,
std::shared_ptr<BucketServerLocation>& serverLocation, int8_t& version) {
- // ACE_Guard< ACE_Recursive_Thread_Mutex > guard( m_regionMetadataLock );
if (region != nullptr) {
ReadGuard guard(m_regionMetadataLock);
LOGDEBUG(
diff --git a/cppcache/src/ClientMetadataService.hpp b/cppcache/src/ClientMetadataService.hpp
index e6c91e9..6411265 100644
--- a/cppcache/src/ClientMetadataService.hpp
+++ b/cppcache/src/ClientMetadataService.hpp
@@ -20,6 +20,7 @@
#ifndef GEODE_CLIENTMETADATASERVICE_H_
#define GEODE_CLIENTMETADATASERVICE_H_
+#include <chrono>
#include <memory>
#include <string>
#include <unordered_map>
@@ -50,29 +51,30 @@ typedef std::map<std::string, std::shared_ptr<ClientMetadata>>
class BucketStatus {
private:
- ACE_Time_Value m_lastTimeout;
+ using clock = std::chrono::steady_clock;
+ const static clock::time_point m_noTimeout;
+ clock::time_point m_lastTimeout;
public:
- BucketStatus() : m_lastTimeout(ACE_Time_Value::zero) {}
+ BucketStatus() = default;
bool isTimedoutAndReset(std::chrono::milliseconds millis) {
- if (m_lastTimeout == ACE_Time_Value::zero) {
+ if (m_lastTimeout == m_noTimeout) {
return false;
} else {
- ACE_Time_Value to(millis);
- to += m_lastTimeout;
- if (to > ACE_OS::gettimeofday()) {
+ auto timeout = m_lastTimeout + millis;
+ if (timeout > clock::now()) {
return true; // timeout as buckste not recovered yet
} else {
// reset to zero as we waited enough to recover bucket
- m_lastTimeout = ACE_Time_Value::zero;
+ m_lastTimeout = m_noTimeout;
return false;
}
}
}
void setTimeout() {
- if (m_lastTimeout == ACE_Time_Value::zero) {
- m_lastTimeout = ACE_OS::gettimeofday(); // set once only for timeout
+ if (m_lastTimeout == m_noTimeout) {
+ m_lastTimeout = clock::now(); // set once only for timeout
}
}
};
@@ -216,7 +218,6 @@ class ClientMetadataService : public ACE_Task_Base,
const std::shared_ptr<Region>& region);
private:
- // ACE_Recursive_Thread_Mutex m_regionMetadataLock;
ACE_RW_Thread_Mutex m_regionMetadataLock;
ClientMetadataService();
ACE_Semaphore m_regionQueueSema;
diff --git a/cppcache/src/ClientProxyMembershipID.cpp b/cppcache/src/ClientProxyMembershipID.cpp
index 54adfa9..8a0ee62 100644
--- a/cppcache/src/ClientProxyMembershipID.cpp
+++ b/cppcache/src/ClientProxyMembershipID.cpp
@@ -22,7 +22,7 @@
#include <memory>
#include <string>
-#include <ace/OS.h>
+#include <boost/process/environment.hpp>
#include <geode/CacheableBuiltins.hpp>
@@ -34,38 +34,19 @@
#define DCPORT 12334
#define VMKIND 13
#define ROLEARRLENGTH 0
-static int synch_counter = 2;
+
namespace apache {
namespace geode {
namespace client {
-namespace {
-static class RandomInitializer {
- public:
- RandomInitializer() {
- // using current time and
- // processor time would be good enough for our purpose
- auto seed = ACE_OS::getpid() + ACE_OS::gettimeofday().msec() + clock();
- seed += ACE_OS::gettimeofday().usec();
- // LOGINFO("PID %ld seed %ld ACE_OS::gettimeofday().usec() = %ld clock =
- // %ld ACE_OS::gettimeofday().msec() = %ld", pid, seed ,
- // ACE_OS::gettimeofday().usec() , clock(),
- // ACE_OS::gettimeofday().msec());
- ACE_OS::srand(seed);
- }
-} oneTimeRandomInitializer;
-} // namespace
+static int synch_counter = 2;
const int ClientProxyMembershipID::VERSION_MASK = 0x8;
const int8_t ClientProxyMembershipID::TOKEN_ORDINAL = -1;
ClientProxyMembershipID::ClientProxyMembershipID()
: m_hostPort(0),
- m_hostAddr(nullptr)
- /* adongre - Coverity II
- * CID 29278: Uninitialized scalar field (UNINIT_CTOR)
- */
- ,
+ m_hostAddr(nullptr),
m_hostAddrLen(0),
m_hostAddrLocalMem(false),
m_vmViewId(0) {}
@@ -79,7 +60,7 @@ ClientProxyMembershipID::ClientProxyMembershipID(
uint32_t hostAddr, uint32_t hostPort, const char* durableClientId,
const std::chrono::seconds durableClntTimeOut)
: m_hostAddrAsUInt32(hostAddr) {
- int32_t vmPID = ACE_OS::getpid();
+ auto vmPID = boost::this_process::get_id();
initObjectVars(hostname, reinterpret_cast<uint8_t*>(&m_hostAddrAsUInt32), 4,
false, hostPort, durableClientId, durableClntTimeOut, DCPORT,
vmPID, VMKIND, 0, dsName.c_str(), randString.c_str(), 0);
@@ -90,7 +71,7 @@ ClientProxyMembershipID::ClientProxyMembershipID(
ClientProxyMembershipID::ClientProxyMembershipID(
uint8_t* hostAddr, uint32_t hostAddrLen, uint32_t hostPort,
const char* dsname, const char* uniqueTag, uint32_t vmViewId) {
- int32_t vmPID = ACE_OS::getpid();
+ auto vmPID = boost::this_process::get_id();
initObjectVars("localhost", hostAddr, hostAddrLen, false, hostPort, "",
std::chrono::seconds::zero(), DCPORT, vmPID, VMKIND, 0, dsname,
uniqueTag, vmViewId);
@@ -152,15 +133,11 @@ void ClientProxyMembershipID::initObjectVars(
reinterpret_cast<char*>(const_cast<uint8_t*>(m_memID.getBuffer(&len)));
m_memIDStr.append(buf, len);
- char PID[15] = {0};
- char Synch_Counter[15] = {0};
- ACE_OS::itoa(vPID, PID, 10);
- ACE_OS::itoa(synch_counter, Synch_Counter, 10);
clientID.append(hostname);
clientID.append("(");
- clientID.append(PID);
+ clientID.append(std::to_string(vPID));
clientID.append(":loner):");
- clientID.append(Synch_Counter);
+ clientID.append(std::to_string(synch_counter));
clientID.append(":");
clientID.append(getUniqueTag());
clientID.append(":");
@@ -169,19 +146,11 @@ void ClientProxyMembershipID::initObjectVars(
// int offset = 0;
for (uint32_t i = 0; i < getHostAddrLen(); i++) {
- char hostInfo[16] = {0};
- // offset += ACE_OS::snprintf(hostInfo + offset , 255 - offset, ":%x",
- // m_hostAddr[i]);
- ACE_OS::itoa(m_hostAddr[i], hostInfo, 16);
m_hashKey.append(":");
- m_hashKey.append(hostInfo);
+ m_hashKey.append(std::to_string(m_hostAddr[i]));
}
m_hashKey.append(":");
- char hostInfoPort[16] = {0};
- ACE_OS::itoa(getHostPort(), hostInfoPort, 10);
- // offset += ACE_OS::snprintf(hostInfo + offset, 255 - offset , ":%d",
- // getHostPort());
- m_hashKey.append(hostInfoPort);
+ m_hashKey.append(std::to_string(getHostPort()));
m_hashKey.append(":");
m_hashKey.append(getDSName());
m_hashKey.append(":");
@@ -189,11 +158,7 @@ void ClientProxyMembershipID::initObjectVars(
m_hashKey.append(getUniqueTag());
} else {
m_hashKey.append(":");
- char viewid[16] = {0};
- ACE_OS::itoa(m_vmViewId, viewid, 10);
- // offset += ACE_OS::snprintf(hostInfo + offset , 255 - offset , ":%d",
- // m_vmViewId);
- m_hashKey.append(viewid);
+ m_hashKey.append(std::to_string(m_vmViewId));
}
LOGDEBUG("GethashKey %s client id: %s ", m_hashKey.c_str(), clientID.c_str());
}
diff --git a/cppcache/src/ClientProxyMembershipID.hpp b/cppcache/src/ClientProxyMembershipID.hpp
index 55080c0..6d9a659 100644
--- a/cppcache/src/ClientProxyMembershipID.hpp
+++ b/cppcache/src/ClientProxyMembershipID.hpp
@@ -22,8 +22,6 @@
#include <string>
-#include <ace/OS.h>
-
#include <geode/DataOutput.hpp>
#include <geode/internal/functional.hpp>
#include <geode/internal/geode_globals.hpp>
@@ -92,8 +90,8 @@ class ClientProxyMembershipID : public DSMemberForVersionStamp {
char hostInfo[255] = {0};
uint32_t offset = 0;
for (uint32_t i = 0; i < getHostAddrLen(); i++) {
- offset += ACE_OS::snprintf(hostInfo + offset, 255 - offset, ":%x",
- m_hostAddr[i]);
+ offset +=
+ std::snprintf(hostInfo + offset, 255 - offset, ":%x", m_hostAddr[i]);
}
result +=
internal::geode_hash<std::string>{}(std::string(hostInfo, offset));
diff --git a/cppcache/src/ClientProxyMembershipIDFactory.cpp b/cppcache/src/ClientProxyMembershipIDFactory.cpp
index e54a055..62e6b6e 100644
--- a/cppcache/src/ClientProxyMembershipIDFactory.cpp
+++ b/cppcache/src/ClientProxyMembershipIDFactory.cpp
@@ -21,6 +21,8 @@
#include <iterator>
#include <random>
+#include <boost/process/environment.hpp>
+
#include "util/Log.hpp"
namespace apache {
@@ -43,7 +45,7 @@ ClientProxyMembershipIDFactory::ClientProxyMembershipIDFactory(
std::generate_n(std::back_inserter(randString), 10,
[&]() { return alphabet[dist(rng)]; });
- auto pid = ACE_OS::getpid();
+ auto pid = boost::this_process::get_id();
randString.append(std::to_string(pid));
LOGINFO("Using %s as random data for ClientProxyMembershipID",
diff --git a/cppcache/src/Condition.cpp b/cppcache/src/Condition.cpp
deleted file mode 100644
index 21e148f..0000000
--- a/cppcache/src/Condition.cpp
+++ /dev/null
@@ -1,49 +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 "Condition.hpp"
-
-namespace apache {
-namespace geode {
-namespace client {
-
-/**
- * Create a Condition protected by the mutex provided.
- */
-Condition::Condition(ACE_Recursive_Thread_Mutex& mutex)
- : m_cond(mutex), m_signaled(false) {}
-
-bool Condition::waitUntil(ACE_Time_Value* absoluteStopTime) {
- ACE_OS::last_error(0);
-
- ACE_Time_Value stopAt = *absoluteStopTime;
- while ((!m_signaled) && (m_cond.wait(&stopAt) != 0) &&
- (ACE_OS::last_error() != ETIME)) {
- ACE_OS::last_error(0);
- stopAt = *absoluteStopTime;
- ACE_Time_Value now = ACE_OS::gettimeofday();
- if (now >= stopAt) {
- break;
- }
- }
- bool result = m_signaled;
- m_signaled = false;
- return result;
-}
-} // namespace client
-} // namespace geode
-} // namespace apache
diff --git a/cppcache/src/Condition.hpp b/cppcache/src/Condition.hpp
deleted file mode 100644
index e345212..0000000
--- a/cppcache/src/Condition.hpp
+++ /dev/null
@@ -1,81 +0,0 @@
-#pragma once
-
-#ifndef GEODE_CONDITION_H_
-#define GEODE_CONDITION_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 <ace/Condition_Recursive_Thread_Mutex.h>
-#include <ace/OS_NS_sys_time.h>
-
-#include <geode/internal/geode_globals.hpp>
-
-namespace apache {
-namespace geode {
-namespace client {
-
-/**
- * Condition wrapper when you want an absolute signal or timeout condition.
- */
-class APACHE_GEODE_EXPORT Condition {
- private:
- ACE_Condition<ACE_Recursive_Thread_Mutex> m_cond;
- bool m_signaled;
-
- public:
- /**
- * Create a Condition protected by the mutex provided.
- */
- explicit Condition(ACE_Recursive_Thread_Mutex& mutex);
-
- ~Condition() {}
-
- /**
- * Release the given mutex, and wait for condition to be signaled, then
- * re-acquire the mutex.
- * Returns true only if the condition is signaled.
- * Returns false only if the time is passed.
- */
- bool waitUntil(ACE_Time_Value* absoluteStopTime);
- /** Convenience to derive absolute time.
- */
- inline bool waitFor(uint32_t seconds) {
- ACE_Time_Value stopAt = ACE_OS::gettimeofday();
- stopAt += seconds;
- return waitUntil(&stopAt);
- }
-
- /**
- * The mutex for this condition should be locked/held by the thread calling
- * this signal method.
- */
- inline void signal() {
- m_signaled = true;
- m_cond.signal();
- }
-
- inline ACE_Recursive_Thread_Mutex& mutex() { return m_cond.mutex(); }
-
- /** Must be called with the mutex held. */
- inline void reset() { m_signaled = false; }
-};
-} // namespace client
-} // namespace geode
-} // namespace apache
-
-#endif // GEODE_CONDITION_H_
diff --git a/cppcache/src/CppCacheLibrary.cpp b/cppcache/src/CppCacheLibrary.cpp
index e3765a6..ada5d08 100644
--- a/cppcache/src/CppCacheLibrary.cpp
+++ b/cppcache/src/CppCacheLibrary.cpp
@@ -22,7 +22,6 @@
#include <ace/ACE.h>
#include <ace/Init_ACE.h>
#include <ace/Log_Msg.h>
-#include <ace/OS.h>
#include <ace/Singleton.h>
#include <geode/CacheFactory.hpp>
diff --git a/cppcache/src/CqAttributesImpl.cpp b/cppcache/src/CqAttributesImpl.cpp
index 6e1f35e..ae64452 100644
--- a/cppcache/src/CqAttributesImpl.cpp
+++ b/cppcache/src/CqAttributesImpl.cpp
@@ -26,7 +26,7 @@ namespace geode {
namespace client {
CqAttributes::listener_container_type CqAttributesImpl::getCqListeners() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::lock_guard<decltype(m_mutex)> _guard(m_mutex);
return m_cqListeners;
}
@@ -34,7 +34,7 @@ void CqAttributesImpl::addCqListener(const std::shared_ptr<CqListener>& cql) {
if (cql == nullptr) {
throw IllegalArgumentException("addCqListener parameter was null");
}
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::lock_guard<decltype(m_mutex)> _guard(m_mutex);
m_cqListeners.push_back(cql);
}
@@ -53,7 +53,7 @@ void CqAttributesImpl::setCqListeners(
decltype(m_cqListeners) oldListeners(m_cqListeners);
{
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::lock_guard<decltype(m_mutex)> _guard(m_mutex);
m_cqListeners = addedListeners;
}
if (!oldListeners.empty()) {
@@ -75,7 +75,7 @@ void CqAttributesImpl::removeCqListener(
if (cql == nullptr) {
throw IllegalArgumentException("removeCqListener parameter was null");
}
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::lock_guard<decltype(m_mutex)> _guard(m_mutex);
if (!m_cqListeners.empty()) {
m_cqListeners.erase(
std::remove_if(
diff --git a/cppcache/src/CqAttributesImpl.hpp b/cppcache/src/CqAttributesImpl.hpp
index 2bd3e0c..26e80f9 100644
--- a/cppcache/src/CqAttributesImpl.hpp
+++ b/cppcache/src/CqAttributesImpl.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_CQATTRIBUTESIMPL_H_
-#define GEODE_CQATTRIBUTESIMPL_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,19 +15,16 @@
* limitations under the License.
*/
-#include <ace/ACE.h>
-#include <ace/Condition_Recursive_Thread_Mutex.h>
-#include <ace/Guard_T.h>
-#include <ace/Recursive_Thread_Mutex.h>
-#include <ace/Time_Value.h>
+#pragma once
+
+#ifndef GEODE_CQATTRIBUTESIMPL_H_
+#define GEODE_CQATTRIBUTESIMPL_H_
+
+#include <mutex>
#include <geode/CqAttributes.hpp>
#include <geode/CqAttributesMutator.hpp>
-/**
- * @file
- */
-
namespace apache {
namespace geode {
namespace client {
@@ -70,8 +62,9 @@ class APACHE_GEODE_EXPORT CqAttributesImpl : public CqAttributes {
private:
listener_container_type m_cqListeners;
bool m_dataPolicyHasBeenSet;
- ACE_Recursive_Thread_Mutex m_mutex;
+ std::recursive_mutex m_mutex;
};
+
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/CqEventImpl.cpp b/cppcache/src/CqEventImpl.cpp
index 222a19c..eb32e7e 100644
--- a/cppcache/src/CqEventImpl.cpp
+++ b/cppcache/src/CqEventImpl.cpp
@@ -92,7 +92,7 @@ bool CqEventImpl::getError() { return m_error; }
std::string CqEventImpl::toString() {
char buffer[1024];
- ACE_OS::snprintf(
+ std::snprintf(
buffer, 1024,
"CqEvent CqName=%s; base operation=%d; cq operation= %d;key=%s;value=%s",
m_cQuery->getName().c_str(), static_cast<int>(m_baseOp),
diff --git a/cppcache/src/CqQueryImpl.cpp b/cppcache/src/CqQueryImpl.cpp
index d7e2bb5..1389d90 100644
--- a/cppcache/src/CqQueryImpl.cpp
+++ b/cppcache/src/CqQueryImpl.cpp
@@ -21,7 +21,6 @@
#include <geode/CqAttributesMutator.hpp>
#include <geode/ExceptionTypes.hpp>
-#include "ReadWriteLock.hpp"
#include "ResultSetImpl.hpp"
#include "StructSetImpl.hpp"
#include "ThinClientRegion.hpp"
@@ -248,7 +247,7 @@ void CqQueryImpl::getCqListeners(
}
GfErrType CqQueryImpl::execute(TcrEndpoint* endpoint) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::lock_guard<decltype(m_mutex)> _guard(m_mutex);
if (m_cqState != CqState::RUNNING) {
return GF_NOERR;
}
@@ -282,23 +281,13 @@ GfErrType CqQueryImpl::execute(TcrEndpoint* endpoint) {
reply.getMessageType() == TcrMessage::CQ_EXCEPTION_TYPE) {
err = ThinClientRegion::handleServerException("CqQuery::execute(endpoint)",
reply.getException());
- /*
- if (err == GF_CACHESERVER_EXCEPTION) {
- throw CqQueryException("CqQuery::execute(endpoint): exception at the
- server side: ",
- reply.getException());
- }
- else {
- GfErrTypeToException("CqQuery::execute(endpoint)", err);
- }
- */
}
return err;
}
void CqQueryImpl::executeAfterFailover() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::lock_guard<decltype(m_mutex)> _guard(m_mutex);
if (m_cqState != CqState::RUNNING) {
return;
}
@@ -311,10 +300,10 @@ void CqQueryImpl::execute() {
gua.setAuthenticatedView(m_authenticatedView);
}
- ACE_Guard<ACE_Recursive_Thread_Mutex> guardRedundancy(
- *(m_tccdm->getRedundancyLock()));
+ auto& redundancyMutex = m_tccdm->getRedundancyLock();
+ std::lock_guard<decltype(redundancyMutex)> guardRedundancy(redundancyMutex);
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::lock_guard<decltype(m_mutex)> _guard(m_mutex);
if (m_cqState == CqState::RUNNING) {
throw IllegalStateException("CqQuery::execute: cq is already running");
}
@@ -355,7 +344,7 @@ bool CqQueryImpl::executeCq(TcrMessage::MsgType) {
GfErrTypeToException("CqQuery::executeCq", err);
}
}
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::lock_guard<decltype(m_mutex)> _guard(m_mutex);
m_cqState = CqState::RUNNING;
updateStats();
return true;
@@ -371,10 +360,10 @@ std::shared_ptr<CqResults> CqQueryImpl::executeWithInitialResults(
gua.setAuthenticatedView(m_authenticatedView);
}
- ACE_Guard<ACE_Recursive_Thread_Mutex> guardRedundancy(
- *(m_tccdm->getRedundancyLock()));
+ std::lock_guard<decltype(m_tccdm->getRedundancyLock())> guardRedundancy(
+ m_tccdm->getRedundancyLock());
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::lock_guard<decltype(m_mutex)> _guard(m_mutex);
if (m_cqState == CqState::RUNNING) {
throw IllegalStateException(
"CqQuery::executeWithInitialResults: cq is already running");
@@ -519,7 +508,7 @@ void CqQueryImpl::setCqState(CqState state) {
if (isClosed()) {
throw CqClosedException(("CQ is closed, CqName : " + m_cqName).c_str());
}
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::lock_guard<decltype(m_mutex)> _guard(m_mutex);
m_cqState = state;
}
@@ -566,7 +555,7 @@ void CqQueryImpl::updateStats(CqEvent& cqEvent) {
* @return true if running, false otherwise
*/
bool CqQueryImpl::isRunning() const {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::lock_guard<decltype(m_mutex)> _guard(m_mutex);
return m_cqState == CqState::RUNNING;
}
@@ -575,7 +564,7 @@ bool CqQueryImpl::isRunning() const {
* @return true if stopped, false otherwise
*/
bool CqQueryImpl::isStopped() const {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::lock_guard<decltype(m_mutex)> _guard(m_mutex);
return m_cqState == CqState::STOPPED ||
(m_authenticatedView && m_authenticatedView->isClosed());
}
@@ -585,7 +574,7 @@ bool CqQueryImpl::isStopped() const {
* @return true if closed, false otherwise
*/
bool CqQueryImpl::isClosed() const {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::lock_guard<decltype(m_mutex)> _guard(m_mutex);
return m_cqState == CqState::CLOSED ||
(m_authenticatedView && m_authenticatedView->isClosed());
}
diff --git a/cppcache/src/CqQueryImpl.hpp b/cppcache/src/CqQueryImpl.hpp
index d4d27da..f03ddd7 100644
--- a/cppcache/src/CqQueryImpl.hpp
+++ b/cppcache/src/CqQueryImpl.hpp
@@ -20,14 +20,9 @@
#ifndef GEODE_CQQUERYIMPL_H_
#define GEODE_CQQUERYIMPL_H_
+#include <mutex>
#include <string>
-#include <ace/ACE.h>
-#include <ace/Condition_Recursive_Thread_Mutex.h>
-#include <ace/Guard_T.h>
-#include <ace/Recursive_Thread_Mutex.h>
-#include <ace/Time_Value.h>
-
#include <geode/AuthenticatedView.hpp>
#include <geode/CqAttributes.hpp>
#include <geode/CqOperation.hpp>
@@ -271,7 +266,7 @@ class CqQueryImpl : public CqQuery,
private:
void updateStats();
- mutable ACE_Recursive_Thread_Mutex m_mutex;
+ mutable std::recursive_mutex m_mutex;
void sendStopOrClose(TcrMessage::MsgType requestType);
ThinClientBaseDM* m_tccdm;
AuthenticatedView* m_authenticatedView;
diff --git a/cppcache/src/CqService.cpp b/cppcache/src/CqService.cpp
index 51ec757..073db46 100644
--- a/cppcache/src/CqService.cpp
+++ b/cppcache/src/CqService.cpp
@@ -129,8 +129,7 @@ std::shared_ptr<CqQuery> CqService::newCq(
std::shared_ptr<UserAttributes> ua = nullptr;
if (m_tccdm != nullptr && m_tccdm->isMultiUserMode()) {
- ua =
- TSSUserAttributesWrapper::s_geodeTSSUserAttributes->getUserAttributes();
+ ua = UserAttributes::threadLocalUserAttributes;
}
auto cQuery = std::make_shared<CqQueryImpl>(
@@ -214,9 +213,7 @@ CqService::query_container_type CqService::getAllCqs() {
* Executes all the cqs on this client.
*/
void CqService::executeAllClientCqs(bool afterFailover) {
- // ACE_Guard< ACE_Recursive_Thread_Mutex > _guard( m_mutex );
query_container_type cqVec = getAllCqs();
- // MapOfRegionGuard guard( m_cqQueryMap->mutex() );
executeCqs(cqVec, afterFailover);
}
diff --git a/cppcache/src/CqService.hpp b/cppcache/src/CqService.hpp
index d3b16db..8d711be 100644
--- a/cppcache/src/CqService.hpp
+++ b/cppcache/src/CqService.hpp
@@ -21,15 +21,10 @@
#define GEODE_CQSERVICE_H_
#include <map>
+#include <mutex>
#include <string>
-#include <ace/ACE.h>
-#include <ace/Condition_Recursive_Thread_Mutex.h>
-#include <ace/Guard_T.h>
-#include <ace/Recursive_Thread_Mutex.h>
#include <ace/Semaphore.h>
-#include <ace/Task.h>
-#include <ace/Time_Value.h>
#include <geode/CacheableKey.hpp>
#include <geode/CqOperation.hpp>
@@ -66,8 +61,6 @@ class APACHE_GEODE_EXPORT CqService
private:
ThinClientBaseDM* m_tccdm;
statistics::StatisticsFactory* m_statisticsFactory;
- ACE_Recursive_Thread_Mutex m_mutex;
- std::string m_queryString;
ACE_Semaphore m_notificationSema;
bool m_running;
diff --git a/cppcache/src/DataOutput.cpp b/cppcache/src/DataOutput.cpp
index b672842..29b5470 100644
--- a/cppcache/src/DataOutput.cpp
+++ b/cppcache/src/DataOutput.cpp
@@ -17,9 +17,6 @@
#include <vector>
-#include <ace/Recursive_Thread_Mutex.h>
-#include <ace/TSS_T.h>
-
#include <geode/DataOutput.hpp>
#include <geode/SystemProperties.hpp>
@@ -34,7 +31,7 @@ namespace apache {
namespace geode {
namespace client {
-ACE_Recursive_Thread_Mutex g_bigBufferLock;
+std::recursive_mutex globalBigBufferMutex;
size_t DataOutput::m_highWaterMark = 50 * 1024 * 1024;
size_t DataOutput::m_lowWaterMark = 8192;
@@ -93,7 +90,7 @@ class TSSDataOutput {
m_buffers.push_back(desc);
}
- static ACE_TSS<TSSDataOutput> s_tssDataOutput;
+ static thread_local TSSDataOutput threadLocalBufferPool;
};
TSSDataOutput::TSSDataOutput() : m_buffers() {
@@ -109,7 +106,7 @@ TSSDataOutput::~TSSDataOutput() {
}
}
-ACE_TSS<TSSDataOutput> TSSDataOutput::s_tssDataOutput;
+thread_local TSSDataOutput TSSDataOutput::threadLocalBufferPool;
DataOutput::DataOutput(const CacheImpl* cache, Pool* pool)
: m_size(0), m_haveBigBuffer(false), m_cache(cache), m_pool(pool) {
@@ -118,11 +115,11 @@ DataOutput::DataOutput(const CacheImpl* cache, Pool* pool)
}
uint8_t* DataOutput::checkoutBuffer(size_t* size) {
- return TSSDataOutput::s_tssDataOutput->getBuffer(size);
+ return TSSDataOutput::threadLocalBufferPool.getBuffer(size);
}
void DataOutput::checkinBuffer(uint8_t* buffer, size_t size) {
- TSSDataOutput::s_tssDataOutput->poolBuffer(buffer, size);
+ TSSDataOutput::threadLocalBufferPool.poolBuffer(buffer, size);
}
void DataOutput::writeObjectInternal(const std::shared_ptr<Serializable>& ptr,
@@ -130,9 +127,9 @@ void DataOutput::writeObjectInternal(const std::shared_ptr<Serializable>& ptr,
getSerializationRegistry().serialize(ptr, *this, isDelta);
}
-void DataOutput::acquireLock() { g_bigBufferLock.acquire(); }
+void DataOutput::acquireLock() { globalBigBufferMutex.lock(); }
-void DataOutput::releaseLock() { g_bigBufferLock.release(); }
+void DataOutput::releaseLock() { globalBigBufferMutex.unlock(); }
const SerializationRegistry& DataOutput::getSerializationRegistry() const {
return *m_cache->getSerializationRegistry();
diff --git a/cppcache/src/DiffieHellman.cpp b/cppcache/src/DiffieHellman.cpp
index d1790d5..fc0c81d 100644
--- a/cppcache/src/DiffieHellman.cpp
+++ b/cppcache/src/DiffieHellman.cpp
@@ -45,8 +45,8 @@ void* DiffieHellman::getOpenSSLFuncPtr(const char* function_name) {
void* func = m_dll.symbol(function_name);
if (func == nullptr) {
char msg[1000];
- ACE_OS::snprintf(msg, 1000, "cannot find function %s in library %s",
- function_name, "cryptoImpl");
+ std::snprintf(msg, 1000, "cannot find function %s in library %s",
+ function_name, "cryptoImpl");
LOGERROR(msg);
throw IllegalStateException(msg);
}
@@ -64,7 +64,7 @@ void DiffieHellman::initOpenSSLFuncPtrs() {
if (m_dll.open(libName, ACE_DEFAULT_SHLIB_MODE, 0) == -1) {
char msg[1000];
- ACE_OS::snprintf(msg, 1000, "cannot open library: %s", libName);
+ std::snprintf(msg, 1000, "cannot open library: %s", libName);
LOGERROR(msg);
throw FileNotFoundException(msg);
}
@@ -102,13 +102,13 @@ void DiffieHellman::initDhKeys(const std::shared_ptr<Properties>& props) {
if (error == DH_ERR_UNSUPPORTED_ALGO) { // Unsupported Algorithm
char msg[64] = {'\0'};
- ACE_OS::snprintf(msg, 64, "Algorithm %s is not supported.",
- dhAlgo->value().c_str());
+ std::snprintf(msg, 64, "Algorithm %s is not supported.",
+ dhAlgo->value().c_str());
throw IllegalArgumentException(msg);
} else if (error == DH_ERR_ILLEGAL_KEYSIZE) { // Illegal Key size
char msg[64] = {'\0'};
- ACE_OS::snprintf(msg, 64, "Illegal key size for algorithm %s.",
- dhAlgo->value().c_str());
+ std::snprintf(msg, 64, "Illegal key size for algorithm %s.",
+ dhAlgo->value().c_str());
throw IllegalArgumentException(msg);
} else if (m_dhCtx == nullptr) {
throw IllegalStateException(
diff --git a/cppcache/src/DiffieHellman.hpp b/cppcache/src/DiffieHellman.hpp
index 31d3238..234cac9 100644
--- a/cppcache/src/DiffieHellman.hpp
+++ b/cppcache/src/DiffieHellman.hpp
@@ -22,8 +22,6 @@
#include <string>
#include <ace/DLL.h>
-#include <ace/OS.h>
-#include <ace/Recursive_Thread_Mutex.h>
#include <geode/CacheableBuiltins.hpp>
#include <geode/Properties.hpp>
diff --git a/cppcache/src/DiskStoreId.cpp b/cppcache/src/DiskStoreId.cpp
index 3fa024b..802efae 100644
--- a/cppcache/src/DiskStoreId.cpp
+++ b/cppcache/src/DiskStoreId.cpp
@@ -17,32 +17,19 @@
#include "DiskStoreId.hpp"
-#include <inttypes.h>
-
-#include <ace/OS.h>
-
namespace apache {
namespace geode {
namespace client {
+
std::string DiskStoreId::getHashKey() {
- if (m_hashCode.size() == 0) {
- char hashCode[128] = {0};
- /* adongre - Coverity II
- * CID 29207: Calling risky function (SECURE_CODING)[VERY RISKY]. Using
- * "sprintf" can cause a
- * buffer overflow when done incorrectly. Because sprintf() assumes an
- * arbitrarily long string,
- * callers must be careful not to overflow the actual space of the
- * destination.
- * Use snprintf() instead, or correct precision specifiers.
- * Fix : using ACE_OS::snprintf
- */
- ACE_OS::snprintf(hashCode, 128, "%" PRIx64 "_%" PRIx64, m_mostSig,
- m_leastSig);
- m_hashCode.append(hashCode);
+ if (m_hashCode.empty()) {
+ m_hashCode.append(std::to_string(m_mostSig))
+ .append("_")
+ .append(std::to_string(m_leastSig));
}
return m_hashCode;
}
+
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/DistributedSystem.cpp b/cppcache/src/DistributedSystem.cpp
index c275d0f..41ae8fb 100644
--- a/cppcache/src/DistributedSystem.cpp
+++ b/cppcache/src/DistributedSystem.cpp
@@ -17,10 +17,6 @@
#include "DistributedSystem.hpp"
-#include <ace/Guard_T.h>
-#include <ace/OS.h>
-#include <ace/Recursive_Thread_Mutex.h>
-
#include <geode/CacheFactory.hpp>
#include <geode/DataOutput.hpp>
#include <geode/SystemProperties.hpp>
diff --git a/cppcache/src/DistributedSystemImpl.cpp b/cppcache/src/DistributedSystemImpl.cpp
index 9681882..836f10d 100644
--- a/cppcache/src/DistributedSystemImpl.cpp
+++ b/cppcache/src/DistributedSystemImpl.cpp
@@ -17,16 +17,16 @@
#include "DistributedSystemImpl.hpp"
+#include <boost/filesystem.hpp>
+
#include <geode/SystemProperties.hpp>
#include "CacheImpl.hpp"
#include "CacheRegionHelper.hpp"
#include "CppCacheLibrary.hpp"
-#include "DiffieHellman.hpp"
#include "PoolStatistics.hpp"
#include "RegionStats.hpp"
#include "config.h"
-#include "statistics/StatisticsManager.hpp"
#include "util/Log.hpp"
#include "version.h"
@@ -36,7 +36,7 @@ namespace client {
volatile bool DistributedSystemImpl::m_isCliCallbackSet = false;
std::map<int, CliCallbackMethod> DistributedSystemImpl::m_cliCallbackMap;
-ACE_Recursive_Thread_Mutex DistributedSystemImpl::m_cliCallbackLock;
+std::recursive_mutex DistributedSystemImpl::m_cliCallbackLock;
DistributedSystemImpl::DistributedSystemImpl(
std::string name, DistributedSystem* implementee,
@@ -81,20 +81,12 @@ void DistributedSystemImpl::logSystemInformation() const {
LOGCONFIG(
"Running on: SystemName=%s Machine=%s Host=%s Release=%s Version=%s",
u.sysname, u.machine, u.nodename, u.release, u.version);
-
-#ifdef _WIN32
- const uint32_t pathMax = _MAX_PATH;
-#else
- const uint32_t pathMax = PATH_MAX;
-#endif
- ACE_TCHAR cwd[pathMax + 1];
- (void)ACE_OS::getcwd(cwd, pathMax);
- LOGCONFIG("Current directory: %s", cwd);
- LOGCONFIG("Current value of PATH: %s", ACE_OS::getenv("PATH"));
+ LOGCONFIG("Current directory: %s",
+ boost::filesystem::current_path().string().c_str());
+ LOGCONFIG("Current value of PATH: %s", Utils::getEnv("PATH").c_str());
#ifndef _WIN32
- const char* ld_libpath = ACE_OS::getenv("LD_LIBRARY_PATH");
LOGCONFIG("Current library path: %s",
- ld_libpath == nullptr ? "nullptr" : ld_libpath);
+ Utils::getEnv("LD_LIBRARY_PATH").c_str());
#endif
// Log the Geode system properties
m_sysProps->logSettings();
@@ -122,7 +114,8 @@ SystemProperties& DistributedSystemImpl::getSystemProperties() const {
const std::string& DistributedSystemImpl::getName() const { return m_name; }
void DistributedSystemImpl::CallCliCallBack(Cache& cache) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> disconnectGuard(m_cliCallbackLock);
+ std::lock_guard<decltype(m_cliCallbackLock)> disconnectGuard(
+ m_cliCallbackLock);
if (m_isCliCallbackSet == true) {
for (const auto& iter : m_cliCallbackMap) {
iter.second(cache);
@@ -132,13 +125,15 @@ void DistributedSystemImpl::CallCliCallBack(Cache& cache) {
void DistributedSystemImpl::registerCliCallback(int appdomainId,
CliCallbackMethod clicallback) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> disconnectGuard(m_cliCallbackLock);
+ std::lock_guard<decltype(m_cliCallbackLock)> disconnectGuard(
+ m_cliCallbackLock);
m_cliCallbackMap[appdomainId] = clicallback;
m_isCliCallbackSet = true;
}
void DistributedSystemImpl::unregisterCliCallback(int appdomainId) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> disconnectGuard(m_cliCallbackLock);
+ std::lock_guard<decltype(m_cliCallbackLock)> disconnectGuard(
+ m_cliCallbackLock);
auto iter = m_cliCallbackMap.find(appdomainId);
if (iter != m_cliCallbackMap.end()) {
m_cliCallbackMap.erase(iter);
diff --git a/cppcache/src/DistributedSystemImpl.hpp b/cppcache/src/DistributedSystemImpl.hpp
index e469627..85f5102 100644
--- a/cppcache/src/DistributedSystemImpl.hpp
+++ b/cppcache/src/DistributedSystemImpl.hpp
@@ -26,12 +26,9 @@
#include <map>
#include <memory>
+#include <mutex>
#include <string>
-#include <ace/Guard_T.h>
-#include <ace/OS.h>
-#include <ace/Recursive_Thread_Mutex.h>
-
#include <geode/internal/geode_globals.hpp>
#include "DiffieHellman.hpp"
@@ -107,7 +104,7 @@ class APACHE_GEODE_EXPORT DistributedSystemImpl {
static void CallCliCallBack(Cache& cache);
private:
- static ACE_Recursive_Thread_Mutex m_cliCallbackLock;
+ static std::recursive_mutex m_cliCallbackLock;
static volatile bool m_isCliCallbackSet;
static std::map<int, CliCallbackMethod> m_cliCallbackMap;
std::unique_ptr<SystemProperties> m_sysProps;
diff --git a/cppcache/src/EntryExpiryHandler.cpp b/cppcache/src/EntryExpiryHandler.cpp
index 253b954..cc02155 100644
--- a/cppcache/src/EntryExpiryHandler.cpp
+++ b/cppcache/src/EntryExpiryHandler.cpp
@@ -17,15 +17,16 @@
#include "EntryExpiryHandler.hpp"
+#include <ace/Reactor.h>
+#include <ace/Timer_Heap.h>
+#include <ace/Timer_Heap_T.h>
+#include <ace/Timer_Queue.h>
+#include <ace/Timer_Queue_Adapters.h>
+#include <ace/svc_export.h>
+
#include "CacheImpl.hpp"
#include "ExpiryTaskManager.hpp"
#include "RegionInternal.hpp"
-#include "ace/Reactor.h"
-#include "ace/Timer_Heap.h"
-#include "ace/Timer_Heap_T.h"
-#include "ace/Timer_Queue.h"
-#include "ace/Timer_Queue_Adapters.h"
-#include "ace/svc_export.h"
namespace apache {
namespace geode {
diff --git a/cppcache/src/EventId.cpp b/cppcache/src/EventId.cpp
index 46b0a1e..a6db548 100644
--- a/cppcache/src/EventId.cpp
+++ b/cppcache/src/EventId.cpp
@@ -120,7 +120,7 @@ std::shared_ptr<Serializable> EventId::createDeserializable() {
EventId::EventId(char* memId, uint32_t memIdLen, int64_t thr, int64_t seq) {
// TODO: statics being assigned; not thread-safe??
- ACE_OS::memcpy(m_eidMem, memId, memIdLen);
+ std::memcpy(m_eidMem, memId, memIdLen);
m_eidMemLen = memIdLen;
m_eidThr = thr;
m_eidSeq = seq;
diff --git a/cppcache/src/EventIdMap.cpp b/cppcache/src/EventIdMap.cpp
index 5b960c5..6fe069e 100644
--- a/cppcache/src/EventIdMap.cpp
+++ b/cppcache/src/EventIdMap.cpp
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "EventIdMap.hpp"
namespace apache {
@@ -27,7 +28,8 @@ void EventIdMap::init(std::chrono::milliseconds expirySecs) {
}
void EventIdMap::clear() {
- GUARD_MAP;
+ std::lock_guard<decltype(m_lock)> guard(m_lock);
+
m_map.clear();
}
@@ -40,9 +42,9 @@ EventIdMapEntry EventIdMap::make(std::shared_ptr<EventId> eventid) {
bool EventIdMap::isDuplicate(std::shared_ptr<EventSource> key,
std::shared_ptr<EventSequence> value) {
- GUARD_MAP;
- const auto& entry = m_map.find(key);
+ std::lock_guard<decltype(m_lock)> guard(m_lock);
+ const auto& entry = m_map.find(key);
if (entry != m_map.end() && ((*value) <= (*(entry->second)))) {
return true;
}
@@ -51,12 +53,11 @@ bool EventIdMap::isDuplicate(std::shared_ptr<EventSource> key,
bool EventIdMap::put(std::shared_ptr<EventSource> key,
std::shared_ptr<EventSequence> value, bool onlynew) {
- GUARD_MAP;
+ std::lock_guard<decltype(m_lock)> guard(m_lock);
value->touch(m_expiry);
const auto& entry = m_map.find(key);
-
if (entry != m_map.end()) {
if (onlynew && ((*value) <= (*(entry->second)))) {
return false;
@@ -71,10 +72,9 @@ bool EventIdMap::put(std::shared_ptr<EventSource> key,
}
bool EventIdMap::touch(std::shared_ptr<EventSource> key) {
- GUARD_MAP;
+ std::lock_guard<decltype(m_lock)> guard(m_lock);
const auto& entry = m_map.find(key);
-
if (entry != m_map.end()) {
entry->second->touch(m_expiry);
return true;
@@ -84,7 +84,7 @@ bool EventIdMap::touch(std::shared_ptr<EventSource> key) {
}
bool EventIdMap::remove(std::shared_ptr<EventSource> key) {
- GUARD_MAP;
+ std::lock_guard<decltype(m_lock)> guard(m_lock);
const auto& entry = m_map.find(key);
@@ -98,7 +98,7 @@ bool EventIdMap::remove(std::shared_ptr<EventSource> key) {
// side-effect: sets acked flags to true
EventIdMapEntryList EventIdMap::getUnAcked() {
- GUARD_MAP;
+ std::lock_guard<decltype(m_lock)> guard(m_lock);
EventIdMapEntryList entries;
@@ -115,7 +115,7 @@ EventIdMapEntryList EventIdMap::getUnAcked() {
}
uint32_t EventIdMap::clearAckedFlags(EventIdMapEntryList& entries) {
- GUARD_MAP;
+ std::lock_guard<decltype(m_lock)> guard(m_lock);
uint32_t cleared = 0;
@@ -132,27 +132,24 @@ uint32_t EventIdMap::clearAckedFlags(EventIdMapEntryList& entries) {
}
uint32_t EventIdMap::expire(bool onlyacked) {
- GUARD_MAP;
+ std::lock_guard<decltype(m_lock)> guard(m_lock);
uint32_t expired = 0;
EventIdMapEntryList entries;
- ACE_Time_Value current = ACE_OS::gettimeofday();
-
for (const auto& entry : m_map) {
if (onlyacked && !entry.second->getAcked()) {
continue;
}
- if (entry.second->getDeadline() < current) {
+ if (entry.second->getDeadline() < EventSequence::clock::now()) {
entries.push_back(std::make_pair(entry.first, entry.second));
}
}
- for (EventIdMapEntryList::iterator expiry = entries.begin();
- expiry != entries.end(); expiry++) {
- m_map.erase((*expiry).first);
+ for (auto&& expiry : entries) {
+ m_map.erase(expiry.first);
expired++;
}
@@ -162,7 +159,7 @@ uint32_t EventIdMap::expire(bool onlyacked) {
void EventSequence::init() {
m_seqNum = -1;
m_acked = false;
- m_deadline = ACE_OS::gettimeofday();
+ m_deadline = clock::now();
}
void EventSequence::clear() { init(); }
@@ -177,8 +174,7 @@ EventSequence::EventSequence(int64_t seqNum) {
EventSequence::~EventSequence() { clear(); }
void EventSequence::touch(std::chrono::milliseconds ageSecs) {
- m_deadline = ACE_OS::gettimeofday();
- m_deadline += ageSecs;
+ m_deadline = clock::now() + ageSecs;
}
void EventSequence::touch(int64_t seqNum, std::chrono::milliseconds ageSecs) {
@@ -195,11 +191,9 @@ bool EventSequence::getAcked() { return m_acked; }
void EventSequence::setAcked(bool acked) { m_acked = acked; }
-ACE_Time_Value EventSequence::getDeadline() { return m_deadline; }
+EventSequence::time_point EventSequence::getDeadline() { return m_deadline; }
-void EventSequence::setDeadline(ACE_Time_Value deadline) {
- m_deadline = deadline;
-}
+void EventSequence::setDeadline(time_point deadline) { m_deadline = deadline; }
bool EventSequence::operator<=(const EventSequence& rhs) const {
return this->m_seqNum <= (&rhs)->m_seqNum;
diff --git a/cppcache/src/EventIdMap.hpp b/cppcache/src/EventIdMap.hpp
index 4b2805a..6ec3379 100644
--- a/cppcache/src/EventIdMap.hpp
+++ b/cppcache/src/EventIdMap.hpp
@@ -20,17 +20,14 @@
#ifndef GEODE_EVENTIDMAP_H_
#define GEODE_EVENTIDMAP_H_
+#include <chrono>
#include <functional>
#include <memory>
+#include <mutex>
#include <unordered_map>
#include <utility>
#include <vector>
-#include <ace/ACE.h>
-#include <ace/Guard_T.h>
-#include <ace/Recursive_Thread_Mutex.h>
-#include <ace/Time_Value.h>
-
#include <geode/internal/functional.hpp>
#include "EventId.hpp"
@@ -47,10 +44,6 @@ typedef std::pair<std::shared_ptr<EventSource>, std::shared_ptr<EventSequence>>
EventIdMapEntry;
typedef std::vector<EventIdMapEntry> EventIdMapEntryList;
-typedef ACE_Guard<ACE_Recursive_Thread_Mutex> MapGuard;
-
-#define GUARD_MAP MapGuard mapguard(m_lock)
-
/** @class EventIdMap EventIdMap.hpp
*
* This is the class that encapsulates a HashMap and
@@ -67,7 +60,7 @@ class APACHE_GEODE_EXPORT EventIdMap {
std::chrono::milliseconds m_expiry;
map_type m_map;
- ACE_Recursive_Thread_Mutex m_lock;
+ std::recursive_mutex m_lock;
// hidden
EventIdMap(const EventIdMap &);
@@ -135,9 +128,14 @@ class APACHE_GEODE_EXPORT EventIdMap {
* a flag indicating whether or not it is ACKed
*/
class APACHE_GEODE_EXPORT EventSequence {
+ public:
+ using clock = std::chrono::steady_clock;
+ using time_point = clock::time_point;
+
+ private:
int64_t m_seqNum;
bool m_acked;
- ACE_Time_Value m_deadline; // current time plus the expiration delay (age)
+ time_point m_deadline; // current time plus the expiration delay (age)
void init();
@@ -161,8 +159,8 @@ class APACHE_GEODE_EXPORT EventSequence {
bool getAcked();
void setAcked(bool acked);
- ACE_Time_Value getDeadline();
- void setDeadline(ACE_Time_Value deadline);
+ time_point getDeadline();
+ void setDeadline(time_point deadline);
bool operator<=(const EventSequence &rhs) const;
};
diff --git a/cppcache/src/EventSource.cpp b/cppcache/src/EventSource.cpp
index d303416..7b9b5cc 100644
--- a/cppcache/src/EventSource.cpp
+++ b/cppcache/src/EventSource.cpp
@@ -14,6 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#include <ace/ACE.h>
+
#include "EventIdMap.hpp"
namespace apache {
diff --git a/cppcache/src/EvictionController.cpp b/cppcache/src/EvictionController.cpp
index 52aac5c..d2c366b 100644
--- a/cppcache/src/EvictionController.cpp
+++ b/cppcache/src/EvictionController.cpp
@@ -17,6 +17,7 @@
#include "EvictionController.hpp"
+#include <chrono>
#include <string>
#include "CacheImpl.hpp"
@@ -60,13 +61,13 @@ int EvictionController::svc() {
int64_t pendingEvictions = 0;
while (m_run) {
int64_t readInfo = 0;
- readInfo = m_queue.get(1500);
+ readInfo = m_queue.getFor(std::chrono::microseconds(1500));
if (readInfo == 0) continue;
processHeapInfo(readInfo, pendingEvictions);
}
- int32_t size = m_queue.size();
- for (int i = 0; i < size; i++) {
+ auto size = m_queue.size();
+ for (decltype(size) i = 0; i < size; i++) {
int64_t readInfo = 0;
readInfo = m_queue.get();
if (readInfo == 0) continue;
diff --git a/cppcache/src/EvictionController.hpp b/cppcache/src/EvictionController.hpp
index 6529d48..ddc6cdc 100644
--- a/cppcache/src/EvictionController.hpp
+++ b/cppcache/src/EvictionController.hpp
@@ -24,11 +24,8 @@
#include <string>
#include <vector>
-#include <ace/ACE.h>
-#include <ace/OS.h>
-#include <ace/Singleton.h>
+#include <ace/RW_Thread_Mutex.h>
#include <ace/Task.h>
-#include <ace/Thread_Mutex.h>
#include <geode/DataOutput.hpp>
diff --git a/cppcache/src/EvictionThread.cpp b/cppcache/src/EvictionThread.cpp
index b658bf5..e28376e 100644
--- a/cppcache/src/EvictionThread.cpp
+++ b/cppcache/src/EvictionThread.cpp
@@ -14,8 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "EvictionThread.hpp"
+#include <chrono>
+
#include "DistributedSystemImpl.hpp"
#include "EvictionController.hpp"
@@ -25,27 +28,22 @@ namespace client {
const char* EvictionThread::NC_Evic_Thread = "NC Evic Thread";
EvictionThread::EvictionThread(EvictionController* parent)
- : m_pParent(parent),
- /* adongre
- * CID 28936: Uninitialized scalar field (UNINIT_CTOR)
- */
- m_run(false) {}
+ : m_pParent(parent), m_run(false) {}
int EvictionThread::svc(void) {
DistributedSystemImpl::setThreadName(NC_Evic_Thread);
while (m_run) {
processEvictions();
}
- int32_t size = m_queue.size();
- for (int i = 0; i < size; i++) {
+ auto size = m_queue.size();
+ for (decltype(size) i = 0; i < size; i++) {
processEvictions();
}
return 1;
}
void EvictionThread::processEvictions() {
- int32_t percentageToEvict = 0;
- percentageToEvict = static_cast<int32_t>(m_queue.get(1500));
+ auto percentageToEvict = m_queue.getFor(std::chrono::microseconds(1500));
if (percentageToEvict != 0) {
m_pParent->evict(percentageToEvict);
}
diff --git a/cppcache/src/EvictionThread.hpp b/cppcache/src/EvictionThread.hpp
index e9fc248..31ffebd 100644
--- a/cppcache/src/EvictionThread.hpp
+++ b/cppcache/src/EvictionThread.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_EVICTIONTHREAD_H_
-#define GEODE_EVICTIONTHREAD_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,25 +15,27 @@
* limitations under the License.
*/
-#include <ace/ACE.h>
-#include <ace/OS.h>
-#include <ace/Singleton.h>
+#pragma once
+
+#ifndef GEODE_EVICTIONTHREAD_H_
+#define GEODE_EVICTIONTHREAD_H_
+
#include <ace/Task.h>
-#include <ace/Thread_Mutex.h>
#include <geode/DataOutput.hpp>
#include "IntQueue.hpp"
#include "util/Log.hpp"
-/**
- * This class does the actual evictions
- */
+
namespace apache {
namespace geode {
namespace client {
+
class EvictionController;
-typedef IntQueue<int64_t> HeapSizeInfoQueue;
+/**
+ * This class does the actual evictions
+ */
class APACHE_GEODE_EXPORT EvictionThread : public ACE_Task_Base {
public:
explicit EvictionThread(EvictionController* parent);
@@ -62,11 +59,12 @@ class APACHE_GEODE_EXPORT EvictionThread : public ACE_Task_Base {
private:
EvictionController* m_pParent;
- HeapSizeInfoQueue m_queue;
+ IntQueue<int32_t> m_queue;
bool m_run;
static const char* NC_Evic_Thread;
};
+
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/Exception.cpp b/cppcache/src/Exception.cpp
index 132eb28..8f984de 100644
--- a/cppcache/src/Exception.cpp
+++ b/cppcache/src/Exception.cpp
@@ -17,8 +17,6 @@
#include <cstdlib>
-#include <ace/OS.h>
-#include <ace/TSS_T.h>
#include <boost/core/demangle.hpp>
#include <geode/CacheableString.hpp>
@@ -55,30 +53,17 @@ std::string Exception::getStackTrace() const {
// class to store/clear last server exception in TSS area
-class TSSExceptionString {
- private:
- std::string m_exMsg;
+thread_local std::string threadLocalExceptionMessage;
- public:
- TSSExceptionString() : m_exMsg() {}
- virtual ~TSSExceptionString() {}
-
- inline std::string& str() { return m_exMsg; }
-
- static ACE_TSS<TSSExceptionString> s_tssExceptionMsg;
-};
-
-ACE_TSS<TSSExceptionString> TSSExceptionString::s_tssExceptionMsg;
-
-void setTSSExceptionMessage(const char* exMsg) {
- TSSExceptionString::s_tssExceptionMsg->str().clear();
+void setThreadLocalExceptionMessage(const char* exMsg) {
+ threadLocalExceptionMessage.clear();
if (exMsg != nullptr) {
- TSSExceptionString::s_tssExceptionMsg->str().append(exMsg);
+ threadLocalExceptionMessage.assign(exMsg);
}
}
-const char* getTSSExceptionMessage() {
- return TSSExceptionString::s_tssExceptionMsg->str().c_str();
+const std::string& getThreadLocalExceptionMessage() {
+ return threadLocalExceptionMessage;
}
} // namespace client
} // namespace geode
diff --git a/cppcache/src/ExceptionTypes.cpp b/cppcache/src/ExceptionTypes.cpp
index ea5af09..366d189 100644
--- a/cppcache/src/ExceptionTypes.cpp
+++ b/cppcache/src/ExceptionTypes.cpp
@@ -30,335 +30,328 @@ namespace apache {
namespace geode {
namespace client {
-void setTSSExceptionMessage(const char* exMsg);
-const char* getTSSExceptionMessage();
+void setThreadLocalExceptionMessage(const char* exMsg);
+const std::string& getThreadLocalExceptionMessage();
[[noreturn]] void GfErrTypeThrowException(const char* str, GfErrType err) {
std::string func;
std::string message;
- const char* exMsg = getTSSExceptionMessage();
- if (exMsg != nullptr && exMsg[0] == '\0') {
- exMsg = nullptr;
- } else {
+ const auto& exMsg = getThreadLocalExceptionMessage();
+ if (!exMsg.empty()) {
func.append(str);
func.append(": ");
- str = func.c_str();
}
switch (err) {
case GF_NOTCON: {
- message.append(exMsg != nullptr ? exMsg : ": not connected to Geode");
+ message.append(!exMsg.empty() ? exMsg : ": not connected to Geode");
NotConnectedException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_MSG: {
- message.append(exMsg != nullptr
+ message.append(!exMsg.empty()
? exMsg
: ": message from server could not be handled");
MessageException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHESERVER_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg
- : ": exception happened at cache server");
+ message.append(!exMsg.empty() ? exMsg
+ : ": exception happened at cache server");
CacheServerException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_NOTOWN: {
- message.append(exMsg != nullptr ? exMsg : ": not own the lock");
+ message.append(!exMsg.empty() ? exMsg : ": not own the lock");
NotOwnerException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_REGION_NOT_FOUND: {
- message.append(exMsg != nullptr ? exMsg : ": region not found on server");
+ message.append(!exMsg.empty() ? exMsg : ": region not found on server");
CacheServerException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_REGION_NOT_GLOBAL: {
- message.append(exMsg != nullptr ? exMsg : ": region not global");
+ message.append(!exMsg.empty() ? exMsg : ": region not global");
IllegalStateException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_ILLEGAL_ARGUMENT_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": illegal argument");
+ message.append(!exMsg.empty() ? exMsg : ": illegal argument");
IllegalArgumentException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_ILLEGAL_STATE_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": illegal State");
+ message.append(!exMsg.empty() ? exMsg : ": illegal State");
IllegalStateException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_WRITER_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg
- : ": exception on server during write");
+ message.append(!exMsg.empty() ? exMsg
+ : ": exception on server during write");
CacheWriterException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHEWRITER_ERROR: {
- message.append(exMsg != nullptr ? exMsg : ": exception in CacheWriter");
+ message.append(!exMsg.empty() ? exMsg : ": exception in CacheWriter");
CacheWriterException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_LOADER_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": exception in CacheLoader");
+ message.append(!exMsg.empty() ? exMsg : ": exception in CacheLoader");
CacheLoaderException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_LISTENER_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": exception in CacheListener");
+ message.append(!exMsg.empty() ? exMsg : ": exception in CacheListener");
CacheListenerException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_REGION_INVALID: {
- message.append(exMsg != nullptr ? exMsg : ": region not valid");
+ message.append(!exMsg.empty() ? exMsg : ": region not valid");
RegionDestroyedException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_PROXY: {
- message.append(exMsg != nullptr ? exMsg : ": error in Cache proxy");
+ message.append(!exMsg.empty() ? exMsg : ": error in Cache proxy");
CacheProxyException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_IOERR: {
- message.append(exMsg != nullptr ? exMsg
- : ": Input/Output error in operation");
+ message.append(!exMsg.empty() ? exMsg
+ : ": Input/Output error in operation");
GeodeIOException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_ENOENT: {
- message.append(exMsg != nullptr ? exMsg : ": entity does not exist");
+ message.append(!exMsg.empty() ? exMsg : ": entity does not exist");
NoSystemException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_REGION_KEYS_NOT_STRINGS: {
- message.append(exMsg != nullptr
- ? exMsg
- : ": region entries do not support C access");
+ message.append(
+ !exMsg.empty() ? exMsg : ": region entries do not support C access");
IllegalArgumentException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_REGION_ENTRY_NOT_BYTES: {
- message.append(exMsg != nullptr
+ message.append(!exMsg.empty()
? exMsg
: ": existing non-null values was not a byte array");
IllegalArgumentException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_TIMEOUT_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": timed out");
+ message.append(!exMsg.empty() ? exMsg : ": timed out");
TimeoutException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_TIMOUT: {
- message.append(exMsg != nullptr ? exMsg : ": timed out");
+ message.append(!exMsg.empty() ? exMsg : ": timed out");
TimeoutException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CLIENT_WAIT_TIMEOUT: {
- message.append(exMsg != nullptr
+ message.append(!exMsg.empty()
? exMsg
: ": timed out, possibly bucket is not available.");
TimeoutException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_ENOMEM: {
- message.append(exMsg != nullptr ? exMsg : ": Out of memory");
+ message.append(!exMsg.empty() ? exMsg : ": Out of memory");
OutOfMemoryException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_ERANGE: {
- message.append(exMsg != nullptr ? exMsg : ": Buffer Size Exceeded");
+ message.append(!exMsg.empty() ? exMsg : ": Buffer Size Exceeded");
BufferSizeExceededException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_LEASE_EXPIRED_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": lock Lease Expired On you");
+ message.append(!exMsg.empty() ? exMsg : ": lock Lease Expired On you");
LeaseExpiredException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_REGION_EXISTS_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": Named Region Exists");
+ message.append(!exMsg.empty() ? exMsg : ": Named Region Exists");
RegionExistsException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_ENTRY_NOT_FOUND: {
- message.append(exMsg != nullptr ? exMsg : ": Entry not found");
+ message.append(!exMsg.empty() ? exMsg : ": Entry not found");
EntryNotFoundException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_ENTRY_EXISTS: {
- message.append(exMsg != nullptr ? exMsg
- : ": Entry already exists in the region");
+ message.append(!exMsg.empty() ? exMsg
+ : ": Entry already exists in the region");
EntryExistsException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_ENTRY_DESTROYED_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": Entry has been destroyed");
+ message.append(!exMsg.empty() ? exMsg : ": Entry has been destroyed");
EntryDestroyedException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_REGION_DESTROYED_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": Named Region Destroyed");
+ message.append(!exMsg.empty() ? exMsg : ": Named Region Destroyed");
RegionDestroyedException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_CLOSED_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": Cache has been closed");
+ message.append(!exMsg.empty() ? exMsg : ": Cache has been closed");
CacheClosedException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_STATISTICS_DISABLED_EXCEPTION: {
- message.append(exMsg != nullptr
+ message.append(!exMsg.empty()
? exMsg
: ": Statistics have been disabled for the region");
StatisticsDisabledException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION: {
- message.append(
- exMsg != nullptr ? exMsg : ": Concurrent modification in the cache");
+ message.append(!exMsg.empty() ? exMsg
+ : ": Concurrent modification in the cache");
ConcurrentModificationException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_NOT_AUTHORIZED_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": unauthorized operation");
+ message.append(!exMsg.empty() ? exMsg : ": unauthorized operation");
NotAuthorizedException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_AUTHENTICATION_FAILED_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": authentication failed");
+ message.append(!exMsg.empty() ? exMsg : ": authentication failed");
AuthenticationFailedException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_AUTHENTICATION_REQUIRED_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": no authentication provided");
+ message.append(!exMsg.empty() ? exMsg : ": no authentication provided");
AuthenticationRequiredException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_DUPLICATE_DURABLE_CLIENT: {
- message.append(exMsg != nullptr ? exMsg
- : ": Duplicate Durable Client Id");
+ message.append(!exMsg.empty() ? exMsg : ": Duplicate Durable Client Id");
DuplicateDurableClientException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_REMOTE_QUERY_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": Query failed");
+ message.append(!exMsg.empty() ? exMsg : ": Query failed");
QueryException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_CACHE_LOCATOR_EXCEPTION: {
NoAvailableLocatorsException cause(
- std::string(str) +
- (exMsg != nullptr ? exMsg : ": No locators available"));
- setTSSExceptionMessage(nullptr);
+ func + (!exMsg.empty() ? exMsg : ": No locators available"));
+ setThreadLocalExceptionMessage(nullptr);
try {
throw cause;
} catch (...) {
NotConnectedException ex(
- std::string(str) +
- (exMsg != nullptr ? exMsg : ": No locators available"));
+ func + (!exMsg.empty() ? exMsg : ": No locators available"));
std::throw_with_nested(ex);
}
}
case GF_ALL_CONNECTIONS_IN_USE_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": All connections are in use");
+ message.append(!exMsg.empty() ? exMsg : ": All connections are in use");
AllConnectionsInUseException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_FUNCTION_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": Function execution failed");
+ message.append(!exMsg.empty() ? exMsg : ": Function execution failed");
FunctionExecutionException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_DISKFULL: {
- message.append(exMsg != nullptr ? exMsg : ": Disk full");
+ message.append(!exMsg.empty() ? exMsg : ": Disk full");
DiskFailureException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_ROLLBACK_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": Transaction rolled back");
+ message.append(!exMsg.empty() ? exMsg : ": Transaction rolled back");
RollbackException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_COMMIT_CONFLICT_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": Commit conflict exception");
+ message.append(!exMsg.empty() ? exMsg : ": Commit conflict exception");
CommitConflictException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_TRANSACTION_DATA_REBALANCED_EXCEPTION: {
message.append(
- exMsg != nullptr ? exMsg : ": Transaction data rebalanced exception");
+ !exMsg.empty() ? exMsg : ": Transaction data rebalanced exception");
TransactionDataRebalancedException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_TRANSACTION_DATA_NODE_HAS_DEPARTED_EXCEPTION: {
- message.append(exMsg != nullptr
+ message.append(!exMsg.empty()
? exMsg
: ": Transaction data node has departed exception");
TransactionDataNodeHasDepartedException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
case GF_PUTALL_PARTIAL_RESULT_EXCEPTION: {
- message.append(exMsg != nullptr ? exMsg : ": PutAll Partial exception");
+ message.append(!exMsg.empty() ? exMsg : ": PutAll Partial exception");
PutAllPartialResultException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
default: {
- char buf[64];
LOGINFO("error code: %d", err);
- if (exMsg == nullptr) {
- ACE_OS::snprintf(buf, 64, "Unknown error code[0x%X]", err);
- exMsg = buf;
+ std::string message = func;
+ if (exMsg.empty()) {
+ message.append("Unknown error code ").append(std::to_string(err));
+ } else {
+ message.append(exMsg);
}
- std::string message = std::string(str) + exMsg;
UnknownException ex(message);
- setTSSExceptionMessage(nullptr);
+ setThreadLocalExceptionMessage(nullptr);
throw ex;
}
}
diff --git a/cppcache/src/ExecutionImpl.cpp b/cppcache/src/ExecutionImpl.cpp
index f8d73b8..6f1f651 100644
--- a/cppcache/src/ExecutionImpl.cpp
+++ b/cppcache/src/ExecutionImpl.cpp
@@ -34,10 +34,9 @@ namespace geode {
namespace client {
FunctionToFunctionAttributes ExecutionImpl::m_func_attrs;
-ACE_Recursive_Thread_Mutex ExecutionImpl::m_func_attrs_lock;
+std::recursive_mutex ExecutionImpl::m_func_attrs_lock;
Execution ExecutionImpl::withFilter(
std::shared_ptr<CacheableVector> routingObj) {
- // ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_lock);
if (routingObj == nullptr) {
throw IllegalArgumentException("Execution::withFilter: filter is null");
}
@@ -53,7 +52,6 @@ Execution ExecutionImpl::withFilter(
}
Execution ExecutionImpl::withArgs(std::shared_ptr<Cacheable> args) {
- // ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_lock);
if (args == nullptr) {
throw IllegalArgumentException("Execution::withArgs: args is null");
}
@@ -64,7 +62,6 @@ Execution ExecutionImpl::withArgs(std::shared_ptr<Cacheable> args) {
}
Execution ExecutionImpl::withCollector(std::shared_ptr<ResultCollector> rs) {
- // ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_lock);
if (rs == nullptr) {
throw IllegalArgumentException(
"Execution::withCollector: collector is null");
@@ -110,7 +107,7 @@ std::shared_ptr<ResultCollector> ExecutionImpl::execute(
auto&& attr = getFunctionAttributes(func);
{
if (attr == nullptr) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_func_attrs_lock);
+ std::lock_guard<decltype(m_func_attrs_lock)> _guard(m_func_attrs_lock);
GfErrType err = GF_NOERR;
attr = getFunctionAttributes(func);
if (attr == nullptr) {
diff --git a/cppcache/src/ExecutionImpl.hpp b/cppcache/src/ExecutionImpl.hpp
index f763632..f7b89ac 100644
--- a/cppcache/src/ExecutionImpl.hpp
+++ b/cppcache/src/ExecutionImpl.hpp
@@ -21,9 +21,7 @@
#define GEODE_EXECUTIONIMPL_H_
#include <map>
-
-#include <ace/Condition_Recursive_Thread_Mutex.h>
-#include <ace/Guard_T.h>
+#include <mutex>
#include <geode/AuthenticatedView.hpp>
#include <geode/CacheableBuiltins.hpp>
@@ -102,7 +100,6 @@ class ExecutionImpl {
m_allServer(allServer),
m_pool(pool),
m_authenticatedView(authenticatedView) {}
- // ACE_Recursive_Thread_Mutex m_lock;
std::shared_ptr<CacheableVector> m_routingObj;
std::shared_ptr<Cacheable> m_args;
std::shared_ptr<ResultCollector> m_rc;
@@ -110,7 +107,7 @@ class ExecutionImpl {
bool m_allServer;
std::shared_ptr<Pool> m_pool;
AuthenticatedView* m_authenticatedView;
- static ACE_Recursive_Thread_Mutex m_func_attrs_lock;
+ static std::recursive_mutex m_func_attrs_lock;
static FunctionToFunctionAttributes m_func_attrs;
// std::vector<int8_t> m_attributes;
diff --git a/cppcache/src/ExpiryHandler_T.hpp b/cppcache/src/ExpiryHandler_T.hpp
index f83bafb..1157cf5 100644
--- a/cppcache/src/ExpiryHandler_T.hpp
+++ b/cppcache/src/ExpiryHandler_T.hpp
@@ -25,8 +25,9 @@
*@version 1.0
*/
+#include <ace/Event_Handler.h>
+
#include "StackTrace.hpp"
-#include "ace/Event_Handler.h"
#include "util/Log.hpp"
namespace apache {
namespace geode {
diff --git a/cppcache/src/ExpiryTaskManager.cpp b/cppcache/src/ExpiryTaskManager.cpp
index 1c741a4..0a3bef3 100644
--- a/cppcache/src/ExpiryTaskManager.cpp
+++ b/cppcache/src/ExpiryTaskManager.cpp
@@ -88,7 +88,11 @@ int ExpiryTaskManager::cancelTask(ExpiryTaskManager::id_type id) {
int ExpiryTaskManager::svc() {
DistributedSystemImpl::setThreadName(NC_ETM_Thread);
LOGFINE("ExpiryTaskManager thread is running.");
- m_reactorEventLoopRunning = true;
+ {
+ std::unique_lock<std::mutex> lock(m_mutex);
+ m_reactorEventLoopRunning = true;
+ m_condition.notify_all();
+ }
m_reactor->owner(ACE_OS::thr_self());
m_reactor->run_reactor_event_loop();
LOGFINE("ExpiryTaskManager thread has stopped.");
@@ -96,21 +100,21 @@ int ExpiryTaskManager::svc() {
}
void ExpiryTaskManager::stopExpiryTaskManager() {
+ std::unique_lock<std::mutex> lock(m_mutex);
+
if (m_reactorEventLoopRunning) {
m_reactor->end_reactor_event_loop();
this->wait();
GF_D_ASSERT(m_reactor->reactor_event_loop_done() > 0);
m_reactorEventLoopRunning = false;
+ m_condition.notify_all();
}
}
void ExpiryTaskManager::begin() {
this->activate();
- ACE_Time_Value t;
- t.msec(50);
- while (!m_reactorEventLoopRunning) {
- ACE_OS::sleep(t);
- }
+ std::unique_lock<std::mutex> lock(m_mutex);
+ m_condition.wait(lock, [this] { return m_reactorEventLoopRunning; });
}
ExpiryTaskManager::~ExpiryTaskManager() {
diff --git a/cppcache/src/ExpiryTaskManager.hpp b/cppcache/src/ExpiryTaskManager.hpp
index 8b8aa06..b64ebe3 100644
--- a/cppcache/src/ExpiryTaskManager.hpp
+++ b/cppcache/src/ExpiryTaskManager.hpp
@@ -21,6 +21,8 @@
#define GEODE_EXPIRYTASKMANAGER_H_
#include <chrono>
+#include <condition_variable>
+#include <mutex>
#include <type_traits>
#include <ace/Reactor.h>
@@ -305,9 +307,10 @@ class APACHE_GEODE_EXPORT ExpiryTaskManager : public ACE_Task_Base {
bool m_reactorEventLoopRunning; // flag to indicate if the reactor event
// loop is running or not.
- ACE_Recursive_Thread_Mutex m_taskLock; // to synchronize scheduling
- // of expiry tasks.
static const char* NC_ETM_Thread;
+
+ std::mutex m_mutex;
+ std::condition_variable m_condition;
};
} // namespace client
} // namespace geode
diff --git a/cppcache/src/IntQueue.hpp b/cppcache/src/IntQueue.hpp
index 4b518c9..667240e 100644
--- a/cppcache/src/IntQueue.hpp
+++ b/cppcache/src/IntQueue.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_INTQUEUE_H_
-#define GEODE_INTQUEUE_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,102 +15,84 @@
* limitations under the License.
*/
-#include <deque>
+#pragma once
-#include <ace/ACE.h>
-#include <ace/Condition_Recursive_Thread_Mutex.h>
-#include <ace/Guard_T.h>
-#include <ace/Recursive_Thread_Mutex.h>
-#include <ace/Time_Value.h>
+#ifndef GEODE_INTQUEUE_H_
+#define GEODE_INTQUEUE_H_
+
+#include <chrono>
+#include <condition_variable>
+#include <deque>
+#include <mutex>
namespace apache {
namespace geode {
namespace client {
template <class T>
-
class APACHE_GEODE_EXPORT IntQueue {
public:
- IntQueue() : m_cond(m_mutex) {}
+ inline IntQueue() = default;
- ~IntQueue() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
-
- while (m_queue.size() > 0) {
- m_queue.pop_back();
- }
- }
-
- /** wait usec time until notified */
- T get(int64_t usec) {
- ACE_Time_Value interval(usec / 1000000, usec % 1000000);
- return getUntil(interval);
- }
+ inline ~IntQueue() noexcept = default;
T get() {
+ std::unique_lock<decltype(m_mutex)> _guard(m_mutex);
T mp = 0;
-
getInternal(mp);
return mp;
}
+ template <class _Rep, class _Period>
+ T getFor(const std::chrono::duration<_Rep, _Period>& duration) {
+ std::unique_lock<decltype(m_mutex)> _guard(m_mutex);
+ T mp = 0;
+ if (!getInternal(mp)) {
+ if (m_cond.wait_for(_guard, duration,
+ [this] { return !m_queue.empty(); })) {
+ mp = m_queue.back();
+ m_queue.pop_back();
+ }
+ }
+ return mp;
+ }
+
void put(T mp) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::unique_lock<decltype(m_mutex)> _guard(m_mutex);
m_queue.push_front(mp);
- m_cond.signal();
+ if (m_queue.size() == 1) {
+ m_cond.notify_one();
+ }
}
- uint32_t size() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
- return static_cast<uint32_t>(m_queue.size());
+ size_t size() {
+ std::unique_lock<decltype(m_mutex)> _guard(m_mutex);
+ return m_queue.size();
}
void clear() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::unique_lock<decltype(m_mutex)> _guard(m_mutex);
m_queue.clear();
- m_cond.signal();
}
- bool empty() { return size() == 0; }
+ bool empty() {
+ std::unique_lock<decltype(m_mutex)> _guard(m_mutex);
+ return m_queue.empty();
+ }
private:
inline bool getInternal(T& val) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
-
if (m_queue.size() > 0) {
val = m_queue.back();
m_queue.pop_back();
return true;
}
-
return false;
}
- T getUntil(const ACE_Time_Value& interval) {
- T mp = 0;
- bool found = getInternal(mp);
-
- if (!found) {
- ACE_Time_Value stopAt(ACE_OS::gettimeofday());
- stopAt += interval;
-
- while (!found && ACE_OS::gettimeofday() < stopAt) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
- m_cond.wait(&stopAt);
- if (m_queue.size() > 0) {
- mp = m_queue.back();
- m_queue.pop_back();
- found = true;
- }
- }
- }
- return mp;
- }
-
- typedef std::deque<T> LocalQueue;
- LocalQueue m_queue;
- ACE_Recursive_Thread_Mutex m_mutex;
- ACE_Condition<ACE_Recursive_Thread_Mutex> m_cond;
+ std::deque<T> m_queue;
+ std::mutex m_mutex;
+ std::condition_variable m_cond;
};
} // namespace client
} // namespace geode
diff --git a/cppcache/src/LRUEntriesMap.cpp b/cppcache/src/LRUEntriesMap.cpp
index bd8f3de..e7248f4 100644
--- a/cppcache/src/LRUEntriesMap.cpp
+++ b/cppcache/src/LRUEntriesMap.cpp
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "LRUEntriesMap.hpp"
#include <mutex>
@@ -27,6 +28,7 @@
namespace apache {
namespace geode {
namespace client {
+
/**
* @brief LRUAction for testing map outside of a region....
*/
@@ -164,7 +166,6 @@ GfErrType LRUEntriesMap::processLRU() {
GfErrType LRUEntriesMap::evictionHelper() {
GfErrType err = GF_NOERR;
- // ACE_Guard< ACE_Recursive_Thread_Mutex > guard( m_mutex );
std::shared_ptr<MapEntryImpl> lruEntryPtr;
m_lruList.getLRUEntry(lruEntryPtr);
if (lruEntryPtr == nullptr) {
@@ -218,7 +219,7 @@ GfErrType LRUEntriesMap::invalidate(const std::shared_ptr<CacheableKey>& key,
// later value
// TODO: assess any other effects of this race
if (CacheableToken::isOverflowed(oldValue)) {
- ACE_Guard<MapSegment> _guard(*segmentRPtr);
+ std::lock_guard<MapSegment> _guard(*segmentRPtr);
auto&& persistenceInfo = me->getLRUProperties().getPersistenceInfo();
// get the old value first which is required for heapLRU
// calculation and for listeners; note even though there is a race
@@ -265,14 +266,14 @@ GfErrType LRUEntriesMap::put(const std::shared_ptr<CacheableKey>& key,
{
if (m_action != nullptr &&
m_action->getType() == LRUAction::OVERFLOW_TO_DISK) {
- segmentRPtr->acquire();
+ segmentRPtr->lock();
segmentLocked = true;
}
std::shared_ptr<MapEntryImpl> mePtr;
if ((err = segmentRPtr->put(key, newValue, me, oldValue, updateCount,
destroyTracker, isUpdate, versionTag, delta)) !=
GF_NOERR) {
- if (segmentLocked == true) segmentRPtr->release();
+ if (segmentLocked == true) segmentRPtr->unlock();
return err;
}
@@ -292,7 +293,7 @@ GfErrType LRUEntriesMap::put(const std::shared_ptr<CacheableKey>& key,
// unless very careful thought has gone into it.
if (CacheableToken::isOverflowed(oldValue)) {
if (!segmentLocked) {
- segmentRPtr->release();
+ segmentRPtr->unlock();
segmentLocked = true;
}
auto&& persistenceInfo = me->getLRUProperties().getPersistenceInfo();
@@ -360,7 +361,7 @@ GfErrType LRUEntriesMap::put(const std::shared_ptr<CacheableKey>& key,
err = processLRU();
if (segmentLocked) {
- segmentRPtr->release();
+ segmentRPtr->unlock();
}
return err;
}
@@ -378,14 +379,14 @@ bool LRUEntriesMap::get(const std::shared_ptr<CacheableKey>& key,
bool segmentLocked = false;
if (m_action != nullptr &&
m_action->getType() == LRUAction::OVERFLOW_TO_DISK) {
- segmentRPtr->acquire();
+ segmentRPtr->lock();
segmentLocked = true;
}
{
returnPtr = nullptr;
std::shared_ptr<MapEntryImpl> mePtr;
if (false == segmentRPtr->getEntry(key, mePtr, returnPtr)) {
- if (segmentLocked == true) segmentRPtr->release();
+ if (segmentLocked == true) segmentRPtr->unlock();
return false;
}
// segmentRPtr->get(key, returnPtr, mePtr);
@@ -398,7 +399,7 @@ bool LRUEntriesMap::get(const std::shared_ptr<CacheableKey>& key,
tmpObj = m_pmPtr->read(key, persistenceInfo);
} catch (Exception& ex) {
LOGERROR("read on the persistence layer failed - %s", ex.what());
- if (segmentLocked == true) segmentRPtr->release();
+ if (segmentLocked == true) segmentRPtr->unlock();
return false;
}
m_region->getRegionStats()->incRetrieves();
@@ -435,13 +436,13 @@ bool LRUEntriesMap::get(const std::shared_ptr<CacheableKey>& key,
GfErrType IsProcessLru = processLRU();
if ((IsProcessLru != GF_NOERR)) {
if (segmentLocked) {
- segmentRPtr->release();
+ segmentRPtr->unlock();
}
return false;
}
}
if (segmentLocked) {
- segmentRPtr->release();
+ segmentRPtr->unlock();
}
return true;
}
@@ -467,7 +468,7 @@ GfErrType LRUEntriesMap::remove(const std::shared_ptr<CacheableKey>& key,
--m_validEntries;
}
if (CacheableToken::isOverflowed(result)) {
- ACE_Guard<MapSegment> _guard(*segmentRPtr);
+ std::lock_guard<MapSegment> _guard(*segmentRPtr);
auto&& persistenceInfo = lruProps.getPersistenceInfo();
// get the old value first which is required for heapLRU
// calculation and for listeners; note even though there is a race
diff --git a/cppcache/src/LocalRegion.hpp b/cppcache/src/LocalRegion.hpp
index c98fbc4..1c067d3 100644
--- a/cppcache/src/LocalRegion.hpp
+++ b/cppcache/src/LocalRegion.hpp
@@ -27,9 +27,7 @@
#include <string>
#include <unordered_map>
-#include <ace/ACE.h>
-#include <ace/Hash_Map_Manager_T.h>
-#include <ace/Recursive_Thread_Mutex.h>
+#include <ace/RW_Thread_Mutex.h>
#include <geode/AttributesMutator.hpp>
#include <geode/Cache.hpp>
diff --git a/cppcache/src/Log.cpp b/cppcache/src/Log.cpp
index d56b886..93a2ffb 100644
--- a/cppcache/src/Log.cpp
+++ b/cppcache/src/Log.cpp
@@ -17,9 +17,12 @@
#include "util/Log.hpp"
+#include <algorithm>
#include <cctype>
#include <chrono>
#include <cinttypes>
+#include <ctime>
+#include <mutex>
#include <string>
#include <thread>
#include <utility>
@@ -28,14 +31,13 @@
#include <ace/ACE.h>
#include <ace/Dirent.h>
#include <ace/Dirent_Selector.h>
-#include <ace/Guard_T.h>
#include <ace/OS.h>
#include <ace/OS_NS_Thread.h>
#include <ace/OS_NS_sys_stat.h>
#include <ace/OS_NS_sys_time.h>
#include <ace/OS_NS_time.h>
#include <ace/OS_NS_unistd.h>
-#include <ace/Thread_Mutex.h>
+#include <boost/process/environment.hpp>
#include <geode/ExceptionTypes.hpp>
#include <geode/internal/geode_globals.hpp>
@@ -44,6 +46,7 @@
#include "../internal/hacks/AceThreadId.h"
#include "Assert.hpp"
#include "geodeBanner.hpp"
+#include "util/chrono/time_point.hpp"
#if defined(_WIN32)
#include <io.h>
@@ -79,7 +82,7 @@ size_t g_diskSpaceLimit = GEODE_MAX_LOG_DISK_LIMIT;
char g_logFileNameBuffer[2048] = {0};
-ACE_Thread_Mutex* g_logMutex = new ACE_Thread_Mutex("Log::logMutex");
+std::mutex g_logMutex;
int g_rollIndex = 0;
size_t g_spaceUsed = 0;
@@ -141,7 +144,7 @@ static int comparator(const dirent** d1, const dirent** d2) {
return 1;
}
- int diff = ACE_OS::strcmp((*d1)->d_name, (*d2)->d_name);
+ int diff = std::strcmp((*d1)->d_name, (*d2)->d_name);
if (diff < 0) {
return -1;
} else if (diff > 0) {
@@ -166,7 +169,6 @@ using apache::geode::log::globals::g_fileSizeLimit;
using apache::geode::log::globals::g_isLogFileOpened;
using apache::geode::log::globals::g_log;
using apache::geode::log::globals::g_logFile;
-using apache::geode::log::globals::g_logFileNameBuffer;
using apache::geode::log::globals::g_logFileWithExt;
using apache::geode::log::globals::g_logMutex;
using apache::geode::log::globals::g_pid;
@@ -176,23 +178,6 @@ using apache::geode::log::globals::g_uname;
/*****************************************************************************/
-const char* Log::logFileName() {
- ACE_Guard<ACE_Thread_Mutex> guard(*g_logMutex);
-
- if (!g_logFile) {
- g_logFileNameBuffer[0] = '\0';
- } else {
- if (g_logFile->size() >= sizeof g_logFileNameBuffer) {
- throw IllegalStateException(
- ("Log file name is too long: " + *g_logFile).c_str());
- }
- ACE_OS::strncpy(g_logFileNameBuffer, g_logFile->c_str(),
- sizeof(g_logFileNameBuffer));
- }
-
- return g_logFileNameBuffer;
-}
-
void Log::init(LogLevel level, const char* logFileName, int32_t logFileLimit,
int64_t logDiskSpaceLimit) {
if (g_log != nullptr) {
@@ -201,7 +186,6 @@ void Log::init(LogLevel level, const char* logFileName, int32_t logFileLimit,
"Call Log::close() before calling Log::init again.");
}
s_logLevel = level;
- if (g_logMutex == nullptr) g_logMutex = new ACE_Thread_Mutex("Log::logMutex");
if (logDiskSpaceLimit <
0 /*|| logDiskSpaceLimit > GEODE_MAX_LOG_DISK_LIMIT*/) {
@@ -212,14 +196,10 @@ void Log::init(LogLevel level, const char* logFileName, int32_t logFileLimit,
logFileLimit = GEODE_MAX_LOG_FILE_LIMIT;
}
- ACE_Guard<ACE_Thread_Mutex> guard(*g_logMutex);
+ std::lock_guard<decltype(g_logMutex)> guard(g_logMutex);
if (logFileName && logFileName[0]) {
std::string filename = logFileName;
- if (filename.size() >= sizeof g_logFileNameBuffer) {
- throw IllegalStateException(
- ("Log file name is too long: " + filename).c_str());
- }
if (g_logFile) {
*g_logFile = filename;
} else {
@@ -228,17 +208,7 @@ void Log::init(LogLevel level, const char* logFileName, int32_t logFileLimit,
#ifdef _WIN32
// replace all '\' with '/' to make everything easier..
- size_t length = g_logFile->length() + 1;
- char* slashtmp = new char[length];
- ACE_OS::strncpy(slashtmp, g_logFile->c_str(), length);
- for (size_t i = 0; i < g_logFile->length(); i++) {
- if (slashtmp[i] == '/') {
- slashtmp[i] = '\\';
- }
- }
- *g_logFile = slashtmp;
- delete[] slashtmp;
- slashtmp = nullptr;
+ std::replace(g_logFile->begin(), g_logFile->end(), '\\', '/');
#endif
// Appending a ".log" at the end if it does not exist or file has some other
@@ -295,7 +265,7 @@ void Log::init(LogLevel level, const char* logFileName, int32_t logFileLimit,
if (fileHyphenPos != std::string::npos) {
std::string buff =
tempname.substr(fileHyphenPos + 1, tempname.length());
- g_rollIndex = ACE_OS::atoi(buff.c_str()) + 1;
+ g_rollIndex = std::stoi(buff) + 1;
}
} // if loop
} // for loop
@@ -304,17 +274,6 @@ void Log::init(LogLevel level, const char* logFileName, int32_t logFileLimit,
FILE* existingFile = fopen(g_logFileWithExt->c_str(), "r");
if (existingFile != nullptr && logFileLimit > 0) {
- /* adongre
- * Coverity - II
- * CID 29205: Calling risky function (SECURE_CODING)[VERY RISKY]. Using
- * "sprintf" can cause a
- * buffer overflow when done incorrectly. Because sprintf() assumes an
- * arbitrarily long string,
- * callers must be careful not to overflow the actual space of the
- * destination.
- * Use snprintf() instead, or correct precision specifiers.
- * Fix : using ACE_OS::snprintf
- */
char rollFile[1024] = {0};
std::string logsdirname;
std::string logsbasename;
@@ -341,18 +300,18 @@ void Log::init(LogLevel level, const char* logFileName, int32_t logFileLimit,
fnameBeforeExt = logsbasename.substr(0, posOfExt);
extName = logsbasename.substr(posOfExt + 1, baselen);
}
- ACE_OS::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(),
- ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(),
- g_rollIndex++, extName.c_str());
+ std::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(),
+ ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(),
+ g_rollIndex++, extName.c_str());
bool rollFileNameGot = false;
while (!rollFileNameGot) {
FILE* checkFile = fopen(rollFile, "r");
if (checkFile != nullptr) {
fclose(checkFile);
checkFile = nullptr;
- ACE_OS::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(),
- ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(),
- g_rollIndex++, extName.c_str());
+ std::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(),
+ ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(),
+ g_rollIndex++, extName.c_str());
} else {
rollFileNameGot = true;
}
@@ -393,7 +352,7 @@ void Log::init(LogLevel level, const char* logFileName, int32_t logFileLimit,
}
void Log::close() {
- ACE_Guard<ACE_Thread_Mutex> guard(*g_logMutex);
+ std::lock_guard<decltype(g_logMutex)> guard(g_logMutex);
std::string oldfile;
@@ -510,8 +469,8 @@ const char* Log::levelToChars(LogLevel level) {
default: {
char buf[64] = {0};
- ACE_OS::snprintf(buf, 64, "Unexpected log level: %d",
- static_cast<int>(level));
+ std::snprintf(buf, 64, "Unexpected log level: %d",
+ static_cast<int>(level));
throw IllegalArgumentException(buf);
}
}
@@ -553,22 +512,24 @@ LogLevel Log::charsToLevel(const std::string& chars) {
char* Log::formatLogLine(char* buf, LogLevel level) {
if (g_pid == 0) {
- g_pid = ACE_OS::getpid();
+ g_pid = boost::this_process::get_id();
ACE_OS::uname(&g_uname);
}
const size_t MINBUFSIZE = 128;
- ACE_Time_Value clock = ACE_OS::gettimeofday();
- time_t secs = clock.sec();
- struct tm* tm_val = ACE_OS::localtime(&secs);
- char* pbuf = buf;
- pbuf += ACE_OS::snprintf(pbuf, 15, "[%s ", Log::levelToChars(level));
- pbuf += ACE_OS::strftime(pbuf, MINBUFSIZE, "%Y/%m/%d %H:%M:%S", tm_val);
- pbuf += ACE_OS::snprintf(pbuf, 15, ".%06" PRId64 " ",
- static_cast<int64_t>(clock.usec()));
- pbuf += ACE_OS::strftime(pbuf, MINBUFSIZE, "%Z ", tm_val);
-
- ACE_OS::snprintf(pbuf, 300, "%s:%d %" PRIu64 "] ", g_uname.nodename, g_pid,
- hacks::aceThreadId(ACE_OS::thr_self()));
+ auto now = std::chrono::system_clock::now();
+ auto secs = std::chrono::system_clock::to_time_t(now);
+ auto microseconds = std::chrono::duration_cast<std::chrono::microseconds>(
+ now - std::chrono::system_clock::from_time_t(secs));
+ auto tm_val = apache::geode::util::chrono::localtime(secs);
+ auto pbuf = buf;
+ pbuf += std::snprintf(pbuf, 15, "[%s ", Log::levelToChars(level));
+ pbuf += std::strftime(pbuf, MINBUFSIZE, "%Y/%m/%d %H:%M:%S", &tm_val);
+ pbuf += std::snprintf(pbuf, 15, ".%06" PRId64 " ",
+ static_cast<int64_t>(microseconds.count()));
+ pbuf += std::strftime(pbuf, MINBUFSIZE, "%Z ", &tm_val);
+
+ std::snprintf(pbuf, 300, "%s:%d %" PRIu64 "] ", g_uname.nodename, g_pid,
+ hacks::aceThreadId(ACE_OS::thr_self()));
return buf;
}
@@ -579,7 +540,7 @@ void Log::put(LogLevel level, const std::string& msg) {
// int g_count = 0;
void Log::put(LogLevel level, const char* msg) {
- ACE_Guard<ACE_Thread_Mutex> guard(*g_logMutex);
+ std::lock_guard<decltype(g_logMutex)> guard(g_logMutex);
g_fileInfo fileInfo;
@@ -608,8 +569,7 @@ void Log::put(LogLevel level, const char* msg) {
}
formatLogLine(buf, level);
- size_t numChars =
- static_cast<int>(ACE_OS::strlen(buf) + ACE_OS::strlen(msg));
+ size_t numChars = static_cast<int>(std::strlen(buf) + std::strlen(msg));
g_bytesWritten +=
numChars + 2; // bcoz we have to count trailing new line (\n)
@@ -640,17 +600,17 @@ void Log::put(LogLevel level, const char* msg) {
fnameBeforeExt = logsbasename.substr(0, posOfExt);
extName = logsbasename.substr(posOfExt + 1, baselen);
}
- ACE_OS::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(),
- ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(),
- g_rollIndex++, extName.c_str());
+ std::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(),
+ ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(),
+ g_rollIndex++, extName.c_str());
bool rollFileNameGot = false;
while (!rollFileNameGot) {
FILE* fp1 = fopen(rollFile, "r");
if (fp1 != nullptr) {
fclose(fp1);
- ACE_OS::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(),
- ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(),
- g_rollIndex++, extName.c_str());
+ std::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(),
+ ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(),
+ g_rollIndex++, extName.c_str());
} else {
rollFileNameGot = true;
}
@@ -679,8 +639,8 @@ void Log::put(LogLevel level, const char* msg) {
int status = sds.open(dirname.c_str(), selector, comparator);
if (status != -1) {
for (int index = 1; index < sds.length(); ++index) {
- ACE_OS::snprintf(fullpath, 512, "%s%c%s", dirname.c_str(),
- ACE_DIRECTORY_SEPARATOR_CHAR, sds[index]->d_name);
+ std::snprintf(fullpath, 512, "%s%c%s", dirname.c_str(),
+ ACE_DIRECTORY_SEPARATOR_CHAR, sds[index]->d_name);
ACE_OS::stat(fullpath, &statBuf);
g_fileInfoPair = std::make_pair(fullpath, statBuf.st_size);
fileInfo.push_back(g_fileInfoPair);
@@ -697,8 +657,8 @@ void Log::put(LogLevel level, const char* msg) {
g_spaceUsed -= fileSize;
} else {
char printmsg[256];
- ACE_OS::snprintf(printmsg, 256, "%s\t%s\n", "Could not delete",
- fileInfo[fileIndex].first.c_str());
+ std::snprintf(printmsg, 256, "%s\t%s\n", "Could not delete",
+ fileInfo[fileIndex].first.c_str());
int numChars =
fprintf(g_log, "%s%s\n", formatLogLine(buf, level), printmsg);
g_bytesWritten +=
@@ -745,7 +705,7 @@ void Log::enterFn(LogLevel level, const char* functionName) {
fn = fn.substr(fn.size() - MAX_NAME_LENGTH, MAX_NAME_LENGTH);
}
char buf[MAX_NAME_LENGTH + 512] = {0};
- ACE_OS::snprintf(buf, 1536, "{{{===>>> Entering function %s", fn.c_str());
+ std::snprintf(buf, 1536, "{{{===>>> Entering function %s", fn.c_str());
put(level, buf);
}
@@ -756,7 +716,7 @@ void Log::exitFn(LogLevel level, const char* functionName) {
fn = fn.substr(fn.size() - MAX_NAME_LENGTH, MAX_NAME_LENGTH);
}
char buf[MAX_NAME_LENGTH + 512] = {0};
- ACE_OS::snprintf(buf, 1536, "<<<===}}} Exiting function %s", fn.c_str());
+ std::snprintf(buf, 1536, "<<<===}}} Exiting function %s", fn.c_str());
put(level, buf);
}
diff --git a/cppcache/src/MapSegment.cpp b/cppcache/src/MapSegment.cpp
index fda7371..13e1e5a 100644
--- a/cppcache/src/MapSegment.cpp
+++ b/cppcache/src/MapSegment.cpp
@@ -17,9 +17,7 @@
#include "MapSegment.hpp"
-#include <mutex>
-
-#include <ace/OS.h>
+#include <chrono>
#include "MapEntry.hpp"
#include "RegionInternal.hpp"
@@ -29,7 +27,6 @@
#include "TombstoneExpiryHandler.hpp"
#include "TrackedMapEntry.hpp"
#include "Utils.hpp"
-#include "ace/Time_Value.h"
#include "util/concurrent/spinlock_mutex.hpp"
namespace apache {
@@ -67,9 +64,9 @@ void MapSegment::clear() {
m_map->unbind_all();
}
-int MapSegment::acquire() { return m_segmentMutex.acquire(); }
+void MapSegment::lock() { m_segmentMutex.lock(); }
-int MapSegment::release() { return m_segmentMutex.release(); }
+void MapSegment::unlock() { m_segmentMutex.unlock(); }
GfErrType MapSegment::create(const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Cacheable>& newValue,
@@ -652,41 +649,46 @@ GfErrType MapSegment::putForTrackedEntry(
if (oldValue == nullptr || CacheableToken::isDestroyed(oldValue) ||
CacheableToken::isInvalid(oldValue) ||
CacheableToken::isTombstone(oldValue)) {
- if (m_poolDM) m_poolDM->updateNotificationStats(false, 0);
+ if (m_poolDM) {
+ m_poolDM->updateNotificationStats(false, std::chrono::nanoseconds(0));
+ }
return GF_INVALID_DELTA;
} else if (CacheableToken::isOverflowed(
oldValue)) { // get Value from disc.
oldValue = getFromDisc(key, entryImpl);
if (oldValue == nullptr) {
- if (m_poolDM) m_poolDM->updateNotificationStats(false, 0);
+ if (m_poolDM) {
+ m_poolDM->updateNotificationStats(false,
+ std::chrono::nanoseconds(0));
+ }
return GF_INVALID_DELTA;
}
}
+ using clock = std::chrono::steady_clock;
+
auto valueWithDelta = std::dynamic_pointer_cast<Delta>(oldValue);
auto& newValue1 = const_cast<std::shared_ptr<Cacheable>&>(newValue);
try {
if (m_region->getAttributes().getCloningEnabled()) {
auto tempVal = valueWithDelta->clone();
- ACE_Time_Value currTimeBefore = ACE_OS::gettimeofday();
+ auto currTimeBefore = clock::now();
tempVal->fromDelta(*delta);
if (m_poolDM) {
- m_poolDM->updateNotificationStats(
- true,
- ((ACE_OS::gettimeofday() - currTimeBefore).msec()) * 1000000);
+ m_poolDM->updateNotificationStats(true,
+ clock::now() - currTimeBefore);
}
newValue1 = std::dynamic_pointer_cast<Serializable>(tempVal);
entryImpl->setValueI(newValue1);
} else {
- ACE_Time_Value currTimeBefore = ACE_OS::gettimeofday();
+ auto currTimeBefore = clock::now();
valueWithDelta->fromDelta(*delta);
newValue1 = std::dynamic_pointer_cast<Serializable>(valueWithDelta);
if (m_poolDM) {
- m_poolDM->updateNotificationStats(
- true,
- ((ACE_OS::gettimeofday() - currTimeBefore).msec()) * 1000000);
+ m_poolDM->updateNotificationStats(true,
+ clock::now() - currTimeBefore);
}
entryImpl->setValueI(
std::dynamic_pointer_cast<Serializable>(valueWithDelta));
diff --git a/cppcache/src/MapSegment.hpp b/cppcache/src/MapSegment.hpp
index 6b5dc36..4f6825c 100644
--- a/cppcache/src/MapSegment.hpp
+++ b/cppcache/src/MapSegment.hpp
@@ -21,14 +21,13 @@
#define GEODE_MAPSEGMENT_H_
#include <memory>
+#include <mutex>
#include <unordered_map>
#include <vector>
#include <ace/Functor_T.h>
#include <ace/Hash_Map_Manager.h>
#include <ace/Null_Mutex.h>
-#include <ace/Recursive_Thread_Mutex.h>
-#include <ace/Thread_Mutex.h>
#include <ace/Versioned_Namespace.h>
#include <ace/config-lite.h>
@@ -92,7 +91,7 @@ class APACHE_GEODE_EXPORT MapSegment {
// index of the current prime in the primes table
uint32_t m_primeIndex;
spinlock_mutex m_spinlock;
- ACE_Recursive_Thread_Mutex m_segmentMutex;
+ std::recursive_mutex m_segmentMutex;
bool m_concurrencyChecksEnabled;
// number of operations that are tracking destroys
@@ -217,10 +216,9 @@ class APACHE_GEODE_EXPORT MapSegment {
~MapSegment();
- // methods to acquire/release MapSegment mutex (not SpinLock)
- // that allow using MapSegment with ACE_Guard
- int acquire();
- int release();
+ // methods for BasicLockable
+ void lock();
+ void unlock();
/**
* @brief initialize underlying map structures. Not called by constructor.
diff --git a/cppcache/src/MapWithLock.hpp b/cppcache/src/MapWithLock.hpp
index 2494032..81ccdfd 100644
--- a/cppcache/src/MapWithLock.hpp
+++ b/cppcache/src/MapWithLock.hpp
@@ -25,8 +25,6 @@
#include <ace/Hash_Map_Manager.h>
#include <ace/Recursive_Thread_Mutex.h>
-#include <ace/Versioned_Namespace.h>
-#include <ace/config-lite.h>
#include <geode/CacheableKey.hpp>
#include <geode/internal/geode_globals.hpp>
@@ -56,6 +54,7 @@ typedef ACE_Hash_Map_Manager_Ex<
* other composite operations. ex.. MapOfRegionGuard guard( map->mutex() );
*/
typedef ACE_Guard<ACE_Recursive_Thread_Mutex> MapOfRegionGuard;
+
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/MemberListForVersionStamp.hpp b/cppcache/src/MemberListForVersionStamp.hpp
index cf6ae92..bc24492 100644
--- a/cppcache/src/MemberListForVersionStamp.hpp
+++ b/cppcache/src/MemberListForVersionStamp.hpp
@@ -23,11 +23,12 @@
#include <memory>
#include <unordered_map>
+#include <ace/RW_Thread_Mutex.h>
+
#include <geode/internal/geode_globals.hpp>
#include "DSMemberForVersionStamp.hpp"
#include "ReadWriteLock.hpp"
-#include "ace/RW_Thread_Mutex.h"
namespace apache {
namespace geode {
diff --git a/cppcache/src/PdxFieldType.cpp b/cppcache/src/PdxFieldType.cpp
index c3b3f86..360ed61 100644
--- a/cppcache/src/PdxFieldType.cpp
+++ b/cppcache/src/PdxFieldType.cpp
@@ -26,9 +26,6 @@
#include <geode/PdxFieldTypes.hpp>
#include "PdxTypes.hpp"
-//#include <malloc.h>
-
-#include "ace/OS.h"
namespace apache {
namespace geode {
@@ -135,11 +132,10 @@ int32_t PdxFieldType::getFixedTypeSize() const {
std::string PdxFieldType::toString() const {
char stringBuf[1024];
- ACE_OS::snprintf(
- stringBuf, 1024,
- " PdxFieldName=%s TypeId=%d VarLenFieldIdx=%d sequenceid=%d\n",
- this->m_fieldName.c_str(), static_cast<int>(this->m_typeId),
- this->m_varLenFieldIdx, this->m_sequenceId);
+ std::snprintf(stringBuf, 1024,
+ " PdxFieldName=%s TypeId=%d VarLenFieldIdx=%d sequenceid=%d\n",
+ this->m_fieldName.c_str(), static_cast<int>(this->m_typeId),
+ this->m_varLenFieldIdx, this->m_sequenceId);
return std::string(stringBuf);
}
diff --git a/cppcache/src/PdxFieldType.hpp b/cppcache/src/PdxFieldType.hpp
index aed8471..ea04687 100644
--- a/cppcache/src/PdxFieldType.hpp
+++ b/cppcache/src/PdxFieldType.hpp
@@ -60,9 +60,9 @@ class APACHE_GEODE_EXPORT PdxFieldType
PdxFieldType();
- inline const char* getFieldName() { return m_fieldName.c_str(); }
+ inline const std::string& getFieldName() { return m_fieldName; }
- inline const char* getClassName() { return m_className.c_str(); }
+ inline const std::string& getClassName() { return m_className; }
inline PdxFieldTypes getTypeId() { return m_typeId; }
diff --git a/cppcache/src/PdxInstanceImpl.cpp b/cppcache/src/PdxInstanceImpl.cpp
index cbaf8b6..0796320 100644
--- a/cppcache/src/PdxInstanceImpl.cpp
+++ b/cppcache/src/PdxInstanceImpl.cpp
@@ -51,7 +51,7 @@ std::shared_ptr<PdxFieldType> PdxInstanceImpl::m_DefaultPdxFieldType(
bool sortFunc(std::shared_ptr<PdxFieldType> field1,
std::shared_ptr<PdxFieldType> field2) {
- int diff = ACE_OS::strcmp(field1->getFieldName(), field2->getFieldName());
+ const auto diff = field1->getFieldName().compare(field2->getFieldName());
if (diff < 0) {
return true;
} else {
@@ -653,7 +653,7 @@ int32_t PdxInstanceImpl::hashcode() const {
auto pField = pdxIdentityFieldList.at(i);
LOGDEBUG("hashcode for pdxfield %s hashcode is %d ",
- pField->getFieldName(), hashCode);
+ pField->getFieldName().c_str(), hashCode);
switch (pField->getTypeId()) {
case PdxFieldTypes::CHAR:
case PdxFieldTypes::BOOLEAN:
@@ -699,18 +699,8 @@ int32_t PdxInstanceImpl::hashcode() const {
}
default: {
char excpStr[256] = {0};
- /* adongre - Coverity II
- * CID 29264: Calling risky function (SECURE_CODING)[VERY RISKY]. Using
- * "sprintf" can cause a
- * buffer overflow when done incorrectly. Because sprintf() assumes an
- * arbitrarily long string,
- * callers must be careful not to overflow the actual space of the
- * destination.
- * Use snprintf() instead, or correct precision specifiers.
- * Fix : using ACE_OS::snprintf
- */
- ACE_OS::snprintf(excpStr, 256, "PdxInstance not found typeid %d ",
- static_cast<int>(pField->getTypeId()));
+ std::snprintf(excpStr, 256, "PdxInstance not found typeid %d ",
+ static_cast<int>(pField->getTypeId()));
throw IllegalStateException(excpStr);
}
}
@@ -880,15 +870,6 @@ void PdxInstanceImpl::getField(const std::string& fieldname, int8_t*** value,
}
std::string PdxInstanceImpl::toString() const {
- /* adongre - Coverity II
- * CID 29265: Calling risky function (SECURE_CODING)[VERY RISKY]. Using
- * "sprintf" can cause a
- * buffer overflow when done incorrectly. Because sprintf() assumes an
- * arbitrarily long string,
- * callers must be careful not to overflow the actual space of the
- * destination. Use snprintf() instead, or correct precision specifiers. Fix
- * : using ACE_OS::snprintf
- */
auto pt = getPdxType();
std::string toString = "PDX[" + std::to_string(pt->getTypeId()) + "," +
pt->getPdxClassName() + "]{";
@@ -1163,7 +1144,8 @@ bool PdxInstanceImpl::operator==(const CacheableKey& other) const {
LOGDEBUG("pdxfield %s ",
((myPFT != m_DefaultPdxFieldType) ? myPFT->getFieldName()
- : otherPFT->getFieldName()));
+ : otherPFT->getFieldName())
+ .c_str());
if (myPFT->equals(m_DefaultPdxFieldType)) {
fieldTypeId = otherPFT->getTypeId();
} else if (otherPFT->equals(m_DefaultPdxFieldType)) {
@@ -1243,18 +1225,8 @@ bool PdxInstanceImpl::operator==(const CacheableKey& other) const {
}
default: {
char excpStr[256] = {0};
- /* adongre - Coverity II
- * CID 29267: Calling risky function (SECURE_CODING)[VERY RISKY]. Using
- * "sprintf" can cause a
- * buffer overflow when done incorrectly. Because sprintf() assumes an
- * arbitrarily long string,
- * callers must be careful not to overflow the actual space of the
- * destination.
- * Use snprintf() instead, or correct precision specifiers.
- * Fix : using ACE_OS::snprintf
- */
- ACE_OS::snprintf(excpStr, 256, "PdxInstance not found typeid %d ",
- static_cast<int>(myPFT->getTypeId()));
+ std::snprintf(excpStr, 256, "PdxInstance not found typeid %d ",
+ static_cast<int>(myPFT->getTypeId()));
throw IllegalStateException(excpStr);
}
}
@@ -1369,7 +1341,7 @@ void PdxInstanceImpl::toDataMutable(PdxWriter& writer) {
for (size_t i = 0; i < pdxFieldList->size(); i++) {
auto currPf = pdxFieldList->at(i);
LOGDEBUG("toData filedname = %s , isVarLengthType = %d ",
- currPf->getFieldName(), currPf->IsVariableLengthType());
+ currPf->getFieldName().c_str(), currPf->IsVariableLengthType());
std::shared_ptr<Cacheable> value = nullptr;
auto&& iter = m_updatedFields.find(currPf->getFieldName());
@@ -1399,7 +1371,7 @@ void PdxInstanceImpl::toDataMutable(PdxWriter& writer) {
for (size_t i = 0; i < pdxFieldList->size(); i++) {
auto currPf = pdxFieldList->at(i);
LOGDEBUG("toData1 filedname = %s , isVarLengthType = %d ",
- currPf->getFieldName(), currPf->IsVariableLengthType());
+ currPf->getFieldName().c_str(), currPf->IsVariableLengthType());
auto value = m_updatedFields[currPf->getFieldName()];
writeField(writer, currPf->getFieldName(), currPf->getTypeId(), value);
}
diff --git a/cppcache/src/PdxReaderWithTypeCollector.cpp b/cppcache/src/PdxReaderWithTypeCollector.cpp
index 44bc9cb..974c603 100644
--- a/cppcache/src/PdxReaderWithTypeCollector.cpp
+++ b/cppcache/src/PdxReaderWithTypeCollector.cpp
@@ -23,8 +23,6 @@
#include "PdxReaderWithTypeCollector.hpp"
-#include <ace/OS_NS_stdio.h>
-
#include <geode/PdxFieldTypes.hpp>
#include "CacheImpl.hpp"
diff --git a/cppcache/src/PdxType.cpp b/cppcache/src/PdxType.cpp
index 04457d9..53bb207 100644
--- a/cppcache/src/PdxType.cpp
+++ b/cppcache/src/PdxType.cpp
@@ -23,8 +23,6 @@
#include "PdxType.hpp"
-#include <ace/OS.h>
-
#include "PdxFieldType.hpp"
#include "PdxHelper.hpp"
#include "PdxTypeRegistry.hpp"
diff --git a/cppcache/src/PdxType.hpp b/cppcache/src/PdxType.hpp
index 54b7e40..b76b824 100644
--- a/cppcache/src/PdxType.hpp
+++ b/cppcache/src/PdxType.hpp
@@ -25,8 +25,7 @@
#include <string>
#include <vector>
-#include <ace/ACE.h>
-#include <ace/Recursive_Thread_Mutex.h>
+#include <ace/RW_Thread_Mutex.h>
#include <geode/CacheableBuiltins.hpp>
#include <geode/PdxFieldTypes.hpp>
diff --git a/cppcache/src/PdxTypeRegistry.hpp b/cppcache/src/PdxTypeRegistry.hpp
index 7998d1e..b2d168e 100644
--- a/cppcache/src/PdxTypeRegistry.hpp
+++ b/cppcache/src/PdxTypeRegistry.hpp
@@ -23,8 +23,7 @@
#include <map>
#include <unordered_map>
-#include <ace/ACE.h>
-#include <ace/Recursive_Thread_Mutex.h>
+#include <ace/RW_Thread_Mutex.h>
#include <geode/Cache.hpp>
#include <geode/PdxSerializable.hpp>
diff --git a/cppcache/src/PoolAttributes.hpp b/cppcache/src/PoolAttributes.hpp
index f8a47e6..3fee900 100644
--- a/cppcache/src/PoolAttributes.hpp
+++ b/cppcache/src/PoolAttributes.hpp
@@ -24,8 +24,6 @@
#include <string>
#include <vector>
-#include <ace/OS.h>
-
#include <geode/ExceptionTypes.hpp>
#include <geode/internal/geode_globals.hpp>
diff --git a/cppcache/src/PoolFactory.cpp b/cppcache/src/PoolFactory.cpp
index d4af923..c01582b 100644
--- a/cppcache/src/PoolFactory.cpp
+++ b/cppcache/src/PoolFactory.cpp
@@ -16,7 +16,6 @@
*/
#include <ace/INET_Addr.h>
-#include <ace/Recursive_Thread_Mutex.h>
#include <geode/Pool.hpp>
#include <geode/PoolFactory.hpp>
diff --git a/cppcache/src/PreservedDataExpiryHandler.cpp b/cppcache/src/PreservedDataExpiryHandler.cpp
index 5cf1a3d..e30dd53 100644
--- a/cppcache/src/PreservedDataExpiryHandler.cpp
+++ b/cppcache/src/PreservedDataExpiryHandler.cpp
@@ -22,13 +22,14 @@
*/
#include "PreservedDataExpiryHandler.hpp"
+#include <ace/Reactor.h>
+#include <ace/Timer_Heap.h>
+#include <ace/Timer_Heap_T.h>
+#include <ace/Timer_Queue.h>
+#include <ace/Timer_Queue_Adapters.h>
+#include <ace/svc_export.h>
+
#include "PdxTypeRegistry.hpp"
-#include "ace/Reactor.h"
-#include "ace/Timer_Heap.h"
-#include "ace/Timer_Heap_T.h"
-#include "ace/Timer_Queue.h"
-#include "ace/Timer_Queue_Adapters.h"
-#include "ace/svc_export.h"
namespace apache {
namespace geode {
diff --git a/cppcache/src/ProxyRemoteQueryService.cpp b/cppcache/src/ProxyRemoteQueryService.cpp
index 381179c..2174a73 100644
--- a/cppcache/src/ProxyRemoteQueryService.cpp
+++ b/cppcache/src/ProxyRemoteQueryService.cpp
@@ -82,7 +82,7 @@ std::shared_ptr<CqQuery> ProxyRemoteQueryService::newCq(
void ProxyRemoteQueryService::addCqQuery(
const std::shared_ptr<CqQuery>& cqQuery) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_cqQueryListLock);
+ std::lock_guard<decltype(m_cqQueryListLock)> guard(m_cqQueryListLock);
m_cqQueries.push_back(cqQuery);
}
@@ -113,7 +113,7 @@ std::shared_ptr<CqQuery> ProxyRemoteQueryService::newCq(
void ProxyRemoteQueryService::closeCqs() { closeCqs(false); }
void ProxyRemoteQueryService::closeCqs(bool keepAlive) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_cqQueryListLock);
+ std::lock_guard<decltype(m_cqQueryListLock)> guard(m_cqQueryListLock);
for (auto&& q : m_cqQueries) {
try {
@@ -135,7 +135,7 @@ void ProxyRemoteQueryService::closeCqs(bool keepAlive) {
}
QueryService::query_container_type ProxyRemoteQueryService::getCqs() const {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_cqQueryListLock);
+ std::lock_guard<decltype(m_cqQueryListLock)> guard(m_cqQueryListLock);
return m_cqQueries;
}
@@ -160,7 +160,7 @@ std::shared_ptr<CqQuery> ProxyRemoteQueryService::getCq(
}
void ProxyRemoteQueryService::executeCqs() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_cqQueryListLock);
+ std::lock_guard<decltype(m_cqQueryListLock)> guard(m_cqQueryListLock);
for (auto&& q : m_cqQueries) {
try {
@@ -176,7 +176,7 @@ void ProxyRemoteQueryService::executeCqs() {
}
void ProxyRemoteQueryService::stopCqs() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_cqQueryListLock);
+ std::lock_guard<decltype(m_cqQueryListLock)> guard(m_cqQueryListLock);
for (auto&& q : m_cqQueries) {
try {
diff --git a/cppcache/src/ProxyRemoteQueryService.hpp b/cppcache/src/ProxyRemoteQueryService.hpp
index f8508b9..82ff468 100644
--- a/cppcache/src/ProxyRemoteQueryService.hpp
+++ b/cppcache/src/ProxyRemoteQueryService.hpp
@@ -19,9 +19,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <memory>
-#include <ace/Recursive_Thread_Mutex.h>
+#include <memory>
+#include <mutex>
#include <geode/AuthenticatedView.hpp>
#include <geode/QueryService.hpp>
@@ -81,7 +81,7 @@ class APACHE_GEODE_EXPORT ProxyRemoteQueryService : public QueryService {
AuthenticatedView* m_authenticatedView;
query_container_type m_cqQueries;
// lock for cqQuery list;
- mutable ACE_Recursive_Thread_Mutex m_cqQueryListLock;
+ mutable std::recursive_mutex m_cqQueryListLock;
friend class AuthenticatedView;
};
diff --git a/cppcache/src/PutAllPartialResult.cpp b/cppcache/src/PutAllPartialResult.cpp
index 7cbf1c1..84adafb 100644
--- a/cppcache/src/PutAllPartialResult.cpp
+++ b/cppcache/src/PutAllPartialResult.cpp
@@ -20,8 +20,8 @@ namespace apache {
namespace geode {
namespace client {
-PutAllPartialResult::PutAllPartialResult(
- int totalMapSize, ACE_Recursive_Thread_Mutex& responseLock) {
+PutAllPartialResult::PutAllPartialResult(int totalMapSize,
+ std::recursive_mutex& responseLock) {
m_succeededKeys = std::make_shared<VersionedCacheableObjectPartList>(
new std::vector<std::shared_ptr<CacheableKey>>(), responseLock);
m_totalMapSize = totalMapSize;
diff --git a/cppcache/src/PutAllPartialResult.hpp b/cppcache/src/PutAllPartialResult.hpp
index 5da3a62..9b7e658 100644
--- a/cppcache/src/PutAllPartialResult.hpp
+++ b/cppcache/src/PutAllPartialResult.hpp
@@ -20,6 +20,9 @@
#ifndef GEODE_PUTALLPARTIALRESULT_H_
#define GEODE_PUTALLPARTIALRESULT_H_
+#include <mutex>
+
+#include <ace/RW_Thread_Mutex.h>
#include <ace/Task.h>
#include <geode/CacheableString.hpp>
@@ -40,8 +43,7 @@ class PutAllPartialResult final : public Serializable {
ACE_RW_Thread_Mutex g_readerWriterLock;
public:
- PutAllPartialResult(int totalMapSize,
- ACE_Recursive_Thread_Mutex& responseLock);
+ PutAllPartialResult(int totalMapSize, std::recursive_mutex& responseLock);
~PutAllPartialResult() noexcept final {}
void setTotalMapSize(int totalMapSize) { m_totalMapSize = totalMapSize; }
@@ -86,8 +88,8 @@ class PutAllPartialResult final : public Serializable {
virtual std::string toString() const final {
char msgStr1[1024];
if (m_firstFailedKey != nullptr) {
- ACE_OS::snprintf(msgStr1, 1024, "[ Key =%s ]",
- m_firstFailedKey->toString().c_str());
+ std::snprintf(msgStr1, 1024, "[ Key =%s ]",
+ m_firstFailedKey->toString().c_str());
}
char msgStr2[1024];
@@ -95,12 +97,12 @@ class PutAllPartialResult final : public Serializable {
// TODO:: impl. CacheableObjectPartList.size();
int failedKeyNum = m_totalMapSize - m_succeededKeys->size();
if (failedKeyNum > 0) {
- ACE_OS::snprintf(
+ std::snprintf(
msgStr2, 1024,
"The putAll operation failed to put %d out of %d entries ",
failedKeyNum, m_totalMapSize);
} else {
- ACE_OS::snprintf(
+ std::snprintf(
msgStr2, 1024,
"The putAll operation successfully put %d out of %d entries ",
m_succeededKeys->size(), m_totalMapSize);
@@ -108,8 +110,8 @@ class PutAllPartialResult final : public Serializable {
}
char stringBuf[7000];
- ACE_OS::snprintf(stringBuf, 7000, "PutAllPartialResult: %s%s", msgStr1,
- msgStr2);
+ std::snprintf(stringBuf, 7000, "PutAllPartialResult: %s%s", msgStr1,
+ msgStr2);
return std::string(stringBuf);
}
};
diff --git a/cppcache/src/PutAllPartialResultServerException.cpp b/cppcache/src/PutAllPartialResultServerException.cpp
index b1cd000..b1a4a6d 100644
--- a/cppcache/src/PutAllPartialResultServerException.cpp
+++ b/cppcache/src/PutAllPartialResultServerException.cpp
@@ -29,7 +29,7 @@ PutAllPartialResultServerException::PutAllPartialResultServerException(
PutAllPartialResultServerException::PutAllPartialResultServerException() {
LOGDEBUG("Partial keys are processed in putAll");
- ACE_Recursive_Thread_Mutex responseLock;
+ std::recursive_mutex responseLock;
m_result = std::make_shared<PutAllPartialResult>(-1, responseLock);
}
diff --git a/cppcache/src/Queue.hpp b/cppcache/src/Queue.hpp
index bdab592..715277d 100644
--- a/cppcache/src/Queue.hpp
+++ b/cppcache/src/Queue.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_QUEUE_H_
-#define GEODE_QUEUE_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,12 +15,15 @@
* limitations under the License.
*/
-#include <deque>
+#pragma once
-#include <ace/Condition_Recursive_Thread_Mutex.h>
-#include <ace/Guard_T.h>
-#include <ace/Recursive_Thread_Mutex.h>
-#include <ace/Time_Value.h>
+#ifndef GEODE_QUEUE_H_
+#define GEODE_QUEUE_H_
+
+#include <chrono>
+#include <condition_variable>
+#include <deque>
+#include <mutex>
namespace apache {
namespace geode {
@@ -39,76 +37,62 @@ class APACHE_GEODE_EXPORT Queue {
* should be deleted in the destructor, and maximum size of queue.
*/
explicit Queue(bool deleteObjs = true, const uint32_t maxSize = 0)
- : m_cond(m_mutex),
- m_deleteObjs(deleteObjs),
- m_maxSize(maxSize),
- m_closed(false) {}
+ : m_deleteObjs(deleteObjs), m_maxSize(maxSize), m_closed(false) {}
~Queue() { close(); }
T get() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::unique_lock<decltype(m_mutex)> _guard(m_mutex);
return getNoLock();
}
- /** wait "sec" secs, "usec" micros time until notified */
- T getUntil(uint32_t sec, uint32_t usec = 0) {
- auto&& mp = get();
-
+ template <class _Rep, class _Period>
+ T getFor(const std::chrono::duration<_Rep, _Period>& duration) {
+ std::unique_lock<decltype(m_mutex)> _guard(m_mutex);
+ auto&& mp = getNoLock();
if (mp == nullptr) {
- ACE_Time_Value interval(sec + usec / 1000000, usec % 1000000);
- ACE_Time_Value stopAt(ACE_OS::gettimeofday());
- stopAt += interval;
-
- while (!m_closed && mp == nullptr && ACE_OS::gettimeofday() < stopAt) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
- if (m_cond.wait(&stopAt) != -1) mp = getNoLock();
- }
+ m_cond.wait_for(_guard, duration, [this, &mp] {
+ return !(m_closed || nullptr == (mp = getNoLock()));
+ });
}
return mp;
}
bool put(T mp) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::unique_lock<decltype(m_mutex)> _guard(m_mutex);
if (m_maxSize > 0 && m_queue.size() >= m_maxSize) {
return false;
}
return putNoLock(mp);
}
- bool putUntil(T mp, uint32_t sec, uint32_t usec = 0) {
+ template <class _Rep, class _Period>
+ bool putFor(T mp, const std::chrono::duration<_Rep, _Period>& duration) {
if (m_maxSize > 0) {
- {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
- if (m_queue.size() < m_maxSize) {
- return putNoLock(mp);
- }
+ std::unique_lock<decltype(m_mutex)> _guard(m_mutex);
+ if (m_queue.size() < m_maxSize) {
+ return putNoLock(mp);
}
- ACE_Time_Value interval(sec + usec / 1000000, usec % 1000000);
- ACE_Time_Value stopAt(ACE_OS::gettimeofday());
- stopAt += interval;
-
- while (ACE_OS::gettimeofday() < stopAt) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
- m_cond.wait(&stopAt);
- if (m_queue.size() < m_maxSize) {
- return putNoLock(mp);
- }
+
+ if (m_cond.wait_for(_guard, duration,
+ [this] { return m_queue.size() < m_maxSize; })) {
+ return putNoLock(mp);
}
+
return false;
} else {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::unique_lock<decltype(m_mutex)> _guard(m_mutex);
return putNoLock(mp);
}
}
void open() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::unique_lock<decltype(m_mutex)> _guard(m_mutex);
m_closed = false;
}
void close() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::unique_lock<decltype(m_mutex)> _guard(m_mutex);
if (m_deleteObjs) {
while (m_queue.size() > 0) {
@@ -119,11 +103,11 @@ class APACHE_GEODE_EXPORT Queue {
m_queue.clear();
}
m_closed = true;
- m_cond.signal();
+ m_cond.notify_all();
}
uint32_t size() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
+ std::unique_lock<decltype(m_mutex)> _guard(m_mutex);
return static_cast<uint32_t>(m_queue.size());
}
@@ -133,13 +117,13 @@ class APACHE_GEODE_EXPORT Queue {
inline T getNoLock() {
T mp = nullptr;
- uint32_t queueSize = static_cast<uint32_t>(m_queue.size());
+ auto queueSize = static_cast<uint32_t>(m_queue.size());
if (queueSize > 0) {
mp = m_queue.back();
m_queue.pop_back();
// signal the waiting putter threads, if any
if (m_maxSize > 0 && queueSize == m_maxSize) {
- m_cond.signal();
+ m_cond.notify_one();
}
}
return mp;
@@ -150,7 +134,7 @@ class APACHE_GEODE_EXPORT Queue {
m_queue.push_front(mp);
// signal the waiting getter threads, if any
if (m_queue.size() == 1) {
- m_cond.signal();
+ m_cond.notify_one();
}
return true;
}
@@ -158,12 +142,13 @@ class APACHE_GEODE_EXPORT Queue {
}
std::deque<T> m_queue;
- ACE_Recursive_Thread_Mutex m_mutex;
- ACE_Condition<ACE_Recursive_Thread_Mutex> m_cond;
+ std::recursive_mutex m_mutex;
+ std::condition_variable_any m_cond;
bool m_deleteObjs;
const uint32_t m_maxSize;
bool m_closed;
};
+
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/ReadWriteLock.cpp b/cppcache/src/ReadWriteLock.cpp
index aa02c6a..2ce5385 100644
--- a/cppcache/src/ReadWriteLock.cpp
+++ b/cppcache/src/ReadWriteLock.cpp
@@ -23,44 +23,6 @@ namespace apache {
namespace geode {
namespace client {
-TimedTryWriteGuard::TimedTryWriteGuard(ACE_RW_Thread_Mutex& lock, uint32_t usec)
- : lock_(lock), isAcquired_(false), mutex_(), cond_(mutex_) {
- int cnt = 10;
- uint32_t timeSlice = usec / cnt;
- do {
- if (lock_.tryacquire_write() != -1) {
- isAcquired_ = true;
- break;
- }
- ACE_Time_Value tv = ACE_OS::gettimeofday();
- ACE_Time_Value offset(0, timeSlice);
- tv += offset;
- ACE_Time_Value stopAt(tv);
- ACE_OS::thr_yield();
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(cond_.mutex());
- cond_.waitUntil(&stopAt);
- } while (cnt-- > 0);
-}
-
-bool TimedTryWriteGuard::tryAcquireLock(uint32_t usec) {
- int cnt = 10;
- uint32_t timeSlice = usec / cnt;
- do {
- if (lock_.tryacquire_write() != -1) {
- isAcquired_ = true;
- break;
- }
- ACE_Time_Value tv = ACE_OS::gettimeofday();
- ACE_Time_Value offset(0, timeSlice);
- tv += offset;
- ACE_Time_Value stopAt(tv);
- ACE_OS::thr_yield();
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(cond_.mutex());
- cond_.waitUntil(&stopAt);
- } while (cnt-- > 0);
- return isAcquired();
-}
-
TryReadGuard::TryReadGuard(ACE_RW_Thread_Mutex& lock,
const volatile bool& exitCondition)
: lock_(lock), isAcquired_(false) {
diff --git a/cppcache/src/ReadWriteLock.hpp b/cppcache/src/ReadWriteLock.hpp
index 825d277..ecad9b8 100644
--- a/cppcache/src/ReadWriteLock.hpp
+++ b/cppcache/src/ReadWriteLock.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_READWRITELOCK_H_
-#define GEODE_READWRITELOCK_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,28 +15,18 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_READWRITELOCK_H_
+#define GEODE_READWRITELOCK_H_
+
#include <ace/RW_Thread_Mutex.h>
-#include "Condition.hpp"
+#include <geode/internal/geode_globals.hpp>
namespace apache {
namespace geode {
namespace client {
-class TimedTryWriteGuard {
- public:
- TimedTryWriteGuard(ACE_RW_Thread_Mutex& lock, uint32_t usec);
- bool tryAcquireLock(uint32_t usec);
- ~TimedTryWriteGuard() {
- if (isAcquired_) lock_.release();
- }
- bool isAcquired() const { return isAcquired_; }
-
- private:
- ACE_RW_Thread_Mutex& lock_;
- bool isAcquired_;
- ACE_Recursive_Thread_Mutex mutex_;
- Condition cond_;
-};
class APACHE_GEODE_EXPORT ReadGuard {
public:
diff --git a/cppcache/src/RegionAttributes.cpp b/cppcache/src/RegionAttributes.cpp
index f696f12..8c37059 100644
--- a/cppcache/src/RegionAttributes.cpp
+++ b/cppcache/src/RegionAttributes.cpp
@@ -19,7 +19,6 @@
#include <string>
#include <ace/DLL.h>
-#include <ace/OS.h>
#include <geode/Cache.hpp>
#include <geode/DataInput.hpp>
diff --git a/cppcache/src/RegionExpiryHandler.cpp b/cppcache/src/RegionExpiryHandler.cpp
index 062f0fb..71ffc46 100644
--- a/cppcache/src/RegionExpiryHandler.cpp
+++ b/cppcache/src/RegionExpiryHandler.cpp
@@ -17,15 +17,16 @@
#include "RegionExpiryHandler.hpp"
+#include <ace/Reactor.h>
+#include <ace/Timer_Heap.h>
+#include <ace/Timer_Heap_T.h>
+#include <ace/Timer_Queue.h>
+#include <ace/Timer_Queue_Adapters.h>
+#include <ace/svc_export.h>
+
#include "CacheImpl.hpp"
#include "ExpiryTaskManager.hpp"
#include "RegionInternal.hpp"
-#include "ace/Reactor.h"
-#include "ace/Timer_Heap.h"
-#include "ace/Timer_Heap_T.h"
-#include "ace/Timer_Queue.h"
-#include "ace/Timer_Queue_Adapters.h"
-#include "ace/svc_export.h"
namespace apache {
namespace geode {
diff --git a/cppcache/src/RegionFactory.cpp b/cppcache/src/RegionFactory.cpp
index 166444f..ab947dd 100644
--- a/cppcache/src/RegionFactory.cpp
+++ b/cppcache/src/RegionFactory.cpp
@@ -18,9 +18,6 @@
#include <map>
#include <string>
-#include <ace/Guard_T.h>
-#include <ace/Recursive_Thread_Mutex.h>
-
#include <geode/Cache.hpp>
#include <geode/CacheFactory.hpp>
#include <geode/PoolManager.hpp>
@@ -156,7 +153,7 @@ RegionFactory& RegionFactory::setRegionTimeToLive(
RegionFactory& RegionFactory::setInitialCapacity(int initialCapacity) {
char excpStr[256] = {0};
if (initialCapacity < 0) {
- ACE_OS::snprintf(excpStr, 256, "initialCapacity must be >= 0 ");
+ std::snprintf(excpStr, 256, "initialCapacity must be >= 0 ");
throw IllegalArgumentException(excpStr);
}
m_regionAttributesFactory->setInitialCapacity(initialCapacity);
diff --git a/cppcache/src/RemoteQuery.cpp b/cppcache/src/RemoteQuery.cpp
index 0c28ea5..ae72a8a 100644
--- a/cppcache/src/RemoteQuery.cpp
+++ b/cppcache/src/RemoteQuery.cpp
@@ -96,10 +96,10 @@ std::shared_ptr<SelectResults> RemoteQuery::execute(
} else {
if (values->size() % fieldNameVec.size() != 0) {
char exMsg[1024];
- ACE_OS::snprintf(exMsg, 1023,
- "%s: Number of values coming from "
- "server has to be exactly divisible by field count",
- func);
+ std::snprintf(exMsg, 1023,
+ "%s: Number of values coming from "
+ "server has to be exactly divisible by field count",
+ func);
throw MessageException(exMsg);
} else {
LOGFINEST("%s: creating StructSet for query: %s", func,
diff --git a/cppcache/src/RemoteQueryService.cpp b/cppcache/src/RemoteQueryService.cpp
index dcec032..8a3d079 100644
--- a/cppcache/src/RemoteQueryService.cpp
+++ b/cppcache/src/RemoteQueryService.cpp
@@ -72,8 +72,6 @@ std::shared_ptr<Query> RemoteQueryService::newQuery(std::string querystring) {
return std::shared_ptr<Query>(
new RemoteQuery(querystring, shared_from_this(), m_tccdm));
} else {
- auto ua =
- TSSUserAttributesWrapper::s_geodeTSSUserAttributes->getUserAttributes();
TryReadGuard guard(m_rwLock, m_invalid);
if (m_invalid) {
@@ -83,7 +81,8 @@ std::shared_ptr<Query> RemoteQueryService::newQuery(std::string querystring) {
LOGDEBUG("RemoteQueryService: creating a new query: " + querystring);
return std::shared_ptr<Query>(new RemoteQuery(
- querystring, shared_from_this(), m_tccdm, ua->getAuthenticatedView()));
+ querystring, shared_from_this(), m_tccdm,
+ UserAttributes::threadLocalUserAttributes->getAuthenticatedView()));
}
}
diff --git a/cppcache/src/RemoteQueryService.hpp b/cppcache/src/RemoteQueryService.hpp
index 6003eeb..9de7ac8 100644
--- a/cppcache/src/RemoteQueryService.hpp
+++ b/cppcache/src/RemoteQueryService.hpp
@@ -23,7 +23,7 @@
#include <memory>
#include <string>
-#include <ace/Recursive_Thread_Mutex.h>
+#include <ace/RW_Thread_Mutex.h>
#include <geode/QueryService.hpp>
#include <geode/internal/geode_globals.hpp>
diff --git a/cppcache/src/ServerLocation.hpp b/cppcache/src/ServerLocation.hpp
index b43b4b4..1461203 100644
--- a/cppcache/src/ServerLocation.hpp
+++ b/cppcache/src/ServerLocation.hpp
@@ -108,12 +108,7 @@ class APACHE_GEODE_EXPORT ServerLocation
inline bool isValid() const { return !m_serverName.empty() && m_port >= 0; }
- inline std::string& getEpString() {
- /*if (m_epString.empty() == false) {
- return m_epString;
- }*/
- return m_epString;
- }
+ inline const std::string& getEpString() { return m_epString; }
inline int hashcode() const {
int prime = 31;
diff --git a/cppcache/src/SslSockStream.cpp b/cppcache/src/SslSockStream.cpp
index a394799..7a30cb0 100644
--- a/cppcache/src/SslSockStream.cpp
+++ b/cppcache/src/SslSockStream.cpp
@@ -17,7 +17,7 @@
#include "SslSockStream.hpp"
-#include <ace/OS_NS_stdio.h>
+#include <ace/OS.h>
#include <geode/ExceptionTypes.hpp>
@@ -31,8 +31,8 @@ void *SslSockStream::getACESSLFuncPtr(const char *function_name) {
void *func = m_dll.symbol(function_name);
if (func == nullptr) {
char msg[1000];
- ACE_OS::snprintf(msg, 1000, "cannot find function %s in library %s",
- function_name, "cryptoImpl");
+ std::snprintf(msg, 1000, "cannot find function %s in library %s",
+ function_name, "cryptoImpl");
LOGERROR(msg);
throw IllegalStateException(msg);
}
@@ -46,7 +46,7 @@ void SslSockStream::initACESSLFuncPtrs() {
LOGERROR("Failed to open cryptoImpl . Errno: %d : %s", lastError,
ACE_OS::strerror(lastError));
char msg[1000] = {0};
- ACE_OS::snprintf(msg, 1000, "cannot open library: %s", libName);
+ std::snprintf(msg, 1000, "cannot open library: %s", libName);
LOGERROR(msg);
throw FileNotFoundException(msg);
}
diff --git a/cppcache/src/SuspendedTxExpiryHandler.cpp b/cppcache/src/SuspendedTxExpiryHandler.cpp
index ab5e50f..d203722 100644
--- a/cppcache/src/SuspendedTxExpiryHandler.cpp
+++ b/cppcache/src/SuspendedTxExpiryHandler.cpp
@@ -16,14 +16,15 @@
*/
#include "SuspendedTxExpiryHandler.hpp"
+#include <ace/Reactor.h>
+#include <ace/Timer_Heap.h>
+#include <ace/Timer_Heap_T.h>
+#include <ace/Timer_Queue.h>
+#include <ace/Timer_Queue_Adapters.h>
+#include <ace/svc_export.h>
+
#include "CacheImpl.hpp"
#include "ExpiryTaskManager.hpp"
-#include "ace/Reactor.h"
-#include "ace/Timer_Heap.h"
-#include "ace/Timer_Heap_T.h"
-#include "ace/Timer_Queue.h"
-#include "ace/Timer_Queue_Adapters.h"
-#include "ace/svc_export.h"
namespace apache {
namespace geode {
diff --git a/cppcache/src/SystemProperties.cpp b/cppcache/src/SystemProperties.cpp
index fda13a3..6e80882 100644
--- a/cppcache/src/SystemProperties.cpp
+++ b/cppcache/src/SystemProperties.cpp
@@ -17,9 +17,7 @@
#include <cstdlib>
#include <string>
-
-#include <ace/DLL.h>
-#include <ace/OS.h>
+#include <thread>
#include <geode/CacheableKey.hpp>
#include <geode/ExceptionTypes.hpp>
@@ -125,7 +123,7 @@ constexpr auto DefaultRedundancyMonitorInterval = std::chrono::seconds(10);
constexpr auto DefaultNotifyAckInterval = std::chrono::seconds(1);
constexpr auto DefaultNotifyDupCheckLife = std::chrono::seconds(300);
const char DefaultSecurityPrefix[] = "security-";
-const uint32_t DefaultThreadPoolSize = ACE_OS::num_processors() * 2;
+const uint32_t DefaultThreadPoolSize = std::thread::hardware_concurrency() * 2;
constexpr auto DefaultSuspendedTxTimeout = std::chrono::seconds(30);
constexpr auto DefaultTombstoneTimeout = std::chrono::seconds(480);
// not disable; all region api will use chunk handler thread
diff --git a/cppcache/src/TcpConn.cpp b/cppcache/src/TcpConn.cpp
index eacc6d5..b7c08ca 100644
--- a/cppcache/src/TcpConn.cpp
+++ b/cppcache/src/TcpConn.cpp
@@ -17,7 +17,9 @@
#include "TcpConn.hpp"
-#include <memory.h>
+#include <chrono>
+#include <memory>
+#include <thread>
#include <ace/INET_Addr.h>
#include <ace/OS.h>
@@ -98,8 +100,8 @@ void TcpConn::init() {
LOGERROR("Failed to create socket. Errno: %d: %s", lastError,
ACE_OS::strerror(lastError));
char msg[256];
- ACE_OS::snprintf(msg, 256, "TcpConn::connect failed with errno: %d: %s",
- lastError, ACE_OS::strerror(lastError));
+ std::snprintf(msg, 256, "TcpConn::connect failed with errno: %d: %s",
+ lastError, ACE_OS::strerror(lastError));
throw GeodeIOException(msg);
}
@@ -175,8 +177,8 @@ void TcpConn::listen(ACE_INET_Addr addr,
"TcpConn::listen Attempt to listen timed out after " +
to_string(waitSeconds) + ".");
}
- ACE_OS::snprintf(msg, 256, "TcpConn::listen failed with errno: %d: %s",
- lastError, ACE_OS::strerror(lastError));
+ std::snprintf(msg, 256, "TcpConn::listen failed with errno: %d: %s",
+ lastError, ACE_OS::strerror(lastError));
throw GeodeIOException(msg);
}
}
@@ -230,8 +232,8 @@ void TcpConn::connect() {
"TcpConn::connect Attempt to connect timed out after" +
to_string(waitMicroSeconds) + ".");
}
- ACE_OS::snprintf(msg, 256, "TcpConn::connect failed with errno: %d: %s",
- lastError, ACE_OS::strerror(lastError));
+ std::snprintf(msg, 256, "TcpConn::connect failed with errno: %d: %s",
+ lastError, ACE_OS::strerror(lastError));
// this is only called by constructor, so we must delete m_io
close();
throw GeodeIOException(msg);
@@ -240,8 +242,8 @@ void TcpConn::connect() {
if (-1 == rc) {
char msg[250];
int32_t lastError = ACE_OS::last_error();
- ACE_OS::snprintf(msg, 256, "TcpConn::NONBLOCK: %d: %s", lastError,
- ACE_OS::strerror(lastError));
+ std::snprintf(msg, 256, "TcpConn::NONBLOCK: %d: %s", lastError,
+ ACE_OS::strerror(lastError));
LOGINFO(msg);
}
@@ -265,22 +267,8 @@ size_t TcpConn::send(const char *buff, size_t len,
}
size_t TcpConn::socketOp(TcpConn::SockOp op, char *buff, size_t len,
- std::chrono::microseconds waitSeconds) {
+ std::chrono::microseconds waitDuration) {
{
- /*{
- ACE_HANDLE handle = m_io->get_handle();
- int val = ACE::get_flags (handle);
-
- if (ACE_BIT_DISABLED (val, ACE_NONBLOCK))
- {
- //ACE::set_flags (handle, ACE_NONBLOCK);
- LOGINFO("Flag is not set");
- }else
- {
- LOGINFO("Flag is set");
- }
- }*/
-
GF_DEV_ASSERT(m_io != nullptr);
GF_DEV_ASSERT(buff != nullptr);
@@ -294,10 +282,8 @@ size_t TcpConn::socketOp(TcpConn::SockOp op, char *buff, size_t len,
}
#endif
- ACE_Time_Value waitTime(waitSeconds);
- ACE_Time_Value endTime(ACE_OS::gettimeofday());
- endTime += waitTime;
- ACE_Time_Value sleepTime(0, 100);
+ ACE_Time_Value waitTime(waitDuration);
+ auto endTime = std::chrono::steady_clock::now() + waitDuration;
size_t readLen = 0;
ssize_t retVal;
bool errnoSet = false;
@@ -324,7 +310,7 @@ size_t TcpConn::socketOp(TcpConn::SockOp op, char *buff, size_t len,
if (retVal < 0) {
int32_t lastError = ACE_OS::last_error();
if (lastError == EAGAIN) {
- ACE_OS::sleep(sleepTime);
+ std::this_thread::sleep_for(std::chrono::microseconds(100));
} else {
errnoSet = true;
break;
@@ -337,7 +323,7 @@ size_t TcpConn::socketOp(TcpConn::SockOp op, char *buff, size_t len,
buff += readLen;
if (sendlen == 0) break;
- waitTime = endTime - ACE_OS::gettimeofday();
+ waitTime = endTime - std::chrono::steady_clock::now();
if (waitTime <= ACE_Time_Value::zero) break;
} while (sendlen > 0);
if (errnoSet) break;
diff --git a/cppcache/src/TcpConn.hpp b/cppcache/src/TcpConn.hpp
index b602796..8fddb8a 100644
--- a/cppcache/src/TcpConn.hpp
+++ b/cppcache/src/TcpConn.hpp
@@ -22,6 +22,7 @@
#include <ace/OS.h>
#include <ace/SOCK_Stream.h>
+#include <boost/interprocess/mapped_region.hpp>
#include <geode/internal/geode_globals.hpp>
@@ -62,17 +63,17 @@ class APACHE_GEODE_EXPORT TcpConn : public Connector {
int32_t maxSize(ACE_HANDLE sock, int32_t flag, int32_t size);
virtual size_t socketOp(SockOp op, char* buff, size_t len,
- std::chrono::microseconds waitSeconds);
+ std::chrono::microseconds waitDuration);
virtual void createSocket(ACE_HANDLE sock);
public:
size_t m_chunkSize;
- static int getDefaultChunkSize() {
+ static size_t getDefaultChunkSize() {
// Attempt to set chunk size to nearest OS page size
// for perf improvement
- int pageSize = ACE_OS::getpagesize();
+ auto pageSize = boost::interprocess::mapped_region::get_page_size();
if (pageSize > 16000000) {
return 16000000;
} else if (pageSize > 0) {
diff --git a/cppcache/src/TcpSslConn.cpp b/cppcache/src/TcpSslConn.cpp
index 2b2bbbf..8712ad0 100644
--- a/cppcache/src/TcpSslConn.cpp
+++ b/cppcache/src/TcpSslConn.cpp
@@ -17,6 +17,9 @@
#include "TcpSslConn.hpp"
+#include <chrono>
+#include <thread>
+
#include <geode/SystemProperties.hpp>
#include "CacheImpl.hpp"
@@ -31,7 +34,7 @@ Ssl* TcpSslConn::getSSLImpl(ACE_HANDLE sock, const char* pubkeyfile,
const char* libName = "cryptoImpl";
if (m_dll.open(libName, RTLD_NOW | RTLD_GLOBAL, 0) == -1) {
char msg[1000] = {0};
- ACE_OS::snprintf(msg, 1000, "cannot open library: %s", libName);
+ std::snprintf(msg, 1000, "cannot open library: %s", libName);
LOGERROR(msg);
throw FileNotFoundException(msg);
}
@@ -40,9 +43,9 @@ Ssl* TcpSslConn::getSSLImpl(ACE_HANDLE sock, const char* pubkeyfile,
reinterpret_cast<gf_create_SslImpl>(m_dll.symbol("gf_create_SslImpl"));
if (func == nullptr) {
char msg[1000];
- ACE_OS::snprintf(msg, 1000,
- "cannot find function %s in library gf_create_SslImpl",
- "cryptoImpl");
+ std::snprintf(msg, 1000,
+ "cannot find function %s in library gf_create_SslImpl",
+ "cryptoImpl");
LOGERROR(msg);
throw IllegalStateException(msg);
}
@@ -71,10 +74,8 @@ void TcpSslConn::listen(ACE_INET_Addr addr,
"TcpSslConn::listen Attempt to listen timed out after" +
to_string(waitSeconds) + ".");
}
- // sprintf( msg, "TcpSslConn::listen failed with errno: %d: %s", lastError,
- // ACE_OS::strerror(lastError) );
- ACE_OS::snprintf(msg, 255, "TcpSslConn::listen failed with errno: %d: %s",
- lastError, ACE_OS::strerror(lastError));
+ std::snprintf(msg, 255, "TcpSslConn::listen failed with errno: %d: %s",
+ lastError, ACE_OS::strerror(lastError));
throw GeodeIOException(msg);
}
}
@@ -106,8 +107,8 @@ void TcpSslConn::connect() {
"TcpSslConn::connect Attempt to connect timed out after " +
to_string(waitMicroSeconds) + ".");
}
- ACE_OS::snprintf(msg, 256, "TcpSslConn::connect failed with errno: %d: %s",
- lastError, ACE_OS::strerror(lastError));
+ std::snprintf(msg, 256, "TcpSslConn::connect failed with errno: %d: %s",
+ lastError, ACE_OS::strerror(lastError));
// this is only called by constructor, so we must delete m_ssl
_GEODE_SAFE_DELETE(m_ssl);
throw GeodeIOException(msg);
@@ -125,7 +126,7 @@ void TcpSslConn::close() {
}
size_t TcpSslConn::socketOp(TcpConn::SockOp op, char* buff, size_t len,
- std::chrono::microseconds waitSeconds) {
+ std::chrono::microseconds waitDuration) {
{
GF_DEV_ASSERT(m_ssl != nullptr);
GF_DEV_ASSERT(buff != nullptr);
@@ -140,10 +141,8 @@ size_t TcpSslConn::socketOp(TcpConn::SockOp op, char* buff, size_t len,
}
#endif
// passing wait time as micro seconds
- ACE_Time_Value waitTime(waitSeconds);
- ACE_Time_Value endTime(ACE_OS::gettimeofday());
- endTime += waitTime;
- ACE_Time_Value sleepTime(0, 100);
+ ACE_Time_Value waitTime(waitDuration);
+ auto endTime = std::chrono::steady_clock::now() + waitDuration;
size_t readLen = 0;
bool errnoSet = false;
@@ -170,7 +169,7 @@ size_t TcpSslConn::socketOp(TcpConn::SockOp op, char* buff, size_t len,
if (retVal < 0) {
int32_t lastError = ACE_OS::last_error();
if (lastError == EAGAIN) {
- ACE_OS::sleep(sleepTime);
+ std::this_thread::sleep_for(std::chrono::microseconds(100));
} else {
errnoSet = true;
break;
@@ -183,7 +182,7 @@ size_t TcpSslConn::socketOp(TcpConn::SockOp op, char* buff, size_t len,
buff += readLen;
- waitTime = endTime - ACE_OS::gettimeofday();
+ waitTime = endTime - std::chrono::steady_clock::now();
if (waitTime <= ACE_Time_Value::zero) break;
} while (sendlen > 0);
if (errnoSet) break;
diff --git a/cppcache/src/TcpSslConn.hpp b/cppcache/src/TcpSslConn.hpp
index 52b6c69..02f3ea5 100644
--- a/cppcache/src/TcpSslConn.hpp
+++ b/cppcache/src/TcpSslConn.hpp
@@ -47,7 +47,7 @@ class TcpSslConn : public TcpConn {
protected:
size_t socketOp(SockOp op, char* buff, size_t len,
- std::chrono::microseconds waitSeconds) override;
+ std::chrono::microseconds waitDuration) override;
void createSocket(ACE_HANDLE sock) override;
diff --git a/cppcache/src/TcrConnection.cpp b/cppcache/src/TcrConnection.cpp
index 031d136..63972be 100644
--- a/cppcache/src/TcrConnection.cpp
+++ b/cppcache/src/TcrConnection.cpp
@@ -63,9 +63,9 @@ bool TcrConnection::InitTcrConnection(
m_queueSize = 0;
m_dh = nullptr;
// m_chunksProcessSema = 0;
- m_creationTime = ACE_OS::gettimeofday();
+ m_creationTime = clock::now();
connectionId = INITIAL_CONNECTION_ID;
- m_lastAccessed = ACE_OS::gettimeofday();
+ m_lastAccessed = clock::now();
auto cacheImpl = m_poolDM->getConnectionManager().getCacheImpl();
const auto& distributedSystem = cacheImpl->getDistributedSystem();
const auto& sysProp = distributedSystem.getSystemProperties();
@@ -709,29 +709,7 @@ void TcrConnection::sendRequestForChunkedResponse(
const TcrMessage& request, size_t len, TcrMessageReply& reply,
std::chrono::microseconds sendTimeoutSec,
std::chrono::microseconds receiveTimeoutSec) {
- int32_t msgType = request.getMessageType();
- // ACE_OS::memcpy(&msgType, buffer, 4);
- // msgType = ntohl(msgType);
-
- /*receiveTimeoutSec = (msgType == TcrMessage::QUERY ||
- msgType == TcrMessage::QUERY_WITH_PARAMETERS ||
- msgType == TcrMessage::EXECUTECQ_WITH_IR_MSG_TYPE ||
- msgType == TcrMessage::GETDURABLECQS_MSG_TYPE ||
- msgType == TcrMessage::EXECUTE_FUNCTION ||
- msgType == TcrMessage::EXECUTE_REGION_FUNCTION ||
- msgType == TcrMessage::EXECUTE_REGION_FUNCTION_SINGLE_HOP)
- ? reply.getTimeout() : receiveTimeoutSec;
-
- //send + recieve should be part of API timeout
- sendTimeoutSec = (msgType == TcrMessage::QUERY ||
- msgType == TcrMessage::QUERY_WITH_PARAMETERS ||
- msgType == TcrMessage::EXECUTECQ_WITH_IR_MSG_TYPE ||
- msgType == TcrMessage::GETDURABLECQS_MSG_TYPE ||
- msgType == TcrMessage::EXECUTE_FUNCTION ||
- msgType == TcrMessage::EXECUTE_REGION_FUNCTION ||
- msgType == TcrMessage::EXECUTE_REGION_FUNCTION_SINGLE_HOP)
- ? reply.getTimeout() : sendTimeoutSec;
- */
+ auto msgType = request.getMessageType();
switch (msgType) {
case TcrMessage::QUERY:
case TcrMessage::QUERY_WITH_PARAMETERS:
@@ -747,18 +725,7 @@ void TcrConnection::sendRequestForChunkedResponse(
default:
break;
}
- /*if((msgType == TcrMessage::QUERY ||
- msgType == TcrMessage::QUERY_WITH_PARAMETERS ||
- msgType == TcrMessage::EXECUTECQ_WITH_IR_MSG_TYPE ||
- msgType == TcrMessage::GETDURABLECQS_MSG_TYPE ||
- msgType == TcrMessage::EXECUTE_FUNCTION ||
- msgType == TcrMessage::EXECUTE_REGION_FUNCTION))
- {
- receiveTimeoutSec = reply.getTimeout();
- sendTimeoutSec = reply.getTimeout();
- }*/
-
- // send(buffer, len, sendTimeoutSec);
+
std::chrono::microseconds timeSpent{0};
send(timeSpent, request.getMsgData(), len, sendTimeoutSec, true);
@@ -893,7 +860,7 @@ char* TcrConnection::readMessage(size_t* recvLen,
char* fullMessage;
*recvLen = HEADER_LENGTH + msgLen;
_GEODE_NEW(fullMessage, char[HEADER_LENGTH + msgLen]);
- ACE_OS::memcpy(fullMessage, msg_header, HEADER_LENGTH);
+ std::memcpy(fullMessage, msg_header, HEADER_LENGTH);
return fullMessage;
// exit(0);
}
@@ -903,7 +870,7 @@ char* TcrConnection::readMessage(size_t* recvLen,
char* fullMessage;
*recvLen = HEADER_LENGTH + msgLen;
_GEODE_NEW(fullMessage, char[HEADER_LENGTH + msgLen]);
- ACE_OS::memcpy(fullMessage, msg_header, HEADER_LENGTH);
+ std::memcpy(fullMessage, msg_header, HEADER_LENGTH);
std::chrono::microseconds mesgBodyTimeout = receiveTimeoutSec;
if (isNotificationMessage) {
@@ -937,20 +904,7 @@ char* TcrConnection::readMessage(size_t* recvLen,
"TcrConnection::readMessage: received message body from "
"endpoint %s; bytes: %s",
m_endpoint,
- Utils::convertBytesToString(fullMessage + HEADER_LENGTH, msgLen)
-
- .c_str());
-
- // This is the test case when msg type is GET_CLIENT_PR_METADATA and msgLen is
- // 0.
- /*if (request == TcrMessage::GET_CLIENT_PR_METADATA) {
- LOGCONFIG("Amey request == TcrMessage::GET_CLIENT_PR_METADATA");
- char* fullMessage2;
- *recvLen = HEADER_LENGTH;
- _GEODE_NEW( fullMessage2, char[HEADER_LENGTH ] );
- ACE_OS::memcpy(fullMessage2, msg_header, HEADER_LENGTH);
- return fullMessage2;
- }*/
+ Utils::convertBytesToString(fullMessage + HEADER_LENGTH, msgLen).c_str());
return fullMessage;
}
@@ -1399,13 +1353,7 @@ bool TcrConnection::hasExpired(const std::chrono::milliseconds& expiryTime) {
return false;
}
- ACE_Time_Value _expiryTime(expiryTime);
-
- if (ACE_OS::gettimeofday() - m_creationTime > _expiryTime) {
- return true;
- } else {
- return false;
- }
+ return (clock::now() - m_creationTime) > expiryTime;
}
bool TcrConnection::isIdle(const std::chrono::milliseconds& idleTime) {
@@ -1413,18 +1361,14 @@ bool TcrConnection::isIdle(const std::chrono::milliseconds& idleTime) {
return false;
}
- ACE_Time_Value _idleTime(idleTime);
-
- if (ACE_OS::gettimeofday() - m_lastAccessed > _idleTime) {
- return true;
- } else {
- return false;
- }
+ return (clock::now() - m_lastAccessed) > idleTime;
}
-void TcrConnection::touch() { m_lastAccessed = ACE_OS::gettimeofday(); }
+void TcrConnection::touch() { m_lastAccessed = clock::now(); }
-ACE_Time_Value TcrConnection::getLastAccessed() { return m_lastAccessed; }
+TcrConnection::time_point TcrConnection::getLastAccessed() {
+ return m_lastAccessed;
+}
uint8_t TcrConnection::getOverrides(const SystemProperties* props) {
uint8_t conflateByte = 0;
@@ -1440,7 +1384,7 @@ uint8_t TcrConnection::getOverrides(const SystemProperties* props) {
}
void TcrConnection::updateCreationTime() {
- m_creationTime = ACE_OS::gettimeofday();
+ m_creationTime = clock::now();
touch();
}
diff --git a/cppcache/src/TcrConnection.hpp b/cppcache/src/TcrConnection.hpp
index 904db27..dae6d2b 100644
--- a/cppcache/src/TcrConnection.hpp
+++ b/cppcache/src/TcrConnection.hpp
@@ -86,6 +86,9 @@ class ThinClientPoolDM;
class TcrConnectionManager;
class APACHE_GEODE_EXPORT TcrConnection {
public:
+ using clock = std::chrono::steady_clock;
+ using time_point = clock::time_point;
+
/** Create one connection, endpoint is in format of hostname:portno
* It will do handshake with j-server. There're 2 types of handshakes:
* 1) handshake for request
@@ -275,7 +278,7 @@ class APACHE_GEODE_EXPORT TcrConnection {
void touch();
bool hasExpired(const std::chrono::milliseconds& expiryTime);
bool isIdle(const std::chrono::milliseconds& idleTime);
- ACE_Time_Value getLastAccessed();
+ time_point getLastAccessed();
void updateCreationTime();
int64_t getConnectionId() {
@@ -403,8 +406,10 @@ class APACHE_GEODE_EXPORT TcrConnection {
// semaphore to synchronize with the chunked response processing thread
ACE_Semaphore m_chunksProcessSema;
- ACE_Time_Value m_creationTime;
- ACE_Time_Value m_lastAccessed;
+
+ time_point m_creationTime;
+ time_point m_lastAccessed;
+
// Disallow copy constructor and assignment operator.
TcrConnection(const TcrConnection&);
TcrConnection& operator=(const TcrConnection&);
diff --git a/cppcache/src/TcrConnectionManager.cpp b/cppcache/src/TcrConnectionManager.cpp
index efccda8..0e4cf74 100644
--- a/cppcache/src/TcrConnectionManager.cpp
+++ b/cppcache/src/TcrConnectionManager.cpp
@@ -141,7 +141,7 @@ void TcrConnectionManager::init(bool isPool) {
void TcrConnectionManager::startFailoverAndCleanupThreads(bool isPool) {
if (m_failoverTask == nullptr || m_cleanupTask == nullptr) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_distMngrsLock);
+ std::lock_guard<decltype(m_distMngrsLock)> _guard(m_distMngrsLock);
if (m_failoverTask == nullptr && !isPool) {
m_failoverTask = new Task<TcrConnectionManager>(
this, &TcrConnectionManager::failover, NC_Failover);
@@ -234,7 +234,7 @@ TcrConnectionManager::~TcrConnectionManager() {
void TcrConnectionManager::connect(
ThinClientBaseDM *distMng, std::vector<TcrEndpoint *> &endpoints,
const std::unordered_set<std::string> &endpointStrs) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guardDistMngrs(m_distMngrsLock);
+ std::lock_guard<decltype(m_distMngrsLock)> guardDistMngrs(m_distMngrsLock);
{
ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_endpoints.mutex());
int32_t numEndPoints = static_cast<int32_t>(endpointStrs.size());
@@ -305,7 +305,7 @@ TcrEndpoint *TcrConnectionManager::addRefToTcrEndpoint(std::string endpointName,
void TcrConnectionManager::disconnect(ThinClientBaseDM *distMng,
std::vector<TcrEndpoint *> &endpoints,
bool keepEndpoints) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guardDistMngrs(m_distMngrsLock);
+ std::lock_guard<decltype(m_distMngrsLock)> guardDistMngrs(m_distMngrsLock);
{
ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_endpoints.mutex());
@@ -373,7 +373,7 @@ int TcrConnectionManager::failover(volatile bool &isRunning) {
m_failoverSema.acquire();
if (isRunning && !m_isNetDown) {
try {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_distMngrsLock);
+ std::lock_guard<decltype(m_distMngrsLock)> guard(m_distMngrsLock);
for (std::list<ThinClientBaseDM *>::iterator it = m_distMngrs.begin();
it != m_distMngrs.end(); ++it) {
(*it)->failover();
@@ -421,7 +421,7 @@ GfErrType TcrConnectionManager::registerInterestAllRegions(
GfErrType err = GF_NOERR;
GfErrType opErr = GF_NOERR;
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_distMngrsLock);
+ std::lock_guard<decltype(m_distMngrsLock)> guard(m_distMngrsLock);
std::list<ThinClientBaseDM *>::iterator begin = m_distMngrs.begin();
std::list<ThinClientBaseDM *>::iterator end = m_distMngrs.end();
for (std::list<ThinClientBaseDM *>::iterator it = begin; it != end; ++it) {
@@ -446,7 +446,7 @@ GfErrType TcrConnectionManager::sendSyncRequestCq(TcrMessage &request,
// 1. m_distMngrs.size() > 1 (query distribution manager + 1 or more
// TcrHADistributionManagers).
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_distMngrsLock);
+ std::lock_guard<decltype(m_distMngrsLock)> guard(m_distMngrsLock);
std::list<ThinClientBaseDM *>::iterator begin = m_distMngrs.begin();
std::list<ThinClientBaseDM *>::iterator end = m_distMngrs.end();
for (std::list<ThinClientBaseDM *>::iterator it = begin; it != end; ++it) {
@@ -494,11 +494,8 @@ void TcrConnectionManager::netDown() {
{
ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_endpoints.mutex());
- for (ACE_Map_Manager<std::string, TcrEndpoint *,
- ACE_Recursive_Thread_Mutex>::iterator currItr =
- m_endpoints.begin();
- currItr != m_endpoints.end(); currItr++) {
- (*currItr).int_id_->setConnectionStatus(false);
+ for (auto &currItr : m_endpoints) {
+ currItr.int_id_->setConnectionStatus(false);
}
}
@@ -533,7 +530,7 @@ int TcrConnectionManager::redundancy(volatile bool &isRunning) {
void TcrConnectionManager::addNotificationForDeletion(
Task<TcrEndpoint> *notifyReceiver, TcrConnection *notifyConnection,
ACE_Semaphore ¬ifyCleanupSema) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_notificationLock);
+ std::lock_guard<decltype(m_notificationLock)> guard(m_notificationLock);
m_connectionReleaseList.put(notifyConnection);
m_receiverReleaseList.put(notifyReceiver);
m_notifyCleanupSemaList.put(¬ifyCleanupSema);
@@ -571,7 +568,7 @@ void TcrConnectionManager::cleanNotificationLists() {
while (true) {
{
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_notificationLock);
+ std::lock_guard<decltype(m_notificationLock)> guard(m_notificationLock);
notifyReceiver = m_receiverReleaseList.get();
if (!notifyReceiver) break;
notifyConnection = m_connectionReleaseList.get();
@@ -591,11 +588,8 @@ void TcrConnectionManager::processMarker() {
// TESTING: Durable clients - return queue status of endpoing. Not thread safe.
bool TcrConnectionManager::getEndpointStatus(const std::string &endpoint) {
- for (ACE_Map_Manager<std::string, TcrEndpoint *,
- ACE_Recursive_Thread_Mutex>::iterator currItr =
- m_endpoints.begin();
- currItr != m_endpoints.end(); currItr++) {
- TcrEndpoint *ep = (*currItr).int_id_;
+ for (auto &currItr : m_endpoints) {
+ auto ep = currItr.int_id_;
const std::string epName = ep->name();
if (epName == endpoint) return ep->getServerQueueStatusTEST();
}
diff --git a/cppcache/src/TcrConnectionManager.hpp b/cppcache/src/TcrConnectionManager.hpp
index 8e01b87..b5bfba9 100644
--- a/cppcache/src/TcrConnectionManager.hpp
+++ b/cppcache/src/TcrConnectionManager.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_TCRCONNECTIONMANAGER_H_
-#define GEODE_TCRCONNECTIONMANAGER_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,7 +15,13 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_TCRCONNECTIONMANAGER_H_
+#define GEODE_TCRCONNECTIONMANAGER_H_
+
#include <list>
+#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
@@ -119,20 +120,20 @@ class APACHE_GEODE_EXPORT TcrConnectionManager {
inline void acquireRedundancyLock() {
m_redundancyManager->acquireRedundancyLock();
- m_distMngrsLock.acquire_read();
+ m_distMngrsLock.lock();
}
inline void releaseRedundancyLock() {
m_redundancyManager->releaseRedundancyLock();
- m_distMngrsLock.release();
+ m_distMngrsLock.unlock();
}
bool checkDupAndAdd(std::shared_ptr<EventId> eventid) {
return m_redundancyManager->checkDupAndAdd(eventid);
}
- ACE_Recursive_Thread_Mutex* getRedundancyLock() {
- return &m_redundancyManager->getRedundancyLock();
+ std::recursive_mutex& getRedundancyLock() {
+ return m_redundancyManager->getRedundancyLock();
}
GfErrType sendRequestToPrimary(TcrMessage& request, TcrMessageReply& reply) {
@@ -150,7 +151,7 @@ class APACHE_GEODE_EXPORT TcrConnectionManager {
// key is hostname:port
std::list<ThinClientBaseDM*> m_distMngrs;
- ACE_Recursive_Thread_Mutex m_distMngrsLock;
+ std::recursive_mutex m_distMngrsLock;
ACE_Semaphore m_failoverSema;
Task<TcrConnectionManager>* m_failoverTask;
@@ -173,7 +174,7 @@ class APACHE_GEODE_EXPORT TcrConnectionManager {
ACE_Semaphore m_redundancySema;
Task<TcrConnectionManager>* m_redundancyTask;
- ACE_Recursive_Thread_Mutex m_notificationLock;
+ std::recursive_mutex m_notificationLock;
bool m_isDurable;
bool m_isNetDown;
@@ -206,10 +207,10 @@ class DistManagersLockGuard {
public:
explicit DistManagersLockGuard(TcrConnectionManager& tccm) : m_tccm(tccm) {
- m_tccm.m_distMngrsLock.acquire();
+ m_tccm.m_distMngrsLock.lock();
}
- ~DistManagersLockGuard() { m_tccm.m_distMngrsLock.release(); }
+ ~DistManagersLockGuard() { m_tccm.m_distMngrsLock.unlock(); }
};
} // namespace client
} // namespace geode
diff --git a/cppcache/src/TcrEndpoint.cpp b/cppcache/src/TcrEndpoint.cpp
index 0a0d6a4..91d942a 100644
--- a/cppcache/src/TcrEndpoint.cpp
+++ b/cppcache/src/TcrEndpoint.cpp
@@ -47,7 +47,6 @@ TcrEndpoint::TcrEndpoint(const std::string& name, CacheImpl* cacheImpl,
: m_notifyConnection(nullptr),
m_notifyReceiver(nullptr),
m_cacheImpl(cacheImpl),
- m_connectLockCond(m_connectLock),
m_maxConnections(cacheImpl->getDistributedSystem()
.getSystemProperties()
.connectionPoolSize()),
@@ -88,7 +87,7 @@ TcrEndpoint::~TcrEndpoint() {
closeConnections();
{
// force close the notification channel -- see bug #295
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_notifyReceiverLock);
+ std::lock_guard<decltype(m_notifyReceiverLock)> guard(m_notifyReceiverLock);
if (m_numRegionListener > 0) {
LOGFINE(
"Connection to %s still has references "
@@ -127,23 +126,25 @@ inline bool TcrEndpoint::needtoTakeConnectLock() {
GfErrType TcrEndpoint::createNewConnectionWL(
TcrConnection*& newConn, bool isClientNotification, bool isSecondary,
std::chrono::microseconds connectTimeout) {
+ using clock = std::chrono::steady_clock;
+
LOGFINE("TcrEndpoint::createNewConnectionWL");
auto connectWaitTimeout = m_cacheImpl->getDistributedSystem()
.getSystemProperties()
.connectWaitTimeout();
- ACE_Time_Value interval(connectWaitTimeout);
- ACE_Time_Value stopAt(ACE_OS::gettimeofday());
- stopAt += interval;
- bool connCreated = false;
- while (ACE_OS::gettimeofday() < stopAt) {
- int32_t ret = m_connectLock.acquire(&stopAt);
+ auto stopAt = clock::now() + connectWaitTimeout;
+ auto connCreated = false;
+ std::unique_lock<decltype(m_connectLock)> lock(m_connectLock,
+ std::defer_lock);
+
+ while (clock::now() < stopAt) {
+ auto locked = lock.try_lock_until(stopAt);
- LOGFINE(
- "TcrEndpoint::createNewConnectionWL ret = %d interval = %ld error =%s",
- ret, interval.get_msec(), ACE_OS::strerror(ACE_OS::last_error()));
+ LOGFINE("TcrEndpoint::createNewConnectionWL ret = %d interval = %ld",
+ locked, connectWaitTimeout.count());
- if (ret != -1) { // got lock
+ if (locked) {
try {
LOGFINE("TcrEndpoint::createNewConnectionWL got lock");
newConn =
@@ -152,29 +153,20 @@ GfErrType TcrEndpoint::createNewConnectionWL(
isClientNotification, isSecondary,
connectTimeout);
- connCreated = true; // to break while loop
-
+ connCreated = true; // to break while loop
m_needToConnectInLock = false; // no need to take lock
-
- m_connectLock.release();
LOGFINE("New Connection Created");
break;
} catch (const TimeoutException&) {
LOGINFO("Timeout1 in handshake with endpoint[%s]", m_name.c_str());
- m_connectLock.release();
- // throw te;
return GF_CLIENT_WAIT_TIMEOUT_REFRESH_PRMETADATA;
} catch (std::exception& ex) {
- m_connectLock.release();
LOGWARN("Failed1 in handshake with endpoint[%s]: %s", m_name.c_str(),
ex.what());
- // throw ex;
return GF_CLIENT_WAIT_TIMEOUT_REFRESH_PRMETADATA;
} catch (...) {
LOGWARN("Unknown1 failure in handshake with endpoint[%s]",
m_name.c_str());
- m_connectLock.release();
- // throw;
return GF_CLIENT_WAIT_TIMEOUT_REFRESH_PRMETADATA;
}
}
@@ -224,7 +216,8 @@ GfErrType TcrEndpoint::createNewConnection(
if (!isClientNotification && sendUpdateNotification) {
bool notificationStarted;
{
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_notifyReceiverLock);
+ std::lock_guard<decltype(m_notifyReceiverLock)> guard(
+ m_notifyReceiverLock);
notificationStarted = (m_numRegionListener > 0) || m_isQueueHosted;
}
if (notificationStarted) {
@@ -247,8 +240,8 @@ GfErrType TcrEndpoint::createNewConnection(
m_needToConnectInLock = true; // while creating the connection
std::this_thread::sleep_for(std::chrono::milliseconds(50));
} catch (const GeodeIOException& ex) {
- LOGINFO("IO error[%d] in handshake with endpoint[%s]: %s",
- ACE_OS::last_error(), m_name.c_str(), ex.what());
+ LOGINFO("IO error in handshake with endpoint[%s]: %s", m_name.c_str(),
+ ex.what());
err = GF_IOERR;
m_needToConnectInLock = true; // while creating the connection
break;
@@ -296,7 +289,8 @@ void TcrEndpoint::authenticateEndpoint(TcrConnection*& conn) {
m_isAuthenticated, m_baseDM);
if (!m_isAuthenticated && m_baseDM) {
this->setConnected();
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_endpointAuthenticationLock);
+ std::lock_guard<decltype(m_endpointAuthenticationLock)> guard(
+ m_endpointAuthenticationLock);
GfErrType err = GF_NOERR;
auto creds = getCredentials();
@@ -401,7 +395,7 @@ GfErrType TcrEndpoint::registerDM(bool clientNotification, bool isSecondary,
bool connected = false;
GfErrType err = GF_NOERR;
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_connectionLock);
+ std::lock_guard<decltype(m_connectionLock)> guard(m_connectionLock);
// Three cases here:
// 1. m_connected is false, m_isActiveEndpoint is false and then
// if isActiveEndpoint is true, then create 'max' connections
@@ -456,7 +450,7 @@ GfErrType TcrEndpoint::registerDM(bool clientNotification, bool isSecondary,
if (m_connected || connected) {
if (clientNotification) {
if (distMgr != nullptr) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guardDistMgrs(m_distMgrsLock);
+ std::lock_guard<decltype(m_distMgrsLock)> guardDistMgrs(m_distMgrsLock);
m_distMgrs.push_back(distMgr);
}
LOGFINEST(
@@ -464,7 +458,8 @@ GfErrType TcrEndpoint::registerDM(bool clientNotification, bool isSecondary,
"channel for endpoint %s",
m_name.c_str());
// setup notification channel for the first region
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_notifyReceiverLock);
+ std::lock_guard<decltype(m_notifyReceiverLock)> guard(
+ m_notifyReceiverLock);
if (m_numRegionListener == 0) {
if ((err = createNewConnection(m_notifyConnection, true, isSecondary,
m_cacheImpl->getDistributedSystem()
@@ -519,14 +514,14 @@ void TcrEndpoint::unregisterDM(bool clientNotification,
"channel for endpoint %s",
m_name.c_str());
// close notification channel if there is no region
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_notifyReceiverLock);
+ std::lock_guard<decltype(m_notifyReceiverLock)> guard(m_notifyReceiverLock);
if (m_numRegionListener > 0 && --m_numRegionListener == 0) {
closeNotification();
}
LOGFINEST("Decremented subscription region count for endpoint %s to %d",
m_name.c_str(), m_numRegionListener);
if (distMgr != nullptr) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guardDistMgrs(m_distMgrsLock);
+ std::lock_guard<decltype(m_distMgrsLock)> guardDistMgrs(m_distMgrsLock);
m_distMgrs.remove(distMgr);
}
LOGFINEST("Done unsubscribe for endpoint %s", m_name.c_str());
@@ -601,7 +596,8 @@ int TcrEndpoint::receiveNotification(volatile bool& isRunning) {
if (isRunning) {
setConnectionStatus(false);
// close notification channel
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_notifyReceiverLock);
+ std::lock_guard<decltype(m_notifyReceiverLock)> guard(
+ m_notifyReceiverLock);
if (m_numRegionListener > 0) {
m_numRegionListener = 0;
closeNotification();
@@ -711,7 +707,8 @@ int TcrEndpoint::receiveNotification(volatile bool& isRunning) {
if (m_connected) {
setConnectionStatus(false);
// close notification channel
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_notifyReceiverLock);
+ std::lock_guard<decltype(m_notifyReceiverLock)> guard(
+ m_notifyReceiverLock);
if (m_numRegionListener > 0) {
m_numRegionListener = 0;
closeNotification();
@@ -919,7 +916,7 @@ GfErrType TcrEndpoint::sendRequestWithRetry(
epFailure = false;
if (useEPPool) {
if (m_maxConnections == 0) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_connectionLock);
+ std::lock_guard<decltype(m_connectionLock)> guard(m_connectionLock);
if (m_maxConnections == 0) {
LOGFINE(
"Creating a new connection when connection-pool-size system "
@@ -1191,7 +1188,7 @@ void TcrEndpoint::setConnectionStatus(bool status) {
// bool wasActive = m_isActiveEndpoint;
// Then after taking the lock:
// If ( !wasActive && isActiveEndpoint ) { return; }
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_connectionLock);
+ std::lock_guard<decltype(m_connectionLock)> guard(m_connectionLock);
if (m_connected != status) {
bool connected = m_connected;
m_connected = status;
@@ -1262,7 +1259,7 @@ void TcrEndpoint::stopNoBlock() {
void TcrEndpoint::stopNotifyReceiverAndCleanup() {
LOGFINER("Stopping subscription receiver and cleaning up");
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_notifyReceiverLock);
+ std::lock_guard<decltype(m_notifyReceiverLock)> guard(m_notifyReceiverLock);
if (m_notifyReceiver != nullptr) {
LOGFINER("Waiting for notification thread...");
diff --git a/cppcache/src/TcrEndpoint.hpp b/cppcache/src/TcrEndpoint.hpp
index ac54349..f5cd263 100644
--- a/cppcache/src/TcrEndpoint.hpp
+++ b/cppcache/src/TcrEndpoint.hpp
@@ -22,9 +22,10 @@
#include <atomic>
#include <list>
+#include <mutex>
#include <string>
-#include <ace/Recursive_Thread_Mutex.h>
+#include <ace/Condition_Recursive_Thread_Mutex.h>
#include <ace/Semaphore.h>
#include <geode/internal/geode_base.hpp>
@@ -166,9 +167,7 @@ class APACHE_GEODE_EXPORT TcrEndpoint {
void setConnected(volatile bool connected = true) { m_connected = connected; }
virtual ThinClientPoolDM* getPoolHADM() { return nullptr; }
bool isQueueHosted();
- ACE_Recursive_Thread_Mutex& getQueueHostedMutex() {
- return m_notifyReceiverLock;
- }
+ std::recursive_mutex& getQueueHostedMutex() { return m_notifyReceiverLock; }
/*
void sendNotificationCloseMsg();
*/
@@ -194,9 +193,8 @@ class APACHE_GEODE_EXPORT TcrEndpoint {
CacheImpl* m_cacheImpl;
std::list<Task<TcrEndpoint>*> m_notifyReceiverList;
std::list<TcrConnection*> m_notifyConnectionList;
- ACE_Condition<ACE_Recursive_Thread_Mutex> m_connectLockCond;
- ACE_Recursive_Thread_Mutex m_connectLock;
- ACE_Recursive_Thread_Mutex m_notifyReceiverLock;
+ std::timed_mutex m_connectLock;
+ std::recursive_mutex m_notifyReceiverLock;
FairQueue<TcrConnection> m_opConnections;
volatile int m_maxConnections;
int m_numRegionListener;
@@ -229,9 +227,9 @@ class APACHE_GEODE_EXPORT TcrEndpoint {
ThinClientBaseDM* m_baseDM;
std::string m_name;
std::list<ThinClientBaseDM*> m_distMgrs;
- ACE_Recursive_Thread_Mutex m_endpointAuthenticationLock;
- ACE_Recursive_Thread_Mutex m_connectionLock;
- ACE_Recursive_Thread_Mutex m_distMgrsLock;
+ std::recursive_mutex m_endpointAuthenticationLock;
+ std::recursive_mutex m_connectionLock;
+ std::recursive_mutex m_distMgrsLock;
ACE_Semaphore m_notificationCleanupSema;
Set<uint16_t> m_ports;
int32_t m_numberOfTimesFailed;
diff --git a/cppcache/src/TcrMessage.hpp b/cppcache/src/TcrMessage.hpp
index f949851..1ac99b4 100644
--- a/cppcache/src/TcrMessage.hpp
+++ b/cppcache/src/TcrMessage.hpp
@@ -26,8 +26,6 @@
#include <string>
#include <vector>
-#include <ace/OS.h>
-
#include <geode/CacheableBuiltins.hpp>
#include <geode/CacheableKey.hpp>
#include <geode/CacheableString.hpp>
@@ -1263,12 +1261,11 @@ class TcrMessageHelper {
} else if (!isObj) {
// otherwise we're currently always expecting an object
char exMsg[256];
- ACE_OS::snprintf(exMsg, 255,
- "TcrMessageHelper::readChunkPartHeader: "
- "%s: part is not object",
- methodName);
+ std::snprintf(exMsg, sizeof(exMsg),
+ "TcrMessageHelper::readChunkPartHeader: "
+ "%s: part is not object",
+ methodName);
LOGDEBUG("%s ", exMsg);
- // throw MessageException(exMsg);
return ChunkObjectType::EXCEPTION;
}
@@ -1284,8 +1281,8 @@ class TcrMessageHelper {
return ChunkObjectType::EXCEPTION;
} else {
char exMsg[256];
- ACE_OS::snprintf(
- exMsg, 255,
+ std::snprintf(
+ exMsg, sizeof(exMsg),
"TcrMessageHelper::readChunkPartHeader: %s: cannot handle "
"java serializable object from server",
methodName);
@@ -1300,10 +1297,10 @@ class TcrMessageHelper {
if (expectedFirstType > DSCode::FixedIDDefault) {
if (partType != expectedFirstType) {
char exMsg[256];
- ACE_OS::snprintf(exMsg, 255,
- "TcrMessageHelper::readChunkPartHeader: "
- "%s: got unhandled object class = %" PRId8,
- methodName, static_cast<int8_t>(partType));
+ std::snprintf(exMsg, sizeof(exMsg),
+ "TcrMessageHelper::readChunkPartHeader: "
+ "%s: got unhandled object class = %" PRId8,
+ methodName, static_cast<int8_t>(partType));
throw MessageException(exMsg);
}
// This is for GETALL
@@ -1316,8 +1313,8 @@ class TcrMessageHelper {
}
if (compId != expectedPartType) {
char exMsg[256];
- ACE_OS::snprintf(
- exMsg, 255,
+ std::snprintf(
+ exMsg, sizeof(exMsg),
"TcrMessageHelper::readChunkPartHeader: "
"%s: got unhandled object type = %d, expected = %d, raw = %d",
methodName, compId, expectedPartType, rawByte);
@@ -1340,10 +1337,10 @@ class TcrMessageHelper {
} else if (!isObj) {
// otherwise we're currently always expecting an object
char exMsg[256];
- ACE_OS::snprintf(exMsg, 255,
- "TcrMessageHelper::readChunkPartHeader: "
- "%s: part is not object",
- methodName);
+ std::snprintf(exMsg, 255,
+ "TcrMessageHelper::readChunkPartHeader: "
+ "%s: part is not object",
+ methodName);
throw MessageException(exMsg);
}
@@ -1356,7 +1353,7 @@ class TcrMessageHelper {
return ChunkObjectType::EXCEPTION;
} else {
char exMsg[256];
- ACE_OS::snprintf(
+ std::snprintf(
exMsg, 255,
"TcrMessageHelper::readChunkPartHeader: %s: cannot handle "
"java serializable object from server",
diff --git a/cppcache/src/TcrPoolEndPoint.cpp b/cppcache/src/TcrPoolEndPoint.cpp
index cd387e5..db114f8 100644
--- a/cppcache/src/TcrPoolEndPoint.cpp
+++ b/cppcache/src/TcrPoolEndPoint.cpp
@@ -68,7 +68,8 @@ GfErrType TcrPoolEndPoint::registerDM(bool, bool isSecondary, bool,
ThinClientBaseDM*) {
GfErrType err = GF_NOERR;
ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_dm->getPoolLock());
- ACE_Guard<ACE_Recursive_Thread_Mutex> guardQueueHosted(getQueueHostedMutex());
+ std::lock_guard<decltype(getQueueHostedMutex())> guardQueueHosted(
+ getQueueHostedMutex());
auto& sysProp = m_cacheImpl->getDistributedSystem().getSystemProperties();
if (!connected()) {
TcrConnection* newConn;
@@ -111,7 +112,8 @@ GfErrType TcrPoolEndPoint::registerDM(bool, bool isSecondary, bool,
}
void TcrPoolEndPoint::unregisterDM(bool, ThinClientBaseDM*,
bool checkQueueHosted) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(getQueueHostedMutex());
+ std::lock_guard<decltype(getQueueHostedMutex())> guardQueueHosted(
+ getQueueHostedMutex());
if (checkQueueHosted && !m_isQueueHosted) {
LOGFINEST(
@@ -125,7 +127,7 @@ void TcrPoolEndPoint::unregisterDM(bool, ThinClientBaseDM*,
"TcrEndpoint: unregistering pool DM and closing notification "
"channel for endpoint %s",
name().c_str());
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard2(m_notifyReceiverLock);
+ std::lock_guard<decltype(m_notifyReceiverLock)> guard2(m_notifyReceiverLock);
if (m_numRegionListener > 0 && --m_numRegionListener == 0) {
closeNotification();
}
diff --git a/cppcache/src/ThinClientBaseDM.cpp b/cppcache/src/ThinClientBaseDM.cpp
index 2bc1baa..ba9cc05 100644
--- a/cppcache/src/ThinClientBaseDM.cpp
+++ b/cppcache/src/ThinClientBaseDM.cpp
@@ -17,6 +17,8 @@
#include "ThinClientBaseDM.hpp"
+#include <chrono>
+
#include <geode/AuthenticatedView.hpp>
#include "ThinClientRegion.hpp"
@@ -194,19 +196,17 @@ void ThinClientBaseDM::failover() {}
void ThinClientBaseDM::queueChunk(TcrChunkedContext* chunk) {
LOGDEBUG("ThinClientBaseDM::queueChunk");
- const uint32_t timeout = 1;
if (m_chunkProcessor == nullptr) {
LOGDEBUG("ThinClientBaseDM::queueChunk2");
// process in same thread if no chunk processor thread
chunk->handleChunk(true);
_GEODE_SAFE_DELETE(chunk);
- } else if (!m_chunks.putUntil(chunk, timeout, 0)) {
+ } else if (!m_chunks.putFor(chunk, std::chrono::seconds(1))) {
LOGDEBUG("ThinClientBaseDM::queueChunk3");
// if put in queue fails due to whatever reason then process in same thread
LOGFINE(
"addChunkToQueue: timed out while adding to queue of "
- "unbounded size after waiting for %d secs",
- timeout);
+ "unbounded size after waiting for 1 secs");
chunk->handleChunk(true);
_GEODE_SAFE_DELETE(chunk);
} else {
@@ -220,7 +220,7 @@ int ThinClientBaseDM::processChunks(volatile bool& isRunning) {
LOGFINE("Starting chunk process thread for region %s",
(m_region != nullptr ? m_region->getFullPath().c_str() : "(null)"));
while (isRunning) {
- chunk = m_chunks.getUntil(0, 100000);
+ chunk = m_chunks.getFor(std::chrono::microseconds(100000));
if (chunk) {
chunk->handleChunk(false);
_GEODE_SAFE_DELETE(chunk);
@@ -270,13 +270,11 @@ void ThinClientBaseDM::beforeSendingRequest(const TcrMessage& request,
connId = conn->getConnectionId();
uniqueId = conn->getEndpointObject()->getUniqueId();
} else {
- auto userAttribute = TSSUserAttributesWrapper::s_geodeTSSUserAttributes
- ->getUserAttributes();
connId = conn->getConnectionId();
if (!(request.getMessageType() == TcrMessage::USER_CREDENTIAL_MESSAGE)) {
- uniqueId =
- userAttribute->getConnectionAttribute(conn->getEndpointObject())
- ->getUniqueId();
+ uniqueId = UserAttributes::threadLocalUserAttributes
+ ->getConnectionAttribute(conn->getEndpointObject())
+ ->getUniqueId();
}
}
@@ -302,11 +300,8 @@ void ThinClientBaseDM::afterSendingRequest(const TcrMessage& request,
if (request.getMessageType() == TcrMessage::USER_CREDENTIAL_MESSAGE) {
if (TcrMessage::RESPONSE == reply.getMessageType()) {
if (this->isMultiUserMode()) {
- auto userAttribute =
- TSSUserAttributesWrapper::s_geodeTSSUserAttributes
- ->getUserAttributes();
- userAttribute->setConnectionAttributes(conn->getEndpointObject(),
- reply.getUniqueId(conn));
+ UserAttributes::threadLocalUserAttributes->setConnectionAttributes(
+ conn->getEndpointObject(), reply.getUniqueId(conn));
} else {
conn->getEndpointObject()->setUniqueId(reply.getUniqueId(conn));
}
diff --git a/cppcache/src/ThinClientBaseDM.hpp b/cppcache/src/ThinClientBaseDM.hpp
index 7a235b9..70a35ec 100644
--- a/cppcache/src/ThinClientBaseDM.hpp
+++ b/cppcache/src/ThinClientBaseDM.hpp
@@ -112,7 +112,7 @@ class ThinClientBaseDM {
return m_connManager.checkDupAndAdd(eventid);
}
- virtual ACE_Recursive_Thread_Mutex* getRedundancyLock() {
+ virtual std::recursive_mutex& getRedundancyLock() {
return m_connManager.getRedundancyLock();
}
diff --git a/cppcache/src/ThinClientCacheDistributionManager.cpp b/cppcache/src/ThinClientCacheDistributionManager.cpp
index 50e1acf..faba3bd 100644
--- a/cppcache/src/ThinClientCacheDistributionManager.cpp
+++ b/cppcache/src/ThinClientCacheDistributionManager.cpp
@@ -52,7 +52,7 @@ GfErrType ThinClientCacheDistributionManager::sendSyncRequestCq(
reply.setDM(this);
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_endpointsLock);
+ std::lock_guard<decltype(m_endpointsLock)> guard(m_endpointsLock);
// Return best effort result: If CQ succeeds on ANY server return no-error
// even if
diff --git a/cppcache/src/ThinClientDistributionManager.cpp b/cppcache/src/ThinClientDistributionManager.cpp
index 723c64d..5aec9e7 100644
--- a/cppcache/src/ThinClientDistributionManager.cpp
+++ b/cppcache/src/ThinClientDistributionManager.cpp
@@ -68,7 +68,7 @@ void ThinClientDistributionManager::destroy(bool keepAlive) {
return;
}
DistManagersLockGuard _guard(m_connManager);
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_endpointsLock);
+ std::lock_guard<decltype(m_endpointsLock)> guard(m_endpointsLock);
if (m_activeEndpoint >= 0) {
m_endpoints[m_activeEndpoint]->unregisterDM(m_clientNotification, this);
}
@@ -160,7 +160,7 @@ GfErrType ThinClientDistributionManager::sendSyncRequest(TcrMessage& request,
}
if (!isFatalError(error)) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_endpointsLock);
+ std::lock_guard<decltype(m_endpointsLock)> guard(m_endpointsLock);
GfErrType connErr = GF_NOERR;
while (error != GF_NOERR && !isFatalError(error) &&
(connErr = selectEndpoint(randIndex, doRand, useActiveEndpoint,
@@ -249,7 +249,7 @@ GfErrType ThinClientDistributionManager::selectEndpoint(
if (currentEndpoint < 0 || !m_endpoints[currentEndpoint]->connected() ||
forceSelect) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_endpointsLock);
+ std::lock_guard<decltype(m_endpointsLock)> guard(m_endpointsLock);
if (m_activeEndpoint < 0 || !m_endpoints[m_activeEndpoint]->connected() ||
forceSelect) { // double check
currentEndpoint = m_activeEndpoint;
diff --git a/cppcache/src/ThinClientDistributionManager.hpp b/cppcache/src/ThinClientDistributionManager.hpp
index d16421e..794cbf2 100644
--- a/cppcache/src/ThinClientDistributionManager.hpp
+++ b/cppcache/src/ThinClientDistributionManager.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_THINCLIENTDISTRIBUTIONMANAGER_H_
-#define GEODE_THINCLIENTDISTRIBUTIONMANAGER_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,11 +15,19 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_THINCLIENTDISTRIBUTIONMANAGER_H_
+#define GEODE_THINCLIENTDISTRIBUTIONMANAGER_H_
+
+#include <mutex>
+
#include "ThinClientBaseDM.hpp"
namespace apache {
namespace geode {
namespace client {
+
class ThinClientDistributionManager : public ThinClientBaseDM {
public:
ThinClientDistributionManager(TcrConnectionManager& connManager,
@@ -40,8 +43,8 @@ class ThinClientDistributionManager : public ThinClientBaseDM {
void failover() override;
- void acquireFailoverLock() override { m_endpointsLock.acquire_read(); };
- void releaseFailoverLock() override { m_endpointsLock.release(); };
+ void acquireFailoverLock() override { m_endpointsLock.lock(); };
+ void releaseFailoverLock() override { m_endpointsLock.unlock(); };
TcrEndpoint* getActiveEndpoint() override {
return m_endpoints[m_activeEndpoint];
@@ -76,7 +79,7 @@ class ThinClientDistributionManager : public ThinClientBaseDM {
volatile int m_activeEndpoint;
std::vector<TcrEndpoint*> m_endpoints;
- ACE_Recursive_Thread_Mutex m_endpointsLock;
+ std::recursive_mutex m_endpointsLock;
};
} // namespace client
} // namespace geode
diff --git a/cppcache/src/ThinClientLocatorHelper.cpp b/cppcache/src/ThinClientLocatorHelper.cpp
index 78fd5f5..153e339 100644
--- a/cppcache/src/ThinClientLocatorHelper.cpp
+++ b/cppcache/src/ThinClientLocatorHelper.cpp
@@ -33,9 +33,11 @@
#include "QueueConnectionResponse.hpp"
#include "TcpSslConn.hpp"
#include "ThinClientPoolDM.hpp"
+
namespace apache {
namespace geode {
namespace client {
+
const int BUFF_SIZE = 3000;
class ConnectionWrapper {
@@ -87,7 +89,7 @@ Connector* ThinClientLocatorHelper::createConnection(
GfErrType ThinClientLocatorHelper::getAllServers(
std::vector<std::shared_ptr<ServerLocation> >& servers,
const std::string& serverGrp) {
- ACE_Guard<ACE_Thread_Mutex> guard(m_locatorLock);
+ std::lock_guard<decltype(m_locatorLock)> guard(m_locatorLock);
auto& sysProps = m_poolDM->getConnectionManager()
.getCacheImpl()
@@ -151,7 +153,7 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewCallBackConn(
ClientProxyMembershipID& memId, std::list<ServerLocation>& outEndpoint,
std::string&, int redundancy, const std::set<ServerLocation>& exclEndPts,
const std::string& serverGrp) {
- ACE_Guard<ACE_Thread_Mutex> guard(m_locatorLock);
+ std::lock_guard<decltype(m_locatorLock)> guard(m_locatorLock);
auto& sysProps = m_poolDM->getConnectionManager()
.getCacheImpl()
->getDistributedSystem()
@@ -233,7 +235,7 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewFwdConn(
const std::set<ServerLocation>& exclEndPts, const std::string& serverGrp,
const TcrConnection* currentServer) {
bool locatorFound = false;
- ACE_Guard<ACE_Thread_Mutex> guard(m_locatorLock);
+ std::lock_guard<decltype(m_locatorLock)> guard(m_locatorLock);
auto& sysProps = m_poolDM->getConnectionManager()
.getCacheImpl()
->getDistributedSystem()
@@ -334,7 +336,7 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewFwdConn(
GfErrType ThinClientLocatorHelper::updateLocators(
const std::string& serverGrp) {
- ACE_Guard<ACE_Thread_Mutex> guard(m_locatorLock);
+ std::lock_guard<decltype(m_locatorLock)> guard(m_locatorLock);
auto& sysProps = m_poolDM->getConnectionManager()
.getCacheImpl()
->getDistributedSystem()
diff --git a/cppcache/src/ThinClientLocatorHelper.hpp b/cppcache/src/ThinClientLocatorHelper.hpp
index a3ede6a..04bde66 100644
--- a/cppcache/src/ThinClientLocatorHelper.hpp
+++ b/cppcache/src/ThinClientLocatorHelper.hpp
@@ -21,6 +21,7 @@
#define GEODE_THINCLIENTLOCATORHELPER_H_
#include <list>
+#include <mutex>
#include <set>
#include <string>
@@ -35,8 +36,10 @@
namespace apache {
namespace geode {
namespace client {
+
class TcrEndpoint;
class ThinClientPoolDM;
+
class ThinClientLocatorHelper {
public:
ThinClientLocatorHelper(const std::vector<std::string>& locatorAddresses,
@@ -63,7 +66,7 @@ class ThinClientLocatorHelper {
int32_t port,
std::chrono::microseconds waitSeconds,
int32_t maxBuffSizePool = 0);
- ACE_Thread_Mutex m_locatorLock;
+ std::mutex m_locatorLock;
std::vector<ServerLocation> m_locHostPort;
const ThinClientPoolDM* m_poolDM;
ThinClientLocatorHelper(const ThinClientLocatorHelper&);
diff --git a/cppcache/src/ThinClientPoolDM.cpp b/cppcache/src/ThinClientPoolDM.cpp
index 4ac91f2..f9cf008 100644
--- a/cppcache/src/ThinClientPoolDM.cpp
+++ b/cppcache/src/ThinClientPoolDM.cpp
@@ -91,8 +91,7 @@ class GetAllWork : public PooledWork<GfErrType>,
m_keys.get(), m_poolDM, m_aCallbackArgument);
m_reply = new TcrMessageReply(true, m_poolDM);
if (m_poolDM->isMultiUserMode()) {
- m_userAttribute = TSSUserAttributesWrapper::s_geodeTSSUserAttributes
- ->getUserAttributes();
+ m_userAttribute = UserAttributes::threadLocalUserAttributes;
}
m_resultCollector = (new ChunkedGetAllResponse(
@@ -398,8 +397,8 @@ void ThinClientPoolDM::cleanStaleConnections(volatile bool& isRunning) {
LOGDEBUG("Cleaning stale connections");
- ACE_Time_Value _idle(getIdleTimeout());
- ACE_Time_Value _nextIdle = _idle;
+ auto _idle = getIdleTimeout();
+ auto _nextIdle = _idle;
{
TcrConnection* conn = nullptr;
@@ -411,9 +410,10 @@ void ThinClientPoolDM::cleanStaleConnections(volatile bool& isRunning) {
if (canItBeDeleted(conn)) {
replacelist.push_back(conn);
} else if (conn) {
- ACE_Time_Value nextIdle =
- _idle - (ACE_OS::gettimeofday() - conn->getLastAccessed());
- if ((ACE_Time_Value(0, 0) < nextIdle) && (nextIdle < _nextIdle)) {
+ auto nextIdle =
+ _idle - std::chrono::duration_cast<std::chrono::milliseconds>(
+ TcrConnection::clock::now() - conn->getLastAccessed());
+ if (nextIdle > std::chrono::seconds::zero() && nextIdle < _nextIdle) {
_nextIdle = nextIdle;
}
savelist.push_back(conn);
@@ -437,9 +437,11 @@ void ThinClientPoolDM::cleanStaleConnections(volatile bool& isRunning) {
createPoolConnection(newConn, excludeServers, maxConnLimit,
/*hasExpired(conn) ? nullptr :*/ conn);
if (newConn) {
- ACE_Time_Value nextIdle =
- _idle - (ACE_OS::gettimeofday() - newConn->getLastAccessed());
- if ((ACE_Time_Value(0, 0) < nextIdle) && (nextIdle < _nextIdle)) {
+ auto nextIdle =
+ _idle -
+ std::chrono::duration_cast<std::chrono::milliseconds>(
+ TcrConnection::clock::now() - conn->getLastAccessed());
+ if (nextIdle > std::chrono::seconds::zero() && nextIdle < _nextIdle) {
_nextIdle = nextIdle;
}
savelist.push_back(newConn);
@@ -457,9 +459,12 @@ void ThinClientPoolDM::cleanStaleConnections(volatile bool& isRunning) {
LOGDEBUG("Removed a connection");
} else {
conn->updateCreationTime();
- ACE_Time_Value nextIdle =
- _idle - (ACE_OS::gettimeofday() - conn->getLastAccessed());
- if ((ACE_Time_Value(0, 0) < nextIdle) && (nextIdle < _nextIdle)) {
+ auto nextIdle =
+ _idle -
+ std::chrono::duration_cast<std::chrono::milliseconds>(
+ TcrConnection::clock::now() - conn->getLastAccessed());
+ if (nextIdle > std::chrono::seconds::zero() &&
+ nextIdle < _nextIdle) {
_nextIdle = nextIdle;
}
savelist.push_back(conn);
@@ -478,11 +483,12 @@ void ThinClientPoolDM::cleanStaleConnections(volatile bool& isRunning) {
}
if (m_connManageTaskId >= 0 && isRunning &&
m_connManager.getCacheImpl()->getExpiryTaskManager().resetTask(
- m_connManageTaskId, static_cast<uint32_t>(_nextIdle.sec() + 1))) {
+ m_connManageTaskId, _nextIdle)) {
LOGERROR("Failed to reschedule connection manager");
} else {
- LOGFINEST("Rescheduled next connection manager run after %d seconds",
- _nextIdle.sec() + 1);
+ LOGFINEST(
+ "Rescheduled next connection manager run after %d seconds",
+ std::chrono::duration_cast<std::chrono::seconds>(_nextIdle).count());
}
LOGDEBUG("Pool size is %d, pool counter is %d", size(), m_poolSize.load());
@@ -568,15 +574,15 @@ std::string ThinClientPoolDM::selectEndpoint(
getStats().incLoctorResposes();
char epNameStr[128] = {0};
- ACE_OS::snprintf(epNameStr, 128, "%s:%d",
- outEndpoint.getServerName().c_str(),
- outEndpoint.getPort());
+ std::snprintf(epNameStr, 128, "%s:%d", outEndpoint.getServerName().c_str(),
+ outEndpoint.getPort());
LOGFINE("ThinClientPoolDM: Locator returned endpoint [%s]", epNameStr);
return epNameStr;
} else if (m_attrs->m_initServList
.size()) { // use specified server endpoints
// highly complex round-robin algorithm
- ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_endpointSelectionLock);
+ std::lock_guard<decltype(m_endpointSelectionLock)> _guard(
+ m_endpointSelectionLock);
if (m_server >= m_attrs->m_initServList.size()) {
m_server = 0;
}
@@ -615,7 +621,7 @@ GfErrType ThinClientPoolDM::sendRequestToAllServers(
getStats().setCurClientOps(++m_clientOps);
- auto resultCollectorLock = std::make_shared<ACE_Recursive_Thread_Mutex>();
+ auto resultCollectorLock = std::make_shared<std::recursive_mutex>();
auto csArray = getServers();
@@ -626,9 +632,8 @@ GfErrType ThinClientPoolDM::sendRequestToAllServers(
int feIndex = 0;
FunctionExecution* fePtrList = new FunctionExecution[csArray->length()];
- auto* threadPool = m_connManager.getCacheImpl()->getThreadPool();
- auto userAttr =
- TSSUserAttributesWrapper::s_geodeTSSUserAttributes->getUserAttributes();
+ auto threadPool = m_connManager.getCacheImpl()->getThreadPool();
+ auto userAttr = UserAttributes::threadLocalUserAttributes;
for (int i = 0; i < csArray->length(); i++) {
auto cs = (*csArray)[i];
std::string endpointStr(cs->value().c_str());
@@ -812,11 +817,8 @@ void ThinClientPoolDM::destroy(bool keepAlive) {
close();
LOGDEBUG("ThinClientPoolDM::destroy( ): after close ");
- for (ACE_Map_Manager<std::string, TcrEndpoint*,
- ACE_Recursive_Thread_Mutex>::iterator iter =
- m_endpoints.begin();
- iter != m_endpoints.end(); ++iter) {
- TcrEndpoint* ep = (*iter).int_id_;
+ for (auto& iter : m_endpoints) {
+ auto ep = iter.int_id_;
LOGFINE("ThinClientPoolDM: forcing endpoint delete for %d in destructor",
ep->name().c_str());
_GEODE_SAFE_DELETE(ep);
@@ -883,16 +885,12 @@ std::shared_ptr<QueryService> ThinClientPoolDM::getQueryServiceWithoutCheck() {
}
void ThinClientPoolDM::sendUserCacheCloseMessage(bool keepAlive) {
LOGDEBUG("ThinClientPoolDM::sendUserCacheCloseMessage");
- auto userAttribute =
- TSSUserAttributesWrapper::s_geodeTSSUserAttributes->getUserAttributes();
+ auto userAttribute = UserAttributes::threadLocalUserAttributes;
- std::map<std::string, UserConnectionAttributes*>& uca =
- userAttribute->getUserConnectionServers();
+ auto& ucs = userAttribute->getUserConnectionServers();
- std::map<std::string, UserConnectionAttributes*>::iterator it;
-
- for (it = uca.begin(); it != uca.end(); it++) {
- UserConnectionAttributes* uca = (*it).second;
+ for (const auto& it : ucs) {
+ auto uca = it.second;
if (uca->isAuthenticated() && uca->getEndpoint()->connected()) {
TcrMessageRemoveUserAuth request(
new DataOutput(m_connManager.getCacheImpl()->createDataOutput()),
@@ -1201,12 +1199,9 @@ TcrEndpoint* ThinClientPoolDM::getEndPoint(
// do for pool with endpoints. Add endpoint into m_endpoints only when we
// did not find it above and it is in the pool's m_initServList.
- for (std::vector<std::string>::iterator itr =
- m_attrs->m_initServList.begin();
- itr != m_attrs->m_initServList.end(); ++itr) {
- if ((ACE_OS::strcmp(serverLocation->getEpString().c_str(),
- (*itr).c_str()) == 0)) {
- ep = addEP(*(serverLocation.get())); // see if this is new endpoint
+ for (const auto& itr : m_attrs->m_initServList) {
+ if (serverLocation->getEpString() == itr) {
+ ep = addEP(*serverLocation); // see if this is new endpoint
break;
}
}
@@ -1393,8 +1388,7 @@ GfErrType ThinClientPoolDM::sendSyncRequest(
request, version, singleHopConnFound,
connFound, serverLocation);
} else {
- userAttr = TSSUserAttributesWrapper::s_geodeTSSUserAttributes
- ->getUserAttributes();
+ userAttr = UserAttributes::threadLocalUserAttributes;
if (userAttr == nullptr) {
LOGWARN("Attempted operation type %d without credentials",
request.getMessageType());
@@ -1973,16 +1967,8 @@ GfErrType ThinClientPoolDM::sendRequestToEP(const TcrMessage& request,
error = this->sendUserCredentials(this->getCredentials(currentEndpoint),
conn, false, isServerException);
} else if (this->m_isMultiUserMode) {
- ua = TSSUserAttributesWrapper::s_geodeTSSUserAttributes
- ->getUserAttributes();
- if (ua == nullptr) {
- LOGWARN("Attempted operation type %d without credentials",
- request.getMessageType());
- if (conn) {
- putInQueue(conn, false, request.forTransaction());
- }
- return GF_NOT_AUTHORIZED_EXCEPTION;
- } else {
+ ua = UserAttributes::threadLocalUserAttributes;
+ if (ua) {
UserConnectionAttributes* uca =
ua->getConnectionAttribute(currentEndpoint);
@@ -1990,6 +1976,13 @@ GfErrType ThinClientPoolDM::sendRequestToEP(const TcrMessage& request,
error = this->sendUserCredentials(ua->getCredentials(), conn, false,
isServerException);
}
+ } else {
+ LOGWARN("Attempted operation type %d without credentials",
+ request.getMessageType());
+ if (conn) {
+ putInQueue(conn, false, request.forTransaction());
+ }
+ return GF_NOT_AUTHORIZED_EXCEPTION;
}
}
}
@@ -2055,13 +2048,13 @@ TcrEndpoint* ThinClientPoolDM::addEP(ServerLocation& serverLoc) {
std::string serverName = serverLoc.getServerName();
int port = serverLoc.getPort();
char endpointName[100];
- ACE_OS::snprintf(endpointName, 100, "%s:%d", serverName.c_str(), port);
+ std::snprintf(endpointName, 100, "%s:%d", serverName.c_str(), port);
return addEP(endpointName);
}
TcrEndpoint* ThinClientPoolDM::addEP(const char* endpointName) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_endpointsLock);
+ std::lock_guard<decltype(m_endpointsLock)> guard(m_endpointsLock);
TcrEndpoint* ep = nullptr;
std::string fullName = endpointName;
@@ -2089,16 +2082,13 @@ void ThinClientPoolDM::netDown() {
void ThinClientPoolDM::pingServerLocal() {
ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(getPoolLock());
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_endpointsLock);
- for (ACE_Map_Manager<std::string, TcrEndpoint*,
- ACE_Recursive_Thread_Mutex>::iterator it =
- m_endpoints.begin();
- it != m_endpoints.end(); it++) {
- if ((*it).int_id_->connected()) {
- (*it).int_id_->pingServer(this);
- if (!(*it).int_id_->connected()) {
- removeEPConnections((*it).int_id_);
- removeCallbackConnection((*it).int_id_);
+ std::lock_guard<decltype(m_endpointsLock)> guard(m_endpointsLock);
+ for (auto& it : m_endpoints) {
+ if (it.int_id_->connected()) {
+ it.int_id_->pingServer(this);
+ if (!it.int_id_->connected()) {
+ removeEPConnections(it.int_id_);
+ removeCallbackConnection(it.int_id_);
}
}
}
@@ -2199,7 +2189,7 @@ bool ThinClientPoolDM::canItBeDeleted(TcrConnection* conn) {
bool queue = false;
{
ACE_Guard<ACE_Recursive_Thread_Mutex> poolguard(m_queueLock); // PXR
- ACE_Guard<ACE_Recursive_Thread_Mutex> guardQueue(
+ std::lock_guard<decltype(endPt->getQueueHostedMutex())> guardQueue(
endPt->getQueueHostedMutex());
queue = endPt->isQueueHosted();
if (queue) {
@@ -2328,11 +2318,11 @@ void ThinClientPoolDM::checkRegions() {
m_destroyPending = true;
}
-void ThinClientPoolDM::updateNotificationStats(bool isDeltaSuccess,
- int64_t timeInNanoSecond) {
+void ThinClientPoolDM::updateNotificationStats(
+ bool isDeltaSuccess, std::chrono::nanoseconds timeInNanoSecond) {
if (isDeltaSuccess) {
getStats().incProcessedDeltaMessages();
- getStats().incProcessedDeltaMessagesTime(timeInNanoSecond);
+ getStats().incProcessedDeltaMessagesTime(timeInNanoSecond.count());
} else {
getStats().incDeltaMessageFailures();
}
diff --git a/cppcache/src/ThinClientPoolDM.hpp b/cppcache/src/ThinClientPoolDM.hpp
index 88bc492..ecd53c9 100644
--- a/cppcache/src/ThinClientPoolDM.hpp
+++ b/cppcache/src/ThinClientPoolDM.hpp
@@ -20,11 +20,15 @@
#ifndef GEODE_THINCLIENTPOOLDM_H_
#define GEODE_THINCLIENTPOOLDM_H_
+#include <chrono>
#include <memory>
+#include <mutex>
#include <set>
#include <string>
#include <vector>
+#include <ace/Map_Manager.h>
+#include <ace/Recursive_Thread_Mutex.h>
#include <ace/Semaphore.h>
#include <geode/Pool.hpp>
@@ -155,7 +159,8 @@ class ThinClientPoolDM
virtual bool canItBeDeletedNoImpl(TcrConnection* conn);
- void updateNotificationStats(bool isDeltaSuccess, int64_t timeInNanoSecond);
+ void updateNotificationStats(bool isDeltaSuccess,
+ std::chrono::nanoseconds timeInNanoSecond);
virtual bool isSecurityOn() { return m_isSecurityOn || m_isMultiUserMode; }
@@ -203,8 +208,8 @@ class ThinClientPoolDM
std::vector<std::string> m_canonicalHosts;
ACE_Map_Manager<std::string, TcrEndpoint*, ACE_Recursive_Thread_Mutex>
m_endpoints;
- ACE_Recursive_Thread_Mutex m_endpointsLock;
- ACE_Recursive_Thread_Mutex m_endpointSelectionLock;
+ std::recursive_mutex m_endpointsLock;
+ std::recursive_mutex m_endpointSelectionLock;
std::string m_poolName;
PoolStats* m_stats;
bool m_sticky;
@@ -346,7 +351,7 @@ class FunctionExecution : public PooledWork<GfErrType> {
std::shared_ptr<Cacheable> m_args;
GfErrType m_error;
std::shared_ptr<ResultCollector>* m_rc;
- std::shared_ptr<ACE_Recursive_Thread_Mutex> m_resultCollectorLock;
+ std::shared_ptr<std::recursive_mutex> m_resultCollectorLock;
std::shared_ptr<CacheableString> exceptionPtr;
std::shared_ptr<UserAttributes> m_userAttr;
@@ -370,7 +375,7 @@ class FunctionExecution : public PooledWork<GfErrType> {
std::chrono::milliseconds timeout,
std::shared_ptr<Cacheable> args, TcrEndpoint* ep,
ThinClientPoolDM* poolDM,
- const std::shared_ptr<ACE_Recursive_Thread_Mutex>& rCL,
+ const std::shared_ptr<std::recursive_mutex>& rCL,
std::shared_ptr<ResultCollector>* rs,
std::shared_ptr<UserAttributes> userAttr) {
exceptionPtr = nullptr;
@@ -390,7 +395,6 @@ class FunctionExecution : public PooledWork<GfErrType> {
}
GfErrType execute(void) {
- // TSSUserAttributesWrapper::s_geodeTSSUserAttributes->setUserAttributes(m_userAttr);
GuardUserAttributes gua;
if (m_userAttr) {
@@ -461,7 +465,7 @@ class OnRegionFunctionExecution : public PooledWork<GfErrType> {
std::shared_ptr<CacheableHashSet> m_routingObj;
std::shared_ptr<ResultCollector> m_rc;
TcrChunkedResult* m_resultCollector;
- std::shared_ptr<ACE_Recursive_Thread_Mutex> m_resultCollectorLock;
+ std::shared_ptr<std::recursive_mutex> m_resultCollectorLock;
std::shared_ptr<UserAttributes> m_userAttr;
const Region* m_region;
bool m_allBuckets;
@@ -471,7 +475,7 @@ class OnRegionFunctionExecution : public PooledWork<GfErrType> {
std::string func, const Region* region, std::shared_ptr<Cacheable> args,
std::shared_ptr<CacheableHashSet> routingObj, uint8_t getResult,
std::chrono::milliseconds timeout, ThinClientPoolDM* poolDM,
- const std::shared_ptr<ACE_Recursive_Thread_Mutex>& rCL,
+ const std::shared_ptr<std::recursive_mutex>& rCL,
std::shared_ptr<ResultCollector> rs,
std::shared_ptr<UserAttributes> userAttr, bool isBGThread,
const std::shared_ptr<BucketServerLocation>& serverLocation,
diff --git a/cppcache/src/ThinClientPoolHADM.cpp b/cppcache/src/ThinClientPoolHADM.cpp
index 5b0270b..ddb9b92 100644
--- a/cppcache/src/ThinClientPoolHADM.cpp
+++ b/cppcache/src/ThinClientPoolHADM.cpp
@@ -209,7 +209,7 @@ GfErrType ThinClientPoolHADM::registerInterestAllRegions(
GfErrType err = GF_NOERR;
GfErrType opErr = GF_NOERR;
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_regionsLock);
+ std::lock_guard<decltype(m_regionsLock)> guard(m_regionsLock);
for (std::list<ThinClientRegion*>::iterator itr = m_regions.begin();
itr != m_regions.end(); itr++) {
if ((opErr = (*itr)->registerKeys(ep, request, reply)) != GF_NOERR) {
@@ -222,17 +222,17 @@ GfErrType ThinClientPoolHADM::registerInterestAllRegions(
}
void ThinClientPoolHADM::addRegion(ThinClientRegion* theTCR) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_regionsLock);
+ std::lock_guard<decltype(m_regionsLock)> guard(m_regionsLock);
m_regions.push_back(theTCR);
}
void ThinClientPoolHADM::addDisMessToQueue(ThinClientRegion* theTCR) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_regionsLock);
+ std::lock_guard<decltype(m_regionsLock)> guard(m_regionsLock);
if (m_redundancyManager->allEndPointDiscon()) {
theTCR->receiveNotification(TcrMessage::getAllEPDisMess());
}
}
void ThinClientPoolHADM::removeRegion(ThinClientRegion* theTCR) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_regionsLock);
+ std::lock_guard<decltype(m_regionsLock)> guard(m_regionsLock);
for (std::list<ThinClientRegion*>::iterator itr = m_regions.begin();
itr != m_regions.end(); itr++) {
if (*itr == theTCR) {
@@ -261,7 +261,7 @@ void ThinClientPoolHADM::netDown() {
ThinClientPoolDM::netDown();
{
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_endpointsLock);
+ std::lock_guard<decltype(m_endpointsLock)> guard(m_endpointsLock);
for (auto&& currItr : m_endpoints) {
currItr.int_id_->setConnectionStatus(false);
}
@@ -271,8 +271,8 @@ void ThinClientPoolHADM::netDown() {
}
void ThinClientPoolHADM::pingServerLocal() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(
- m_redundancyManager->getRedundancyLock());
+ auto& mutex = m_redundancyManager->getRedundancyLock();
+ std::lock_guard<decltype(mutex)> guard(mutex);
ThinClientPoolDM::pingServerLocal();
}
@@ -281,7 +281,7 @@ void ThinClientPoolHADM::removeCallbackConnection(TcrEndpoint* ep) {
}
void ThinClientPoolHADM::sendNotConMesToAllregions() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_regionsLock);
+ std::lock_guard<decltype(m_regionsLock)> guard(m_regionsLock);
for (std::list<ThinClientRegion*>::iterator it = m_regions.begin();
it != m_regions.end(); it++) {
(*it)->receiveNotification(TcrMessage::getAllEPDisMess());
diff --git a/cppcache/src/ThinClientPoolHADM.hpp b/cppcache/src/ThinClientPoolHADM.hpp
index f2ca229..7ebd9cb 100644
--- a/cppcache/src/ThinClientPoolHADM.hpp
+++ b/cppcache/src/ThinClientPoolHADM.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_THINCLIENTPOOLHADM_H_
-#define GEODE_THINCLIENTPOOLHADM_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,11 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#pragma once
+
+#ifndef GEODE_THINCLIENTPOOLHADM_H_
+#define GEODE_THINCLIENTPOOLHADM_H_
+
+#include <mutex>
+
#include "PoolAttributes.hpp"
#include "TcrConnectionManager.hpp"
#include "ThinClientHARegion.hpp"
#include "ThinClientPoolDM.hpp"
-//#include "TcrPoolEndPoint.hpp"
+
namespace apache {
namespace geode {
namespace client {
@@ -78,8 +81,8 @@ class ThinClientPoolHADM : public ThinClientPoolDM {
virtual void releaseRedundancyLock() {
m_redundancyManager->releaseRedundancyLock();
};
- virtual ACE_Recursive_Thread_Mutex* getRedundancyLock() {
- return &m_redundancyManager->getRedundancyLock();
+ virtual std::recursive_mutex& getRedundancyLock() {
+ return m_redundancyManager->getRedundancyLock();
}
GfErrType sendRequestToPrimary(TcrMessage& request, TcrMessageReply& reply) {
@@ -133,7 +136,7 @@ class ThinClientPoolHADM : public ThinClientPoolDM {
void removeCallbackConnection(TcrEndpoint*);
std::list<ThinClientRegion*> m_regions;
- ACE_Recursive_Thread_Mutex m_regionsLock;
+ std::recursive_mutex m_regionsLock;
void addRegion(ThinClientRegion* theTCR);
void removeRegion(ThinClientRegion* theTCR);
void sendNotConMesToAllregions();
diff --git a/cppcache/src/ThinClientRedundancyManager.cpp b/cppcache/src/ThinClientRedundancyManager.cpp
index c2658e0..8830762 100644
--- a/cppcache/src/ThinClientRedundancyManager.cpp
+++ b/cppcache/src/ThinClientRedundancyManager.cpp
@@ -121,7 +121,8 @@ GfErrType ThinClientRedundancyManager::maintainRedundancyLevel(
// to nonfatal errors such as server not available
GfErrType fatalError = GF_NOERR;
bool fatal = false;
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_redundantEndpointsLock);
+ std::lock_guard<decltype(m_redundantEndpointsLock)> guard(
+ m_redundantEndpointsLock);
bool isRedundancySatisfied = false;
int secondaryCount = 0;
bool isPrimaryConnected = false;
@@ -667,9 +668,8 @@ void ThinClientRedundancyManager::initialize(int redundancyLevel) {
if (interval < std::chrono::milliseconds(100)) {
interval = std::chrono::milliseconds(100);
}
- m_nextAckInc = ACE_Time_Value(interval);
- m_nextAck = ACE_OS::gettimeofday();
- m_nextAck += m_nextAckInc;
+ m_nextAckInc = interval;
+ m_nextAck = clock::now() + interval;
}
if (m_poolHADM) {
@@ -693,7 +693,8 @@ void ThinClientRedundancyManager::initialize(int redundancyLevel) {
}
void ThinClientRedundancyManager::sendNotificationCloseMsgs() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_redundantEndpointsLock);
+ std::lock_guard<decltype(m_redundantEndpointsLock)> guard(
+ m_redundantEndpointsLock);
for (auto&& endpoint : m_redundantEndpoints) {
LOGDEBUG(
@@ -726,7 +727,8 @@ void ThinClientRedundancyManager::close() {
_GEODE_SAFE_DELETE(m_periodicAckTask);
}
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_redundantEndpointsLock);
+ std::lock_guard<decltype(m_redundantEndpointsLock)> guard(
+ m_redundantEndpointsLock);
for (auto&& endpoint : m_redundantEndpoints) {
LOGDEBUG(
@@ -827,7 +829,8 @@ GfErrType ThinClientRedundancyManager::sendSyncRequestCq(
TcrMessage& request, TcrMessageReply& reply, ThinClientBaseDM* theHADM) {
LOGDEBUG("ThinClientRedundancyManager::sendSyncRequestCq msgType[%d]",
request.getMessageType());
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_redundantEndpointsLock);
+ std::lock_guard<decltype(m_redundantEndpointsLock)> guard(
+ m_redundantEndpointsLock);
GfErrType err = GF_NOERR;
GfErrType opErr;
@@ -872,8 +875,7 @@ GfErrType ThinClientRedundancyManager::sendSyncRequestCq(
while (attempts--) {
if (err != GF_NOERR || m_redundantEndpoints.empty()) {
- auto userAttr = TSSUserAttributesWrapper::s_geodeTSSUserAttributes
- ->getUserAttributes();
+ auto userAttr = UserAttributes::threadLocalUserAttributes;
if (userAttr) {
authenticatedView = userAttr->getAuthenticatedView();
}
@@ -918,7 +920,8 @@ GfErrType ThinClientRedundancyManager::sendSyncRequestRegisterInterest(
ThinClientBaseDM* theHADM, ThinClientRegion* region) {
LOGDEBUG("ThinClientRedundancyManager::sendSyncRequestRegisterInterest ");
if (!endpoint) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_redundantEndpointsLock);
+ std::lock_guard<decltype(m_redundantEndpointsLock)> guard(
+ m_redundantEndpointsLock);
auto err = GF_NOERR;
auto opErr = GF_NOERR;
@@ -1015,12 +1018,9 @@ void ThinClientRedundancyManager::getAllEndpoints(
TcrEndpoint* maxQEp = nullptr;
TcrEndpoint* primaryEp = nullptr;
- for (ACE_Map_Manager<std::string, TcrEndpoint*,
- ACE_Recursive_Thread_Mutex>::iterator currItr =
- (*tempContainer).begin();
- currItr != (*tempContainer).end(); currItr++) {
+ for (auto& currItr : *tempContainer) {
if (isDurable()) {
- TcrEndpoint* ep = (*currItr).int_id_;
+ auto ep = currItr.int_id_;
int32_t queueSize = 0;
TcrConnection* statusConn = nullptr;
ServerQueueStatus status =
@@ -1048,13 +1048,13 @@ void ThinClientRedundancyManager::getAllEndpoints(
"ThinClientRedundancyManager::getAllEndpoints(): sorting "
"endpoints, found primary endpoint.");
} else {
- endpoints.push_back((*currItr).int_id_);
+ endpoints.push_back(currItr.int_id_);
LOGDEBUG(
"ThinClientRedundancyManager::getAllEndpoints(): sorting "
"endpoints, found nonredundant endpoint.");
}
} else {
- endpoints.push_back((*currItr).int_id_);
+ endpoints.push_back(currItr.int_id_);
}
//(*currItr)++;
}
@@ -1113,7 +1113,8 @@ void ThinClientRedundancyManager::readyForEvents() {
GfErrType result = GF_NOTCON;
unsigned int epCount = 0;
- ACE_Guard<ACE_Recursive_Thread_Mutex> guardEPs(m_redundantEndpointsLock);
+ std::lock_guard<decltype(m_redundantEndpointsLock)> guard(
+ m_redundantEndpointsLock);
if (m_sentReadyForEvents) {
throw IllegalStateException("Already called readyForEvents");
@@ -1177,21 +1178,19 @@ void ThinClientRedundancyManager::doPeriodicAck() {
"ThinClientRedundancyManager::processEventIdMap( ): Examining eventid "
"map.");
// do periodic ack if HA is enabled and the time has come
- if (m_HAenabled && (m_nextAck < ACE_OS::gettimeofday())) {
+ if (m_HAenabled && (m_nextAck < clock::now())) {
LOGFINER("Doing periodic ack");
m_nextAck += m_nextAckInc;
- EventIdMapEntryList entries = m_eventidmap.getUnAcked();
- uint32_t count = static_cast<uint32_t>(entries.size());
-
+ auto entries = m_eventidmap.getUnAcked();
+ auto count = entries.size();
if (count > 0) {
bool acked = false;
- ACE_Guard<ACE_Recursive_Thread_Mutex> guardEPs(m_redundantEndpointsLock);
-
- std::vector<TcrEndpoint*>::iterator endpoint =
- m_redundantEndpoints.begin();
+ std::lock_guard<decltype(m_redundantEndpointsLock)> guard(
+ m_redundantEndpointsLock);
+ auto endpoint = m_redundantEndpoints.begin();
if (endpoint != m_redundantEndpoints.end()) {
TcrMessagePeriodicAck request(
new DataOutput(
@@ -1277,7 +1276,8 @@ bool ThinClientRedundancyManager::checkDupAndAdd(
}
void ThinClientRedundancyManager::netDown() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_redundantEndpointsLock);
+ std::lock_guard<decltype(m_redundantEndpointsLock)> guard(
+ m_redundantEndpointsLock);
if (!m_poolHADM) {
m_nonredundantEndpoints.insert(m_nonredundantEndpoints.end(),
@@ -1288,13 +1288,15 @@ void ThinClientRedundancyManager::netDown() {
}
void ThinClientRedundancyManager::removeCallbackConnection(TcrEndpoint* ep) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_redundantEndpointsLock);
+ std::lock_guard<decltype(m_redundantEndpointsLock)> guard(
+ m_redundantEndpointsLock);
ep->unregisterDM(false, nullptr, true);
}
GfErrType ThinClientRedundancyManager::sendRequestToPrimary(
TcrMessage& request, TcrMessageReply& reply) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_redundantEndpointsLock);
+ std::lock_guard<decltype(m_redundantEndpointsLock)> guard(
+ m_redundantEndpointsLock);
GfErrType err = GF_NOTCON;
for (size_t count = 0;
count <= m_redundantEndpoints.size() + m_nonredundantEndpoints.size();
diff --git a/cppcache/src/ThinClientRedundancyManager.hpp b/cppcache/src/ThinClientRedundancyManager.hpp
index 11cb1a8..39e1bce 100644
--- a/cppcache/src/ThinClientRedundancyManager.hpp
+++ b/cppcache/src/ThinClientRedundancyManager.hpp
@@ -20,7 +20,9 @@
#ifndef GEODE_THINCLIENTREDUNDANCYMANAGER_H_
#define GEODE_THINCLIENTREDUNDANCYMANAGER_H_
+#include <chrono>
#include <list>
+#include <mutex>
#include <set>
#include <string>
@@ -69,19 +71,20 @@ class ThinClientRedundancyManager {
void startPeriodicAck();
bool checkDupAndAdd(std::shared_ptr<EventId> eventid);
void netDown();
- void acquireRedundancyLock() { m_redundantEndpointsLock.acquire_read(); }
- void releaseRedundancyLock() { m_redundantEndpointsLock.release(); }
+ void acquireRedundancyLock() { m_redundantEndpointsLock.lock(); }
+ void releaseRedundancyLock() { m_redundantEndpointsLock.unlock(); }
bool allEndPointDiscon() { return m_IsAllEpDisCon; }
void removeCallbackConnection(TcrEndpoint*);
- ACE_Recursive_Thread_Mutex& getRedundancyLock() {
- return m_redundantEndpointsLock;
- }
+ std::recursive_mutex& getRedundancyLock() { return m_redundantEndpointsLock; }
GfErrType sendRequestToPrimary(TcrMessage& request, TcrMessageReply& reply);
bool isSentReadyForEvents() const { return m_sentReadyForEvents; }
private:
+ using clock = std::chrono::steady_clock;
+ using time_point = clock::time_point;
+
// for selectServers
volatile bool m_IsAllEpDisCon;
int m_server;
@@ -91,7 +94,7 @@ class ThinClientRedundancyManager {
ThinClientPoolHADM* m_poolHADM;
std::vector<TcrEndpoint*> m_redundantEndpoints;
std::vector<TcrEndpoint*> m_nonredundantEndpoints;
- ACE_Recursive_Thread_Mutex m_redundantEndpointsLock;
+ std::recursive_mutex m_redundantEndpointsLock;
TcrConnectionManager* m_theTcrConnManager;
std::shared_ptr<CacheableStringArray> m_locators;
std::shared_ptr<CacheableStringArray> m_servers;
@@ -129,8 +132,8 @@ class ThinClientRedundancyManager {
// and/or expiry
int periodicAck(volatile bool& isRunning);
void doPeriodicAck();
- ACE_Time_Value m_nextAck; // next ack time
- ACE_Time_Value m_nextAckInc; // next ack time increment
+ time_point m_nextAck; // next ack time
+ std::chrono::milliseconds m_nextAckInc; // next ack time increment
volatile bool m_HAenabled;
EventIdMap m_eventidmap;
diff --git a/cppcache/src/ThinClientRegion.cpp b/cppcache/src/ThinClientRegion.cpp
index ffe9a44..0dbc90f 100644
--- a/cppcache/src/ThinClientRegion.cpp
+++ b/cppcache/src/ThinClientRegion.cpp
@@ -51,7 +51,7 @@ namespace client {
static const std::regex PREDICATE_IS_FULL_QUERY_REGEX(
"^\\s*(?:select|import)\\b", std::regex::icase);
-void setTSSExceptionMessage(const char* exMsg);
+void setThreadLocalExceptionMessage(const char* exMsg);
class PutAllWork : public PooledWork<GfErrType>,
private NonCopyable,
@@ -102,13 +102,12 @@ class PutAllWork : public PooledWork<GfErrType>,
m_reply = new TcrMessageReply(true, m_poolDM);
// create new instanceof VCOPL
- ACE_Recursive_Thread_Mutex responseLock;
+ std::recursive_mutex responseLock;
m_verObjPartListPtr = std::make_shared<VersionedCacheableObjectPartList>(
keys.get(), responseLock);
if (m_poolDM->isMultiUserMode()) {
- m_userAttribute = TSSUserAttributesWrapper::s_geodeTSSUserAttributes
- ->getUserAttributes();
+ m_userAttribute = UserAttributes::threadLocalUserAttributes;
}
m_request->setTimeout(m_timeout);
@@ -245,13 +244,12 @@ class RemoveAllWork : public PooledWork<GfErrType>,
*keys, m_aCallbackArgument, m_poolDM);
m_reply = new TcrMessageReply(true, m_poolDM);
// create new instanceof VCOPL
- ACE_Recursive_Thread_Mutex responseLock;
+ std::recursive_mutex responseLock;
m_verObjPartListPtr = std::make_shared<VersionedCacheableObjectPartList>(
keys.get(), responseLock);
if (m_poolDM->isMultiUserMode()) {
- m_userAttribute = TSSUserAttributesWrapper::s_geodeTSSUserAttributes
- ->getUserAttributes();
+ m_userAttribute = UserAttributes::threadLocalUserAttributes;
}
m_resultCollector = new ChunkedRemoveAllResponse(
@@ -1234,7 +1232,7 @@ GfErrType ThinClientRegion::getAllNoThrow_remote(
aCallbackArgument); // now we need to initialize later
TcrMessageReply reply(true, m_tcrdm);
- ACE_Recursive_Thread_Mutex responseLock;
+ std::recursive_mutex responseLock;
// need to check
TcrChunkedResult* resultCollector(new ChunkedGetAllResponse(
reply, this, keys, values, exceptions, resultKeys, updateCountMap,
@@ -1439,7 +1437,7 @@ GfErrType ThinClientRegion::singleHopPutAllNoThrow_remote(
* versions. C. ToDO:: what if the value in the resultMap is of type
* PutAllPartialResultServerException
*/
- ACE_Recursive_Thread_Mutex responseLock;
+ std::recursive_mutex responseLock;
auto result = std::make_shared<PutAllPartialResult>(
static_cast<int>(map.size()), responseLock);
LOGDEBUG(
@@ -1608,7 +1606,7 @@ GfErrType ThinClientRegion::multiHopPutAllNoThrow_remote(
request.setTimeout(timeout);
reply.setTimeout(timeout);
- ACE_Recursive_Thread_Mutex responseLock;
+ std::recursive_mutex responseLock;
versionedObjPartList =
std::make_shared<VersionedCacheableObjectPartList>(this, responseLock);
// need to check
@@ -1794,7 +1792,7 @@ GfErrType ThinClientRegion::singleHopRemoveAllNoThrow_remote(
* versions. C. ToDO:: what if the value in the resultMap is of type
* PutAllPartialResultServerException
*/
- ACE_Recursive_Thread_Mutex responseLock;
+ std::recursive_mutex responseLock;
auto result = std::make_shared<PutAllPartialResult>(
static_cast<int>(keys.size()), responseLock);
LOGDEBUG(
@@ -1943,7 +1941,7 @@ GfErrType ThinClientRegion::multiHopRemoveAllNoThrow_remote(
this, keys, aCallbackArgument, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
- ACE_Recursive_Thread_Mutex responseLock;
+ std::recursive_mutex responseLock;
versionedObjPartList =
std::make_shared<VersionedCacheableObjectPartList>(this, responseLock);
// need to check
@@ -2261,7 +2259,7 @@ GfErrType ThinClientRegion::registerKeysNoThrow(
CHECK_DESTROY_PENDING_NOTHROW(TryReadGuard);
GfErrType err = GF_NOERR;
- ACE_Guard<ACE_Recursive_Thread_Mutex> keysGuard(m_keysLock);
+ std::lock_guard<decltype(m_keysLock)> keysGuard(m_keysLock);
if (keys.empty()) {
return err;
}
@@ -2281,7 +2279,7 @@ GfErrType ThinClientRegion::registerKeysNoThrow(
new DataOutput(m_cacheImpl->createDataOutput()), this, keys, isDurable,
getAttributes().getCachingEnabled(), receiveValues, interestPolicy,
m_tcrdm);
- ACE_Recursive_Thread_Mutex responseLock;
+ std::recursive_mutex responseLock;
TcrChunkedResult* resultCollector = nullptr;
if (interestPolicy.ordinal == InterestResultPolicy::KEYS_VALUES.ordinal) {
auto values = std::make_shared<HashMapOfCacheable>();
@@ -2332,7 +2330,7 @@ GfErrType ThinClientRegion::unregisterKeysNoThrow(
RegionGlobalLocks acquireLocksFailover(this);
CHECK_DESTROY_PENDING_NOTHROW(TryReadGuard);
GfErrType err = GF_NOERR;
- ACE_Guard<ACE_Recursive_Thread_Mutex> keysGuard(m_keysLock);
+ std::lock_guard<decltype(m_keysLock)> keysGuard(m_keysLock);
TcrMessageReply reply(true, m_tcrdm);
if (keys.empty()) {
return err;
@@ -2368,7 +2366,7 @@ GfErrType ThinClientRegion::unregisterKeysNoThrowLocalDestroy(
RegionGlobalLocks acquireLocksRedundancy(this, false);
RegionGlobalLocks acquireLocksFailover(this);
GfErrType err = GF_NOERR;
- ACE_Guard<ACE_Recursive_Thread_Mutex> keysGuard(m_keysLock);
+ std::lock_guard<decltype(m_keysLock)> keysGuard(m_keysLock);
TcrMessageReply reply(true, m_tcrdm);
if (keys.empty()) {
return err;
@@ -2420,7 +2418,7 @@ GfErrType ThinClientRegion::registerRegexNoThrow(
GfErrType err = GF_NOERR;
bool allKeys = (regex == ".*");
- ACE_Guard<ACE_Recursive_Thread_Mutex> keysGuard(m_keysLock);
+ std::lock_guard<decltype(m_keysLock)> keysGuard(m_keysLock);
if (attemptFailover) {
if ((isDurable &&
@@ -2459,7 +2457,7 @@ GfErrType ThinClientRegion::registerRegexNoThrow(
new DataOutput(m_cacheImpl->createDataOutput()), m_fullPath,
regex.c_str(), interestPolicy, isDurable,
getAttributes().getCachingEnabled(), receiveValues, m_tcrdm);
- ACE_Recursive_Thread_Mutex responseLock;
+ std::recursive_mutex responseLock;
if (reply == nullptr) {
TcrMessageReply replyLocal(true, m_tcrdm);
auto values = std::make_shared<HashMapOfCacheable>();
@@ -2551,7 +2549,7 @@ GfErrType ThinClientRegion::unregisterRegexNoThrow(const std::string& regex,
GfErrType ThinClientRegion::findRegex(const std::string& regex) {
GfErrType err = GF_NOERR;
- ACE_Guard<ACE_Recursive_Thread_Mutex> keysGuard(m_keysLock);
+ std::lock_guard<decltype(m_keysLock)> keysGuard(m_keysLock);
if (m_interestListRegex.find(regex) == m_interestListRegex.end() &&
m_durableInterestListRegex.find(regex) ==
@@ -2567,7 +2565,7 @@ GfErrType ThinClientRegion::findRegex(const std::string& regex) {
}
void ThinClientRegion::clearRegex(const std::string& regex) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> keysGuard(m_keysLock);
+ std::lock_guard<decltype(m_keysLock)> keysGuard(m_keysLock);
m_interestListRegex.erase(regex);
m_durableInterestListRegex.erase(regex);
m_interestListRegexForUpdatesAsInvalidates.erase(regex);
@@ -2642,11 +2640,11 @@ void ThinClientRegion::addRegex(const std::string& regex, bool isDurable,
std::vector<std::shared_ptr<CacheableKey>> ThinClientRegion::getInterestList()
const {
- ThinClientRegion* nthis = const_cast<ThinClientRegion*>(this);
+ auto nthis = const_cast<ThinClientRegion*>(this);
RegionGlobalLocks acquireLocksRedundancy(nthis, false);
RegionGlobalLocks acquireLocksFailover(nthis);
CHECK_DESTROY_PENDING(TryReadGuard, getInterestList);
- ACE_Guard<ACE_Recursive_Thread_Mutex> keysGuard(nthis->m_keysLock);
+ std::lock_guard<decltype(m_keysLock)> keysGuard(nthis->m_keysLock);
std::vector<std::shared_ptr<CacheableKey>> vlist;
@@ -2665,11 +2663,11 @@ std::vector<std::shared_ptr<CacheableKey>> ThinClientRegion::getInterestList()
}
std::vector<std::shared_ptr<CacheableString>>
ThinClientRegion::getInterestListRegex() const {
- ThinClientRegion* nthis = const_cast<ThinClientRegion*>(this);
+ auto nthis = const_cast<ThinClientRegion*>(this);
RegionGlobalLocks acquireLocksRedundancy(nthis, false);
RegionGlobalLocks acquireLocksFailover(nthis);
CHECK_DESTROY_PENDING(TryReadGuard, getInterestListRegex);
- ACE_Guard<ACE_Recursive_Thread_Mutex> keysGuard(nthis->m_keysLock);
+ std::lock_guard<decltype(m_keysLock)> keysGuard(nthis->m_keysLock);
std::vector<std::shared_ptr<CacheableString>> vlist;
@@ -2769,7 +2767,7 @@ GfErrType ThinClientRegion::clientNotificationHandler(TcrMessage& msg) {
GfErrType ThinClientRegion::handleServerException(const char* func,
const char* exceptionMsg) {
GfErrType error = GF_NOERR;
- setTSSExceptionMessage(exceptionMsg);
+ setThreadLocalExceptionMessage(exceptionMsg);
if (strstr(exceptionMsg,
"org.apache.geode.security.NotAuthorizedException") != nullptr) {
error = GF_NOT_AUTHORIZED_EXCEPTION;
@@ -3165,9 +3163,8 @@ bool ThinClientRegion::executeFunctionSH(
std::shared_ptr<CacheableHashSet>& failedNodes,
std::chrono::milliseconds timeout, bool allBuckets) {
bool reExecute = false;
- auto resultCollectorLock = std::make_shared<ACE_Recursive_Thread_Mutex>();
- const auto& userAttr =
- TSSUserAttributesWrapper::s_geodeTSSUserAttributes->getUserAttributes();
+ auto resultCollectorLock = std::make_shared<std::recursive_mutex>();
+ const auto& userAttr = UserAttributes::threadLocalUserAttributes;
std::vector<std::shared_ptr<OnRegionFunctionExecution>> feWorkers;
auto* threadPool =
CacheRegionHelper::getCacheImpl(&getCache())->getThreadPool();
@@ -3209,7 +3206,8 @@ bool ThinClientRegion::executeFunctionSH(
}
worker->getResultCollector()->reset();
{
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(*resultCollectorLock);
+ std::lock_guard<decltype(*resultCollectorLock)> guard(
+ *resultCollectorLock);
rc->clearResults();
}
std::shared_ptr<CacheableHashSet> failedNodeIds(
@@ -3235,7 +3233,8 @@ bool ThinClientRegion::executeFunctionSH(
}
worker->getResultCollector()->reset();
{
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(*resultCollectorLock);
+ std::lock_guard<decltype(*resultCollectorLock)> guard(
+ *resultCollectorLock);
rc->clearResults();
}
} else {
@@ -3712,7 +3711,8 @@ void ChunkedFunctionExecutionResponse::handleChunk(
result = value;
}
if (m_resultCollectorLock) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(*m_resultCollectorLock);
+ std::lock_guard<decltype(*m_resultCollectorLock)> guard(
+ *m_resultCollectorLock);
m_rc->addResult(result);
} else {
m_rc->addResult(result);
@@ -3806,7 +3806,7 @@ void ChunkedPutAllResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
if (chunkType == TcrMessageHelper::ChunkObjectType::OBJECT) {
LOGDEBUG("ChunkedPutAllResponse::handleChunk object");
- ACE_Recursive_Thread_Mutex responseLock;
+ std::recursive_mutex responseLock;
auto vcObjPart = std::make_shared<VersionedCacheableObjectPartList>(
dynamic_cast<ThinClientRegion*>(m_region.get()),
m_msg.getChunkedResultHandler()->getEndpointMemId(), responseLock);
@@ -3864,7 +3864,7 @@ void ChunkedRemoveAllResponse::handleChunk(const uint8_t* chunk,
if (chunkType == TcrMessageHelper::ChunkObjectType::OBJECT) {
LOGDEBUG("ChunkedRemoveAllResponse::handleChunk object");
- ACE_Recursive_Thread_Mutex responseLock;
+ std::recursive_mutex responseLock;
auto vcObjPart = std::make_shared<VersionedCacheableObjectPartList>(
dynamic_cast<ThinClientRegion*>(m_region.get()),
m_msg.getChunkedResultHandler()->getEndpointMemId(), responseLock);
@@ -3912,7 +3912,7 @@ void ChunkedDurableCQListResponse::handleChunk(const uint8_t* chunk,
if (!input.readBoolean()) {
// we're currently always expecting an object
char exMsg[256];
- ACE_OS::snprintf(
+ std::snprintf(
exMsg, 255,
"ChunkedDurableCQListResponse::handleChunk: part is not object");
throw MessageException(exMsg);
diff --git a/cppcache/src/ThinClientRegion.hpp b/cppcache/src/ThinClientRegion.hpp
index b039ee5..2f00550 100644
--- a/cppcache/src/ThinClientRegion.hpp
+++ b/cppcache/src/ThinClientRegion.hpp
@@ -20,8 +20,11 @@
#ifndef GEODE_THINCLIENTREGION_H_
#define GEODE_THINCLIENTREGION_H_
+#include <mutex>
#include <unordered_map>
+#include <ace/RW_Thread_Mutex.h>
+#include <ace/Semaphore.h>
#include <ace/Task.h>
#include <geode/ResultCollector.hpp>
@@ -35,9 +38,6 @@
#include "TcrChunkedContext.hpp"
#include "TcrEndpoint.hpp"
#include "TcrMessage.hpp"
-/**
- * @file
- */
namespace apache {
namespace geode {
@@ -52,7 +52,6 @@ class ThinClientBaseDM;
* region. It will inherit from DistributedRegion and overload some methods
*
*/
-
class APACHE_GEODE_EXPORT ThinClientRegion : public LocalRegion {
public:
/**
@@ -285,7 +284,7 @@ class APACHE_GEODE_EXPORT ThinClientRegion : public LocalRegion {
bool isDurableClient() { return m_isDurableClnt; }
/** @brief Protected fields. */
ThinClientBaseDM* m_tcrdm;
- ACE_Recursive_Thread_Mutex m_keysLock;
+ std::recursive_mutex m_keysLock;
mutable ACE_RW_Thread_Mutex m_rwDestroyLock;
std::unordered_map<std::shared_ptr<CacheableKey>, InterestResultPolicy>
m_interestList;
@@ -470,7 +469,7 @@ class ChunkedFunctionExecutionResponse : public TcrChunkedResult {
// std::shared_ptr<CacheableVector> m_functionExecutionResults;
bool m_getResult;
std::shared_ptr<ResultCollector> m_rc;
- std::shared_ptr<ACE_Recursive_Thread_Mutex> m_resultCollectorLock;
+ std::shared_ptr<std::recursive_mutex> m_resultCollectorLock;
// disabled
ChunkedFunctionExecutionResponse(const ChunkedFunctionExecutionResponse&);
@@ -484,7 +483,7 @@ class ChunkedFunctionExecutionResponse : public TcrChunkedResult {
inline ChunkedFunctionExecutionResponse(
TcrMessage& msg, bool getResult, std::shared_ptr<ResultCollector> rc,
- const std::shared_ptr<ACE_Recursive_Thread_Mutex>& resultCollectorLock)
+ const std::shared_ptr<std::recursive_mutex>& resultCollectorLock)
: TcrChunkedResult(),
m_msg(msg),
m_getResult(getResult),
@@ -526,7 +525,7 @@ class ChunkedGetAllResponse : public TcrChunkedResult {
int32_t m_destroyTracker;
bool m_addToLocalCache;
uint32_t m_keysOffset;
- ACE_Recursive_Thread_Mutex& m_responseLock;
+ std::recursive_mutex& m_responseLock;
// disabled
ChunkedGetAllResponse(const ChunkedGetAllResponse&);
ChunkedGetAllResponse& operator=(const ChunkedGetAllResponse&);
@@ -540,7 +539,7 @@ class ChunkedGetAllResponse : public TcrChunkedResult {
const std::shared_ptr<std::vector<std::shared_ptr<CacheableKey>>>&
resultKeys,
MapOfUpdateCounters& trackerMap, int32_t destroyTracker,
- bool addToLocalCache, ACE_Recursive_Thread_Mutex& responseLock)
+ bool addToLocalCache, std::recursive_mutex& responseLock)
: TcrChunkedResult(),
m_msg(msg),
m_region(region),
@@ -567,7 +566,7 @@ class ChunkedGetAllResponse : public TcrChunkedResult {
return m_resultKeys;
}
MapOfUpdateCounters& getUpdateCounters() { return m_trackerMap; }
- ACE_Recursive_Thread_Mutex& getResponseLock() { return m_responseLock; }
+ std::recursive_mutex& getResponseLock() { return m_responseLock; }
};
/**
@@ -577,7 +576,7 @@ class ChunkedPutAllResponse : public TcrChunkedResult {
private:
TcrMessage& m_msg;
const std::shared_ptr<Region> m_region;
- ACE_Recursive_Thread_Mutex& m_responseLock;
+ std::recursive_mutex& m_responseLock;
std::shared_ptr<VersionedCacheableObjectPartList> m_list;
// disabled
ChunkedPutAllResponse(const ChunkedPutAllResponse&);
@@ -586,7 +585,7 @@ class ChunkedPutAllResponse : public TcrChunkedResult {
public:
inline ChunkedPutAllResponse(
const std::shared_ptr<Region>& region, TcrMessage& msg,
- ACE_Recursive_Thread_Mutex& responseLock,
+ std::recursive_mutex& responseLock,
std::shared_ptr<VersionedCacheableObjectPartList>& list)
: TcrChunkedResult(),
m_msg(msg),
@@ -599,7 +598,7 @@ class ChunkedPutAllResponse : public TcrChunkedResult {
const CacheImpl* cacheImpl);
virtual void reset();
std::shared_ptr<VersionedCacheableObjectPartList> getList() { return m_list; }
- ACE_Recursive_Thread_Mutex& getResponseLock() { return m_responseLock; }
+ std::recursive_mutex& getResponseLock() { return m_responseLock; }
};
/**
@@ -609,7 +608,7 @@ class ChunkedRemoveAllResponse : public TcrChunkedResult {
private:
TcrMessage& m_msg;
const std::shared_ptr<Region> m_region;
- ACE_Recursive_Thread_Mutex& m_responseLock;
+ std::recursive_mutex& m_responseLock;
std::shared_ptr<VersionedCacheableObjectPartList> m_list;
// disabled
ChunkedRemoveAllResponse(const ChunkedRemoveAllResponse&);
@@ -618,7 +617,7 @@ class ChunkedRemoveAllResponse : public TcrChunkedResult {
public:
inline ChunkedRemoveAllResponse(
const std::shared_ptr<Region>& region, TcrMessage& msg,
- ACE_Recursive_Thread_Mutex& responseLock,
+ std::recursive_mutex& responseLock,
std::shared_ptr<VersionedCacheableObjectPartList>& list)
: TcrChunkedResult(),
m_msg(msg),
@@ -631,7 +630,7 @@ class ChunkedRemoveAllResponse : public TcrChunkedResult {
const CacheImpl* cacheImpl);
virtual void reset();
std::shared_ptr<VersionedCacheableObjectPartList> getList() { return m_list; }
- ACE_Recursive_Thread_Mutex& getResponseLock() { return m_responseLock; }
+ std::recursive_mutex& getResponseLock() { return m_responseLock; }
};
/**
diff --git a/cppcache/src/ThinClientStickyManager.cpp b/cppcache/src/ThinClientStickyManager.cpp
index debc020..8474641 100644
--- a/cppcache/src/ThinClientStickyManager.cpp
+++ b/cppcache/src/ThinClientStickyManager.cpp
@@ -25,7 +25,6 @@ bool ThinClientStickyManager::getStickyConnection(
std::set<ServerLocation>& excludeServers, bool forTransaction) {
bool maxConnLimit = false;
bool connFound = false;
- // ACE_Guard<ACE_Recursive_Thread_Mutex> guard( m_stickyLock );
conn = (*TssConnectionWrapper::s_geodeTSSConn)->getConnection();
if (!conn) {
@@ -58,7 +57,7 @@ void ThinClientStickyManager::getSingleHopStickyConnection(
}
void ThinClientStickyManager::addStickyConnection(TcrConnection* conn) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_stickyLock);
+ std::lock_guard<decltype(m_stickyLock)> keysGuard(m_stickyLock);
TcrConnection* oldConn =
(*TssConnectionWrapper::s_geodeTSSConn)->getConnection();
if (oldConn) {
@@ -86,9 +85,8 @@ void ThinClientStickyManager::addStickyConnection(TcrConnection* conn) {
void ThinClientStickyManager::setStickyConnection(TcrConnection* conn,
bool forTransaction) {
- // ACE_Guard<ACE_Recursive_Thread_Mutex> guard( m_stickyLock );
if (!conn) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_stickyLock);
+ std::lock_guard<decltype(m_stickyLock)> keysGuard(m_stickyLock);
(*TssConnectionWrapper::s_geodeTSSConn)
->setConnection(nullptr, m_dm->shared_from_this());
} else {
@@ -96,7 +94,7 @@ void ThinClientStickyManager::setStickyConnection(TcrConnection* conn,
(*TssConnectionWrapper::s_geodeTSSConn)->getConnection();
if (currentConn != conn) // otherwsie no need to set it again
{
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_stickyLock);
+ std::lock_guard<decltype(m_stickyLock)> keysGuard(m_stickyLock);
(*TssConnectionWrapper::s_geodeTSSConn)
->setConnection(conn, m_dm->shared_from_this());
conn->setAndGetBeingUsed(
@@ -120,7 +118,7 @@ void ThinClientStickyManager::setSingleHopStickyConnection(
void ThinClientStickyManager::cleanStaleStickyConnection() {
LOGDEBUG("Cleaning sticky connections");
std::set<ServerLocation> excludeServers;
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_stickyLock);
+ std::lock_guard<decltype(m_stickyLock)> keysGuard(m_stickyLock);
std::find_if(m_stickyConnList.begin(), m_stickyConnList.end(),
ThinClientStickyManager::isNULL);
while (1) {
@@ -159,7 +157,7 @@ void ThinClientStickyManager::cleanStaleStickyConnection() {
void ThinClientStickyManager::closeAllStickyConnections() {
LOGDEBUG("ThinClientStickyManager::closeAllStickyConnections()");
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_stickyLock);
+ std::lock_guard<decltype(m_stickyLock)> keysGuard(m_stickyLock);
for (std::set<TcrConnection**>::iterator it = m_stickyConnList.begin();
it != m_stickyConnList.end(); it++) {
TcrConnection** tempConn = *it;
@@ -173,10 +171,10 @@ void ThinClientStickyManager::closeAllStickyConnections() {
bool ThinClientStickyManager::canThisConnBeDeleted(TcrConnection* conn) {
bool canBeDeleted = false;
LOGDEBUG("ThinClientStickyManager::canThisConnBeDeleted()");
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_stickyLock);
+ std::lock_guard<decltype(m_stickyLock)> keysGuard(m_stickyLock);
if (m_dm->canItBeDeletedNoImpl(conn)) return true;
TcrEndpoint* endPt = conn->getEndpointObject();
- ACE_Guard<ACE_Recursive_Thread_Mutex> guardQueue(
+ std::lock_guard<decltype(endPt->getQueueHostedMutex())> guardQueue(
endPt->getQueueHostedMutex());
if (endPt->isQueueHosted()) {
for (std::set<TcrConnection**>::iterator it = m_stickyConnList.begin();
@@ -194,7 +192,7 @@ void ThinClientStickyManager::releaseThreadLocalConnection() {
TcrConnection* conn =
(*TssConnectionWrapper::s_geodeTSSConn)->getConnection();
if (conn) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_stickyLock);
+ std::lock_guard<decltype(m_stickyLock)> keysGuard(m_stickyLock);
std::set<TcrConnection**>::iterator it = m_stickyConnList.find(
(*TssConnectionWrapper::s_geodeTSSConn)->getConnDoublePtr());
LOGDEBUG("ThinClientStickyManager::releaseThreadLocalConnection()");
diff --git a/cppcache/src/ThinClientStickyManager.hpp b/cppcache/src/ThinClientStickyManager.hpp
index cd25998..ec02b8a 100644
--- a/cppcache/src/ThinClientStickyManager.hpp
+++ b/cppcache/src/ThinClientStickyManager.hpp
@@ -21,19 +21,21 @@
*/
#include <algorithm>
+#include <mutex>
#include <set>
#include <vector>
-#include <ace/Recursive_Thread_Mutex.h>
-
#include "TssConnectionWrapper.hpp"
+
namespace apache {
namespace geode {
namespace client {
+
class ThinClientPoolDM;
class ServerLocation;
class TcrConnection;
class TcrEndpoint;
+
class ThinClientStickyManager {
public:
explicit ThinClientStickyManager(ThinClientPoolDM* poolDM) : m_dm(poolDM) {}
@@ -56,8 +58,9 @@ class ThinClientStickyManager {
static bool isNULL(TcrConnection** conn);
ThinClientPoolDM* m_dm;
std::set<TcrConnection**> m_stickyConnList;
- ACE_Recursive_Thread_Mutex m_stickyLock;
+ std::recursive_mutex m_stickyLock;
};
+
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/ThreadPool.cpp b/cppcache/src/ThreadPool.cpp
index 2e21142..9921f7d 100644
--- a/cppcache/src/ThreadPool.cpp
+++ b/cppcache/src/ThreadPool.cpp
@@ -40,13 +40,13 @@ ThreadPoolWorker::~ThreadPoolWorker() { shutDown(); }
int ThreadPoolWorker::perform(ACE_Method_Request* req) {
ACE_TRACE(ACE_TEXT("Worker::perform"));
- return this->queue_.enqueue(req);
+ return queue_.enqueue(req);
}
int ThreadPoolWorker::svc(void) {
threadId_ = ACE_Thread::self();
while (1) {
- ACE_Method_Request* request = this->queue_.dequeue();
+ ACE_Method_Request* request = queue_.dequeue();
if (request == nullptr) {
shutDown();
break;
@@ -56,7 +56,7 @@ int ThreadPoolWorker::svc(void) {
request->call();
// Return to work.
- this->manager_->returnToWork(this);
+ manager_->returnToWork(this);
}
return 0;
}
@@ -74,18 +74,13 @@ int ThreadPoolWorker::shutDown(void) {
ACE_thread_t ThreadPoolWorker::threadId(void) { return threadId_; }
ThreadPool::ThreadPool(uint32_t threadPoolSize)
- : poolSize_(threadPoolSize),
- shutdown_(0),
- workersLock_(),
- workersCond_(workersLock_) {
+ : poolSize_(threadPoolSize), shutdown_(0) {
activate();
}
ThreadPool::~ThreadPool() { shutDown(); }
-int ThreadPool::perform(ACE_Method_Request* req) {
- return this->queue_.enqueue(req);
-}
+int ThreadPool::perform(ACE_Method_Request* req) { return queue_.enqueue(req); }
const char* ThreadPool::NC_Pool_Thread = "NC Pool Thread";
int ThreadPool::svc(void) {
@@ -94,13 +89,13 @@ int ThreadPool::svc(void) {
createWorkerPool();
while (!done()) {
// Get the next message
- ACE_Method_Request* request = this->queue_.dequeue();
+ ACE_Method_Request* request = queue_.dequeue();
if (request == nullptr) {
shutDown();
break;
}
// Choose a worker.
- ThreadPoolWorker* worker = chooseWorker();
+ auto worker = chooseWorker();
// Ask the worker to do the job.
worker->perform(request);
}
@@ -118,26 +113,28 @@ int ThreadPool::shutDown(void) {
}
int ThreadPool::returnToWork(ThreadPoolWorker* worker) {
- ACE_GUARD_RETURN(ACE_Thread_Mutex, workerMon, this->workersLock_, -1);
- this->workers_.enqueue_tail(worker);
- this->workersCond_.signal();
+ std::unique_lock<decltype(workersLock_)> lock(workersLock_);
+ workers_.push_back(worker);
+ workersCond_.notify_one();
return 0;
}
ThreadPoolWorker* ThreadPool::chooseWorker(void) {
- ACE_GUARD_RETURN(ACE_Thread_Mutex, workerMon, this->workersLock_, nullptr);
- while (this->workers_.is_empty()) workersCond_.wait();
- ThreadPoolWorker* worker;
- this->workers_.dequeue_head(worker);
+ std::unique_lock<decltype(workersLock_)> lock(workersLock_);
+ if (workers_.empty()) {
+ workersCond_.wait(lock, [this] { return !workers_.empty(); });
+ }
+ auto worker = workers_.front();
+ workers_.pop_front();
return worker;
}
int ThreadPool::createWorkerPool(void) {
- ACE_GUARD_RETURN(ACE_Thread_Mutex, worker_mon, this->workersLock_, -1);
+ std::unique_lock<decltype(workersLock_)> lock(workersLock_);
for (int i = 0; i < poolSize_; i++) {
ThreadPoolWorker* worker;
ACE_NEW_RETURN(worker, ThreadPoolWorker(this), -1);
- this->workers_.enqueue_tail(worker);
+ workers_.push_back(worker);
worker->activate();
}
return 0;
@@ -145,10 +142,6 @@ int ThreadPool::createWorkerPool(void) {
int ThreadPool::done(void) { return (shutdown_ == 1); }
-ACE_thread_t ThreadPool::threadId(ThreadPoolWorker* worker) {
- return worker->threadId();
-}
-
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/ThreadPool.hpp b/cppcache/src/ThreadPool.hpp
index 77f7754..73ddfc5 100644
--- a/cppcache/src/ThreadPool.hpp
+++ b/cppcache/src/ThreadPool.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_THREADPOOL_H_
-#define GEODE_THREADPOOL_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,23 +14,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * ThreadPool.hpp
- *
- * Created on: 16-Mar-2010
- * Author: ankurs
- */
-#include <ace/Method_Request.h>
-#include <ace/Task.h>
-//#include <ace/Future.h>
+#pragma once
+
+#ifndef GEODE_THREADPOOL_H_
+#define GEODE_THREADPOOL_H_
+
#include <condition_variable>
+#include <deque>
#include <mutex>
#include <ace/Activation_Queue.h>
-#include <ace/Condition_T.h>
-#include <ace/Guard_T.h>
+#include <ace/Method_Request.h>
+#include <ace/Recursive_Thread_Mutex.h>
#include <ace/Singleton.h>
+#include <ace/Task.h>
+
namespace apache {
namespace geode {
namespace client {
@@ -79,22 +73,6 @@ class PooledWork : public ACE_Method_Request {
virtual T execute(void) = 0;
};
-template <typename S, typename R = int>
-class PooledWorkFP : public PooledWork<R> {
- public:
- typedef R (S::*OPERATION)(void);
- PooledWorkFP(S* op_handler, OPERATION op)
- : op_handler_(op_handler), m_op(op) {}
- virtual ~PooledWorkFP() {}
-
- protected:
- virtual R execute(void) { return (this->op_handler_->*m_op)(); }
-
- private:
- S* op_handler_;
- OPERATION m_op;
-};
-
class ThreadPoolWorker;
class IThreadPool {
@@ -135,17 +113,17 @@ class ThreadPool : public ACE_Task_Base, IThreadPool {
ThreadPoolWorker* chooseWorker(void);
int createWorkerPool(void);
int done(void);
- ACE_thread_t threadId(ThreadPoolWorker* worker);
private:
int poolSize_;
int shutdown_;
- ACE_Thread_Mutex workersLock_;
- ACE_Condition<ACE_Thread_Mutex> workersCond_;
- ACE_Unbounded_Queue<ThreadPoolWorker*> workers_;
+ std::mutex workersLock_;
+ std::condition_variable workersCond_;
+ std::deque<ThreadPoolWorker*> workers_;
ACE_Activation_Queue queue_;
static const char* NC_Pool_Thread;
};
+
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/TimeoutTimer.hpp b/cppcache/src/TimeoutTimer.hpp
deleted file mode 100644
index 0925026..0000000
--- a/cppcache/src/TimeoutTimer.hpp
+++ /dev/null
@@ -1,73 +0,0 @@
-#pragma once
-
-#ifndef GEODE_TIMEOUTTIMER_H_
-#define GEODE_TIMEOUTTIMER_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 <ace/Condition_Recursive_Thread_Mutex.h>
-#include <ace/Condition_T.h>
-#include <ace/Guard_T.h>
-#include <ace/OS_NS_sys_time.h>
-#include <ace/Time_Value.h>
-
-#include <geode/internal/geode_globals.hpp>
-
-namespace apache {
-namespace geode {
-namespace client {
-
-class APACHE_GEODE_EXPORT TimeoutTimer {
- private:
- ACE_Recursive_Thread_Mutex m_mutex;
- ACE_Condition<ACE_Recursive_Thread_Mutex> m_cond;
- volatile bool m_reset;
-
- public:
- TimeoutTimer() : m_mutex(), m_cond(m_mutex), m_reset(false) {}
-
- /**
- * Return only after seconds have passed without receiving a reset.
- */
- void untilTimeout(int seconds) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_mutex);
-
- ACE_OS::last_error(0);
- while ((ACE_OS::last_error() != ETIME) || m_reset) {
- m_reset = false;
- ACE_Time_Value stopTime = ACE_OS::gettimeofday();
- stopTime += seconds;
- ACE_OS::last_error(0);
- m_cond.wait(&stopTime);
- }
- }
-
- /**
- * Reset the timeout interval so that it restarts now.
- */
- void reset() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_mutex);
- // m_cond.signal();
- m_reset = true;
- }
-};
-} // namespace client
-} // namespace geode
-} // namespace apache
-
-#endif // GEODE_TIMEOUTTIMER_H_
diff --git a/cppcache/src/TombstoneExpiryHandler.cpp b/cppcache/src/TombstoneExpiryHandler.cpp
index 6a7acc4..72e9f7a 100644
--- a/cppcache/src/TombstoneExpiryHandler.cpp
+++ b/cppcache/src/TombstoneExpiryHandler.cpp
@@ -14,18 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "TombstoneExpiryHandler.hpp"
+#include <ace/Reactor.h>
+#include <ace/Timer_Heap.h>
+#include <ace/Timer_Heap_T.h>
+#include <ace/Timer_Queue.h>
+#include <ace/Timer_Queue_Adapters.h>
+#include <ace/svc_export.h>
+
#include "CacheImpl.hpp"
#include "ExpiryTaskManager.hpp"
#include "MapEntry.hpp"
#include "RegionInternal.hpp"
-#include "ace/Reactor.h"
-#include "ace/Timer_Heap.h"
-#include "ace/Timer_Heap_T.h"
-#include "ace/Timer_Queue.h"
-#include "ace/Timer_Queue_Adapters.h"
-#include "ace/svc_export.h"
namespace apache {
namespace geode {
@@ -39,31 +41,33 @@ TombstoneExpiryHandler::TombstoneExpiryHandler(
m_cacheImpl(cacheImpl),
m_tombstoneList(tombstoneList) {}
-int TombstoneExpiryHandler::handle_timeout(const ACE_Time_Value& current_time,
- const void*) {
+int TombstoneExpiryHandler::handle_timeout(const ACE_Time_Value&, const void*) {
std::shared_ptr<CacheableKey> key;
m_entryPtr->getEntry()->getKeyI(key);
auto creationTime = m_entryPtr->getTombstoneCreationTime();
- auto curr_time = static_cast<int64_t>(current_time.get_msec());
+ auto curr_time = TombstoneEntry::clock::now();
auto expiryTaskId = m_entryPtr->getExpiryTaskId();
- auto sec = curr_time - creationTime - m_duration.count();
+ auto sec = curr_time - creationTime - m_duration;
try {
+ using apache::geode::internal::chrono::duration::to_string;
LOGDEBUG(
"Entered entry expiry task handler for tombstone of key [%s]: "
- "%lld,%lld,%d,%lld",
- Utils::nullSafeToString(key).c_str(), curr_time, creationTime,
- m_duration.count(), sec);
- if (sec >= 0) {
+ "%s,%s,%s,%s",
+ Utils::nullSafeToString(key).c_str(),
+ to_string(curr_time.time_since_epoch()).c_str(),
+ to_string(creationTime.time_since_epoch()).c_str(),
+ to_string(m_duration).c_str(), to_string(sec).c_str());
+ if (sec >= std::chrono::seconds::zero()) {
DoTheExpirationAction(key);
} else {
// reset the task after
// (lastAccessTime + entryExpiryDuration - curr_time) in seconds
LOGDEBUG(
- "Resetting expiry task %d secs later for key "
+ "Resetting expiry task %s later for key "
"[%s]",
- -sec / 1000 + 1, Utils::nullSafeToString(key).c_str());
+ to_string(-sec).c_str(), Utils::nullSafeToString(key).c_str());
m_cacheImpl->getExpiryTaskManager().resetTask(
- m_entryPtr->getExpiryTaskId(), uint32_t(-sec / 1000 + 1));
+ m_entryPtr->getExpiryTaskId(), -sec);
return 0;
}
} catch (...) {
diff --git a/cppcache/src/TombstoneList.cpp b/cppcache/src/TombstoneList.cpp
index a3eb9c3..211d95d 100644
--- a/cppcache/src/TombstoneList.cpp
+++ b/cppcache/src/TombstoneList.cpp
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "TombstoneList.hpp"
#include <unordered_map>
@@ -46,9 +47,8 @@ ExpiryTaskManager::id_type TombstoneList::getExpiryTask(
auto duration = m_cacheImpl->getDistributedSystem()
.getSystemProperties()
.tombstoneTimeout();
- ACE_Time_Value currTime(ACE_OS::gettimeofday());
- auto tombstoneEntryPtr = std::make_shared<TombstoneEntry>(
- nullptr, static_cast<int64_t>(currTime.get_msec()));
+
+ auto tombstoneEntryPtr = std::make_shared<TombstoneEntry>(nullptr);
*handler = new TombstoneExpiryHandler(tombstoneEntryPtr, this, duration,
m_cacheImpl);
tombstoneEntryPtr->setHandler(*handler);
@@ -61,11 +61,8 @@ void TombstoneList::add(const std::shared_ptr<MapEntryImpl>& entry,
TombstoneExpiryHandler* handler,
ExpiryTaskManager::id_type taskid) {
// This function is not guarded as all functions of this class are called from
- // MapSegment
- // read TombstoneTImeout from systemProperties.
- ACE_Time_Value currTime(ACE_OS::gettimeofday());
- auto tombstoneEntryPtr = std::make_shared<TombstoneEntry>(
- entry, static_cast<int64_t>(currTime.get_msec()));
+ // MapSegment read TombstoneTImeout from systemProperties.
+ auto tombstoneEntryPtr = std::make_shared<TombstoneEntry>(entry);
handler->setTombstoneEntry(tombstoneEntryPtr);
tombstoneEntryPtr->setHandler(handler);
std::shared_ptr<CacheableKey> key;
diff --git a/cppcache/src/TombstoneList.hpp b/cppcache/src/TombstoneList.hpp
index 7feed98..99b8fe2 100644
--- a/cppcache/src/TombstoneList.hpp
+++ b/cppcache/src/TombstoneList.hpp
@@ -20,13 +20,11 @@
#ifndef GEODE_TOMBSTONELIST_H_
#define GEODE_TOMBSTONELIST_H_
+#include <chrono>
#include <list>
#include <memory>
#include <unordered_map>
-#include <ace/Guard_T.h>
-#include <ace/Recursive_Thread_Mutex.h>
-
#include <geode/CacheableBuiltins.hpp>
#include <geode/internal/functional.hpp>
@@ -35,19 +33,23 @@
namespace apache {
namespace geode {
namespace client {
+
class MapSegment;
class TombstoneExpiryHandler;
+
class TombstoneEntry {
public:
- TombstoneEntry(const std::shared_ptr<MapEntryImpl>& entry,
- int64_t tombstoneCreationTime)
+ using clock = std::chrono::steady_clock;
+ using time_point = clock::time_point;
+
+ explicit TombstoneEntry(const std::shared_ptr<MapEntryImpl>& entry)
: m_entry(entry),
- m_tombstoneCreationTime(tombstoneCreationTime),
+ m_tombstoneCreationTime(TombstoneEntry::clock::now()),
m_expiryTaskId(0),
m_handler(nullptr) {}
virtual ~TombstoneEntry() {}
std::shared_ptr<MapEntryImpl> getEntry() { return m_entry; }
- int64_t getTombstoneCreationTime() { return m_tombstoneCreationTime; }
+ time_point getTombstoneCreationTime() { return m_tombstoneCreationTime; }
ExpiryTaskManager::id_type getExpiryTaskId() { return m_expiryTaskId; }
void setExpiryTaskId(ExpiryTaskManager::id_type expiryTaskId) {
m_expiryTaskId = expiryTaskId;
@@ -57,7 +59,7 @@ class TombstoneEntry {
private:
std::shared_ptr<MapEntryImpl> m_entry;
- int64_t m_tombstoneCreationTime;
+ time_point m_tombstoneCreationTime;
ExpiryTaskManager::id_type m_expiryTaskId;
TombstoneExpiryHandler* m_handler;
};
@@ -94,11 +96,11 @@ class TombstoneList {
dereference_equal_to<std::shared_ptr<CacheableKey>>>
TombstoneMap;
TombstoneMap m_tombstoneMap;
- ACE_Recursive_Thread_Mutex m_queueLock;
MapSegment* m_mapSegment;
CacheImpl* m_cacheImpl;
friend class TombstoneExpiryHandler;
};
+
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/TssConnectionWrapper.hpp b/cppcache/src/TssConnectionWrapper.hpp
index 9d1a47d..8e01590 100644
--- a/cppcache/src/TssConnectionWrapper.hpp
+++ b/cppcache/src/TssConnectionWrapper.hpp
@@ -22,8 +22,6 @@
#include <map>
#include <string>
-#include <ace/TSS_T.h>
-
#include <geode/Pool.hpp>
#include "TcrEndpoint.hpp"
diff --git a/cppcache/src/UserAttributes.cpp b/cppcache/src/UserAttributes.cpp
index bcae70a..50b2549 100644
--- a/cppcache/src/UserAttributes.cpp
+++ b/cppcache/src/UserAttributes.cpp
@@ -34,12 +34,10 @@ UserAttributes::UserAttributes(std::shared_ptr<Properties> credentials,
bool UserAttributes::isCacheClosed() { return m_authenticatedView->isClosed(); }
UserAttributes::~UserAttributes() {
- std::map<std::string, UserConnectionAttributes*>::iterator it;
-
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_listLock);
- for (it = m_connectionAttr.begin(); it != m_connectionAttr.end(); it++) {
- UserConnectionAttributes* uca = (*it).second;
- if (uca != nullptr) {
+ std::lock_guard<decltype(m_listLock)> guard(m_listLock);
+ for (auto& it : m_connectionAttr) {
+ auto uca = it.second;
+ if (uca) {
_GEODE_SAFE_DELETE(uca);
}
}
@@ -47,19 +45,6 @@ UserAttributes::~UserAttributes() {
UserConnectionAttributes* UserAttributes::getConnectionAttribute() {
LOGDEBUG("UserConnectionAttributes* getConnectionAttribute().");
- if (m_connectionAttr.size() == 0) return nullptr;
-
- // std::map<std::string, UserConnectionAttributes*>::iterator it;
-
- // ACE_Guard< ACE_Recursive_Thread_Mutex > guard( m_listLock );
- /*for( it = m_connectionAttr.begin(); it != m_connectionAttr.end(); it++ )
- {
- UserConnectionAttributes* uca = &((*it).second);
- if (uca->isAuthenticated() && uca->getEndpoint()->connected())
- return uca;
- else
- uca->setUnAuthenticated();
- }*/
return nullptr;
}
@@ -71,9 +56,9 @@ void UserAttributes::unAuthenticateEP(TcrEndpoint* endpoint) {
// TODO: chk before returing whether endpoint is up or not
// std::map<std::string, UserConnectionAttributes>::iterator it;
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_listLock);
- UserConnectionAttributes* uca = m_connectionAttr[endpoint->name()];
- if (uca != nullptr) {
+ std::lock_guard<decltype(m_listLock)> guard(m_listLock);
+ auto uca = m_connectionAttr[endpoint->name()];
+ if (uca) {
m_connectionAttr.erase(endpoint->name());
_GEODE_SAFE_DELETE(uca);
}
@@ -91,15 +76,7 @@ UserConnectionAttributes* UserAttributes::getConnectionAttribute(
LOGDEBUG("UserConnectionAttributes* getConnectionAttribute with EP.");
if (m_connectionAttr.size() == 0) return nullptr;
- // std::map<std::string, UserConnectionAttributes>::iterator it;
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_listLock);
- /*for( it = m_connectionAttr.begin(); it != m_connectionAttr.end(); it++ )
- {
- UserConnectionAttributes* uca = &((*it).second);
- if (uca->isAuthenticated() && (uca->getEndpoint() == ep))
- return uca;
- }*/
-
+ std::lock_guard<decltype(m_listLock)> guard(m_listLock);
return m_connectionAttr[ep->name()];
}
@@ -108,9 +85,9 @@ bool UserAttributes::isEndpointAuthenticated(TcrEndpoint* ep) {
"UserAttributes::isEndpointAuthenticated: (TcrEndpoint* ep) with EP.");
if (m_connectionAttr.size() == 0) return false;
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_listLock);
- UserConnectionAttributes* uca = m_connectionAttr[ep->name()];
- if (uca != nullptr && uca->isAuthenticated() && (uca->getEndpoint() == ep)) {
+ std::lock_guard<decltype(m_listLock)> guard(m_listLock);
+ auto uca = m_connectionAttr[ep->name()];
+ if (uca && uca->isAuthenticated() && (uca->getEndpoint() == ep)) {
return true;
}
return false;
@@ -130,8 +107,8 @@ AuthenticatedView* UserAttributes::getAuthenticatedView() {
return m_authenticatedView;
}
-ACE_TSS<TSSUserAttributesWrapper>
- TSSUserAttributesWrapper::s_geodeTSSUserAttributes;
+thread_local std::shared_ptr<UserAttributes>
+ UserAttributes::threadLocalUserAttributes;
GuardUserAttributes::GuardUserAttributes(AuthenticatedView* authenticatedView) {
setAuthenticatedView(authenticatedView);
@@ -142,8 +119,8 @@ void GuardUserAttributes::setAuthenticatedView(
m_authenticatedView = authenticatedView;
LOGDEBUG("GuardUserAttributes::GuardUserAttributes:");
if (m_authenticatedView != nullptr && !authenticatedView->isClosed()) {
- TSSUserAttributesWrapper::s_geodeTSSUserAttributes->setUserAttributes(
- authenticatedView->m_userAttributes);
+ UserAttributes::threadLocalUserAttributes =
+ authenticatedView->m_userAttributes;
} else {
throw CacheClosedException("User Cache has been closed");
}
@@ -153,8 +130,7 @@ GuardUserAttributes::GuardUserAttributes() { m_authenticatedView = nullptr; }
GuardUserAttributes::~GuardUserAttributes() {
if (m_authenticatedView != nullptr) {
- TSSUserAttributesWrapper::s_geodeTSSUserAttributes->setUserAttributes(
- nullptr);
+ UserAttributes::threadLocalUserAttributes = nullptr;
}
}
diff --git a/cppcache/src/UserAttributes.hpp b/cppcache/src/UserAttributes.hpp
index da03bda..a75bd43 100644
--- a/cppcache/src/UserAttributes.hpp
+++ b/cppcache/src/UserAttributes.hpp
@@ -21,10 +21,9 @@
#define GEODE_USERATTRIBUTES_H_
#include <map>
+#include <mutex>
#include <string>
-#include <ace/TSS_T.h>
-
#include <geode/Properties.hpp>
#include <geode/internal/geode_globals.hpp>
@@ -33,8 +32,10 @@
namespace apache {
namespace geode {
namespace client {
+
class AuthenticatedView;
class ThinClientPoolDM;
+
class UserConnectionAttributes {
public:
UserConnectionAttributes(TcrEndpoint* endpoint, uint64_t id) {
@@ -71,7 +72,7 @@ class UserConnectionAttributes {
// UserConnectionAttributes & operator =(const UserConnectionAttributes &);
};
-class APACHE_GEODE_EXPORT UserAttributes {
+class UserAttributes {
// TODO: need to add lock here so that user should not be authenticated at two
// servers
public:
@@ -88,11 +89,9 @@ class APACHE_GEODE_EXPORT UserAttributes {
void setConnectionAttributes(TcrEndpoint* endpoint, uint64_t id) {
m_isUserAuthenticated = true;
- UserConnectionAttributes* ucb = new UserConnectionAttributes(endpoint, id);
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_listLock);
- // m_connectionAttr.push_back(ucb);
- std::string fullName(endpoint->name().c_str());
- m_connectionAttr[fullName] = ucb;
+ auto ucb = new UserConnectionAttributes(endpoint, id);
+ std::lock_guard<decltype(m_listLock)> guard(m_listLock);
+ m_connectionAttr[endpoint->name()] = ucb;
}
void unAuthenticateEP(TcrEndpoint* endpoint);
@@ -109,11 +108,12 @@ class APACHE_GEODE_EXPORT UserAttributes {
bool isEndpointAuthenticated(TcrEndpoint* ep);
+ static thread_local std::shared_ptr<UserAttributes> threadLocalUserAttributes;
+
private:
std::map<std::string, UserConnectionAttributes*> m_connectionAttr;
std::shared_ptr<Properties> m_credentials;
- // ThinClientPoolDM m_pool;
- ACE_Recursive_Thread_Mutex m_listLock;
+ std::recursive_mutex m_listLock;
bool m_isUserAuthenticated;
AuthenticatedView* m_authenticatedView;
std::shared_ptr<Pool> m_pool;
@@ -123,24 +123,6 @@ class APACHE_GEODE_EXPORT UserAttributes {
UserAttributes& operator=(const UserAttributes&);
};
-class TSSUserAttributesWrapper {
- private:
- std::shared_ptr<UserAttributes> m_userAttribute;
- TSSUserAttributesWrapper& operator=(const TSSUserAttributesWrapper&);
- TSSUserAttributesWrapper(const TSSUserAttributesWrapper&);
-
- public:
- static ACE_TSS<TSSUserAttributesWrapper> s_geodeTSSUserAttributes;
- std::shared_ptr<UserAttributes> getUserAttributes() {
- return m_userAttribute;
- }
- void setUserAttributes(std::shared_ptr<UserAttributes> userAttr) {
- m_userAttribute = userAttr;
- }
- TSSUserAttributesWrapper() : m_userAttribute(nullptr) {}
- ~TSSUserAttributesWrapper() {}
-};
-
class GuardUserAttributes {
public:
GuardUserAttributes();
@@ -154,6 +136,7 @@ class GuardUserAttributes {
private:
AuthenticatedView* m_authenticatedView;
};
+
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/Utils.cpp b/cppcache/src/Utils.cpp
index b816529..f8fa0ec 100644
--- a/cppcache/src/Utils.cpp
+++ b/cppcache/src/Utils.cpp
@@ -19,34 +19,25 @@
#include <chrono>
#include <cstdio>
+#include <cstdlib>
#include <iomanip>
#include <sstream>
#include <ace/INET_Addr.h>
#include <ace/OS.h>
-#include <ace/Recursive_Thread_Mutex.h>
namespace apache {
namespace geode {
namespace client {
int32_t Utils::getLastError() { return ACE_OS::last_error(); }
+
std::string Utils::getEnv(const char* varName) {
-#ifdef _WIN32
- DWORD dwRet;
- char varValue[8192];
- dwRet = ::GetEnvironmentVariable(varName, varValue, 8192);
- if (dwRet == 0 && (::GetLastError() == ERROR_ENVVAR_NOT_FOUND)) {
- return "";
- }
- return varValue;
-#else
- char* varValue = ACE_OS::getenv(varName);
- if (varValue == nullptr) {
- return "";
+ std::string env;
+ if (const auto varValue = std::getenv(varName)) {
+ env = varValue;
}
- return varValue;
-#endif
+ return env;
}
void Utils::parseEndpointString(const char* endpoints, std::string& host,
@@ -107,7 +98,7 @@ std::string Utils::convertHostToCanonicalForm(const char* endpoints) {
struct hostent* host;
host = ACE_OS::gethostbyname(hostName);
if (host) {
- ACE_OS::snprintf(fullName, 256, "%s:%d", host->h_name, port);
+ std::snprintf(fullName, 256, "%s:%d", host->h_name, port);
return fullName;
}
} else {
@@ -115,7 +106,7 @@ std::string Utils::convertHostToCanonicalForm(const char* endpoints) {
if (pos != std::string::npos) {
ACE_INET_Addr addr(endpoints);
addr.get_host_name(hostName, 256);
- ACE_OS::snprintf(fullName, 256, "%s:%d", hostName, port);
+ std::snprintf(fullName, 256, "%s:%d", hostName, port);
return fullName;
}
}
@@ -173,32 +164,6 @@ std::string Utils::convertBytesToString(const uint8_t* bytes, size_t length,
return "";
}
-int32_t Utils::logWideString(char* buf, size_t maxLen, const wchar_t* wStr) {
- if (wStr != nullptr) {
- mbstate_t state;
- ACE_OS::memset(&state, 0, sizeof(mbstate_t));
- const char* bufStart = buf;
- do {
- if (maxLen < static_cast<size_t>(MB_CUR_MAX)) {
- break;
- }
- size_t numChars = wcrtomb(buf, *wStr, &state);
- if (numChars == static_cast<size_t>(-1)) {
- // write short when conversion cannot be done
- numChars = ACE_OS::snprintf(buf, maxLen, "<%u>", *wStr);
- }
- buf += numChars;
- if (numChars >= maxLen) {
- break;
- }
- maxLen -= numChars;
- } while (*wStr++ != L'\0');
- return static_cast<int32_t>(buf - bufStart);
- } else {
- return ACE_OS::snprintf(buf, maxLen, "null");
- }
-}
-
int64_t Utils::startStatOpTime() {
return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::steady_clock::now().time_since_epoch())
diff --git a/cppcache/src/Utils.hpp b/cppcache/src/Utils.hpp
index 32b6ead..b3577c1 100644
--- a/cppcache/src/Utils.hpp
+++ b/cppcache/src/Utils.hpp
@@ -98,8 +98,6 @@ class APACHE_GEODE_EXPORT Utils {
return std::string(typeIdName);
}
- static int logWideString(char* buf, size_t maxLen, const wchar_t* wStr);
-
/**
* The only operations that is well defined on the result is "asChar".
*/
diff --git a/cppcache/src/VersionStamp.cpp b/cppcache/src/VersionStamp.cpp
index 9d1004a..ef1c3e9 100644
--- a/cppcache/src/VersionStamp.cpp
+++ b/cppcache/src/VersionStamp.cpp
@@ -187,7 +187,9 @@ GfErrType VersionStamp::checkForDeltaConflict(
"delta requires full value due to version mismatch. key=%s tagVersion "
"%lld stampVersion %lld ",
keystr.c_str(), tagVersion, stampVersion);
- if (poolDM) poolDM->updateNotificationStats(false, 0);
+ if (poolDM) {
+ poolDM->updateNotificationStats(false, std::chrono::nanoseconds(0));
+ }
return GF_INVALID_DELTA;
} else {
@@ -199,7 +201,9 @@ GfErrType VersionStamp::checkForDeltaConflict(
"MemberId of the version stamp could not be found. Requesting full "
"delta value. key=%s",
keystr.c_str());
- if (poolDM) poolDM->updateNotificationStats(false, 0);
+ if (poolDM) {
+ poolDM->updateNotificationStats(false, std::chrono::nanoseconds(0));
+ }
return GF_INVALID_DELTA;
}
@@ -209,7 +213,9 @@ GfErrType VersionStamp::checkForDeltaConflict(
"Previous MemberId of the version tag could not be found. Requesting "
"full delta value. key=%s",
keystr.c_str());
- if (poolDM) poolDM->updateNotificationStats(false, 0);
+ if (poolDM) {
+ poolDM->updateNotificationStats(false, std::chrono::nanoseconds(0));
+ }
return GF_INVALID_DELTA;
}
@@ -220,7 +226,9 @@ GfErrType VersionStamp::checkForDeltaConflict(
keystr.c_str(), tagID->getHashKey().c_str(),
stampID->getHashKey().c_str());
- if (poolDM) poolDM->updateNotificationStats(false, 0);
+ if (poolDM) {
+ poolDM->updateNotificationStats(false, std::chrono::nanoseconds(0));
+ }
return GF_INVALID_DELTA;
}
return GF_NOERR;
diff --git a/cppcache/src/VersionedCacheableObjectPartList.cpp b/cppcache/src/VersionedCacheableObjectPartList.cpp
index 3df5504..15b8ea3 100644
--- a/cppcache/src/VersionedCacheableObjectPartList.cpp
+++ b/cppcache/src/VersionedCacheableObjectPartList.cpp
@@ -87,7 +87,7 @@ void VersionedCacheableObjectPartList::readObjectPart(
}
void VersionedCacheableObjectPartList::fromData(DataInput& input) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_responseLock);
+ std::lock_guard<decltype(m_responseLock)> guard(m_responseLock);
LOGDEBUG("VersionedCacheableObjectPartList::fromData");
uint8_t flags = input.read();
m_hasKeys = (flags & 0x01) == 0x01;
diff --git a/cppcache/src/VersionedCacheableObjectPartList.hpp b/cppcache/src/VersionedCacheableObjectPartList.hpp
index 4c9e7e4..68b3846 100644
--- a/cppcache/src/VersionedCacheableObjectPartList.hpp
+++ b/cppcache/src/VersionedCacheableObjectPartList.hpp
@@ -20,17 +20,13 @@
#ifndef GEODE_VERSIONEDCACHEABLEOBJECTPARTLIST_H_
#define GEODE_VERSIONEDCACHEABLEOBJECTPARTLIST_H_
+#include <mutex>
#include <vector>
-#include <ace/Task.h>
-
#include "CacheableObjectPartList.hpp"
#include "VersionTag.hpp"
#include "util/Log.hpp"
-/** @file
- */
-
namespace apache {
namespace geode {
namespace client {
@@ -57,7 +53,7 @@ class VersionedCacheableObjectPartList : public CacheableObjectPartList {
std::vector<uint8_t> m_byteArray;
uint16_t m_endpointMemId;
std::shared_ptr<std::vector<std::shared_ptr<CacheableKey>>> m_tempKeys;
- ACE_Recursive_Thread_Mutex& m_responseLock;
+ std::recursive_mutex& m_responseLock;
static const uint8_t FLAG_NULL_TAG;
static const uint8_t FLAG_FULL_TAG;
@@ -71,13 +67,6 @@ class VersionedCacheableObjectPartList : public CacheableObjectPartList {
const VersionedCacheableObjectPartList& other);
VersionedCacheableObjectPartList(
const VersionedCacheableObjectPartList& other);
- /*inline VersionedCacheableObjectPartList() : m_responseLock()
- {
- m_regionIsVersioned = false;
- m_serializeValues = false;
- m_endpointMemId = 0;
- _GEODE_NEW(m_tempKeys, std::vector<std::shared_ptr<CacheableKey>> );
- }*/
public:
VersionedCacheableObjectPartList(
@@ -88,7 +77,7 @@ class VersionedCacheableObjectPartList : public CacheableObjectPartList {
resultKeys,
ThinClientRegion* region, MapOfUpdateCounters* trackerMap,
int32_t destroyTracker, bool addToLocalCache, uint16_t m_dsmemId,
- ACE_Recursive_Thread_Mutex& responseLock)
+ std::recursive_mutex& responseLock)
: CacheableObjectPartList(keys, keysOffset, values, exceptions,
resultKeys, region, trackerMap, destroyTracker,
addToLocalCache),
@@ -104,7 +93,7 @@ class VersionedCacheableObjectPartList : public CacheableObjectPartList {
VersionedCacheableObjectPartList(
std::vector<std::shared_ptr<CacheableKey>>* keys, int32_t totalMapSize,
- ACE_Recursive_Thread_Mutex& responseLock)
+ std::recursive_mutex& responseLock)
: m_tempKeys(keys), m_responseLock(responseLock) {
m_regionIsVersioned = false;
m_serializeValues = false;
@@ -116,7 +105,7 @@ class VersionedCacheableObjectPartList : public CacheableObjectPartList {
}
VersionedCacheableObjectPartList(ThinClientRegion* region, uint16_t dsmemId,
- ACE_Recursive_Thread_Mutex& responseLock)
+ std::recursive_mutex& responseLock)
: CacheableObjectPartList(region),
m_endpointMemId(dsmemId),
m_responseLock(responseLock) {
@@ -129,7 +118,7 @@ class VersionedCacheableObjectPartList : public CacheableObjectPartList {
VersionedCacheableObjectPartList(
std::vector<std::shared_ptr<CacheableKey>>* keys,
- ACE_Recursive_Thread_Mutex& responseLock)
+ std::recursive_mutex& responseLock)
: m_tempKeys(keys), m_responseLock(responseLock) {
m_regionIsVersioned = false;
m_serializeValues = false;
@@ -141,7 +130,7 @@ class VersionedCacheableObjectPartList : public CacheableObjectPartList {
VersionedCacheableObjectPartList(
ThinClientRegion* region,
std::vector<std::shared_ptr<CacheableKey>>* keys,
- ACE_Recursive_Thread_Mutex& responseLock)
+ std::recursive_mutex& responseLock)
: CacheableObjectPartList(region),
m_tempKeys(keys),
m_responseLock(responseLock) {
@@ -153,7 +142,7 @@ class VersionedCacheableObjectPartList : public CacheableObjectPartList {
}
VersionedCacheableObjectPartList(ThinClientRegion* region,
- ACE_Recursive_Thread_Mutex& responseLock)
+ std::recursive_mutex& responseLock)
: CacheableObjectPartList(region), m_responseLock(responseLock) {
m_regionIsVersioned = false;
m_serializeValues = false;
@@ -183,8 +172,8 @@ class VersionedCacheableObjectPartList : public CacheableObjectPartList {
return m_tempKeys;
}
- inline VersionedCacheableObjectPartList(
- uint16_t endpointMemId, ACE_Recursive_Thread_Mutex& responseLock)
+ inline VersionedCacheableObjectPartList(uint16_t endpointMemId,
+ std::recursive_mutex& responseLock)
: m_tempKeys(
std::make_shared<std::vector<std::shared_ptr<CacheableKey>>>()),
m_responseLock(responseLock) {
@@ -196,8 +185,6 @@ class VersionedCacheableObjectPartList : public CacheableObjectPartList {
}
void addAll(std::shared_ptr<VersionedCacheableObjectPartList> other) {
- // LOGDEBUG("DEBUG:: COPL.addAll called");
- // ACE_Guard< ACE_Recursive_Thread_Mutex > guard( this->m_responseLock );
if (other->m_tempKeys != nullptr) {
if (this->m_tempKeys == nullptr) {
this->m_tempKeys =
diff --git a/cppcache/src/dllmain.cpp b/cppcache/src/dllmain.cpp
index 0ad9d12..54a97d5 100644
--- a/cppcache/src/dllmain.cpp
+++ b/cppcache/src/dllmain.cpp
@@ -19,8 +19,6 @@
#include <cstdlib>
#include <string>
-#include <ace/TSS_T.h>
-
#include <geode/Exception.hpp>
#include "CppCacheLibrary.hpp"
diff --git a/cppcache/src/internal/duration.cpp b/cppcache/src/internal/chrono/duration.cpp
similarity index 100%
rename from cppcache/src/internal/duration.cpp
rename to cppcache/src/internal/chrono/duration.cpp
diff --git a/cppcache/src/statistics/AtomicStatisticsImpl.cpp b/cppcache/src/statistics/AtomicStatisticsImpl.cpp
index 8ad053e..3618844 100644
--- a/cppcache/src/statistics/AtomicStatisticsImpl.cpp
+++ b/cppcache/src/statistics/AtomicStatisticsImpl.cpp
@@ -19,8 +19,6 @@
#include <atomic>
-#include <ace/OS_NS_stdio.h>
-
#include <geode/internal/geode_globals.hpp>
#include "../Assert.hpp"
@@ -140,7 +138,7 @@ void AtomicStatisticsImpl::close() {
void AtomicStatisticsImpl::_setInt(int32_t offset, int32_t value) {
if (offset >= statsType->getIntStatCount()) {
char s[128] = {'\0'};
- ACE_OS::snprintf(
+ std::snprintf(
s, 128, "setInt:The id (%d) of the Statistic Descriptor is not valid ",
offset);
throw IllegalArgumentException(s);
@@ -152,7 +150,7 @@ void AtomicStatisticsImpl::_setLong(int32_t offset, int64_t value) {
if (offset >= statsType->getLongStatCount()) {
char s[128] = {'\0'};
- ACE_OS::snprintf(
+ std::snprintf(
s, 128, "setLong:The id (%d) of the Statistic Descriptor is not valid ",
offset);
throw IllegalArgumentException(s);
@@ -164,7 +162,7 @@ void AtomicStatisticsImpl::_setLong(int32_t offset, int64_t value) {
void AtomicStatisticsImpl::_setDouble(int32_t offset, double value) {
if (offset >= statsType->getDoubleStatCount()) {
char s[128] = {'\0'};
- ACE_OS::snprintf(
+ std::snprintf(
s, 128,
"setDouble:The id (%d) of the Statistic Descriptor is not valid ",
offset);
@@ -177,7 +175,7 @@ void AtomicStatisticsImpl::_setDouble(int32_t offset, double value) {
int32_t AtomicStatisticsImpl::_getInt(int32_t offset) const {
if (offset >= statsType->getIntStatCount()) {
char s[128] = {'\0'};
- ACE_OS::snprintf(
+ std::snprintf(
s, 128, "getInt:The id (%d) of the Statistic Descriptor is not valid ",
offset);
throw IllegalArgumentException(s);
@@ -189,7 +187,7 @@ int32_t AtomicStatisticsImpl::_getInt(int32_t offset) const {
int64_t AtomicStatisticsImpl::_getLong(int32_t offset) const {
if (offset >= statsType->getLongStatCount()) {
char s[128] = {'\0'};
- ACE_OS::snprintf(
+ std::snprintf(
s, 128, "getLong:The id (%d) of the Statistic Descriptor is not valid ",
offset);
throw IllegalArgumentException(s);
@@ -200,7 +198,7 @@ int64_t AtomicStatisticsImpl::_getLong(int32_t offset) const {
double AtomicStatisticsImpl::_getDouble(int32_t offset) const {
if (offset >= statsType->getDoubleStatCount()) {
char s[128] = {'\0'};
- ACE_OS::snprintf(
+ std::snprintf(
s, 128,
"getDouble:The id (%d) of the Statistic Descriptor is not valid ",
offset);
@@ -243,7 +241,7 @@ int64_t AtomicStatisticsImpl::getRawBits(
int32_t AtomicStatisticsImpl::_incInt(int32_t offset, int32_t delta) {
if (offset >= statsType->getIntStatCount()) {
char s[128] = {'\0'};
- ACE_OS::snprintf(
+ std::snprintf(
s, 128, "incInt:The id (%d) of the Statistic Descriptor is not valid ",
offset);
throw IllegalArgumentException(s);
@@ -254,24 +252,9 @@ int32_t AtomicStatisticsImpl::_incInt(int32_t offset, int32_t delta) {
int64_t AtomicStatisticsImpl::_incLong(int32_t offset, int64_t delta) {
if (offset >= statsType->getLongStatCount()) {
- char s[128] = {'\0'};
- /* adongre - Coverity II
- * CID 29273: Calling risky function (SECURE_CODING)[VERY RISKY]. Using
- * "sprintf" can cause a
- * buffer overflow when done incorrectly. Because sprintf() assumes an
- * arbitrarily long string,
- * callers must be careful not to overflow the actual space of the
- * destination.
- * Use snprintf() instead, or correct precision specifiers.
- * Fix : using ACE_OS::snprintf
- */
- // sprintf(s, "incLong:The id (%d) of the Statistic Descriptor is not valid
- // ", offset);
-
- ACE_OS::snprintf(
- s, 128, "incLong:The id (%d) of the Statistic Descriptor is not valid ",
- offset);
- throw IllegalArgumentException(s);
+ throw IllegalArgumentException(
+ "incLong:The id " + std::to_string(offset) +
+ " of the Statistic Descriptor is not valid.");
}
return (longStorage[offset] += delta);
@@ -279,12 +262,9 @@ int64_t AtomicStatisticsImpl::_incLong(int32_t offset, int64_t delta) {
double AtomicStatisticsImpl::_incDouble(int32_t offset, double delta) {
if (offset >= statsType->getDoubleStatCount()) {
- char s[128] = {'\0'};
- ACE_OS::snprintf(
- s, 128,
- "incDouble:The id (%d) of the Statistic Descriptor is not valid ",
- offset);
- throw IllegalArgumentException(s);
+ throw IllegalArgumentException(
+ "incDouble:The id " + std::to_string(offset) +
+ " of the Statistic Descriptor is not valid.");
}
double expected = doubleStorage[offset];
diff --git a/cppcache/src/statistics/GeodeStatisticsFactory.cpp b/cppcache/src/statistics/GeodeStatisticsFactory.cpp
index db19ec3..90a2e57 100644
--- a/cppcache/src/statistics/GeodeStatisticsFactory.cpp
+++ b/cppcache/src/statistics/GeodeStatisticsFactory.cpp
@@ -1,4 +1,3 @@
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,10 +19,7 @@
#include <string>
-#include <ace/Guard_T.h>
-#include <ace/OS.h>
-#include <ace/Recursive_Thread_Mutex.h>
-#include <ace/Thread_Mutex.h>
+#include <boost/process/environment.hpp>
#include <geode/Exception.hpp>
#include <geode/internal/geode_globals.hpp>
@@ -43,7 +39,7 @@ using client::OutOfMemoryException;
GeodeStatisticsFactory::GeodeStatisticsFactory(StatisticsManager* statMngr) {
m_name = "GeodeStatisticsFactory";
- m_id = ACE_OS::getpid();
+ m_id = boost::this_process::get_id();
m_statsListUniqueId = 1;
m_statMngr = statMngr;
@@ -56,9 +52,7 @@ GeodeStatisticsFactory::~GeodeStatisticsFactory() {
// Clean Map : Delete all the pointers of StatisticsType from the map.
if (statsTypeMap.total_size() == 0) return;
- ACE_Map_Manager<std::string, StatisticsTypeImpl*,
- ACE_Recursive_Thread_Mutex>::iterator iterFind =
- statsTypeMap.begin();
+ auto iterFind = statsTypeMap.begin();
while (iterFind != statsTypeMap.end()) {
delete (*iterFind).int_id_;
(*iterFind).int_id_ = nullptr;
@@ -107,7 +101,8 @@ Statistics* GeodeStatisticsFactory::createOsStatistics(
int64_t myUniqueId;
{
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_statsListUniqueIdLock);
+ std::lock_guard<decltype(m_statsListUniqueIdLock)> guard(
+ m_statsListUniqueIdLock);
myUniqueId = m_statsListUniqueId++;
}
@@ -137,7 +132,8 @@ Statistics* GeodeStatisticsFactory::createAtomicStatistics(
int64_t myUniqueId;
{
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_statsListUniqueIdLock);
+ std::lock_guard<decltype(m_statsListUniqueIdLock)> guard(
+ m_statsListUniqueIdLock);
myUniqueId = m_statsListUniqueId++;
}
diff --git a/cppcache/src/statistics/GeodeStatisticsFactory.hpp b/cppcache/src/statistics/GeodeStatisticsFactory.hpp
index 790bede..fde07ce 100644
--- a/cppcache/src/statistics/GeodeStatisticsFactory.hpp
+++ b/cppcache/src/statistics/GeodeStatisticsFactory.hpp
@@ -20,6 +20,7 @@
#ifndef GEODE_STATISTICS_GEODESTATISTICSFACTORY_H_
#define GEODE_STATISTICS_GEODESTATISTICSFACTORY_H_
+#include <mutex>
#include <vector>
#include <ace/Map_Manager.h>
@@ -56,7 +57,7 @@ class GeodeStatisticsFactory : public StatisticsFactory {
int64_t m_statsListUniqueId; // Creates a unique id for each stats object in
// the list
- ACE_Recursive_Thread_Mutex m_statsListUniqueIdLock;
+ std::recursive_mutex m_statsListUniqueIdLock;
/* Maps a stat name to its StatisticDescriptor*/
ACE_Map_Manager<std::string, StatisticsTypeImpl*, ACE_Recursive_Thread_Mutex>
diff --git a/cppcache/src/statistics/HostStatSampler.cpp b/cppcache/src/statistics/HostStatSampler.cpp
index 74fb443..579c2a2 100644
--- a/cppcache/src/statistics/HostStatSampler.cpp
+++ b/cppcache/src/statistics/HostStatSampler.cpp
@@ -31,6 +31,7 @@
#include <ace/OS_NS_sys_utsname.h>
#include <ace/Task.h>
#include <ace/Thread_Mutex.h>
+#include <boost/process/environment.hpp>
#include <geode/SystemProperties.hpp>
#include <geode/internal/geode_globals.hpp>
@@ -81,7 +82,7 @@ int selector(const dirent* d) {
size_t fileHyphenPos = tempname.find_last_of('-');
if (fileHyphenPos != std::string::npos) {
std::string buff1 = tempname.substr(0, fileHyphenPos);
- if (ACE_OS::strstr(filebasename.c_str(), buff1.c_str()) == nullptr) {
+ if (filebasename.find(buff1) == std::string::npos) {
return 0;
}
if (fileHyphenPos != actualHyphenPos) return 0;
@@ -108,7 +109,7 @@ int comparator(const dirent** d1, const dirent** d2) {
} else if (strlen((*d1)->d_name) > strlen((*d2)->d_name)) {
return 1;
}
- int diff = ACE_OS::strcmp((*d1)->d_name, (*d2)->d_name);
+ int diff = std::strcmp((*d1)->d_name, (*d2)->d_name);
if (diff < 0) {
return -1;
} else if (diff > 0) {
@@ -146,7 +147,7 @@ HostStatSampler::HostStatSampler(const char* filePath,
m_archiver = nullptr;
m_samplerStats = new StatSamplerStats(statMngr->getStatisticsFactory());
m_startTime = system_clock::now();
- m_pid = ACE_OS::getpid();
+ m_pid = boost::this_process::get_id();
m_statMngr = statMngr;
m_archiveFileName = filePath;
globals::g_statFile = filePath;
@@ -190,28 +191,15 @@ HostStatSampler::HostStatSampler(const char* filePath,
#ifdef _WIN32
// replace all '\' with '/' to make everything easier..
- size_t len = globals::g_statFile.length() + 1;
- char* slashtmp = new char[len];
- ACE_OS::strncpy(slashtmp, globals::g_statFile.c_str(), len);
- for (size_t i = 0; i < globals::g_statFile.length(); i++) {
- if (slashtmp[i] == '/') {
- slashtmp[i] = '\\';
- }
- }
- globals::g_statFile = slashtmp;
- delete[] slashtmp;
- slashtmp = nullptr;
+ std::replace(globals::g_statFile.begin(), globals::g_statFile.end(), '\\',
+ '/');
#endif
std::string dirname = ACE::dirname(globals::g_statFile.c_str());
- // struct dirent **resultArray;
- // int entries_count = ACE_OS::scandir(dirname.c_str(), &resultArray,
- // selector, comparator);
ACE_Dirent_Selector sds;
int status = sds.open(dirname.c_str(), selector, comparator);
if (status != -1) {
for (int i = 0; i < sds.length(); i++) {
- // std::string strname = ACE::basename(resultArray[i]->d_name);
std::string strname = ACE::basename(sds[i]->d_name);
size_t fileExtPos = strname.find_last_of('.', strname.length());
if (fileExtPos != std::string::npos) {
@@ -220,34 +208,21 @@ HostStatSampler::HostStatSampler(const char* filePath,
if (fileHyphenPos != std::string::npos) {
std::string buff =
tempname.substr(fileHyphenPos + 1, tempname.length());
- rollIndex = ACE_OS::atoi(buff.c_str()) + 1;
+ rollIndex = std::stoi(buff) + 1;
}
}
}
sds.close();
}
- /*for(int i = 0; i < entries_count; i++) {
- ACE_OS::free ( resultArray[i] );
- }
- if (entries_count >= 0) {
- ACE_OS::free( resultArray );
- resultArray = nullptr;
- }*/
FILE* existingFile = fopen(globals::g_statFileWithExt.c_str(), "r");
if (existingFile != nullptr && statFileLimit > 0) {
fclose(existingFile);
- /* adongre
- * CID 28820: Resource leak (RESOURCE_LEAK)
- */
existingFile = nullptr;
changeArchive(globals::g_statFileWithExt);
} else {
writeGfs();
}
- /* adongre
- * CID 28820: Resource leak (RESOURCE_LEAK)
- */
if (existingFile != nullptr) {
fclose(existingFile);
existingFile = nullptr;
@@ -271,15 +246,15 @@ HostStatSampler::~HostStatSampler() {
std::string HostStatSampler::createArchiveFileName() {
if (!m_isStatDiskSpaceEnabled) {
char buff[1024] = {0};
- int32_t pid = ACE_OS::getpid();
- int32_t len = static_cast<int32_t>(m_archiveFileName.length());
- size_t fileExtPos = m_archiveFileName.find_last_of('.', len);
+ auto pid = boost::this_process::get_id();
+ auto len = m_archiveFileName.length();
+ auto fileExtPos = m_archiveFileName.find_last_of('.', len);
if (fileExtPos == std::string::npos) {
- ACE_OS::snprintf(buff, 1024, "%s-%d.gfs", m_archiveFileName.c_str(), pid);
+ std::snprintf(buff, 1024, "%s-%d.gfs", m_archiveFileName.c_str(), pid);
} else {
std::string tmp;
tmp = m_archiveFileName.substr(0, fileExtPos);
- ACE_OS::snprintf(buff, 1024, "%s-%d.gfs", tmp.c_str(), pid);
+ std::snprintf(buff, 1024, "%s-%d.gfs", tmp.c_str(), pid);
}
m_archiveFileName = buff;
return m_archiveFileName;
@@ -309,7 +284,8 @@ void HostStatSampler::accountForTimeSpentWorking(int64_t nanosSpentWorking) {
}
bool HostStatSampler::statisticsExists(const int64_t id) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_statMngr->getListMutex());
+ std::lock_guard<decltype(m_statMngr->getListMutex())> guard(
+ m_statMngr->getListMutex());
std::vector<Statistics*>& statsList = m_statMngr->getStatsList();
std::vector<Statistics*>::iterator i;
for (i = statsList.begin(); i != statsList.end(); ++i) {
@@ -321,7 +297,8 @@ bool HostStatSampler::statisticsExists(const int64_t id) {
}
Statistics* HostStatSampler::findStatistics(const int64_t id) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_statMngr->getListMutex());
+ std::lock_guard<decltype(m_statMngr->getListMutex())> guard(
+ m_statMngr->getListMutex());
std::vector<Statistics*>& statsList = m_statMngr->getStatsList();
std::vector<Statistics*>::iterator i;
for (i = statsList.begin(); i != statsList.end(); ++i) {
@@ -332,7 +309,7 @@ Statistics* HostStatSampler::findStatistics(const int64_t id) {
return nullptr;
}
-ACE_Recursive_Thread_Mutex& HostStatSampler::getStatListMutex() {
+std::recursive_mutex& HostStatSampler::getStatListMutex() {
return m_statMngr->getListMutex();
}
@@ -461,13 +438,13 @@ int32_t HostStatSampler::rollArchive(std::string filename) {
while (!gotNewFileName) {
char newfilename[1000] = {0};
if (i < 10) {
- ACE_OS::snprintf(newfilename, 1000, "%s%c%s-%d.%s", statsdirname.c_str(),
- ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), i,
- extName.c_str());
+ std::snprintf(newfilename, 1000, "%s%c%s-%d.%s", statsdirname.c_str(),
+ ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), i,
+ extName.c_str());
} else {
- ACE_OS::snprintf(newfilename, 1000, "%s%c%s-%d.%s", statsdirname.c_str(),
- ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), i,
- extName.c_str());
+ std::snprintf(newfilename, 1000, "%s%c%s-%d.%s", statsdirname.c_str(),
+ ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), i,
+ extName.c_str());
}
FILE* fp = fopen(newfilename, "r");
@@ -512,9 +489,6 @@ void HostStatSampler::start() {
void HostStatSampler::stop() {
m_stopRequested = true;
this->wait();
- // while (m_running) {
- // ACE_OS::sleep(100);
- //}
}
bool HostStatSampler::isRunning() { return m_running; }
@@ -557,7 +531,7 @@ void HostStatSampler::putStatsInAdminRegion() {
}
}
}
- static int numCPU = ACE_OS::num_processors();
+ static auto numCPU = std::thread::hardware_concurrency();
auto obj = client::ClientHealthStats::create(
gets, puts, misses, numListeners, numThreads, cpuTime, numCPU);
if (clientId.empty()) {
@@ -589,7 +563,7 @@ void HostStatSampler::writeGfs() {
}
void HostStatSampler::forceSample() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> samplingGuard(m_samplingLock);
+ std::lock_guard<decltype(m_samplingLock)> guard(m_samplingLock);
if (m_archiver) {
sampleSpecialStats();
@@ -599,7 +573,7 @@ void HostStatSampler::forceSample() {
}
void HostStatSampler::doSample(std::string& archivefilename) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> samplingGuard(m_samplingLock);
+ std::lock_guard<decltype(m_samplingLock)> guard(m_samplingLock);
sampleSpecialStats();
checkListeners();
@@ -641,29 +615,19 @@ void HostStatSampler::checkDiskLimit() {
globals::g_spaceUsed = 0;
char fullpath[512] = {0};
std::string dirname = ACE::dirname(globals::g_statFile.c_str());
- // struct dirent **resultArray;
- // int entries_count = ACE_OS::scandir(dirname.c_str(), &resultArray,
- // selector, comparator);
ACE_stat statBuf = {};
ACE_Dirent_Selector sds;
int status = sds.open(dirname.c_str(), selector, comparator);
if (status != -1) {
for (int i = 1; i < sds.length(); i++) {
- ACE_OS::snprintf(fullpath, 512, "%s%c%s", dirname.c_str(),
- ACE_DIRECTORY_SEPARATOR_CHAR, sds[i]->d_name);
+ std::snprintf(fullpath, 512, "%s%c%s", dirname.c_str(),
+ ACE_DIRECTORY_SEPARATOR_CHAR, sds[i]->d_name);
ACE_OS::stat(fullpath, &statBuf);
globals::g_fileInfoPair = std::make_pair(fullpath, statBuf.st_size);
fileInfo.push_back(globals::g_fileInfoPair);
globals::g_spaceUsed += fileInfo[i - 1].second;
}
globals::g_spaceUsed += m_archiver->bytesWritten();
- /*for(int i = 0; i < entries_count; i++) {
- ACE_OS::free ( resultArray[i] );
- }
- if (entries_count >= 0) {
- ACE_OS::free( resultArray );
- resultArray = nullptr;
- }*/
sds.close();
}
int fileIndex = 0;
@@ -697,7 +661,7 @@ int32_t HostStatSampler::svc(void) {
while (!m_stopRequested) {
try {
if (gotexception) {
- ACE_OS::sleep(1);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
waitTime++;
if (waitTime < 60) { // sleep for minute and then try to recreate
diff --git a/cppcache/src/statistics/HostStatSampler.hpp b/cppcache/src/statistics/HostStatSampler.hpp
index 0d110f9..1a1ec2e 100644
--- a/cppcache/src/statistics/HostStatSampler.hpp
+++ b/cppcache/src/statistics/HostStatSampler.hpp
@@ -22,10 +22,10 @@
#include <chrono>
#include <memory>
+#include <mutex>
#include <string>
#include <vector>
-#include <ace/Recursive_Thread_Mutex.h>
#include <ace/Task.h>
#include <geode/ExceptionTypes.hpp>
@@ -39,8 +39,6 @@
#include "StatisticsManager.hpp"
#include "StatisticsType.hpp"
-/** @file
- */
#ifndef GEMFIRE_MAX_STATS_FILE_LIMIT
#define GEMFIRE_MAX_STATS_FILE_LIMIT (1024 * 1024 * 1024)
#endif
@@ -48,6 +46,7 @@
#ifndef GEMFIRE_MAX_STAT_DISK_LIMIT
#define GEMFIRE_MAX_STAT_DISK_LIMIT (1024LL * 1024LL * 1024LL * 1024LL)
#endif
+
namespace apache {
namespace geode {
namespace statistics {
@@ -122,7 +121,7 @@ class APACHE_GEODE_EXPORT HostStatSampler : public ACE_Task_Base,
/**
* Gets list mutex for synchronization
*/
- ACE_Recursive_Thread_Mutex& getStatListMutex();
+ std::recursive_mutex& getStatListMutex();
/**
* Returns a vector of ptrs to all the current statistic resource instances.
*/
@@ -190,7 +189,7 @@ class APACHE_GEODE_EXPORT HostStatSampler : public ACE_Task_Base,
~HostStatSampler();
private:
- ACE_Recursive_Thread_Mutex m_samplingLock;
+ std::recursive_mutex m_samplingLock;
bool m_adminError;
// Related to ACE Thread.
bool m_running;
@@ -247,6 +246,7 @@ class APACHE_GEODE_EXPORT HostStatSampler : public ACE_Task_Base,
static const char* NC_HSS_Thread;
};
+
} // namespace statistics
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/statistics/OsStatisticsImpl.cpp b/cppcache/src/statistics/OsStatisticsImpl.cpp
index 90c770b..2afbc22 100644
--- a/cppcache/src/statistics/OsStatisticsImpl.cpp
+++ b/cppcache/src/statistics/OsStatisticsImpl.cpp
@@ -20,7 +20,6 @@
#include "../util/Log.hpp"
#include "StatisticDescriptorImpl.hpp"
#include "StatisticsTypeImpl.hpp"
-#include "ace/OS.h"
namespace apache {
namespace geode {
@@ -164,7 +163,7 @@ void OsStatisticsImpl::close() {
void OsStatisticsImpl::_setInt(int32_t offset, int32_t value) {
if (offset >= statsType->getIntStatCount()) {
char s[128] = {'\0'};
- ACE_OS::snprintf(
+ std::snprintf(
s, 128, "setInt:The id (%d) of the Statistic Descriptor is not valid ",
offset);
throw IllegalArgumentException(s);
@@ -175,19 +174,7 @@ void OsStatisticsImpl::_setInt(int32_t offset, int32_t value) {
void OsStatisticsImpl::_setLong(int32_t offset, int64_t value) {
if (offset >= statsType->getLongStatCount()) {
char s[128] = {'\0'};
- /* adongre - Coverity II
- * CID 29275: Calling risky function (SECURE_CODING)[VERY RISKY]. Using
- * "sprintf" can cause a
- * buffer overflow when done incorrectly. Because sprintf() assumes an
- * arbitrarily long string,
- * callers must be careful not to overflow the actual space of the
- * destination.
- * Use snprintf() instead, or correct precision specifiers.
- * Fix : using ACE_OS::snprintf
- */
- // sprintf(s, "setLong:The id (%d) of the Statistic Descriptor is not valid
- // ", offset);
- ACE_OS::snprintf(
+ std::snprintf(
s, 128, "setLong:The id (%d) of the Statistic Descriptor is not valid ",
offset);
throw IllegalArgumentException(s);
@@ -198,7 +185,7 @@ void OsStatisticsImpl::_setLong(int32_t offset, int64_t value) {
void OsStatisticsImpl::_setDouble(int32_t offset, double value) {
if (offset >= statsType->getDoubleStatCount()) {
char s[128] = {'\0'};
- ACE_OS::snprintf(
+ std::snprintf(
s, 128,
"setDouble:The id (%d) of the Statistic Descriptor is not valid ",
offset);
@@ -212,7 +199,7 @@ void OsStatisticsImpl::_setDouble(int32_t offset, double value) {
int32_t OsStatisticsImpl::_getInt(int32_t offset) const {
if (offset >= statsType->getIntStatCount()) {
char s[128] = {'\0'};
- ACE_OS::snprintf(
+ std::snprintf(
s, 128, "getInt:The id (%d) of the Statistic Descriptor is not valid ",
offset);
throw IllegalArgumentException(s);
@@ -224,7 +211,7 @@ int32_t OsStatisticsImpl::_getInt(int32_t offset) const {
int64_t OsStatisticsImpl::_getLong(int32_t offset) const {
if (offset >= statsType->getLongStatCount()) {
char s[128] = {'\0'};
- ACE_OS::snprintf(
+ std::snprintf(
s, 128, "getLong:The id (%d) of the Statistic Descriptor is not valid ",
offset);
throw IllegalArgumentException(s);
@@ -236,7 +223,7 @@ int64_t OsStatisticsImpl::_getLong(int32_t offset) const {
double OsStatisticsImpl::_getDouble(int32_t offset) const {
if (offset >= statsType->getDoubleStatCount()) {
char s[128] = {'\0'};
- ACE_OS::snprintf(
+ std::snprintf(
s, 128,
"getDouble:The id (%d) of the Statistic Descriptor is not valid ",
offset);
@@ -274,7 +261,7 @@ int64_t OsStatisticsImpl::_getRawBits(
int32_t OsStatisticsImpl::_incInt(int32_t offset, int32_t delta) {
if (offset >= statsType->getIntStatCount()) {
char s[128] = {'\0'};
- ACE_OS::snprintf(
+ std::snprintf(
s, 128, "incInt:The id (%d) of the Statistic Descriptor is not valid ",
offset);
throw IllegalArgumentException(s);
@@ -287,20 +274,7 @@ int32_t OsStatisticsImpl::_incInt(int32_t offset, int32_t delta) {
int64_t OsStatisticsImpl::_incLong(int32_t offset, int64_t delta) {
if (offset >= statsType->getLongStatCount()) {
char s[128] = {'\0'};
- /* adongre - Coverity II
- * CID 29274: Calling risky function (SECURE_CODING)[VERY RISKY]. Using
- * "sprintf" can cause a
- * buffer overflow when done incorrectly. Because sprintf() assumes an
- * arbitrarily long string,
- * callers must be careful not to overflow the actual space of the
- * destination.
- * Use snprintf() instead, or correct precision specifiers.
- * Fix : using ACE_OS::snprintf
- */
- // sprintf(s, "incLong:The id (%d) of the Statistic Descriptor is not valid
- // ", offset);
-
- ACE_OS::snprintf(
+ std::snprintf(
s, 128, "incLong:The id (%d) of the Statistic Descriptor is not valid ",
offset);
throw IllegalArgumentException(s);
@@ -312,7 +286,7 @@ int64_t OsStatisticsImpl::_incLong(int32_t offset, int64_t delta) {
double OsStatisticsImpl::_incDouble(int32_t offset, double delta) {
if (offset >= statsType->getDoubleStatCount()) {
char s[128] = {'\0'};
- ACE_OS::snprintf(
+ std::snprintf(
s, 128,
"incDouble:The id (%d) of the Statistic Descriptor is not valid ",
offset);
diff --git a/cppcache/src/statistics/PoolStatsSampler.cpp b/cppcache/src/statistics/PoolStatsSampler.cpp
index f205c71..c6b868f 100644
--- a/cppcache/src/statistics/PoolStatsSampler.cpp
+++ b/cppcache/src/statistics/PoolStatsSampler.cpp
@@ -106,7 +106,7 @@ void PoolStatsSampler::putStatsInAdminRegion() {
}
}
}
- static int numCPU = ACE_OS::num_processors();
+ static auto numCPU = std::thread::hardware_concurrency();
auto obj = client::ClientHealthStats::create(
gets, puts, misses, numListeners, numThreads, cpuTime, numCPU);
const auto memId = m_distMan->getMembershipId();
diff --git a/cppcache/src/statistics/PoolStatsSampler.hpp b/cppcache/src/statistics/PoolStatsSampler.hpp
index c04505b..067723f 100644
--- a/cppcache/src/statistics/PoolStatsSampler.hpp
+++ b/cppcache/src/statistics/PoolStatsSampler.hpp
@@ -20,6 +20,10 @@
#ifndef GEODE_STATISTICS_POOLSTATSSAMPLER_H_
#define GEODE_STATISTICS_POOLSTATSSAMPLER_H_
+#include <chrono>
+#include <memory>
+#include <mutex>
+
#include <ace/Task.h>
#include <geode/internal/geode_globals.hpp>
@@ -67,7 +71,7 @@ class APACHE_GEODE_EXPORT PoolStatsSampler : public ACE_Task_Base {
std::chrono::milliseconds m_sampleRate;
std::shared_ptr<AdminRegion> m_adminRegion;
ThinClientPoolDM* m_distMan;
- ACE_Recursive_Thread_Mutex m_lock;
+ std::recursive_mutex m_lock;
static const char* NC_PSS_Thread;
GeodeStatisticsFactory* m_statisticsFactory;
};
diff --git a/cppcache/src/statistics/StatArchiveWriter.cpp b/cppcache/src/statistics/StatArchiveWriter.cpp
index 1369871..0dbea36 100644
--- a/cppcache/src/statistics/StatArchiveWriter.cpp
+++ b/cppcache/src/statistics/StatArchiveWriter.cpp
@@ -17,6 +17,9 @@
#include "StatArchiveWriter.hpp"
+#include <chrono>
+#include <ctime>
+
#include <ace/ACE.h>
#include <ace/OS_NS_sys_time.h>
#include <ace/OS_NS_sys_utsname.h>
@@ -27,6 +30,7 @@
#include <geode/internal/geode_globals.hpp>
#include "../CacheImpl.hpp"
+#include "../util/chrono/time_point.hpp"
#include "GeodeStatisticsFactory.hpp"
namespace apache {
@@ -347,11 +351,10 @@ StatArchiveWriter::StatArchiveWriter(std::string outfile,
tzOffset = tzOffset * -1 * 1000;
this->dataBuffer->writeInt(tzOffset);
- struct tm *tm_val;
- time_t clock = ACE_OS::time();
- tm_val = ACE_OS::localtime(&clock);
+ auto now = std::chrono::system_clock::now();
+ auto tm_val = apache::geode::util::chrono::localtime(now);
char buf[512] = {0};
- ACE_OS::strftime(buf, sizeof(buf), "%Z", tm_val);
+ std::strftime(buf, sizeof(buf), "%Z", &tm_val);
std::string tzId(buf);
this->dataBuffer->writeUTF(tzId);
@@ -396,7 +399,8 @@ int64_t StatArchiveWriter::bytesWritten() { return bytesWrittenToFile; }
int64_t StatArchiveWriter::getSampleSize() { return m_samplesize; }
void StatArchiveWriter::sample(const steady_clock::time_point &timeStamp) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(sampler->getStatListMutex());
+ std::lock_guard<decltype(sampler->getStatListMutex())> guard(
+ sampler->getStatListMutex());
m_samplesize = dataBuffer->getBytesWritten();
sampleResources();
@@ -502,7 +506,8 @@ void StatArchiveWriter::sampleResources() {
}
void StatArchiveWriter::resampleResources() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(sampler->getStatListMutex());
+ std::lock_guard<decltype(sampler->getStatListMutex())> guard(
+ sampler->getStatListMutex());
std::vector<Statistics *> &statsList = sampler->getStatistics();
std::vector<Statistics *>::iterator statlistIter = statsList.begin();
while (statlistIter != statsList.end()) {
diff --git a/cppcache/src/statistics/StatisticsManager.cpp b/cppcache/src/statistics/StatisticsManager.cpp
index 06a7cc2..ea2d0cb 100644
--- a/cppcache/src/statistics/StatisticsManager.cpp
+++ b/cppcache/src/statistics/StatisticsManager.cpp
@@ -19,11 +19,6 @@
#include <string>
-#include <ace/Guard_T.h>
-#include <ace/OS.h>
-#include <ace/Thread_Mutex.h>
-#include <ace/Time_Value.h>
-
#include <geode/Exception.hpp>
#include <geode/internal/geode_globals.hpp>
@@ -73,7 +68,7 @@ StatisticsManager::~StatisticsManager() {
// List should be empty if close() is called on each Stats object
// If this is not done, delete all the pointers
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_statsListLock);
+ std::lock_guard<decltype(m_statsListLock)> guard(m_statsListLock);
int32_t count = static_cast<int32_t>(m_statsList.size());
if (count > 0) {
LOGFINEST("~StatisticsManager has found %d leftover statistics:", count);
@@ -109,7 +104,7 @@ StatisticsManager::~StatisticsManager() {
}
}
-ACE_Recursive_Thread_Mutex& StatisticsManager::getListMutex() {
+std::recursive_mutex& StatisticsManager::getListMutex() {
return m_statsListLock;
}
@@ -123,7 +118,7 @@ void StatisticsManager::closeSampler() {
void StatisticsManager::addStatisticsToList(Statistics* stat) {
if (stat) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_statsListLock);
+ std::lock_guard<decltype(m_statsListLock)> guard(m_statsListLock);
m_statsList.push_back(stat);
/* Add to m_newlyAddedStatsList also so that a fresh traversal not needed
@@ -135,7 +130,7 @@ void StatisticsManager::addStatisticsToList(Statistics* stat) {
}
int32_t StatisticsManager::getStatListModCount() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_statsListLock);
+ std::lock_guard<decltype(m_statsListLock)> guard(m_statsListLock);
return static_cast<int32_t>(m_statsList.size());
}
@@ -149,7 +144,7 @@ std::vector<Statistics*>& StatisticsManager::getNewlyAddedStatsList() {
Statistics* StatisticsManager::findFirstStatisticsByType(
const StatisticsType* type) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_statsListLock);
+ std::lock_guard<decltype(m_statsListLock)> guard(m_statsListLock);
std::vector<Statistics*>::iterator start = m_statsList.begin();
while (start != m_statsList.end()) {
if (!((*start)->isClosed()) && ((*start)->getType() == type)) {
@@ -164,7 +159,7 @@ std::vector<Statistics*> StatisticsManager::findStatisticsByType(
StatisticsType* type) {
std::vector<Statistics*> hits;
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_statsListLock);
+ std::lock_guard<decltype(m_statsListLock)> guard(m_statsListLock);
std::vector<Statistics*>::iterator start = m_statsList.begin();
while (start != m_statsList.end()) {
@@ -180,7 +175,7 @@ std::vector<Statistics*> StatisticsManager::findStatisticsByTextId(
char* textId) {
std::vector<Statistics*> hits;
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_statsListLock);
+ std::lock_guard<decltype(m_statsListLock)> guard(m_statsListLock);
std::vector<Statistics*>::iterator start = m_statsList.begin();
while (start != m_statsList.end()) {
@@ -196,7 +191,7 @@ std::vector<Statistics*> StatisticsManager::findStatisticsByNumericId(
int64_t numericId) {
std::vector<Statistics*> hits;
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_statsListLock);
+ std::lock_guard<decltype(m_statsListLock)> guard(m_statsListLock);
std::vector<Statistics*>::iterator start = m_statsList.begin();
while (start != m_statsList.end()) {
@@ -209,7 +204,7 @@ std::vector<Statistics*> StatisticsManager::findStatisticsByNumericId(
}
Statistics* StatisticsManager::findStatisticsByUniqueId(int64_t uniqueId) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_statsListLock);
+ std::lock_guard<decltype(m_statsListLock)> guard(m_statsListLock);
std::vector<Statistics*>::iterator start = m_statsList.begin();
while (start != m_statsList.end()) {
diff --git a/cppcache/src/statistics/StatisticsManager.hpp b/cppcache/src/statistics/StatisticsManager.hpp
index 84ccd99..f4c99c2 100644
--- a/cppcache/src/statistics/StatisticsManager.hpp
+++ b/cppcache/src/statistics/StatisticsManager.hpp
@@ -21,6 +21,7 @@
#define GEODE_STATISTICS_STATISTICSMANAGER_H_
#include <memory>
+#include <mutex>
#include <vector>
#include <geode/ExceptionTypes.hpp>
@@ -59,7 +60,7 @@ class StatisticsManager {
std::vector<Statistics*> m_newlyAddedStatsList;
// Mutex to lock the list of Stats
- ACE_Recursive_Thread_Mutex m_statsListLock;
+ std::recursive_mutex m_statsListLock;
std::shared_ptr<AdminRegion> m_adminRegion;
@@ -91,7 +92,7 @@ class StatisticsManager {
std::vector<Statistics*>& getNewlyAddedStatsList();
- ACE_Recursive_Thread_Mutex& getListMutex();
+ std::recursive_mutex& getListMutex();
/** Return the first instance that matches the type, or nullptr */
Statistics* findFirstStatisticsByType(const StatisticsType* type);
diff --git a/cppcache/src/statistics/StatisticsTypeImpl.cpp b/cppcache/src/statistics/StatisticsTypeImpl.cpp
index 0a65577..200cdde 100644
--- a/cppcache/src/statistics/StatisticsTypeImpl.cpp
+++ b/cppcache/src/statistics/StatisticsTypeImpl.cpp
@@ -19,8 +19,6 @@
#include <string>
-#include <ace/OS.h>
-
#include "../util/Log.hpp"
#include "StatisticDescriptorImpl.hpp"
@@ -44,15 +42,10 @@ StatisticsTypeImpl::StatisticsTypeImpl(std::string nameArg,
throw NullPointerException(s);
}
if (statsLengthArg > MAX_DESCRIPTORS_PER_TYPE) {
- char buffer[100];
- ACE_OS::snprintf(buffer, 100, "%d", statsLengthArg);
- std::string temp(buffer);
- std::string s = "The requested descriptor count " + temp +
- " exceeds the maximum which is ";
- ACE_OS::snprintf(buffer, 100, "%d", MAX_DESCRIPTORS_PER_TYPE);
- std::string buf(buffer);
- s += buf + ".";
- throw IllegalArgumentException(s.c_str());
+ throw IllegalArgumentException(
+ "The requested descriptor count " + std::to_string(statsLengthArg) +
+ " exceeds the maximum which is " +
+ std::to_string(MAX_DESCRIPTORS_PER_TYPE) + ".");
}
this->name = nameArg;
this->description = descriptionArg;
@@ -65,14 +58,6 @@ StatisticsTypeImpl::StatisticsTypeImpl(std::string nameArg,
// Concrete class required to set the ids only.
StatisticDescriptorImpl* sd =
dynamic_cast<StatisticDescriptorImpl*>(stats[i]);
- /* adongre
- * CID 28694: Dereference after null check (FORWARD_NULL)Comparing "sd" to
- * null implies that "sd" might be null.
- *
- * FIX : Do not check null from the dynamic_cast
- * catch the exception thrown by the dynamic_cast
- */
-
if (sd != nullptr) {
if (sd->getTypeCode() == INT_TYPE) {
sd->setId(intCount);
@@ -87,9 +72,8 @@ StatisticsTypeImpl::StatisticsTypeImpl(std::string nameArg,
std::string str = stats[i]->getName();
StatisticsDescMap::iterator iterFind = statsDescMap.find(str);
if (iterFind != statsDescMap.end()) {
- std::string s = "Duplicate StatisticDescriptor named ";
- s += sd->getName();
- throw IllegalArgumentException(s.c_str());
+ throw IllegalArgumentException("Duplicate StatisticDescriptor named " +
+ sd->getName());
} else {
// statsDescMap.insert(make_pair(stats[i]->getName(), stats[i]));
statsDescMap.insert(
@@ -111,10 +95,8 @@ StatisticsTypeImpl::~StatisticsTypeImpl() {
}
// same pointers are also stored in this map.
// So, Set the pointers to null.
- StatisticsDescMap::iterator iterFind = statsDescMap.begin();
- while (iterFind != statsDescMap.end()) {
- (*iterFind).second = nullptr;
- iterFind++;
+ for (auto& it : statsDescMap) {
+ it.second = nullptr;
}
} catch (...) {
}
@@ -141,7 +123,7 @@ StatisticDescriptor* StatisticsTypeImpl::nameToDescriptor(
std::string s = "There is no statistic named " + nameArg +
" in this statistics instance ";
LOGWARN("StatisticsTypeImpl::nameToDescriptor %s", s.c_str());
- throw IllegalArgumentException(s.c_str());
+ throw IllegalArgumentException(s);
} else {
return iterFind->second;
}
diff --git a/cppcache/src/util/Log.hpp b/cppcache/src/util/Log.hpp
index 7c80fcd..740a13d 100644
--- a/cppcache/src/util/Log.hpp
+++ b/cppcache/src/util/Log.hpp
@@ -157,13 +157,6 @@ class APACHE_GEODE_EXPORT Log {
static void setLogLevel(LogLevel level) { s_logLevel = level; }
/**
- * @return the name of the current log file.
- * NOTE: This function is for debugging only, as it is not completely
- * thread-safe!
- */
- static const char* logFileName();
-
- /**
* Initializes logging facility with given level and filenames.
* This method is called automatically within @ref DistributedSystem::connect
* with the log-file, log-level, and log-file-size system properties used as
@@ -260,6 +253,10 @@ class APACHE_GEODE_EXPORT Log {
if (errorEnabled()) put(LogLevel::Error, msg);
}
+ static void error(const std::string& msg) {
+ if (errorEnabled()) put(LogLevel::Error, msg.c_str());
+ }
+
/**
* Logs both a message and thrown exception.
* The message level is "error".
diff --git a/cppcache/src/util/chrono/time_point.hpp b/cppcache/src/util/chrono/time_point.hpp
new file mode 100644
index 0000000..5614598
--- /dev/null
+++ b/cppcache/src/util/chrono/time_point.hpp
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#ifndef GEODE_UTIL_CHRONO_TIME_POINT_H_
+#define GEODE_UTIL_CHRONO_TIME_POINT_H_
+
+#include <iomanip>
+#include <sstream>
+
+#include "time_point.hpp"
+
+namespace apache {
+namespace geode {
+namespace util {
+namespace chrono {
+
+/**
+ * Wrapper around platform specific thread safe localtime functions.
+ * @param time to get local time for
+ * @return local time
+ */
+inline std::tm localtime(const time_t& time) {
+ std::tm localtime;
+#if defined(_WIN32)
+ localtime_s(&localtime, &time);
+#else
+ localtime_r(&time, &localtime);
+#endif
+ return localtime;
+}
+
+/**
+ * Wrapper around platform specific thread safe localtime functions.
+ * @param time to get local time for
+ * @return local time
+ */
+inline std::tm localtime(
+ const std::chrono::system_clock::time_point& time_point) {
+ return localtime(std::chrono::system_clock::to_time_t(time_point));
+}
+
+/**
+ * Produces string representation for given time.
+ * @param time to get string for
+ * @return string representation of given time
+ */
+inline std::string to_string(const time_t& time) {
+ std::stringstream stringstream;
+ const auto local = localtime(time);
+
+#if defined(_WIN32)
+ /*
+ Windows does not allow for time_t to be negative (in the past). Any negative
+ time_t will result in a tm with negative values. Converting this to a string
+ will result in an assertion failure. The original string converstion would
+ then result in something like -1/-1/1998. Rather than return a formatted but
+ invalid time we should return a string indicating and invalid time failed to
+ convert.
+
+ TODO: replace with C++20 std::chrono::format or other date library
+ */
+ if (-1 == local.tm_hour) {
+ return "invalid time";
+ }
+#endif
+
+ stringstream << std::put_time(&local, "%c %Z");
+ return stringstream.str();
+}
+
+/**
+ * Produces string representation for given time_point.
+ * @param time_point to get string for
+ * @return string representation of given time_point
+ */
+inline std::string to_string(
+ const std::chrono::system_clock::time_point& time_point) {
+ return to_string(std::chrono::system_clock::to_time_t(time_point));
+}
+
+} // namespace chrono
+} // namespace util
+} // namespace geode
+} // namespace apache
+
+#endif /* GEODE_UTIL_CHRONO_TIME_POINT_H_ */
diff --git a/cppcache/src/util/string.hpp b/cppcache/src/util/string.hpp
index 76869cc..e05e263 100644
--- a/cppcache/src/util/string.hpp
+++ b/cppcache/src/util/string.hpp
@@ -20,6 +20,7 @@
#ifndef GEODE_UTIL_STRING_H_
#define GEODE_UTIL_STRING_H_
+#include <cctype>
#include <codecvt>
#include <locale>
#include <string>
@@ -155,6 +156,16 @@ inline std::string to_utf8(const std::u32string& ucs4) {
#endif
}
+inline bool equal_ignore_case(const std::string& str1,
+ const std::string& str2) {
+ return ((str1.size() == str2.size()) &&
+ std::equal(str1.begin(), str1.end(), str2.begin(),
+ [](const char& c1, const char& c2) {
+ return (c1 == c2 ||
+ std::toupper(c1) == std::toupper(c2));
+ }));
+}
+
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/test/CMakeLists.txt b/cppcache/test/CMakeLists.txt
index 9cb1e22..d26e090 100644
--- a/cppcache/test/CMakeLists.txt
+++ b/cppcache/test/CMakeLists.txt
@@ -16,8 +16,6 @@
cmake_minimum_required( VERSION 3.10 )
project(apache-geode_unittests LANGUAGES CXX)
-file(GLOB_RECURSE SOURCES "*.cpp")
-
add_executable(apache-geode_unittests
AutoDeleteTest.cpp
ByteArray.cpp
@@ -43,6 +41,7 @@ add_executable(apache-geode_unittests
SerializableCreateTests.cpp
StructSetTest.cpp
TcrMessage_unittest.cpp
+ CacheableDate.cpp
)
target_compile_definitions(apache-geode_unittests
diff --git a/cppcache/test/CacheableDate.cpp b/cppcache/test/CacheableDate.cpp
new file mode 100644
index 0000000..a22774e
--- /dev/null
+++ b/cppcache/test/CacheableDate.cpp
@@ -0,0 +1,125 @@
+/*
+ * 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 <chrono>
+#include <ctime>
+#include <iomanip>
+#include <sstream>
+
+#include <gtest/gtest.h>
... 230 lines suppressed ...