You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bb...@apache.org on 2021/03/26 19:38:35 UTC
[geode-native] branch develop updated: GEODE-9058: Remove ACE_OS
references (#774)
This is an automated email from the ASF dual-hosted git repository.
bbender pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push:
new 5ca01f5 GEODE-9058: Remove ACE_OS references (#774)
5ca01f5 is described below
commit 5ca01f5c4730315cbe036e8a8e79c9d57c788437
Author: Mario Salazar de Torres <ma...@est.tech>
AuthorDate: Fri Mar 26 20:38:24 2021 +0100
GEODE-9058: Remove ACE_OS references (#774)
- All references to ACE_OS have been removed in the source and replaced
by a suitable boost alternative, an STL alternative or in few cases,
a custom alternative.
- Note that most of the impacts are in the old integration tests.
- Boost::iostream added to old integration tests.
---
cppcache/CMakeLists.txt | 2 +
cppcache/integration-test/BBNamingContext.cpp | 45 +-
cppcache/integration-test/BBNamingContext.hpp | 2 +-
.../integration-test/BuiltinCacheableWrappers.hpp | 8 +-
cppcache/integration-test/CMakeLists.txt | 2 +
cppcache/integration-test/CacheHelper.cpp | 780 +++++++++------------
cppcache/integration-test/CacheHelper.hpp | 70 +-
cppcache/integration-test/LocatorHelper.hpp | 6 +-
cppcache/integration-test/QueryHelper.hpp | 29 +-
cppcache/integration-test/ThinClientCQ.hpp | 4 +-
.../integration-test/ThinClientCallbackArg.hpp | 2 +-
cppcache/integration-test/ThinClientDistOps.hpp | 19 +-
cppcache/integration-test/ThinClientDistOps2.hpp | 16 +-
cppcache/integration-test/ThinClientDurable.hpp | 2 +-
.../integration-test/ThinClientDurableConnect.hpp | 27 +-
.../integration-test/ThinClientDurableFailover.hpp | 2 +-
.../integration-test/ThinClientDurableInit.hpp | 2 +-
.../integration-test/ThinClientDurableInterest.hpp | 2 +-
cppcache/integration-test/ThinClientFailover.hpp | 23 +-
cppcache/integration-test/ThinClientFailover2.hpp | 8 +-
cppcache/integration-test/ThinClientFailover3.hpp | 17 +-
.../ThinClientFailoverInterest.hpp | 8 +-
.../ThinClientFailoverInterest2.hpp | 8 +-
.../ThinClientFailoverInterestAllWithCache.hpp | 8 +-
.../integration-test/ThinClientFailoverRegex.hpp | 9 +-
.../integration-test/ThinClientGatewayTest.hpp | 4 +-
cppcache/integration-test/ThinClientHeapLRU.hpp | 2 +-
cppcache/integration-test/ThinClientHelper.hpp | 20 +-
cppcache/integration-test/ThinClientInterest1.hpp | 2 +-
cppcache/integration-test/ThinClientInterest2.hpp | 2 +-
cppcache/integration-test/ThinClientInterest3.hpp | 2 +-
.../ThinClientInterest3Cacheless.hpp | 2 +-
.../integration-test/ThinClientInterestList.hpp | 8 +-
.../integration-test/ThinClientInterestList2.hpp | 6 +-
.../integration-test/ThinClientListenerInit.hpp | 2 +-
.../integration-test/ThinClientListenerWriter.hpp | 9 +-
.../ThinClientLocalCacheLoader.hpp | 2 +-
.../integration-test/ThinClientMultipleCaches.hpp | 2 +-
.../integration-test/ThinClientNotification.hpp | 13 +-
.../integration-test/ThinClientPdxSerializer.hpp | 4 +-
cppcache/integration-test/ThinClientPutAll.hpp | 16 +-
.../integration-test/ThinClientPutAllTimeout.hpp | 2 +-
.../ThinClientPutAllWithCallBack.hpp | 12 +-
cppcache/integration-test/ThinClientPutGetAll.hpp | 8 +-
.../ThinClientRIwithlocalRegionDestroy.hpp | 47 +-
cppcache/integration-test/ThinClientRegex.hpp | 8 +-
cppcache/integration-test/ThinClientRegex2.hpp | 8 +-
cppcache/integration-test/ThinClientRegex3.hpp | 8 +-
cppcache/integration-test/ThinClientRemoveAll.hpp | 8 +-
cppcache/integration-test/ThinClientSecurity.hpp | 2 +-
.../integration-test/ThinClientSecurityHelper.hpp | 39 +-
cppcache/integration-test/ThinClientTXFailover.hpp | 23 +-
.../integration-test/ThinClientTransactions.hpp | 30 +-
.../integration-test/ThinClientTransactionsXA.hpp | 26 +-
.../integration-test/ThinClientVersionedOps.hpp | 2 +-
cppcache/integration-test/TimeBomb.hpp | 30 +-
cppcache/integration-test/fw_dunit.cpp | 222 +++---
cppcache/integration-test/fw_dunit.hpp | 17 +-
cppcache/integration-test/fw_helper.hpp | 10 +-
cppcache/integration-test/fw_spawn.hpp | 74 +-
cppcache/integration-test/locator_globals.hpp | 2 +-
cppcache/integration-test/testCacheless.cpp | 10 +-
.../integration-test/testCreateAndDestroyPool.cpp | 2 +-
cppcache/integration-test/testExpiration.cpp | 60 +-
cppcache/integration-test/testFwPerf.cpp | 2 +-
.../integration-test/testOverflowPutGetSqLite.cpp | 56 +-
.../integration-test/testPdxMetadataCheckTest.cpp | 6 +-
.../testRegionAccessThreadSafe.cpp | 2 +-
cppcache/integration-test/testSpinLock.cpp | 16 +-
cppcache/integration-test/testSystemProperties.cpp | 2 +-
.../testThinClientAfterRegionLive.cpp | 2 +-
.../integration-test/testThinClientBigValue.cpp | 2 +-
.../testThinClientCacheableStringArray.cpp | 13 +-
.../testThinClientCacheablesLimits.cpp | 5 +-
.../integration-test/testThinClientClearRegion.cpp | 2 +-
cppcache/integration-test/testThinClientCq.cpp | 58 +-
.../integration-test/testThinClientCqDelta.cpp | 8 +-
.../integration-test/testThinClientCqDurable.cpp | 4 +-
.../integration-test/testThinClientCqFailover.cpp | 20 +-
.../testThinClientCqHAFailover.cpp | 20 +-
cppcache/integration-test/testThinClientCqIR.cpp | 2 +-
.../testThinClientDeltaWithNotification.cpp | 15 +-
.../testThinClientDisconnectionListioner.cpp | 2 +-
.../testThinClientFixedPartitionResolver.cpp | 2 +-
.../integration-test/testThinClientHADistOps.cpp | 2 +-
.../testThinClientHAEventIDMap.cpp | 2 +-
.../integration-test/testThinClientHAFailover.cpp | 2 +-
.../testThinClientHAFailoverRegex.cpp | 2 +-
.../testThinClientHAMixedRedundancy.cpp | 2 +-
.../testThinClientHAPeriodicAck.cpp | 2 +-
.../testThinClientHAQueryFailover.cpp | 14 +-
.../testThinClientInterest1Cacheless.cpp | 6 +-
.../testThinClientInterestNotify.cpp | 3 +-
.../testThinClientLRUExpiration.cpp | 72 +-
.../testThinClientListenerCallbackArgTest.cpp | 2 +-
.../integration-test/testThinClientLocator.cpp | 10 +-
.../testThinClientLocatorFailover.cpp | 10 +-
.../integration-test/testThinClientMultiDS.cpp | 8 +-
...ThinClientNotificationWithDeltaWithoutcache.cpp | 8 +-
.../testThinClientPRPutAllFailover.cpp | 2 +-
.../integration-test/testThinClientPRSingleHop.cpp | 56 +-
.../testThinClientPRSingleHopServerGroup.cpp | 2 +-
.../testThinClientPdxDeltaWithNotification.cpp | 28 +-
.../integration-test/testThinClientPdxEnum.cpp | 4 +-
.../integration-test/testThinClientPdxInstance.cpp | 21 +-
.../integration-test/testThinClientPdxTests.cpp | 2 +-
.../testThinClientPoolAttrTest.cpp | 15 +-
...hinClientPoolExecuteFunctionThrowsException.cpp | 10 +-
.../testThinClientPoolExecuteHAFunction.cpp | 15 +-
.../testThinClientPoolExecuteHAFunctionPrSHOP.cpp | 2 +-
.../integration-test/testThinClientPoolLocator.cpp | 4 +-
.../testThinClientPoolRedundancy.cpp | 2 +-
.../testThinClientPoolRegInterest.cpp | 2 +-
.../integration-test/testThinClientPoolServer.cpp | 4 +-
.../testThinClientPutAllPRSingleHop.cpp | 38 +-
.../testThinClientPutWithDelta.cpp | 10 +-
...ThinClientRegionQueryDifferentServerConfigs.cpp | 2 +-
.../testThinClientRegionQueryExclusiveness.cpp | 4 +-
.../testThinClientRemoteQueryFailover.cpp | 16 +-
.../testThinClientRemoteQueryFailoverPdx.cpp | 16 +-
.../testThinClientRemoteQueryRS.cpp | 22 +-
.../testThinClientRemoteQuerySS.cpp | 39 +-
.../testThinClientRemoteQueryTimeout.cpp | 31 +-
.../testThinClientRemoteRegionQuery.cpp | 74 +-
.../integration-test/testThinClientRemoveOps.cpp | 10 +-
.../testThinClientSecurityAuthentication.cpp | 4 +-
.../testThinClientSecurityAuthenticationMU.cpp | 4 +-
...ientSecurityAuthenticationSetAuthInitialize.cpp | 6 +-
.../testThinClientSecurityAuthorization.cpp | 4 +-
.../testThinClientSecurityAuthorizationMU.cpp | 4 +-
.../testThinClientSecurityCQAuthorizationMU.cpp | 6 +-
...tThinClientSecurityDurableCQAuthorizationMU.cpp | 4 +-
.../testThinClientSecurityPostAuthorization.cpp | 8 +-
.../testThinClientWriterException.cpp | 4 +-
cppcache/integration-test/testTimedSemaphore.cpp | 46 +-
.../testXmlCacheCreationWithOverFlow.cpp | 2 +-
.../testXmlCacheCreationWithPools.cpp | 29 +-
.../testXmlCacheCreationWithRefid.cpp | 2 +-
.../testXmlCacheInitialization.cpp | 9 +-
cppcache/src/DistributedSystemImpl.cpp | 7 +-
cppcache/src/ReadWriteLock.cpp | 6 +-
cppcache/src/TcrEndpoint.cpp | 13 +-
cppcache/src/Utils.cpp | 106 ++-
cppcache/src/Utils.hpp | 4 +
cppcache/src/config.h.in | 1 +
dependencies/boost/CMakeLists.txt | 2 +
146 files changed, 1439 insertions(+), 1494 deletions(-)
diff --git a/cppcache/CMakeLists.txt b/cppcache/CMakeLists.txt
index dad7bb5..975f706 100644
--- a/cppcache/CMakeLists.txt
+++ b/cppcache/CMakeLists.txt
@@ -24,6 +24,8 @@ if (CMAKE_USE_PTHREADS_INIT)
check_function_exists("pthread_setname_np" HAVE_pthread_setname_np)
endif()
+check_function_exists(uname HAVE_uname)
+
# Search OpenSSL
find_package(OpenSSL COMPONENTS Crypto)
diff --git a/cppcache/integration-test/BBNamingContext.cpp b/cppcache/integration-test/BBNamingContext.cpp
index c788e73..8a8001a 100644
--- a/cppcache/integration-test/BBNamingContext.cpp
+++ b/cppcache/integration-test/BBNamingContext.cpp
@@ -47,7 +47,7 @@ static int hashcode(char *str) {
}
static int getRandomNum() {
- char *testName = ACE_OS::getenv("TESTNAME");
+ char *testName = std::getenv("TESTNAME");
int seed = hashcode(testName) + 11;
@@ -57,9 +57,9 @@ static int getRandomNum() {
// value specific to the test by way of the test name.
// Whilst this approach is pessimal, it can not be
// remedied as the test depend upon it.
- ACE_OS::srand(seed);
+ std::srand(seed);
// NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.rand)
- return (ACE_OS::rand() % 49999) + 14000;
+ return (std::rand() % 49999) + 14000;
}
static int G_BBPORT = getRandomNum();
@@ -77,7 +77,7 @@ class BBNamingContextClientImpl {
void close();
void dump();
int rebind(const char *key, const char *value, char *type);
- int resolve(const char *key, char *value, char *type);
+ int resolve(const std::string &key, std::string &value, char *);
};
class BBNamingContextServerImpl {
@@ -100,16 +100,11 @@ BBNamingContextClientImpl::BBNamingContextClientImpl()
BBNamingContextClientImpl::~BBNamingContextClientImpl() { close(); }
void BBNamingContextClientImpl::open() {
try {
- // char * bbPort = ACE_OS::getenv( "BB_PORT" );
-
- char temp[8];
- char *bbPort = ACE_OS::itoa(G_BBPORT, temp, 10);
-
- char buf[1024];
- ACE_OS::sprintf(buf, "localhost:%s", bbPort);
- fprintf(stdout, "Blackboard client is talking on %s\n", buf);
+ // char * bbPort = std::getenv( "BB_PORT" );
+ std::string endpoint = "localhost:" + std::to_string(G_BBPORT);
+ fprintf(stdout, "Blackboard client is talking on %s\n", endpoint.c_str());
fflush(stdout);
- m_bbc = new FwkBBClient(buf);
+ m_bbc = new FwkBBClient(endpoint);
} catch (FwkException &e) {
FWKEXCEPTION("create bb client encounted Exception: " << e.what());
} catch (...) {
@@ -177,8 +172,8 @@ void BBNamingContextClientImpl::dump() {
FWKEXCEPTION("dump unknown exception\n");
}
}
-int BBNamingContextClientImpl::resolve(const char *key, char *value, char *) {
- // fprintf(stdout, "resolve: key=%s\n", key);fflush(stdout);
+int BBNamingContextClientImpl::resolve(const std::string &key,
+ std::string &value, char *) {
if (m_bbc == nullptr) {
return -1;
}
@@ -187,16 +182,11 @@ int BBNamingContextClientImpl::resolve(const char *key, char *value, char *) {
return -1;
}
try {
- std::string k(key);
- std::string k1("1");
- std::string v = m_bbc->getString(k, k1);
- // fprintf(stdout, "resolve: got value %s for key=%s\n", v.c_str(),
- // key);fflush(stdout);
- ACE_OS::strncpy(value, v.c_str(), sizeof(value));
+ value = m_bbc->getString(key, "1");
if (m_errCount > 0) {
m_errCount = 0;
}
- return v.length() == 0 ? -1 : 0;
+ return value.length() == 0 ? -1 : 0;
} catch (FwkException &e) {
m_errCount++;
FWKEXCEPTION("create resolve encounted Exception: " << e.what());
@@ -223,10 +213,10 @@ bool BBNamingContextClientImpl::checkValue(const std::string &k,
BBNamingContextServerImpl::BBNamingContextServerImpl() {
try {
- // char * bbPort = ACE_OS::getenv( "BB_PORT" );
- char temp[8];
- char *bbPort = ACE_OS::itoa(G_BBPORT, temp, 10);
- FwkStrCvt bPort(bbPort);
+ // char * bbPort = std::getenv( "BB_PORT" );
+
+ std::string port = std::to_string(G_BBPORT);
+ FwkStrCvt bPort(port);
uint32_t prt = bPort.toUInt32();
fprintf(stdout, "Blackboard server is on port:%u\n", prt);
fflush(stdout);
@@ -273,7 +263,8 @@ int BBNamingContextClient::rebind(const char *key, const char *value,
char *type) {
return m_impl->rebind(key, value, type);
}
-int BBNamingContextClient::resolve(const char *key, char *value, char *type) {
+int BBNamingContextClient::resolve(const std::string &key, std::string &value,
+ char *type) {
return m_impl->resolve(key, value, type);
}
//
diff --git a/cppcache/integration-test/BBNamingContext.hpp b/cppcache/integration-test/BBNamingContext.hpp
index b1791ea..c00ebfb 100644
--- a/cppcache/integration-test/BBNamingContext.hpp
+++ b/cppcache/integration-test/BBNamingContext.hpp
@@ -44,7 +44,7 @@ class BBNamingContextClient {
void close();
int rebind(const char* key, const char* value, char* type = nullptr);
void dump();
- int resolve(const char* key, char* value, char* type = nullptr);
+ int resolve(const std::string& key, std::string& value, char* type = nullptr);
};
class BBNamingContextServerImpl;
class BBNamingContextServer {
diff --git a/cppcache/integration-test/BuiltinCacheableWrappers.hpp b/cppcache/integration-test/BuiltinCacheableWrappers.hpp
index 1efa2a1..acdd36c 100644
--- a/cppcache/integration-test/BuiltinCacheableWrappers.hpp
+++ b/cppcache/integration-test/BuiltinCacheableWrappers.hpp
@@ -336,10 +336,12 @@ class CacheableDateWrapper : public CacheableWrapper {
void initRandomValue(int32_t) override {
auto rnd = CacheableHelper::random<int32_t>(INT_MAX);
- const ACE_Time_Value currentTime = ACE_OS::gettimeofday();
- auto timeofday = currentTime.sec();
+ auto timeofday = std::chrono::time_point_cast<std::chrono::seconds>(
+ std::chrono::system_clock::now())
+ .time_since_epoch()
+ .count();
time_t epoctime =
- static_cast<time_t>(timeofday + (rnd * (rnd % 2 == 0 ? 1 : -1)));
+ static_cast<time_t>(timeofday + (rnd * (rnd & 1 ? -1 : 1)));
m_cacheableObject = CacheableDate::create(epoctime);
}
diff --git a/cppcache/integration-test/CMakeLists.txt b/cppcache/integration-test/CMakeLists.txt
index a2ceb77..efc7f43 100644
--- a/cppcache/integration-test/CMakeLists.txt
+++ b/cppcache/integration-test/CMakeLists.txt
@@ -108,6 +108,8 @@ foreach(FILE ${SOURCES})
target_link_libraries(${TEST}
PRIVATE
ACE::ACE
+ Boost::boost
+ Boost::iostreams
test-cppcache-utils
_WarningsAsError
_CppCodeCoverage
diff --git a/cppcache/integration-test/CacheHelper.cpp b/cppcache/integration-test/CacheHelper.cpp
index dde64e2..a7be4fd 100644
--- a/cppcache/integration-test/CacheHelper.cpp
+++ b/cppcache/integration-test/CacheHelper.cpp
@@ -19,10 +19,11 @@
#include <regex>
#include <list>
-#include <ace/OS.h>
#include <ace/INET_Addr.h>
#include <ace/SOCK_Acceptor.h>
+#include <boost/process.hpp>
+
#include <geode/SystemProperties.hpp>
#include <geode/PoolManager.hpp>
#include <geode/internal/chrono/duration.hpp>
@@ -36,7 +37,6 @@
#include "TimeBomb.hpp"
#include "Utils.hpp"
#include "CacheImpl.hpp"
-#include "config.h"
#include "CacheHelper.hpp"
#define __DUNIT_NO_MAIN__
@@ -55,10 +55,8 @@
#if defined(WIN32)
#define COPY_COMMAND "copy /y"
-#define DELETE_COMMAND "del /f"
#define PATH_SEP "\\"
#else
-#define DELETE_COMMAND "rm -f"
#define PATH_SEP "/"
#endif
@@ -111,16 +109,14 @@ CacheHelper::CacheHelper(const char *,
}
/** rootRegionPtr will still be null... */
-CacheHelper::CacheHelper(const char *, const char *cachexml,
+CacheHelper::CacheHelper(const char *, const std::string &cachexml,
const std::shared_ptr<Properties> &configPtr) {
auto pp = configPtr;
if (pp == nullptr) {
pp = Properties::create();
}
- if (cachexml != nullptr) {
- std::string tmpXmlFile(cachexml);
- std::string newFile;
- CacheHelper::createDuplicateXMLFile(newFile, tmpXmlFile);
+ if (!cachexml.empty()) {
+ auto newFile = CacheHelper::createDuplicateXMLFile(cachexml);
pp->insert("cache-xml-file", newFile.c_str());
}
auto cacheFactory = CacheFactory(pp);
@@ -208,8 +204,8 @@ CacheHelper::CacheHelper(const bool, bool pdxIgnoreUnreadFields,
}
}
-CacheHelper::CacheHelper(const bool, const char *poolName, const char *locators,
- const char *serverGroup,
+CacheHelper::CacheHelper(const bool, const char *poolName,
+ const std::string &locators, const char *serverGroup,
const std::shared_ptr<Properties> &configPtr,
int redundancy, bool clientNotification,
int subscriptionAckInterval, int connections,
@@ -230,7 +226,7 @@ CacheHelper::CacheHelper(const bool, const char *poolName, const char *locators,
poolFactory.setThreadLocalConnections(threadLocal);
printf(" Setting pr-single-hop to prSingleHop = %d ", prSingleHop);
printf("Setting threadLocal to %d ", threadLocal);
- if (locators) {
+ if (!locators.empty()) {
addServerLocatorEPs(locators, poolFactory);
if (serverGroup) {
poolFactory.setServerGroup(serverGroup);
@@ -365,7 +361,7 @@ std::shared_ptr<Region> CacheHelper::getRegion(const std::string &name) {
return cachePtr->getRegion(name);
}
std::shared_ptr<Region> CacheHelper::createRegion(
- const char *name, bool, bool caching,
+ const std::string &name, bool, bool caching,
const std::shared_ptr<CacheListener> &listener, bool, bool,
bool concurrencyCheckEnabled, int32_t) {
RegionAttributesFactory regionAttributeFactory;
@@ -385,10 +381,10 @@ std::shared_ptr<Region> CacheHelper::createRegion(
return regionPtr;
}
std::shared_ptr<Region> CacheHelper::createRegion(
- const char *name, bool, bool caching, const std::chrono::seconds &ettl,
- const std::chrono::seconds &eit, const std::chrono::seconds &rttl,
- const std::chrono::seconds &rit, int lel, ExpirationAction action,
- const char *, bool) {
+ const std::string &name, bool, bool caching,
+ const std::chrono::seconds &ettl, const std::chrono::seconds &eit,
+ const std::chrono::seconds &rttl, const std::chrono::seconds &rit, int lel,
+ ExpirationAction action, const std::string &, bool) {
RegionAttributesFactory regionAttributeFactory;
regionAttributeFactory.setCachingEnabled(caching);
regionAttributeFactory.setLruEntriesLimit(lel);
@@ -405,15 +401,15 @@ std::shared_ptr<Region> CacheHelper::createRegion(
return regionPtr;
}
std::shared_ptr<Pool> CacheHelper::createPool(
- const std::string &poolName, const char *locators, const char *serverGroup,
- int redundancy, bool clientNotification,
+ const std::string &poolName, const std::string &locators,
+ const std::string &serverGroup, int redundancy, bool clientNotification,
std::chrono::milliseconds subscriptionAckInterval, int connections,
int loadConditioningInterval, bool isMultiuserMode) {
// printf(" in createPool isMultiuserMode = %d \n", isMultiuserMode);
auto poolFac = getCache()->getPoolManager().createFactory();
addServerLocatorEPs(locators, poolFac);
- if (serverGroup) {
+ if (!serverGroup.empty()) {
poolFac.setServerGroup(serverGroup);
}
@@ -439,17 +435,17 @@ std::shared_ptr<Pool> CacheHelper::createPool(
// this will create pool even endpoints and locatorhost has been not defined
std::shared_ptr<Pool> CacheHelper::createPool2(
- const char *poolName, const char *locators, const char *serverGroup,
- const char *servers, int redundancy, bool clientNotification,
- int subscriptionAckInterval, int connections) {
+ const std::string &poolName, const std::string &locators,
+ const std::string &serverGroup, const std::string &servers, int redundancy,
+ bool clientNotification, int subscriptionAckInterval, int connections) {
auto poolFac = getCache()->getPoolManager().createFactory();
- if (servers) {
+ if (!servers.empty()) {
addServerLocatorEPs(servers, poolFac, false);
// do region creation with end
- } else if (locators) {
+ } else if (!locators.empty()) {
addServerLocatorEPs(locators, poolFac);
- if (serverGroup) {
+ if (!serverGroup.empty()) {
poolFac.setServerGroup(serverGroup);
}
}
@@ -501,10 +497,10 @@ void CacheHelper::logPoolAttributes(std::shared_ptr<Pool> &pool) {
}
void CacheHelper::createPoolWithLocators(
- const std::string &name, const char *locators,
+ const std::string &name, const std::string &locators,
bool clientNotificationEnabled, int subscriptionRedundancy,
std::chrono::milliseconds subscriptionAckInterval, int connections,
- bool isMultiuserMode, const char *serverGroup) {
+ bool isMultiuserMode, const std::string &serverGroup) {
LOG("createPool() entered.");
printf(" in createPoolWithLocators isMultiuserMode = %d\n", isMultiuserMode);
auto poolPtr = createPool(name, locators, serverGroup, subscriptionRedundancy,
@@ -561,8 +557,8 @@ std::shared_ptr<Region> CacheHelper::createRegionAndAttachPool2(
return regionFactory.create(name);
}
-void CacheHelper::addServerLocatorEPs(const char *epList, PoolFactory &pf,
- bool poolLocators) {
+void CacheHelper::addServerLocatorEPs(const std::string &epList,
+ PoolFactory &pf, bool poolLocators) {
std::unordered_set<std::string> endpointNames;
Utils::parseEndpointNamesString(epList, endpointNames);
for (const auto &endpointName : endpointNames) {
@@ -580,8 +576,8 @@ void CacheHelper::addServerLocatorEPs(const char *epList, PoolFactory &pf,
}
std::shared_ptr<Region> CacheHelper::createPooledRegion(
- const char *name, bool, const char *locators, const char *poolName,
- bool caching, bool clientNotificationEnabled,
+ const std::string &name, bool, const std::string &locators,
+ const std::string &poolName, bool caching, bool clientNotificationEnabled,
const std::chrono::seconds &ettl, const std::chrono::seconds &eit,
const std::chrono::seconds &rttl, const std::chrono::seconds &rit, int lel,
const std::shared_ptr<CacheListener> &cacheListener,
@@ -589,7 +585,7 @@ std::shared_ptr<Region> CacheHelper::createPooledRegion(
auto poolFac = getCache()->getPoolManager().createFactory();
poolFac.setSubscriptionEnabled(clientNotificationEnabled);
- if (locators) {
+ if (!locators.empty()) {
LOG("adding pool locators");
addServerLocatorEPs(locators, poolFac);
}
@@ -619,10 +615,11 @@ std::shared_ptr<Region> CacheHelper::createPooledRegion(
return regionFactory.create(name);
}
std::shared_ptr<Region> CacheHelper::createPooledRegionConcurrencyCheckDisabled(
- const char *name, bool, const char *locators, const char *poolName,
- bool caching, bool clientNotificationEnabled, bool concurrencyCheckEnabled,
- const std::chrono::seconds &ettl, const std::chrono::seconds &eit,
- const std::chrono::seconds &rttl, const std::chrono::seconds &rit, int lel,
+ const std::string &name, bool, const std::string &locators,
+ const std::string &poolName, bool caching, bool clientNotificationEnabled,
+ bool concurrencyCheckEnabled, const std::chrono::seconds &ettl,
+ const std::chrono::seconds &eit, const std::chrono::seconds &rttl,
+ const std::chrono::seconds &rit, int lel,
const std::shared_ptr<CacheListener> &cacheListener,
ExpirationAction action) {
auto poolFac = getCache()->getPoolManager().createFactory();
@@ -657,9 +654,10 @@ std::shared_ptr<Region> CacheHelper::createPooledRegionConcurrencyCheckDisabled(
return regionFactory.create(name);
}
std::shared_ptr<Region> CacheHelper::createRegionDiscOverFlow(
- const char *name, bool caching, bool, const std::chrono::seconds &ettl,
- const std::chrono::seconds &eit, const std::chrono::seconds &rttl,
- const std::chrono::seconds &rit, int lel, ExpirationAction action) {
+ const std::string &name, bool caching, bool,
+ const std::chrono::seconds &ettl, const std::chrono::seconds &eit,
+ const std::chrono::seconds &rttl, const std::chrono::seconds &rit, int lel,
+ ExpirationAction action) {
RegionAttributesFactory regionAttributeFactory;
regionAttributeFactory.setCachingEnabled(caching);
regionAttributeFactory.setLruEntriesLimit(lel);
@@ -674,7 +672,7 @@ std::shared_ptr<Region> CacheHelper::createRegionDiscOverFlow(
sqLiteProps->insert("PageSize", "65536");
sqLiteProps->insert("MaxPageCount", "1073741823");
std::string sqlite_dir =
- "SqLiteRegionData" + std::to_string(ACE_OS::getpid());
+ "SqLiteRegionData" + std::to_string(boost::this_process::get_id());
sqLiteProps->insert("PersistenceDirectory", sqlite_dir.c_str());
regionAttributeFactory.setPersistenceManager(
"SqLiteImpl", "createSqLiteInstance", sqLiteProps);
@@ -687,8 +685,8 @@ std::shared_ptr<Region> CacheHelper::createRegionDiscOverFlow(
return regionPtr;
}
std::shared_ptr<Region> CacheHelper::createPooledRegionDiscOverFlow(
- const char *name, bool, const char *locators, const char *poolName,
- bool caching, bool clientNotificationEnabled,
+ const std::string &name, bool, const std::string &locators,
+ const std::string &poolName, bool caching, bool clientNotificationEnabled,
const std::chrono::seconds &ettl, const std::chrono::seconds &eit,
const std::chrono::seconds &rttl, const std::chrono::seconds &rit, int lel,
const std::shared_ptr<CacheListener> &cacheListener,
@@ -696,7 +694,7 @@ std::shared_ptr<Region> CacheHelper::createPooledRegionDiscOverFlow(
auto poolFac = getCache()->getPoolManager().createFactory();
poolFac.setSubscriptionEnabled(clientNotificationEnabled);
- if (locators) // with locator
+ if (!locators.empty()) // with locator
{
LOG("adding pool locators");
addServerLocatorEPs(locators, poolFac);
@@ -731,7 +729,7 @@ std::shared_ptr<Region> CacheHelper::createPooledRegionDiscOverFlow(
sqLiteProps->insert("PageSize", "65536");
sqLiteProps->insert("MaxPageCount", "1073741823");
std::string sqlite_dir =
- "SqLiteRegionData" + std::to_string(ACE_OS::getpid());
+ "SqLiteRegionData" + std::to_string(boost::this_process::get_id());
sqLiteProps->insert("PersistenceDirectory", sqlite_dir.c_str());
regionFactory.setPersistenceManager("SqLiteImpl", "createSqLiteInstance",
sqLiteProps);
@@ -741,9 +739,10 @@ std::shared_ptr<Region> CacheHelper::createPooledRegionDiscOverFlow(
}
return regionFactory.create(name);
}
+
std::shared_ptr<Region> CacheHelper::createPooledRegionSticky(
- const char *name, bool, const char *locators, const char *poolName,
- bool caching, bool clientNotificationEnabled,
+ const std::string &name, bool, const std::string &locators,
+ const std::string &poolName, bool caching, bool clientNotificationEnabled,
const std::chrono::seconds &ettl, const std::chrono::seconds &eit,
const std::chrono::seconds &rttl, const std::chrono::seconds &rit, int lel,
const std::shared_ptr<CacheListener> &cacheListener,
@@ -783,8 +782,8 @@ std::shared_ptr<Region> CacheHelper::createPooledRegionSticky(
return regionFactory.create(name);
}
std::shared_ptr<Region> CacheHelper::createPooledRegionStickySingleHop(
- const char *name, bool, const char *locators, const char *poolName,
- bool caching, bool clientNotificationEnabled,
+ const std::string &name, bool, const std::string &locators,
+ const std::string &poolName, bool caching, bool clientNotificationEnabled,
const std::chrono::seconds &ettl, const std::chrono::seconds &eit,
const std::chrono::seconds &rttl, const std::chrono::seconds &rit, int lel,
const std::shared_ptr<CacheListener> &cacheListener,
@@ -863,169 +862,139 @@ void CacheHelper::showRegionAttributes(RegionAttributes attributes) {
printf("Load Factor = %f\n", attributes.getLoadFactor());
printf("End Points = %s\n", attributes.getEndpoints().c_str());
}
+
std::shared_ptr<QueryService> CacheHelper::getQueryService() {
return cachePtr->getQueryService();
}
const std::string CacheHelper::getTcrEndpoints(bool &isLocalServer,
int numberOfServers) {
- static char *gfjavaenv = ACE_OS::getenv("GFJAVA");
- std::string gfendpoints;
static bool gflocalserver = false;
- char tmp[100];
-
- if (gfendpoints.empty()) {
- ASSERT(gfjavaenv != nullptr,
- "Environment variable GFJAVA for java build directory is not set.");
- if ((ACE_OS::strchr(gfjavaenv, '\\') != nullptr) ||
- (ACE_OS::strchr(gfjavaenv, '/') != nullptr)) {
- gflocalserver = true;
- /* Support for multiple servers Max = 10*/
- switch (numberOfServers) {
- case 1:
- // gfendpoints = "localhost:24680";
- {
- gfendpoints = "localhost:";
- sprintf(tmp, "%d", CacheHelper::staticHostPort1);
- gfendpoints += tmp;
- }
- break;
- case 2:
- // gfendpoints = "localhost:24680,localhost:24681";
- {
- gfendpoints = "localhost:";
- sprintf(tmp, "%d", CacheHelper::staticHostPort1);
- gfendpoints += tmp;
- gfendpoints += ",localhost:";
- sprintf(tmp, "%d", CacheHelper::staticHostPort2);
- gfendpoints += tmp;
- }
- break;
- case 3:
- // gfendpoints = "localhost:24680,localhost:24681,localhost:24682";
- {
- gfendpoints = "localhost:";
- sprintf(tmp, "%d", CacheHelper::staticHostPort1);
- gfendpoints += tmp;
- gfendpoints += ",localhost:";
- sprintf(tmp, "%d", CacheHelper::staticHostPort2);
- gfendpoints += tmp;
- gfendpoints += ",localhost:";
- sprintf(tmp, "%d", CacheHelper::staticHostPort3);
- gfendpoints += tmp;
- }
- break;
- default:
- // ASSERT( ( numberOfServers <= 10 )," More than 10 servers not
- // supported");
- // TODO: need to support more servers, need to generate random ports
- // here
- ASSERT((numberOfServers <= 4), " More than 4 servers not supported");
+ static const auto gfjavaenv = Utils::getEnv("GFJAVA");
+
+ ASSERT(!gfjavaenv.empty(),
+ "Environment variable GFJAVA for java build directory is not set.");
+
+ std::string gfendpoints;
+ if (gfjavaenv.find(PATH_SEP) != std::string::npos) {
+ gflocalserver = true;
+ /* Support for multiple servers Max = 10*/
+ switch (numberOfServers) {
+ case 1:
+ // gfendpoints = "localhost:24680";
+ {
gfendpoints = "localhost:";
- sprintf(tmp, "%d", CacheHelper::staticHostPort1);
- gfendpoints += tmp;
+ gfendpoints += std::to_string(CacheHelper::staticHostPort1);
+ }
+ break;
+ case 2:
+ // gfendpoints = "localhost:24680,localhost:24681";
+ {
+ gfendpoints = "localhost:";
+ gfendpoints += std::to_string(CacheHelper::staticHostPort1);
gfendpoints += ",localhost:";
- sprintf(tmp, "%d", CacheHelper::staticHostPort2);
- gfendpoints += tmp;
+ gfendpoints += std::to_string(CacheHelper::staticHostPort2);
+ }
+ break;
+ case 3:
+ // gfendpoints = "localhost:24680,localhost:24681,localhost:24682";
+ {
+ gfendpoints = "localhost:";
+ gfendpoints += std::to_string(CacheHelper::staticHostPort1);
gfendpoints += ",localhost:";
- sprintf(tmp, "%d", CacheHelper::staticHostPort3);
- gfendpoints += tmp;
+ gfendpoints += std::to_string(CacheHelper::staticHostPort2);
gfendpoints += ",localhost:";
- sprintf(tmp, "%d", CacheHelper::staticHostPort4);
- gfendpoints += tmp;
- /*gfendpoints = "localhost:24680";
- char temp[8];
- for(int i =1; i <= numberOfServers - 1; i++) {
- gfendpoints += ",localhost:2468";
- gfendpoints += ACE_OS::itoa(i,temp,10);
- }*/
- break;
- }
- } else {
- gfendpoints = gfjavaenv;
+ gfendpoints += std::to_string(CacheHelper::staticHostPort3);
+ }
+ break;
+ default:
+ // ASSERT( ( numberOfServers <= 10 )," More than 10 servers not
+ // supported");
+ // TODO: need to support more servers, need to generate random ports
+ // here
+ ASSERT((numberOfServers <= 4), " More than 4 servers not supported");
+ gfendpoints = "localhost:";
+ gfendpoints += std::to_string(CacheHelper::staticHostPort1);
+ gfendpoints += ",localhost:";
+ gfendpoints += std::to_string(CacheHelper::staticHostPort2);
+ gfendpoints += ",localhost:";
+ gfendpoints += std::to_string(CacheHelper::staticHostPort3);
+ gfendpoints += ",localhost:";
+ gfendpoints += std::to_string(CacheHelper::staticHostPort4);
+ break;
}
+ } else {
+ gfendpoints = gfjavaenv;
}
+
isLocalServer = gflocalserver;
printf("getHostPort :: %s \n", gfendpoints.c_str());
- return (gfendpoints);
+
+ return gfendpoints;
}
-const char *CacheHelper::getstaticLocatorHostPort1() {
+std::string CacheHelper::getstaticLocatorHostPort1() {
return getLocatorHostPort(staticLocatorHostPort1);
}
-const char *CacheHelper::getstaticLocatorHostPort2() {
+std::string CacheHelper::getstaticLocatorHostPort2() {
return getLocatorHostPort(staticLocatorHostPort2);
}
-const char *CacheHelper::getLocatorHostPort(int locPort) {
- char tmp[128];
- std::string gfendpoints;
- gfendpoints = "localhost:";
- sprintf(tmp, "%d", locPort);
- gfendpoints += tmp;
- return (new std::string(gfendpoints.c_str()))->c_str();
+std::string CacheHelper::getLocatorHostPort(int locPort) {
+ return "localhost:" + std::to_string(locPort);
}
-const char *CacheHelper::getLocatorHostPort(bool &isLocator,
+std::string CacheHelper::getLocatorHostPort(bool &isLocator,
bool &isLocalServer,
int numberOfLocators) {
- static char *gfjavaenv = ACE_OS::getenv("GFJAVA");
- static std::string gflchostport;
+ static const auto gfjavaenv = Utils::getEnv("GFJAVA");
static bool gflocator = false;
static bool gflocalserver = false;
- char tmp[100];
-
- if (gflchostport.empty()) {
- if ((ACE_OS::strchr(gfjavaenv, '\\') != nullptr) ||
- (ACE_OS::strchr(gfjavaenv, '/') != nullptr)) {
- gflocator = true;
- gflocalserver = true;
- switch (numberOfLocators) {
- case 1:
- // gflchostport = "localhost:34756";
- {
- gflchostport = "localhost:";
- sprintf(tmp, "%d", CacheHelper::staticLocatorHostPort1);
- gflchostport += tmp;
- }
- break;
- case 2:
- // gflchostport = "localhost:34756,localhost:34757";
- {
- gflchostport = "localhost:";
- sprintf(tmp, "%d", CacheHelper::staticLocatorHostPort1);
- gflchostport += tmp;
- sprintf(tmp, "%d", CacheHelper::staticLocatorHostPort2);
- gflchostport += ",localhost:";
- gflchostport += tmp;
- }
- break;
- default:
- // gflchostport = "localhost:34756,localhost:34757,localhost:34758";
- {
- gflchostport = "localhost:";
- sprintf(tmp, "%d", CacheHelper::staticLocatorHostPort1);
- gflchostport += tmp;
- sprintf(tmp, "%d", CacheHelper::staticLocatorHostPort2);
- gflchostport += ",localhost:";
- gflchostport += tmp;
- sprintf(tmp, "%d", CacheHelper::staticLocatorHostPort3);
- gflchostport += ",localhost:";
- gflchostport += tmp;
- }
- break;
- }
- } else {
- gflchostport = "";
+
+ ASSERT(!gfjavaenv.empty(),
+ "Environment variable GFJAVA for java build directory is not set.");
+
+ std::string gflchostport;
+ if (gfjavaenv.find(PATH_SEP) != std::string::npos) {
+ gflocator = true;
+ gflocalserver = true;
+ switch (numberOfLocators) {
+ case 1:
+ // gflchostport = "localhost:34756";
+ {
+ gflchostport = "localhost:";
+ gflchostport += std::to_string(CacheHelper::staticLocatorHostPort1);
+ }
+ break;
+ case 2:
+ // gflchostport = "localhost:34756,localhost:34757";
+ {
+ gflchostport = "localhost:";
+ gflchostport += std::to_string(CacheHelper::staticLocatorHostPort1);
+ gflchostport += ",localhost:";
+ gflchostport += std::to_string(CacheHelper::staticLocatorHostPort2);
+ }
+ break;
+ default:
+ // gflchostport = "localhost:34756,localhost:34757,localhost:34758";
+ {
+ gflchostport = "localhost:";
+ gflchostport += std::to_string(CacheHelper::staticLocatorHostPort1);
+ gflchostport += ",localhost:";
+ gflchostport += std::to_string(CacheHelper::staticLocatorHostPort2);
+ gflchostport += ",localhost:";
+ gflchostport += std::to_string(CacheHelper::staticLocatorHostPort3);
+ }
+ break;
}
}
- ASSERT(gfjavaenv != nullptr,
- "Environment variable GFJAVA for java build directory is not set.");
+
isLocator = gflocator;
isLocalServer = gflocalserver;
printf("getLocatorHostPort :: %s \n", gflchostport.c_str());
- return gflchostport.c_str();
+
+ return gflchostport;
}
void CacheHelper::cleanupServerInstances() {
@@ -1039,11 +1008,11 @@ void CacheHelper::cleanupServerInstances() {
}
}
}
-void CacheHelper::initServer(int instance, const char *xml,
- const char *locHostport, const char * /*unused*/,
- bool ssl, bool enableDelta, bool multiDS,
- bool testServerGC, bool untrustedCert,
- bool useSecurityManager) {
+void CacheHelper::initServer(int instance, const std::string &xml,
+ const std::string &locHostport,
+ const char * /*unused*/, bool ssl,
+ bool enableDelta, bool, bool testServerGC,
+ bool untrustedCert, bool useSecurityManager) {
if (!isServerCleanupCallbackRegistered &&
gClientCleanup.registerCallback(&CacheHelper::cleanupServerInstances)) {
isServerCleanupCallbackRegistered = true;
@@ -1051,38 +1020,29 @@ void CacheHelper::initServer(int instance, const char *xml,
}
printf("Inside initServer added\n");
- static const char *gfjavaenv = ACE_OS::getenv("GFJAVA");
- static const char *gfLogLevel = ACE_OS::getenv("GFE_LOGLEVEL");
- static const char *gfSecLogLevel = ACE_OS::getenv("GFE_SECLOGLEVEL");
- static const char *path = ACE_OS::getenv("TESTSRC");
- static const char *mcastPort = ACE_OS::getenv("MCAST_PORT");
- static const char *mcastAddr = ACE_OS::getenv("MCAST_ADDR");
- static char *classpath = ACE_OS::getenv("GF_CLASSPATH");
+ static const auto gfjavaenv = Utils::getEnv("GFJAVA");
+ static auto gfLogLevel = Utils::getEnv("GFE_LOGLEVEL");
+ static auto gfSecLogLevel = Utils::getEnv("GFE_SECLOGLEVEL");
+ static const auto path = Utils::getEnv("TESTSRC");
+ static const auto classpath = Utils::getEnv("GF_CLASSPATH");
- char tmp[128];
- char currWDPath[2048];
int portNum = 0;
- std::string currDir = ACE_OS::getcwd(currWDPath, 2048);
+ std::string currDir = boost::filesystem::current_path().string();
- ASSERT(gfjavaenv != nullptr,
+ ASSERT(!gfjavaenv.empty(),
"Environment variable GFJAVA for java build directory is not set.");
- ASSERT(path != nullptr,
+ ASSERT(!path.empty(),
"Environment variable TESTSRC for test source directory is not set.");
- ASSERT(mcastPort != nullptr,
- "Environment variable MCAST_PORT for multicast port is not set.");
- ASSERT(mcastAddr != nullptr,
- "Environment variable MCAST_ADDR for multicast address is not set.");
- ASSERT(!currDir.empty(),
- "Current working directory could not be determined.");
- if (gfLogLevel == nullptr || gfLogLevel[0] == '\0') {
+
+ if (gfLogLevel.empty()) {
gfLogLevel = "config";
}
- if (gfSecLogLevel == nullptr || gfSecLogLevel[0] == '\0') {
+
+ if (gfSecLogLevel.empty()) {
gfSecLogLevel = "config";
}
- if ((ACE_OS::strchr(gfjavaenv, '\\') == nullptr) &&
- (ACE_OS::strchr(gfjavaenv, '/') == nullptr)) {
+ if (gfjavaenv.find(PATH_SEP) == std::string::npos) {
return;
}
@@ -1094,90 +1054,54 @@ void CacheHelper::initServer(int instance, const char *xml,
case 0:
// note: this need to take for multiple tests run
xmlFile += "cacheserver.xml";
- sname += "0";
- if (multiDS) {
- mcastPort = "5431";
- mcastAddr = "224.10.11.";
- }
break;
case 1:
xmlFile += "cacheserver.xml";
- sprintf(tmp, "%d", CacheHelper::staticHostPort1);
- sname += tmp; // sname += "1";
portNum = CacheHelper::staticHostPort1;
-
- if (multiDS) {
- mcastPort = "5431";
- mcastAddr = "224.10.11.";
- }
break;
case 2:
xmlFile += "cacheserver2.xml";
- sprintf(tmp, "%d", CacheHelper::staticHostPort2);
- sname += tmp; // sname += "3";
portNum = CacheHelper::staticHostPort2;
- // sname += "2";
- if (multiDS) {
- mcastPort = "5431";
- mcastAddr = "224.10.11.";
- }
break;
case 3:
xmlFile += "cacheserver3.xml";
- sprintf(tmp, "%d", CacheHelper::staticHostPort3);
- sname += tmp; // sname += "3";
portNum = CacheHelper::staticHostPort3;
- // sname += "3";
- if (multiDS) {
- mcastPort = "5433";
- mcastAddr = "224.10.11.";
- }
break;
case 4:
xmlFile += "cacheserver4.xml";
- // sname += "4";
- sprintf(tmp, "%d", CacheHelper::staticHostPort4);
- sname += tmp; // sname += "3";
portNum = CacheHelper::staticHostPort4;
- if (multiDS) {
- mcastPort = "5433";
- mcastAddr = "224.10.11.";
- }
break;
default: /* Support for any number of servers Max 10*/
ASSERT((instance <= 10), " More than 10 servers not supported");
- ASSERT(xml != nullptr,
+ ASSERT(!xml.empty(),
"xml == nullptr : For server instance > 3 xml file is must");
- char temp[8];
portNum = CacheHelper::staticHostPort4;
- sname += ACE_OS::itoa(CacheHelper::staticHostPort4, temp, 10);
break;
}
+ sname += std::to_string(portNum);
currDir += sname;
- if (xml != nullptr) {
+ if (!xml.empty()) {
xmlFile = xml;
}
std::string xmlFile_new;
printf(" xml file name = %s \n", xmlFile.c_str());
- CacheHelper::createDuplicateXMLFile(xmlFile_new, xmlFile);
-
- xmlFile = xmlFile_new;
+ xmlFile = CacheHelper::createDuplicateXMLFile(xmlFile);
printf(" creating dir = %s \n", sname.c_str());
- ACE_OS::mkdir(sname.c_str());
+ boost::filesystem::create_directory(sname);
int64_t defaultTombstone_timeout = 600000;
int64_t defaultTombstone_gc_threshold = 100000;
int64_t userTombstone_timeout = 1000;
int64_t userTombstone_gc_threshold = 10;
if (testServerGC) {
- ACE_OS::mkdir("backupDirectory1");
- ACE_OS::mkdir("backupDirectory2");
- ACE_OS::mkdir("backupDirectory3");
- ACE_OS::mkdir("backupDirectory4");
+ boost::filesystem::create_directory("backupDirectory1");
+ boost::filesystem::create_directory("backupDirectory2");
+ boost::filesystem::create_directory("backupDirectory3");
+ boost::filesystem::create_directory("backupDirectory4");
}
GfshExecute gfsh;
@@ -1205,7 +1129,7 @@ void CacheHelper::initServer(int instance, const char *xml,
server.withUser("root").withPassword("root-password");
}
- if (locHostport != nullptr) {
+ if (!locHostport.empty()) {
server.withPropertiesFile(generateGeodeProperties(
currDir, ssl, -1, 0, untrustedCert, useSecurityManager));
}
@@ -1220,33 +1144,31 @@ void CacheHelper::initServer(int instance, const char *xml,
printf("added server instance %d\n", instance);
}
-void CacheHelper::createDuplicateXMLFile(std::string &originalFile,
- int hostport1, int hostport2,
- int locport1, int locport2) {
- char cmd[1024];
- char currWDPath[2048];
- std::string currDir = ACE_OS::getcwd(currWDPath, 2048);
- currDir += PATH_SEP;
- std::string testSrc = ACE_OS::getenv("TESTSRC");
- testSrc += PATH_SEP;
- testSrc += "resources";
- testSrc += PATH_SEP;
-
- // file name will have hostport1.xml(i.e. CacheHelper::staticHostPort1) as
- // suffix
-
- replacePortsInFile(
- hostport1, hostport2, CacheHelper::staticHostPort3,
- CacheHelper::staticHostPort4, locport1, locport2, testSrc + originalFile,
- currDir + originalFile + std::to_string(hostport1) + ".xml");
-
- // this file need to delete
- sprintf(cmd, "%s%s%d.xml", currDir.c_str(), originalFile.c_str(), hostport1);
- std::string s(cmd);
- CacheHelper::staticConfigFileList.push_back(s);
-
- printf("createDuplicateXMLFile added file %s %zd", cmd,
+std::string CacheHelper::createDuplicateXMLFile(const std::string &source,
+ int hostport1, int hostport2,
+ int locport1, int locport2) {
+ std::string dest = boost::filesystem::current_path().string();
+ dest += PATH_SEP;
+ dest += boost::filesystem::path{source}.filename().stem().string();
+ dest += '.';
+ dest += std::to_string(hostport1);
+ dest += ".xml";
+
+ std::string src = Utils::getEnv("TESTSRC");
+ src += PATH_SEP;
+ src += "resources";
+ src += PATH_SEP;
+ src += source;
+
+ replacePortsInFile(hostport1, hostport2, CacheHelper::staticHostPort3,
+ CacheHelper::staticHostPort4, locport1, locport2, src,
+ dest);
+
+ CacheHelper::staticConfigFileList.push_back(dest);
+ printf("createDuplicateXMLFile added file %s %zd", dest.c_str(),
CacheHelper::staticConfigFileList.size());
+
+ return dest;
}
// Need to avoid regex usage in Solaris Studio 12.4.
@@ -1290,7 +1212,7 @@ void CacheHelper::replacePortsInFile(int hostPort1, int hostPort2,
int hostPort3, int hostPort4, int locPort1,
int locPort2, const std::string &inFile,
const std::string &outFile) {
- std::ifstream in(inFile, std::ios::in | std::ios::binary);
+ std::ifstream in(inFile, std::ios::in);
if (in) {
std::string contents;
contents.assign(std::istreambuf_iterator<char>(in),
@@ -1317,37 +1239,22 @@ void CacheHelper::replacePortsInFile(int hostPort1, int hostPort2,
}
#endif
-void CacheHelper::createDuplicateXMLFile(std::string &duplicateFile,
- std::string &originalFile) {
- CacheHelper::createDuplicateXMLFile(
- originalFile, CacheHelper::staticHostPort1, CacheHelper::staticHostPort2,
+std::string CacheHelper::createDuplicateXMLFile(const std::string &source) {
+ return CacheHelper::createDuplicateXMLFile(
+ source, CacheHelper::staticHostPort1, CacheHelper::staticHostPort2,
CacheHelper::staticLocatorHostPort1, CacheHelper::staticLocatorHostPort2);
-
- char tmp[32];
-
- sprintf(tmp, "%d.xml", CacheHelper::staticHostPort1);
-
- char currWDPath[2048];
- duplicateFile = ACE_OS::getcwd(currWDPath, 2048);
- duplicateFile += PATH_SEP;
- duplicateFile += originalFile + tmp;
}
void CacheHelper::closeServer(int instance) {
- static char *gfjavaenv = ACE_OS::getenv("GFJAVA");
-
- char tmp[128];
- char currWDPath[2048];
-
- std::string currDir = ACE_OS::getcwd(currWDPath, 2048);
+ static const auto gfjavaenv = Utils::getEnv("GFJAVA");
+ std::string currDir = boost::filesystem::current_path().string();
- ASSERT(gfjavaenv != nullptr,
+ ASSERT(!gfjavaenv.empty(),
"Environment variable GFJAVA for java build directory is not set.");
ASSERT(!currDir.empty(),
"Current working directory could not be determined.");
- if ((ACE_OS::strchr(gfjavaenv, '\\') == nullptr) &&
- (ACE_OS::strchr(gfjavaenv, '/') == nullptr)) {
+ if (gfjavaenv.find(PATH_SEP) == std::string::npos) {
return;
}
@@ -1357,23 +1264,19 @@ void CacheHelper::closeServer(int instance) {
currDir += "0";
break;
case 1:
- sprintf(tmp, "%d", CacheHelper::staticHostPort1);
- currDir += tmp; // currDir += "1";
+ currDir += std::to_string(CacheHelper::staticHostPort1);
break;
case 2:
- sprintf(tmp, "%d", CacheHelper::staticHostPort2);
- currDir += tmp; // currDir += "2";
+ currDir += std::to_string(CacheHelper::staticHostPort2);
break;
case 3:
- sprintf(tmp, "%d", CacheHelper::staticHostPort3);
- currDir += tmp; // currDir += "3";
+ currDir += std::to_string(CacheHelper::staticHostPort3);
break;
default: /* Support for any number of servers Max 10*/
// ASSERT( ( instance <= 10 )," More than 10 servers not supported");
// TODO: need to support more then three servers
ASSERT((instance <= 4), " More than 4 servers not supported");
- char temp[8];
- currDir += ACE_OS::itoa(CacheHelper::staticHostPort4, temp, 10);
+ currDir += std::to_string(CacheHelper::staticHostPort4);
break;
}
@@ -1390,46 +1293,38 @@ void CacheHelper::closeServer(int instance) {
}
// closing locator
void CacheHelper::closeLocator(int instance, bool) {
- static char *gfjavaenv = ACE_OS::getenv("GFJAVA");
+ static const auto gfjavaenv = Utils::getEnv("GFJAVA");
+ static const auto testsrcenv = Utils::getEnv("TESTSRC");
- char cmd[2048];
- char currWDPath[2048];
- std::string currDir = ACE_OS::getcwd(currWDPath, 2048);
- std::string keystore = std::string(ACE_OS::getenv("TESTSRC")) + "/keystore";
+ auto currDir = boost::filesystem::current_path().string();
- ASSERT(gfjavaenv != nullptr,
+ ASSERT(!gfjavaenv.empty(),
"Environment variable GFJAVA for java build directory is not set.");
- ASSERT(!currDir.empty(),
- "Current working directory could not be determined.");
- if ((ACE_OS::strchr(gfjavaenv, '\\') == nullptr) &&
- (ACE_OS::strchr(gfjavaenv, '/') == nullptr)) {
+ ASSERT(!testsrcenv.empty(),
+ "Environment variable TESTSRC for test source directory is not set.");
+
+ std::string keystore = testsrcenv + "/keystore";
+ if (gfjavaenv.find(PATH_SEP) == std::string::npos) {
return;
}
currDir += PATH_SEP;
currDir += "GFELOC";
- char tmp[100];
switch (instance) {
case 1:
- sprintf(tmp, "%d", CacheHelper::staticLocatorHostPort1);
- currDir += tmp; // currDir += "1";
+ currDir += std::to_string(CacheHelper::staticLocatorHostPort1);
break;
case 2:
- sprintf(tmp, "%d", CacheHelper::staticLocatorHostPort2);
- currDir += tmp;
- // currDir += "2";
+ currDir += std::to_string(CacheHelper::staticLocatorHostPort2);
break;
case 3:
- sprintf(tmp, "%d", CacheHelper::staticLocatorHostPort3);
- currDir += tmp;
- // currDir += "3";
+ currDir += std::to_string(CacheHelper::staticLocatorHostPort3);
break;
default: /* Support for any number of Locator Max 10*/
// TODO://
ASSERT((instance <= 3), " More than 3 servers not supported");
- char temp[8];
- currDir += ACE_OS::itoa(instance, temp, 10);
+ currDir += std::to_string(instance);
break;
}
@@ -1442,10 +1337,7 @@ void CacheHelper::closeLocator(int instance, bool) {
terminate_process_file(currDir + "/vf.gf.locator.pid",
std::chrono::seconds(10));
- sprintf(cmd, "%s .%stest.geode.properties", DELETE_COMMAND, PATH_SEP);
- LOG(cmd);
- ACE_OS::system(cmd);
-
+ std::remove("test.geode.properties");
staticLocatorInstanceList.remove(instance);
}
@@ -1457,32 +1349,37 @@ void CacheHelper::terminate_process_file(
std::string pid;
read_single_line(pidFileName, pid);
+ if (pid.empty()) {
+ return;
+ }
- if (!pid.empty()) {
- LOG("CacheHelper::terminate_process_file: process running. pidFileName=" +
- pidFileName + ", pid=" + pid);
-
- // Wait for process to terminate or timeout
- auto start = std::chrono::system_clock::now();
- while (std::chrono::system_clock::now() < timeout) {
- if (!file_exists(pidFileName)) {
- auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
- std::chrono::system_clock::now() - start);
- LOG("CacheHelper::terminate_process_file: process exited. "
- "pidFileName=" +
- pidFileName + ", pid=" + pid +
- ", elapsed=" + std::to_string(elapsed.count()) + "ms");
- return;
- }
- std::this_thread::yield();
+ LOG("CacheHelper::terminate_process_file: process running. pidFileName=" +
+ pidFileName + ", pid=" + pid);
+
+ // Wait for process to terminate or timeout
+ auto start = std::chrono::system_clock::now();
+ while (std::chrono::system_clock::now() < timeout) {
+ if (!file_exists(pidFileName)) {
+ auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::system_clock::now() - start);
+ LOG("CacheHelper::terminate_process_file: process exited. "
+ "pidFileName=" +
+ pidFileName + ", pid=" + pid +
+ ", elapsed=" + std::to_string(elapsed.count()) + "ms");
+ return;
}
- LOG("CacheHelper::terminate_process_file: timeout. pidFileName=" +
- pidFileName + ", pid=" + pid);
-
- // Didn't exit on its own, kill it.
- LOG("ACE::terminate_process: pid=" + pid);
- ACE::terminate_process(std::stoi(pid));
+ std::this_thread::yield();
}
+ LOG("CacheHelper::terminate_process_file: timeout. pidFileName=" +
+ pidFileName + ", pid=" + pid);
+
+ // Didn't exit on its own, kill it.
+ LOG("ACE::terminate_process: pid=" + pid);
+
+ boost::process::pid_t id =
+ static_cast<boost::process::pid_t>(std::stoul(pid));
+ boost::process::child process{id};
+ process.terminate();
}
bool CacheHelper::file_exists(const std::string &fileName) {
@@ -1497,15 +1394,10 @@ void CacheHelper::read_single_line(const std::string &fileName,
}
void CacheHelper::cleanupTmpConfigFiles() {
- std::list<std::string>::const_iterator its;
-
- char cmd[1024];
- for (its = CacheHelper::staticConfigFileList.begin();
+ for (auto its = CacheHelper::staticConfigFileList.begin();
its != CacheHelper::staticConfigFileList.end(); ++its) {
try {
- sprintf(cmd, "rm %s", its->c_str());
- LOG(cmd);
- ACE_OS::system(cmd);
+ std::remove(its->c_str());
} catch (...) {
}
}
@@ -1527,56 +1419,50 @@ void CacheHelper::cleanupLocatorInstances() {
void CacheHelper::initLocator(int instance, bool ssl, bool, int dsId,
int remoteLocator, bool untrustedCert,
bool useSecurityManager) {
+ static const auto gfjavaenv = Utils::getEnv("GFJAVA");
+
if (!isLocatorCleanupCallbackRegistered &&
gClientCleanup.registerCallback(&CacheHelper::cleanupLocatorInstances)) {
isLocatorCleanupCallbackRegistered = true;
}
- static char *gfjavaenv = ACE_OS::getenv("GFJAVA");
- char currWDPath[2048];
- std::string currDir = ACE_OS::getcwd(currWDPath, 2048);
+ std::string currDir = boost::filesystem::current_path().string();
- ASSERT(gfjavaenv != nullptr,
+ ASSERT(!gfjavaenv.empty(),
"Environment variable GFJAVA for java build directory is not set.");
- ASSERT(!currDir.empty(),
- "Current working directory could not be determined.");
- if ((ACE_OS::strchr(gfjavaenv, '\\') == nullptr) &&
- (ACE_OS::strchr(gfjavaenv, '/') == nullptr)) {
+ if (gfjavaenv.find(PATH_SEP) == std::string::npos) {
return;
}
- std::string locDirname = "GFELOC";
+
int portnum = 0;
+ std::string locDirname = "GFELOC";
+
currDir += PATH_SEP;
- char tmp[100];
+
switch (instance) {
case 1:
portnum = CacheHelper::staticLocatorHostPort1;
- sprintf(tmp, "%d", CacheHelper::staticLocatorHostPort1);
- locDirname += tmp;
break;
case 2:
portnum = CacheHelper::staticLocatorHostPort2;
- sprintf(tmp, "%d", CacheHelper::staticLocatorHostPort2);
- locDirname += tmp;
break;
default:
portnum = CacheHelper::staticLocatorHostPort3;
- sprintf(tmp, "%d", CacheHelper::staticLocatorHostPort3);
- locDirname += tmp;
break;
}
+ locDirname += std::to_string(portnum);
+
int jmxManagerPort = CacheHelper::staticJmxManagerPort;
currDir += locDirname;
-
- ACE_OS::mkdir(locDirname.c_str());
+ boost::filesystem::create_directory(locDirname);
std::string geodeFile = generateGeodeProperties(
currDir, ssl, dsId, remoteLocator, untrustedCert, useSecurityManager);
- std::string classpath = ACE_OS::getenv("GF_CLASSPATH");
+ auto classpath = Utils::getEnv("GF_CLASSPATH");
GfshExecute gfsh;
auto locator = gfsh.start()
@@ -1606,17 +1492,18 @@ void CacheHelper::setJavaConnectionPoolSize(uint32_t size) {
}
bool CacheHelper::setSeed() {
- char *testName = ACE_OS::getenv("TESTNAME");
-
- int seed = hashcode(testName);
+ static const auto testnameenv = Utils::getEnv("TESTNAME");
+ ASSERT(!testnameenv.empty(),
+ "Environment variable TESTNAME for test name is not set.");
+ int seed = std::hash<std::string>{}(testnameenv);
printf("seed for process %d\n", seed);
// The integration tests rely on the pseudo-random
// number generator being seeded with a very particular
// value specific to the test by way of the test name.
// Whilst this approach is pessimal, it can not be
// remedied as the test depend upon it.
- ACE_OS::srand(seed);
+ std::srand(seed);
return true;
}
@@ -1636,8 +1523,7 @@ int CacheHelper::hashcode(char *str) {
}
int CacheHelper::getRandomNumber() {
- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.rand)
- return (ACE_OS::rand() % RANDOM_NUMBER_DIVIDER) + RANDOM_NUMBER_OFFSET;
+ return (std::rand() % RANDOM_NUMBER_DIVIDER) + RANDOM_NUMBER_OFFSET;
}
int CacheHelper::getRandomAvailablePort() {
@@ -1660,31 +1546,33 @@ int CacheHelper::getRandomAvailablePort() {
}
std::string CacheHelper::unitTestOutputFile() {
- char cwd[1024];
- if (!ACE_OS::getcwd(cwd, sizeof(cwd))) {
- throw Exception("Failed to get current working directory.");
- }
+ static const auto testnameenv = Utils::getEnv("TESTNAME");
- std::string outputFile(cwd);
- outputFile += "/";
- outputFile += ACE_OS::getenv("TESTNAME");
+ ASSERT(!testnameenv.empty(),
+ "Environment variable TESTNAME for test name is not set.");
+
+ std::string outputFile = boost::filesystem::current_path().string();
+ outputFile += PATH_SEP;
+ outputFile += testnameenv;
outputFile += ".log";
return outputFile;
}
-int CacheHelper::getNumLocatorListUpdates(const char *s) {
- std::string searchStr(s);
+int CacheHelper::getNumLocatorListUpdates(const std::string &search) {
std::string testFile = CacheHelper::unitTestOutputFile();
- FILE *fp = fopen(testFile.c_str(), "r");
- ASSERT(nullptr != fp, "Failed to open log file.");
- char buf[512];
+ std::ifstream file{testFile};
+ ASSERT(!file.fail(), "Failed to open log file.");
+
+ std::string line;
int numMatched = 0;
- while (fgets(buf, sizeof(buf), fp)) {
- std::string line(buf);
- if (line.find(searchStr) != std::string::npos) numMatched++;
+ while (std::getline(file, line)) {
+ if (line.find(search) != std::string::npos) {
+ ++numMatched;
+ }
}
+
return numMatched;
}
@@ -1692,29 +1580,29 @@ std::string CacheHelper::generateGeodeProperties(
const std::string &path, const bool ssl, const int dsId,
const int remoteLocator, const bool untrustedCert,
const bool useSecurityManager) {
- char cmd[2048];
- std::string keystore = std::string(ACE_OS::getenv("TESTSRC")) + "/keystore";
+ static const auto testnameenv = Utils::getEnv("TESTNAME");
+
+ ASSERT(!testnameenv.empty(),
+ "Environment variable TESTNAME for test name is not set.");
+
+ std::string keystore = testnameenv + "/keystore";
std::string geodeFile = path;
geodeFile += "/test.geode.properties";
- sprintf(cmd, "%s %s%stest.geode.properties", DELETE_COMMAND, path.c_str(),
- PATH_SEP);
- LOG(cmd);
- ACE_OS::system(cmd);
- FILE *urandom = /*ACE_OS::*/
- fopen(geodeFile.c_str(), "w");
- char gemStr[258];
- sprintf(gemStr, "locators=localhost[%d],localhost[%d],localhost[%d]\n",
- CacheHelper::staticLocatorHostPort1,
- CacheHelper::staticLocatorHostPort2,
- CacheHelper::staticLocatorHostPort3);
- std::string msg = gemStr;
-
- msg += "log-level=config\n";
- msg += "mcast-port=0\n";
- msg += "enable-network-partition-detection=false\n";
+
+ std::ofstream file{geodeFile};
+
+ file << "locators=localhost[" << CacheHelper::staticLocatorHostPort1
+ << "],localhost[" << CacheHelper::staticLocatorHostPort2
+ << "],localhost[" << CacheHelper::staticLocatorHostPort3 << "]"
+ << std::endl;
+
+ file << "log-level=config" << std::endl;
+ file << "mcast-port=0" << std::endl;
+ file << "enable-network-partition-detection=false" << std::endl;
+
if (useSecurityManager) {
- msg += "security-manager=javaobject.SimpleSecurityManager\n";
+ file << "security-manager=javaobject.SimpleSecurityManager" << std::endl;
}
std::string serverKeystore;
@@ -1731,35 +1619,31 @@ std::string CacheHelper::generateGeodeProperties(
serverTruststore += "server_truststore_chained_root.jks";
password += "apachegeode";
}
- msg += "jmx-manager-ssl-enabled=false\n";
- msg += "cluster-ssl-enabled=true\n";
- msg += "cluster-ssl-require-authentication=false\n";
- msg += "cluster-ssl-ciphers=TLS_RSA_WITH_AES_128_CBC_SHA\n";
- msg += "cluster-ssl-keystore-type=jks\n";
- msg += "cluster-ssl-keystore=" + keystore + "/" + serverKeystore.c_str() +
- "\n";
- msg += "cluster-ssl-keystore-password=" + password + "\n";
- msg += "cluster-ssl-truststore=" + keystore + "/" +
- serverTruststore.c_str() + "\n";
- msg += "cluster-ssl-truststore-password=" + password + "\n";
- msg += "security-username=xxxx\n";
- msg += "security-userPassword=yyyy \n";
- }
+ file << "jmx-manager-ssl-enabled=false" << std::endl;
+ file << "cluster-ssl-enabled=true" << std::endl;
+ file << "cluster-ssl-require-authentication=false" << std::endl;
+ file << "cluster-ssl-ciphers=TLS_RSA_WITH_AES_128_CBC_SHA" << std::endl;
+ file << "cluster-ssl-keystore-type=jks" << std::endl;
+ file << "cluster-ssl-keystore=" + keystore + PATH_SEP + serverKeystore
+ << std::endl;
+ file << "cluster-ssl-keystore-password=" + password + "" << std::endl;
+ file << "cluster-ssl-truststore=" + keystore + PATH_SEP +
+ serverTruststore.c_str() + ""
+ << std::endl;
+ file << "cluster-ssl-truststore-password=" + password + "" << std::endl;
+ file << "security-username=xxxx" << std::endl;
+ file << "security-userPassword=yyyy " << std::endl;
+ }
+
+ file << "distributed-system-id=" << dsId << std::endl;
+
if (remoteLocator != 0) {
- sprintf(gemStr, "distributed-system-id=%d\n remote-locators=localhost[%d]",
- dsId, remoteLocator);
- } else {
- sprintf(gemStr, "distributed-system-id=%d\n ", dsId);
+ file << "remote-locators=localhost[" << remoteLocator << "]";
}
- msg += gemStr;
- /*ACE_OS::*/
- fwrite(msg.c_str(), msg.size(), 1, urandom);
- /*ACE_OS::*/
- fflush(urandom);
- /*ACE_OS::*/
- fclose(urandom);
- LOG(geodeFile.c_str());
+ file.close();
+
+ LOG(geodeFile);
return geodeFile;
}
diff --git a/cppcache/integration-test/CacheHelper.hpp b/cppcache/integration-test/CacheHelper.hpp
index 553f84c..1c4646b 100644
--- a/cppcache/integration-test/CacheHelper.hpp
+++ b/cppcache/integration-test/CacheHelper.hpp
@@ -62,14 +62,14 @@ class CacheHelper {
static void resetHelper();
static std::string unitTestOutputFile();
- static int getNumLocatorListUpdates(const char* s);
+ static int getNumLocatorListUpdates(const std::string& search);
explicit CacheHelper(const char* member_id,
const std::shared_ptr<Properties>& configPtr = nullptr,
const bool noRootRegion = false);
/** rootRegionPtr will still be null... */
- CacheHelper(const char* member_id, const char* cachexml,
+ CacheHelper(const char* member_id, const std::string& cachexml,
const std::shared_ptr<Properties>& configPtr = nullptr);
explicit CacheHelper(const std::shared_ptr<Properties>& configPtr = nullptr,
@@ -89,7 +89,7 @@ class CacheHelper {
const bool noRootRegion = false);
CacheHelper(const bool isthinClient, const char* poolName,
- const char* locators, const char* serverGroup,
+ const std::string& locators, const char* serverGroup,
const std::shared_ptr<Properties>& configPtr = nullptr,
int redundancy = 0, bool clientNotification = false,
int subscriptionAckInterval = -1, int connections = -1,
@@ -124,23 +124,23 @@ class CacheHelper {
std::shared_ptr<Region> getRegion(const std::string& name);
std::shared_ptr<Region> createRegion(
- const char* name, bool ack, bool caching,
+ const std::string& name, bool ack, bool caching,
const std::shared_ptr<CacheListener>& listener,
bool clientNotificationEnabled = false, bool scopeLocal = false,
bool concurrencyCheckEnabled = false, int32_t tombstonetimeout = -1);
std::shared_ptr<Region> createRegion(
- const char* name, bool ack, bool caching = true,
+ const std::string& name, bool ack, bool caching = true,
const std::chrono::seconds& ettl = std::chrono::seconds::zero(),
const std::chrono::seconds& eit = std::chrono::seconds::zero(),
const std::chrono::seconds& rttl = std::chrono::seconds::zero(),
const std::chrono::seconds& rit = std::chrono::seconds::zero(),
int lel = 0, ExpirationAction action = ExpirationAction::DESTROY,
- const char* endpoints = nullptr, bool clientNotificationEnabled = false);
+ const std::string& endpoints = {}, bool clientNotificationEnabled = false);
std::shared_ptr<Pool> createPool(
- const std::string& poolName, const char* locators,
- const char* serverGroup, int redundancy = 0,
+ const std::string& poolName, const std::string& locators,
+ const std::string& serverGroup, int redundancy = 0,
bool clientNotification = false,
std::chrono::milliseconds subscriptionAckInterval =
std::chrono::milliseconds::zero(),
@@ -148,9 +148,9 @@ class CacheHelper {
bool isMultiuserMode = false);
// this will create pool even endpoints and locatorhost has been not defined
- std::shared_ptr<Pool> createPool2(const char* poolName, const char* locators,
- const char* serverGroup,
- const char* servers = nullptr,
+ std::shared_ptr<Pool> createPool2(
+ const std::string& poolName, const std::string& locators,
+ const std::string& serverGroup, const std::string& servers = {},
int redundancy = 0,
bool clientNotification = false,
int subscriptionAckInterval = -1,
@@ -159,12 +159,12 @@ class CacheHelper {
void logPoolAttributes(std::shared_ptr<Pool>& pool);
void createPoolWithLocators(
- const std::string& name, const char* locators = nullptr,
+ const std::string& name, const std::string& locators = {},
bool clientNotificationEnabled = false, int subscriptionRedundancy = -1,
std::chrono::milliseconds subscriptionAckInterval =
std::chrono::milliseconds::zero(),
int connections = -1, bool isMultiuserMode = false,
- const char* serverGroup = nullptr);
+ const std::string& serverGroup = {});
std::shared_ptr<Region> createRegionAndAttachPool(
const std::string& name, bool ack, const std::string& poolName,
@@ -185,12 +185,12 @@ class CacheHelper {
const std::chrono::seconds& rit = std::chrono::seconds::zero(),
int lel = 0, ExpirationAction action = ExpirationAction::DESTROY);
- static void addServerLocatorEPs(const char* epList, PoolFactory& pfPtr,
+ static void addServerLocatorEPs(const std::string& epList, PoolFactory& pfPtr,
bool poolLocators = true);
std::shared_ptr<Region> createPooledRegion(
- const char* name, bool ack, const char* locators = nullptr,
- const char* poolName = "__TEST_POOL1__", bool caching = true,
+ const std::string& name, bool ack, const std::string& locators = {},
+ const std::string& poolName = "__TEST_POOL1__", bool caching = true,
bool clientNotificationEnabled = false,
const std::chrono::seconds& ettl = std::chrono::seconds::zero(),
const std::chrono::seconds& eit = std::chrono::seconds::zero(),
@@ -201,8 +201,8 @@ class CacheHelper {
ExpirationAction action = ExpirationAction::DESTROY);
std::shared_ptr<Region> createPooledRegionConcurrencyCheckDisabled(
- const char* name, bool ack, const char* locators = nullptr,
- const char* poolName = "__TEST_POOL1__", bool caching = true,
+ const std::string& name, bool ack, const std::string& locators = {},
+ const std::string& poolName = "__TEST_POOL1__", bool caching = true,
bool clientNotificationEnabled = false,
bool concurrencyCheckEnabled = true,
const std::chrono::seconds& ettl = std::chrono::seconds::zero(),
@@ -214,7 +214,7 @@ class CacheHelper {
ExpirationAction action = ExpirationAction::DESTROY);
std::shared_ptr<Region> createRegionDiscOverFlow(
- const char* name, bool caching = true,
+ const std::string& name, bool caching = true,
bool clientNotificationEnabled = false,
const std::chrono::seconds& ettl = std::chrono::seconds::zero(),
const std::chrono::seconds& eit = std::chrono::seconds::zero(),
@@ -223,8 +223,8 @@ class CacheHelper {
int lel = 0, ExpirationAction action = ExpirationAction::DESTROY);
std::shared_ptr<Region> createPooledRegionDiscOverFlow(
- const char* name, bool ack, const char* locators = nullptr,
- const char* poolName = "__TEST_POOL1__", bool caching = true,
+ const std::string& name, bool ack, const std::string& locators = {},
+ const std::string& poolName = "__TEST_POOL1__", bool caching = true,
bool clientNotificationEnabled = false,
const std::chrono::seconds& ettl = std::chrono::seconds::zero(),
const std::chrono::seconds& eit = std::chrono::seconds::zero(),
@@ -235,8 +235,8 @@ class CacheHelper {
ExpirationAction action = ExpirationAction::DESTROY);
std::shared_ptr<Region> createPooledRegionSticky(
- const char* name, bool ack, const char* locators = nullptr,
- const char* poolName = "__TEST_POOL1__", bool caching = true,
+ const std::string& name, bool ack, const std::string& locators = {},
+ const std::string& poolName = "__TEST_POOL1__", bool caching = true,
bool clientNotificationEnabled = false,
const std::chrono::seconds& ettl = std::chrono::seconds::zero(),
const std::chrono::seconds& eit = std::chrono::seconds::zero(),
@@ -247,8 +247,8 @@ class CacheHelper {
ExpirationAction action = ExpirationAction::DESTROY);
std::shared_ptr<Region> createPooledRegionStickySingleHop(
- const char* name, bool ack, const char* locators = nullptr,
- const char* poolName = "__TEST_POOL1__", bool caching = true,
+ const std::string& name, bool ack, const std::string& locators = {},
+ const std::string& poolName = "__TEST_POOL1__", bool caching = true,
bool clientNotificationEnabled = false,
const std::chrono::seconds& ettl = std::chrono::seconds::zero(),
const std::chrono::seconds& eit = std::chrono::seconds::zero(),
@@ -290,13 +290,13 @@ class CacheHelper {
static int staticJmxManagerPort;
- static const char* getstaticLocatorHostPort1();
+ static std::string getstaticLocatorHostPort1();
- static const char* getstaticLocatorHostPort2();
+ static std::string getstaticLocatorHostPort2();
- static const char* getLocatorHostPort(int locPort);
+ static std::string getLocatorHostPort(int locPort);
- static const char* getLocatorHostPort(bool& isLocator, bool& isLocalServer,
+ static std::string getLocatorHostPort(bool& isLocator, bool& isLocalServer,
int numberOfLocators = 0);
static const std::string getTcrEndpoints2(bool& isLocalServer,
@@ -306,18 +306,18 @@ class CacheHelper {
static bool isServerCleanupCallbackRegistered;
static void cleanupServerInstances();
- static void initServer(int instance, const char* xml = nullptr,
- const char* locHostport = nullptr,
+ static void initServer(int instance, const std::string& xml = {},
+ const std::string& locHostport = {},
const char* authParam = nullptr, bool ssl = false,
bool enableDelta = true, bool multiDS = false,
bool testServerGC = false, bool untrustedCert = false,
bool useSecurityManager = false);
- static void createDuplicateXMLFile(std::string& originalFile, int hostport1,
- int hostport2, int locport1, int locport2);
+ static std::string createDuplicateXMLFile(const std::string& source,
+ int hostport1, int hostport2,
+ int locport1, int locport2);
- static void createDuplicateXMLFile(std::string& duplicateFile,
- std::string& originalFile);
+ static std::string createDuplicateXMLFile(const std::string& source);
static void closeServer(int instance);
diff --git a/cppcache/integration-test/LocatorHelper.hpp b/cppcache/integration-test/LocatorHelper.hpp
index 441af29..c3e90e3 100644
--- a/cppcache/integration-test/LocatorHelper.hpp
+++ b/cppcache/integration-test/LocatorHelper.hpp
@@ -47,7 +47,7 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER1, CreateServer1_With_Locator)
{
// starting servers
- if (isLocalServer) CacheHelper::initServer(1, nullptr, locatorsG);
+ if (isLocalServer) CacheHelper::initServer(1, {}, locatorsG);
}
END_TASK_DEFINITION
@@ -55,7 +55,7 @@ DUNIT_TASK_DEFINITION(SERVER1, CreateServer1_With_Locator_And_SSL)
{
// starting servers
if (isLocalServer) {
- CacheHelper::initServer(1, nullptr, locatorsG, nullptr, true);
+ CacheHelper::initServer(1, {}, locatorsG, nullptr, true);
}
}
END_TASK_DEFINITION
@@ -64,7 +64,7 @@ DUNIT_TASK_DEFINITION(SERVER1, CreateServer2_With_Locator)
{
// starting servers
if (isLocalServer) {
- CacheHelper::initServer(2, nullptr, locatorsG);
+ CacheHelper::initServer(2, {}, locatorsG);
}
}
END_TASK_DEFINITION
diff --git a/cppcache/integration-test/QueryHelper.hpp b/cppcache/integration-test/QueryHelper.hpp
index 0725810..27a8b83 100644
--- a/cppcache/integration-test/QueryHelper.hpp
+++ b/cppcache/integration-test/QueryHelper.hpp
@@ -188,10 +188,9 @@ void QueryHelper::populatePortfolioData(
auto port = std::make_shared<Portfolio>(static_cast<int32_t>(current),
objSize, nm);
- char portname[100] = {0};
- ACE_OS::sprintf(portname, "port%zd-%zd", set, current);
-
- auto keyport = CacheableKey::create(portname);
+ std::string key =
+ "port" + std::to_string(set) + '-' + std::to_string(current);
+ auto keyport = CacheableKey::create(key);
// printf(" QueryHelper::populatePortfolioData creating key = %s and
// puting data \n",portname);
rptr->put(keyport, port);
@@ -215,10 +214,9 @@ void QueryHelper::populatePositionData(std::shared_ptr<Region>& rptr,
auto pos = std::make_shared<Position>(
secIds[current % numSecIds], static_cast<int32_t>(current * 100));
- char posname[100] = {0};
- ACE_OS::sprintf(posname, "pos%zd-%zd", set, current);
-
- auto keypos = CacheableKey::create(posname);
+ std::string key =
+ "pos" + std::to_string(set) + '-' + std::to_string(current);
+ auto keypos = CacheableKey::create(key);
rptr->put(keypos, pos);
}
}
@@ -235,13 +233,12 @@ void QueryHelper::populatePortfolioPdxData(std::shared_ptr<Region>& rptr,
for (size_t current = 1; current <= setSize; current++) {
auto port = std::make_shared<PortfolioPdx>(static_cast<int32_t>(current),
objSize);
+ std::string key =
+ "port" + std::to_string(set) + '-' + std::to_string(current);
- char portname[100] = {0};
- ACE_OS::sprintf(portname, "port%zd-%zd", set, current);
-
- auto keyport = CacheableKey::create(portname);
-
+ auto keyport = CacheableKey::create(key);
rptr->put(keyport, port);
+
LOGDEBUG("populatePortfolioPdxData:: Put for iteration current = %d done",
current);
}
@@ -261,10 +258,10 @@ void QueryHelper::populatePositionPdxData(std::shared_ptr<Region>& rptr,
auto pos = std::make_shared<PositionPdx>(
secIds[current % numSecIds], static_cast<int32_t>(current * 100));
- char posname[100] = {0};
- ACE_OS::sprintf(posname, "pos%zd-%zd", set, current);
+ std::string key =
+ "pos" + std::to_string(set) + '-' + std::to_string(current);
- auto keypos = CacheableKey::create(posname);
+ auto keypos = CacheableKey::create(key);
rptr->put(keypos, pos);
}
}
diff --git a/cppcache/integration-test/ThinClientCQ.hpp b/cppcache/integration-test/ThinClientCQ.hpp
index cf450a8..578dd77 100644
--- a/cppcache/integration-test/ThinClientCQ.hpp
+++ b/cppcache/integration-test/ThinClientCQ.hpp
@@ -28,10 +28,10 @@
static bool isLocator = false;
static bool isLocalServer = false;
static int numberOfLocators = 1;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
-void createRegionForCQ(const char* name, bool ackMode,
+void createRegionForCQ(const std::string& name, bool ackMode,
bool clientNotificationEnabled = false,
int redundancyLevel = 0,
bool caching = true) {
diff --git a/cppcache/integration-test/ThinClientCallbackArg.hpp b/cppcache/integration-test/ThinClientCallbackArg.hpp
index b298bcd..80b7663 100644
--- a/cppcache/integration-test/ThinClientCallbackArg.hpp
+++ b/cppcache/integration-test/ThinClientCallbackArg.hpp
@@ -45,7 +45,7 @@ using apache::geode::client::testing::TallyWriter;
static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
const char* poolName = "__TESTPOOL1_";
std::shared_ptr<TallyListener> regListener;
diff --git a/cppcache/integration-test/ThinClientDistOps.hpp b/cppcache/integration-test/ThinClientDistOps.hpp
index 9b1218e..371c898 100644
--- a/cppcache/integration-test/ThinClientDistOps.hpp
+++ b/cppcache/integration-test/ThinClientDistOps.hpp
@@ -56,7 +56,7 @@ static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
void initClient(const bool isthinClient, const bool redirectLog) {
@@ -183,12 +183,12 @@ void createRegion(const char* name, bool ackMode, const char* endpoints,
ASSERT(regPtr != nullptr, "Failed to create region.");
LOG("Region created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode, const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
@@ -197,12 +197,13 @@ void createPooledRegion(const char* name, bool ackMode, const char* locators,
LOG("Pooled Region created.");
}
-void createPooledRegionSticky(const char* name, bool ackMode,
- const char* locators, const char* poolname,
+void createPooledRegionSticky(const std::string& name, bool ackMode,
+ const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr = getHelper()->createPooledRegionSticky(
name, ackMode, locators, poolname, cachingEnable,
@@ -538,7 +539,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, CreatePoolForUpdateLocatorList)
isMultiuserMode = false, int updateLocatorListInterval = 5000 )
*/
initClient(true, true);
- getHelper()->createPool("__TESTPOOL1_", locatorsG, nullptr, 0, false,
+ getHelper()->createPool("__TESTPOOL1_", locatorsG, {}, 0, false,
std::chrono::milliseconds::zero(), -1, -1, false);
LOG("CreatePoolForUpdateLocatorList complete.");
}
@@ -554,7 +555,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, CreatePoolForDontUpdateLocatorList)
isMultiuserMode = false, int updateLocatorListInterval = 5000 )
*/
initClient(true, true);
- getHelper()->createPool("__TESTPOOL1_", locatorsG, nullptr, 0, false,
+ getHelper()->createPool("__TESTPOOL1_", locatorsG, {}, 0, false,
std::chrono::milliseconds::zero(), -1, -1, false);
LOG("CreatePoolForDontUpdateLocatorList complete.");
}
diff --git a/cppcache/integration-test/ThinClientDistOps2.hpp b/cppcache/integration-test/ThinClientDistOps2.hpp
index e6da087..c08f7b6 100644
--- a/cppcache/integration-test/ThinClientDistOps2.hpp
+++ b/cppcache/integration-test/ThinClientDistOps2.hpp
@@ -53,7 +53,7 @@ static bool isLocator = false;
static int numberOfLocators = 0;
const char* poolName = "__TEST_POOL1__";
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
#include "LocatorHelper.hpp"
@@ -93,15 +93,19 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER2, CreateServer2And3_Locator)
{
- if (isLocalServer) CacheHelper::initServer(2, nullptr, locatorsG);
- if (isLocalServer) CacheHelper::initServer(3, nullptr, locatorsG);
+ if (isLocalServer) {
+ CacheHelper::initServer(2, {}, locatorsG);
+ }
+ if (isLocalServer) {
+ CacheHelper::initServer(3, {}, locatorsG);
+ }
LOG("SERVER23 started");
}
END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, CreateClient1Regions_Pooled_Locator)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, {}, nullptr, 0,
true);
createPooledRegion(_regionNames[0], USE_ACK, locatorsG, poolName);
createPooledRegion(_regionNames[1], NO_ACK, locatorsG, poolName);
@@ -111,7 +115,7 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, CreateClient2Regions_Pooled_Locator)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, {}, nullptr, 0,
true);
createPooledRegion(_regionNames[0], USE_ACK, locatorsG, poolName);
createPooledRegion(_regionNames[1], NO_ACK, locatorsG, poolName);
@@ -169,7 +173,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1GetAll)
// re-create region with caching enabled
reg0->localDestroyRegion();
reg0 = nullptr;
- getHelper()->createPooledRegion(regionNames[0], USE_ACK, nullptr,
+ getHelper()->createPooledRegion(regionNames[0], USE_ACK, {},
"__TEST_POOL1__", true, true);
reg0 = getHelper()->getRegion(_regionNames[0]);
// check for IllegalArgumentException for empty key list
diff --git a/cppcache/integration-test/ThinClientDurable.hpp b/cppcache/integration-test/ThinClientDurable.hpp
index 1929d83..fc7faf7 100644
--- a/cppcache/integration-test/ThinClientDurable.hpp
+++ b/cppcache/integration-test/ThinClientDurable.hpp
@@ -226,7 +226,7 @@ void feederUpdate(int value, int ignoreR2 = false) {
DUNIT_TASK_DEFINITION(FEEDER, FeederInit)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, {}, nullptr, 0,
true);
getHelper()->createPooledRegion(regionNames[0], USE_ACK, locatorsG,
"__TEST_POOL1__", true, true);
diff --git a/cppcache/integration-test/ThinClientDurableConnect.hpp b/cppcache/integration-test/ThinClientDurableConnect.hpp
index 5c1c94b..defc92e 100644
--- a/cppcache/integration-test/ThinClientDurableConnect.hpp
+++ b/cppcache/integration-test/ThinClientDurableConnect.hpp
@@ -52,7 +52,6 @@ const char* durableId = "DurableId";
#include "ThinClientDurableInit.hpp"
#include "ThinClientTasks_C2S2.hpp"
-const char* g_Locators = locatorsG;
std::string getServerEndPoint(int instance) {
char instanceStr[16];
@@ -67,30 +66,14 @@ std::string getServerEndPoint(int instance) {
port = CacheHelper::staticHostPort4;
}
- std::string retVal(ACE_OS::itoa(port, instanceStr, 10));
- return retVal;
-
- std::string allEndPts(endPointsList);
- std::string::size_type start_idx = 0;
- std::string::size_type end_idx = 0;
-
- for (int i = 0; i < instance - 1; i++) {
- start_idx = allEndPts.find(',', start_idx) + 1;
- }
-
- end_idx = allEndPts.find(',', start_idx);
- if (end_idx == std::string::npos) { /* asking for last endpoint */
- end_idx = allEndPts.size();
- }
-
- return (std::string(allEndPts, start_idx, end_idx - start_idx));
+ return std::to_string(port);
}
DUNIT_TASK_DEFINITION(SERVER_SET1, S1Up)
{
if (isLocalServer) {
CacheHelper::initServer(1, "cacheserver_notify_subscription.xml",
- g_Locators);
+ locatorsG);
}
LOG("SERVER 1 started");
}
@@ -100,7 +83,7 @@ DUNIT_TASK_DEFINITION(SERVER_SET1, S2Up)
{
if (isLocalServer) {
CacheHelper::initServer(2, "cacheserver_notify_subscription2.xml",
- g_Locators);
+ locatorsG);
}
LOG("SERVER 2 started");
}
@@ -110,7 +93,7 @@ DUNIT_TASK_DEFINITION(SERVER_SET2, S3Up)
{
if (isLocalServer) {
CacheHelper::initServer(3, "cacheserver_notify_subscription3.xml",
- g_Locators);
+ locatorsG);
}
LOG("SERVER 3 started");
}
@@ -120,7 +103,7 @@ DUNIT_TASK_DEFINITION(SERVER_SET2, S4Up)
{
if (isLocalServer) {
CacheHelper::initServer(4, "cacheserver_notify_subscription4.xml",
- g_Locators);
+ locatorsG);
}
LOG("SERVER 4 started");
}
diff --git a/cppcache/integration-test/ThinClientDurableFailover.hpp b/cppcache/integration-test/ThinClientDurableFailover.hpp
index 4f3000a..97fff56 100644
--- a/cppcache/integration-test/ThinClientDurableFailover.hpp
+++ b/cppcache/integration-test/ThinClientDurableFailover.hpp
@@ -234,7 +234,7 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(FEEDER, FeederInit)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, {}, nullptr, 0,
true);
getHelper()->createPooledRegion(regionNames[0], USE_ACK, locatorsG,
"__TEST_POOL1__", true, true);
diff --git a/cppcache/integration-test/ThinClientDurableInit.hpp b/cppcache/integration-test/ThinClientDurableInit.hpp
index d5375dc..6b85adf 100644
--- a/cppcache/integration-test/ThinClientDurableInit.hpp
+++ b/cppcache/integration-test/ThinClientDurableInit.hpp
@@ -26,7 +26,7 @@ const char* durableIds[] = {"DurableId1", "DurableId2"};
static bool isLocator = false;
static int numberOfLocators = 1;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
void initClientAndRegion(
diff --git a/cppcache/integration-test/ThinClientDurableInterest.hpp b/cppcache/integration-test/ThinClientDurableInterest.hpp
index 8cb610b..cd432e3 100644
--- a/cppcache/integration-test/ThinClientDurableInterest.hpp
+++ b/cppcache/integration-test/ThinClientDurableInterest.hpp
@@ -214,7 +214,7 @@ void feederUpdate1(int value) {
DUNIT_TASK_DEFINITION(FEEDER, FeederInit)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, {}, nullptr, 0,
true);
getHelper()->createPooledRegion(regionNames[0], USE_ACK, locatorsG,
"__TEST_POOL1__", true, true);
diff --git a/cppcache/integration-test/ThinClientFailover.hpp b/cppcache/integration-test/ThinClientFailover.hpp
index 21d2770..c5c3352 100644
--- a/cppcache/integration-test/ThinClientFailover.hpp
+++ b/cppcache/integration-test/ThinClientFailover.hpp
@@ -31,7 +31,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT(google-build-namespaces)
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
@@ -47,7 +47,7 @@ CacheHelper* cacheHelper = nullptr;
#define SERVER2 s2p2
static bool isLocator = false;
// static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
void initClient(const bool isthinClient) {
@@ -127,7 +127,8 @@ void _verifyEntry(const char* name, const char* key, const char* val,
std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr));
ASSERT(checkPtr != nullptr, "Value Ptr should not be null.");
- LOG("In verify loop, get returned " + checkPtr->value() + " for key " + key);
+ LOG("In verify loop, get returned " + checkPtr->value() + " for key " +
+ key);
if (strcmp(checkPtr->value().c_str(), value) != 0) {
testValueCnt++;
} else {
@@ -161,12 +162,14 @@ void createRegion(const char* name, bool ackMode, const char* endpoints,
ASSERT(regPtr != nullptr, "Failed to create region.");
LOG("Region created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode,
+ const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
@@ -175,12 +178,14 @@ void createPooledRegion(const char* name, bool ackMode, const char* locators,
LOG("Pooled Region created.");
}
-void createPooledRegionSticky(const char* name, bool ackMode,
- const char* locators, const char* poolname,
+void createPooledRegionSticky(const std::string& name, bool ackMode,
+ const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
auto regPtr = getHelper()->createPooledRegionSticky(
name, ackMode, locators, poolname, cachingEnable,
diff --git a/cppcache/integration-test/ThinClientFailover2.hpp b/cppcache/integration-test/ThinClientFailover2.hpp
index 094f6bf..fe79757 100644
--- a/cppcache/integration-test/ThinClientFailover2.hpp
+++ b/cppcache/integration-test/ThinClientFailover2.hpp
@@ -50,7 +50,7 @@ CacheHelper* cacheHelper = nullptr;
#define SERVER2 s2p2
static bool isLocator = false;
static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
#include "LocatorHelper.hpp"
void initClient(const bool isthinClient) {
@@ -183,12 +183,12 @@ void createRegion(const char* name, bool ackMode, const char* endpoints,
ASSERT(regPtr != nullptr, "Failed to create region.");
LOG("Region created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode, const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
diff --git a/cppcache/integration-test/ThinClientFailover3.hpp b/cppcache/integration-test/ThinClientFailover3.hpp
index 7de886f..a2a007f 100644
--- a/cppcache/integration-test/ThinClientFailover3.hpp
+++ b/cppcache/integration-test/ThinClientFailover3.hpp
@@ -31,7 +31,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT(google-build-namespaces)
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
@@ -47,7 +47,7 @@ CacheHelper* cacheHelper = nullptr;
#define SERVER2 s2p2
static bool isLocator = false;
// static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
void initClient(const bool isthinClient) {
@@ -126,7 +126,8 @@ void _verifyEntry(const char* name, const char* key, const char* val,
std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr));
ASSERT(checkPtr != nullptr, "Value Ptr should not be null.");
- LOG("In verify loop, get returned " + checkPtr->value() + " for key " + key);
+ LOG("In verify loop, get returned " + checkPtr->value() + " for key " +
+ key);
if (strcmp(checkPtr->value().c_str(), value) != 0) {
testValueCnt++;
} else {
@@ -149,12 +150,14 @@ void _verifyEntry(const char* name, const char* key, const char* val,
LOG("Entry verified.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode,
+ const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
@@ -244,7 +247,7 @@ std::vector<std::string> storeEndPoints(const std::string points) {
size_t end = 0;
size_t start;
std::string delim = ",";
- while ((start = points.find_first_not_of(delim, end)) != std::string::npos) {
+ while ((start = points.find_first_not_of(delim, end)) != std::string::npos) {
end = points.find(delim, start);
if (end == std::string::npos) {
end = points.length();
diff --git a/cppcache/integration-test/ThinClientFailoverInterest.hpp b/cppcache/integration-test/ThinClientFailoverInterest.hpp
index e4c93b0..60a3575 100644
--- a/cppcache/integration-test/ThinClientFailoverInterest.hpp
+++ b/cppcache/integration-test/ThinClientFailoverInterest.hpp
@@ -46,7 +46,7 @@ CacheHelper* cacheHelper = nullptr;
#define SERVER2 s2p2
static bool isLocator = false;
// static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
void initClient(const bool isthinClient) {
@@ -188,12 +188,12 @@ void createRegion(const char* name, bool ackMode, const char* endpoints,
ASSERT(regPtr != nullptr, "Failed to create region.");
LOG("Region created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode, const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
diff --git a/cppcache/integration-test/ThinClientFailoverInterest2.hpp b/cppcache/integration-test/ThinClientFailoverInterest2.hpp
index f8e5593..bf0d6bb 100644
--- a/cppcache/integration-test/ThinClientFailoverInterest2.hpp
+++ b/cppcache/integration-test/ThinClientFailoverInterest2.hpp
@@ -45,7 +45,7 @@ bool isLocalServer = false;
#define SERVER2 s2p2
static bool isLocator = false;
// static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
void initClient(const bool isthinClient) {
@@ -187,12 +187,12 @@ void createRegion(const char* name, bool ackMode, const char* endpoints,
ASSERT(regPtr != nullptr, "Failed to create region.");
LOG("Region created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode, const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
diff --git a/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp b/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp
index a0b6bbc..cf405f2 100644
--- a/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp
+++ b/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp
@@ -47,7 +47,7 @@ volatile bool g_poolLocators = false;
#define SERVER2 s2p2
static bool isLocator = false;
// static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
#include "ThinClientTasks_C2S2.hpp"
@@ -181,13 +181,13 @@ void _verifyCreated(const char* name, const char* key, int line) {
LOG("Entry created.");
}
-void createRegion(const char* name, bool ackMode, const char* endpoints,
+void createRegion(const std::string& name, bool ackMode, const std::string&,
bool clientNotificationEnabled = false) {
LOG("createRegion() entered.");
- LOGINFO("Creating region -- %s ackMode is %d", name, ackMode);
+ LOGINFO("Creating region -- %s ackMode is %d", name.c_str(), ackMode);
// ack, caching
auto regPtr = getHelper()->createRegion(name, ackMode, true, nullptr,
- endpoints, clientNotificationEnabled);
+ clientNotificationEnabled);
ASSERT(regPtr != nullptr, "Failed to create region.");
LOG("Region created.");
}
diff --git a/cppcache/integration-test/ThinClientFailoverRegex.hpp b/cppcache/integration-test/ThinClientFailoverRegex.hpp
index b1ed8c7..abd2088 100644
--- a/cppcache/integration-test/ThinClientFailoverRegex.hpp
+++ b/cppcache/integration-test/ThinClientFailoverRegex.hpp
@@ -46,7 +46,7 @@ CacheHelper* cacheHelper = nullptr;
#define SERVER2 s2p2
static bool isLocator = false;
// static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
void initClient(const bool isthinClient) {
@@ -188,12 +188,13 @@ void createRegion(const char* name, bool ackMode, const char* endpoints,
ASSERT(regPtr != nullptr, "Failed to create region.");
LOG("Region created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode,
+ const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
diff --git a/cppcache/integration-test/ThinClientGatewayTest.hpp b/cppcache/integration-test/ThinClientGatewayTest.hpp
index 9be06a0..a7b0864 100644
--- a/cppcache/integration-test/ThinClientGatewayTest.hpp
+++ b/cppcache/integration-test/ThinClientGatewayTest.hpp
@@ -73,8 +73,8 @@ void setCacheListener(const char* regName,
attrMutator->setCacheListener(regListener);
}
-const char* locHostPort1 = nullptr;
-const char* locHostPort2 = nullptr;
+std::string locHostPort1;
+std::string locHostPort2;
DUNIT_TASK_DEFINITION(SERVER1, StartLocator1)
{
CacheHelper::initLocator(1, false, true, 1,
diff --git a/cppcache/integration-test/ThinClientHeapLRU.hpp b/cppcache/integration-test/ThinClientHeapLRU.hpp
index 37532a0..9dce2bb 100644
--- a/cppcache/integration-test/ThinClientHeapLRU.hpp
+++ b/cppcache/integration-test/ThinClientHeapLRU.hpp
@@ -42,7 +42,7 @@ static bool isLocator = false;
static bool isLocalServer = false;
static int numberOfLocators = 0;
const char* poolName = "__TESTPOOL1_";
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
const char* keys[] = {"Key-1", "Key-2", "Key-3", "Key-4"};
diff --git a/cppcache/integration-test/ThinClientHelper.hpp b/cppcache/integration-test/ThinClientHelper.hpp
index 409e5d5..acfb7ac 100644
--- a/cppcache/integration-test/ThinClientHelper.hpp
+++ b/cppcache/integration-test/ThinClientHelper.hpp
@@ -22,8 +22,10 @@
#include <chrono>
-#include <ace/OS.h>
#include <ace/High_Res_Timer.h>
+
+#include <boost/process.hpp>
+
#include "testUtils.hpp"
#include "security/typedefs.hpp"
#include "security/CredentialGenerator.hpp"
@@ -66,7 +68,7 @@ void initClient(const bool isthinClient,
}
void initClientWithPool(const bool isthinClient, const char* poolName,
- const char* locators, const char* serverGroup,
+ const std::string& locators, const char* serverGroup,
const std::shared_ptr<Properties>& configPtr = nullptr,
int redundancy = 0, bool clientNotification = false,
int subscriptionAckInterval = -1, int connections = -1,
@@ -367,7 +369,7 @@ std::shared_ptr<Region> createOverflowRegion(const char* name, bool,
sqLiteProps->insert("PageSize", "65536");
sqLiteProps->insert("MaxPageCount", "1073741823");
std::string sqlite_dir =
- "SqLiteRegionData" + std::to_string(ACE_OS::getpid());
+ "SqLiteRegionData" + std::to_string(boost::this_process::get_id());
sqLiteProps->insert("PersistenceDirectory", sqlite_dir.c_str());
regionAttributesFactory.setPersistenceManager(
"SqLiteImpl", "createSqLiteInstance", sqLiteProps);
@@ -380,7 +382,7 @@ std::shared_ptr<Region> createOverflowRegion(const char* name, bool,
return regionPtr;
}
std::shared_ptr<Region> createPooledRegion(
- const char* name, bool ackMode, const char* locators, const char* poolname,
+ const char* name, bool ackMode, const std::string& locators, const char* poolname,
bool clientNotificationEnabled = false,
const std::shared_ptr<CacheListener>& listener = nullptr,
bool caching = true) {
@@ -409,7 +411,7 @@ std::shared_ptr<Pool> findPool(const char* poolName) {
return poolPtr;
}
std::shared_ptr<Pool> createPool(
- const char* poolName, const char* locators, const char* serverGroup,
+ const std::string& poolName, const std::string& locators, const std::string& serverGroup,
int redundancy = 0, bool clientNotification = false,
std::chrono::milliseconds subscriptionAckInterval =
std::chrono::milliseconds::zero(),
@@ -424,7 +426,7 @@ std::shared_ptr<Pool> createPool(
return poolPtr;
}
std::shared_ptr<Pool> createPoolAndDestroy(
- const char* poolName, const char* locators, const char* serverGroup,
+ const std::string& poolName, const std::string& locators, const std::string& serverGroup,
int redundancy = 0, bool clientNotification = false,
std::chrono::milliseconds subscriptionAckInterval =
std::chrono::milliseconds::zero(),
@@ -440,9 +442,9 @@ std::shared_ptr<Pool> createPoolAndDestroy(
return poolPtr;
}
// this will create pool even endpoints and locatorhost has been not defined
-std::shared_ptr<Pool> createPool2(const char* poolName, const char* locators,
- const char* serverGroup,
- const char* servers = nullptr,
+std::shared_ptr<Pool> createPool2(const std::string& poolName, const std::string& locators,
+ const std::string& serverGroup,
+ const std::string& servers = nullptr,
int redundancy = 0,
bool clientNotification = false) {
LOG("createPool2() entered.");
diff --git a/cppcache/integration-test/ThinClientInterest1.hpp b/cppcache/integration-test/ThinClientInterest1.hpp
index 6015ea0..c234a2e 100644
--- a/cppcache/integration-test/ThinClientInterest1.hpp
+++ b/cppcache/integration-test/ThinClientInterest1.hpp
@@ -30,7 +30,7 @@
bool isLocalServer = true;
static bool isLocator = false;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
DUNIT_TASK_DEFINITION(SERVER1, StartServer)
diff --git a/cppcache/integration-test/ThinClientInterest2.hpp b/cppcache/integration-test/ThinClientInterest2.hpp
index b121446..44b2ae7 100644
--- a/cppcache/integration-test/ThinClientInterest2.hpp
+++ b/cppcache/integration-test/ThinClientInterest2.hpp
@@ -30,7 +30,7 @@
bool isLocalServer = true;
static bool isLocator = false;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
diff --git a/cppcache/integration-test/ThinClientInterest3.hpp b/cppcache/integration-test/ThinClientInterest3.hpp
index 2be8310..d86cffd 100644
--- a/cppcache/integration-test/ThinClientInterest3.hpp
+++ b/cppcache/integration-test/ThinClientInterest3.hpp
@@ -36,7 +36,7 @@ using apache::geode::client::testing::TallyWriter;
bool isLocalServer = true;
static bool isLocator = false;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
std::shared_ptr<TallyListener> reg1Listener1;
diff --git a/cppcache/integration-test/ThinClientInterest3Cacheless.hpp b/cppcache/integration-test/ThinClientInterest3Cacheless.hpp
index 7c773cd..ac038db 100644
--- a/cppcache/integration-test/ThinClientInterest3Cacheless.hpp
+++ b/cppcache/integration-test/ThinClientInterest3Cacheless.hpp
@@ -36,7 +36,7 @@ using apache::geode::client::testing::TallyWriter;
bool isLocalServer = true;
static bool isLocator = false;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
std::shared_ptr<TallyListener> reg1Listener1;
diff --git a/cppcache/integration-test/ThinClientInterestList.hpp b/cppcache/integration-test/ThinClientInterestList.hpp
index b29f77c..a28fa91 100644
--- a/cppcache/integration-test/ThinClientInterestList.hpp
+++ b/cppcache/integration-test/ThinClientInterestList.hpp
@@ -44,7 +44,7 @@ bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 1;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
#include "LocatorHelper.hpp"
void initClient(const bool isthinClient) {
@@ -184,12 +184,12 @@ void _verifyCreated(const char* name, const char* key, int line) {
LOG("Entry created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode, const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
diff --git a/cppcache/integration-test/ThinClientInterestList2.hpp b/cppcache/integration-test/ThinClientInterestList2.hpp
index 4cfeb4d..27b8f87 100644
--- a/cppcache/integration-test/ThinClientInterestList2.hpp
+++ b/cppcache/integration-test/ThinClientInterestList2.hpp
@@ -45,7 +45,7 @@ bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
#include "LocatorHelper.hpp"
void initClient(const bool isthinClient) {
@@ -185,11 +185,11 @@ void _verifyCreated(const char* name, const char* key, int line) {
LOG("Entry created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode, const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locatorsG, poolname,
diff --git a/cppcache/integration-test/ThinClientListenerInit.hpp b/cppcache/integration-test/ThinClientListenerInit.hpp
index 046cc6b..926ff1d 100644
--- a/cppcache/integration-test/ThinClientListenerInit.hpp
+++ b/cppcache/integration-test/ThinClientListenerInit.hpp
@@ -41,7 +41,7 @@ using apache::geode::client::testing::TallyWriter;
static bool isLocator = false;
static bool isLocalServer = true;
static int numberOfLocators = 1;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
const char* poolName = "__TESTPOOL1_";
std::shared_ptr<TallyListener> reg1Listener1, reg1Listener2;
diff --git a/cppcache/integration-test/ThinClientListenerWriter.hpp b/cppcache/integration-test/ThinClientListenerWriter.hpp
index f96e43d..0a3ae8e 100644
--- a/cppcache/integration-test/ThinClientListenerWriter.hpp
+++ b/cppcache/integration-test/ThinClientListenerWriter.hpp
@@ -122,7 +122,7 @@ void SimpleCacheListener::afterRegionClear(const RegionEvent& event) {
static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
const char* poolName = "__TESTPOOL1_";
std::shared_ptr<TallyListener> regListener;
@@ -377,10 +377,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, doEventOperations)
auto subregPtr2 = exmpRegPtr->getSubregion(myRegNames[4]);
for (int index = 0; index < 5; index++) {
- char key[100] = {0};
- char value[100] = {0};
- ACE_OS::sprintf(key, "Key-%d", index);
- ACE_OS::sprintf(value, "Value-%d", index);
+ std::string key = "Key-" + std::to_string(index);
+ std::string value = "Value-" + std::to_string(index);
+
auto keyptr = CacheableKey::create(key);
auto valuePtr = CacheableString::create(value);
regPtr0->put(keyptr, valuePtr);
diff --git a/cppcache/integration-test/ThinClientLocalCacheLoader.hpp b/cppcache/integration-test/ThinClientLocalCacheLoader.hpp
index b74e38a..7b50069 100644
--- a/cppcache/integration-test/ThinClientLocalCacheLoader.hpp
+++ b/cppcache/integration-test/ThinClientLocalCacheLoader.hpp
@@ -98,7 +98,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, SetupClient)
{
// Create a Geode Cache with the "client_Loader.xml" Cache XML file.
const char* clientXmlFile = "client_Loader.xml";
- static char* path = ACE_OS::getenv("TESTSRC");
+ static char* path = std::getenv("TESTSRC");
std::string clientXml = path;
clientXml += "/resources/";
clientXml += clientXmlFile;
diff --git a/cppcache/integration-test/ThinClientMultipleCaches.hpp b/cppcache/integration-test/ThinClientMultipleCaches.hpp
index 6214eed..4e519ab 100644
--- a/cppcache/integration-test/ThinClientMultipleCaches.hpp
+++ b/cppcache/integration-test/ThinClientMultipleCaches.hpp
@@ -43,7 +43,7 @@ using apache::geode::client::RegionShortcut;
static bool isLocalServer = false;
static bool isLocator = false;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer);
#include "LocatorHelper.hpp"
diff --git a/cppcache/integration-test/ThinClientNotification.hpp b/cppcache/integration-test/ThinClientNotification.hpp
index 84a7b5e..50b863d 100644
--- a/cppcache/integration-test/ThinClientNotification.hpp
+++ b/cppcache/integration-test/ThinClientNotification.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT(google-build-namespaces)
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
@@ -124,7 +124,8 @@ void _verifyEntry(const char* name, const char* key, const char* val,
std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr));
ASSERT(checkPtr != nullptr, "Value Ptr should not be null.");
- LOG("In verify loop, get returned " + checkPtr->value() + " for key " + key);
+ LOG("In verify loop, get returned " + checkPtr->value() + " for key " +
+ key);
if (strcmp(checkPtr->value().c_str(), value) != 0) {
testValueCnt++;
} else {
@@ -168,12 +169,14 @@ void _verifyEntry(const char* name, const char* key, const char* val,
LOG("Entry verified.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode,
+ const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
diff --git a/cppcache/integration-test/ThinClientPdxSerializer.hpp b/cppcache/integration-test/ThinClientPdxSerializer.hpp
index 5a01829..036424c 100644
--- a/cppcache/integration-test/ThinClientPdxSerializer.hpp
+++ b/cppcache/integration-test/ThinClientPdxSerializer.hpp
@@ -51,7 +51,7 @@ bool isLocator = false;
bool isLocalServer = false;
const char* poolNames[] = {"Pool1", "Pool2", "Pool3"};
-const char* locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
bool isPoolConfig = false; // To track if pool case is running
@@ -68,7 +68,7 @@ void stepOne(bool isPdxIgnoreUnreadFields = false) {
// Create just one pool and attach all regions to that.
initClient(true, isPdxIgnoreUnreadFields);
isPoolConfig = true;
- createPool(poolNames[0], locHostPort, nullptr, 0, true);
+ createPool(poolNames[0], locHostPort, {}, 0, true);
createRegionAndAttachPool("DistRegionAck", USE_ACK, poolNames[0],
false /*Caching disabled*/);
LOG("StepOne complete.");
diff --git a/cppcache/integration-test/ThinClientPutAll.hpp b/cppcache/integration-test/ThinClientPutAll.hpp
index 0724fd9..68ce7ac 100644
--- a/cppcache/integration-test/ThinClientPutAll.hpp
+++ b/cppcache/integration-test/ThinClientPutAll.hpp
@@ -57,7 +57,7 @@ static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
const char* poolName = "__TESTPOOL1_";
@@ -199,12 +199,12 @@ void createRegion(const char* name, bool ackMode, bool isCacheEnabled,
ASSERT(regPtr != nullptr, "Failed to create region.");
LOG("Region created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode, const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
@@ -214,11 +214,11 @@ void createPooledRegion(const char* name, bool ackMode, const char* locators,
}
void createPooledRegionConcurrencyCheckDisabled(
- const char* name, bool ackMode, const char*, const char* locators,
- const char* poolname, bool clientNotificationEnabled = false,
+ const std::string& name, bool ackMode, const std::string& locators,
+ const std::string& poolname, bool clientNotificationEnabled = false,
bool cachingEnable = true, bool concurrencyCheckEnabled = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr = getHelper()->createPooledRegionConcurrencyCheckDisabled(
name, ackMode, locators, poolname, cachingEnable,
@@ -365,7 +365,7 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StepOne_Pooled_Locator_ConcurrencyCheckDisabled)
{
initClient(true);
- createPooledRegionConcurrencyCheckDisabled(regionNames[0], USE_ACK, nullptr,
+ createPooledRegionConcurrencyCheckDisabled(regionNames[0], USE_ACK,
locatorsG, poolName, true, true,
false);
LOG("StepOne_Pooled_Locator_ConcurrencyCheckDisabled complete.");
diff --git a/cppcache/integration-test/ThinClientPutAllTimeout.hpp b/cppcache/integration-test/ThinClientPutAllTimeout.hpp
index fa179ec..d4997b0 100644
--- a/cppcache/integration-test/ThinClientPutAllTimeout.hpp
+++ b/cppcache/integration-test/ThinClientPutAllTimeout.hpp
@@ -40,7 +40,7 @@ using apache::geode::client::testing::TallyWriter;
bool isLocalServer = true;
static bool isLocator = false;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
diff --git a/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp b/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
index 005dd1d..8034176 100644
--- a/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
+++ b/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
@@ -56,7 +56,7 @@ static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
const char* poolName = "__TESTPOOL1_";
@@ -197,12 +197,12 @@ void createRegion(const char* name, bool ackMode, bool isCacheEnabled,
ASSERT(regPtr != nullptr, "Failed to create region.");
LOG("Region created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode, const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
@@ -212,11 +212,11 @@ void createPooledRegion(const char* name, bool ackMode, const char* locators,
}
void createPooledRegionConcurrencyCheckDisabled(
- const char* name, bool ackMode, const char* locators, const char* poolname,
+ const std::string& name, bool ackMode, const std::string& locators, const std::string& poolname,
bool clientNotificationEnabled = false, bool cachingEnable = true,
bool concurrencyCheckEnabled = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr = getHelper()->createPooledRegionConcurrencyCheckDisabled(
name, ackMode, locators, poolname, cachingEnable,
diff --git a/cppcache/integration-test/ThinClientPutGetAll.hpp b/cppcache/integration-test/ThinClientPutGetAll.hpp
index e69839d..ec027e4 100644
--- a/cppcache/integration-test/ThinClientPutGetAll.hpp
+++ b/cppcache/integration-test/ThinClientPutGetAll.hpp
@@ -59,7 +59,7 @@ static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
const char* poolName = "__TEST_POOL1__";
@@ -109,12 +109,12 @@ void verifyGetAllWithCallBackArg(std::shared_ptr<Region> region,
verifyGetAll(region, values, startIndex, callBack);
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode, const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
diff --git a/cppcache/integration-test/ThinClientRIwithlocalRegionDestroy.hpp b/cppcache/integration-test/ThinClientRIwithlocalRegionDestroy.hpp
index f3e8c0d..2507832 100644
--- a/cppcache/integration-test/ThinClientRIwithlocalRegionDestroy.hpp
+++ b/cppcache/integration-test/ThinClientRIwithlocalRegionDestroy.hpp
@@ -49,7 +49,7 @@ CacheHelper* cacheHelper = nullptr;
bool isLocalServer = false;
static bool isLocator = false;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
@@ -120,12 +120,12 @@ CacheHelper* getHelper() {
return cacheHelper;
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode, const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
@@ -223,12 +223,12 @@ DUNIT_TASK_DEFINITION(CLIENT2, putOps)
auto regPtr0 = getHelper()->getRegion(regionNames[0]);
for (int index = 0; index < 5; index++) {
- char key[100] = {0};
- char value[100] = {0};
- ACE_OS::sprintf(key, "Key-%d", index);
- ACE_OS::sprintf(value, "Value-%d", index);
+ auto key = "Key-" + std::to_string(index);
+ auto value = "Value-" + std::to_string(index);
+
auto keyptr = CacheableKey::create(key);
auto valuePtr = CacheableString::create(value);
+
regPtr0->put(keyptr, valuePtr);
}
LOG("StepFour complete.");
@@ -253,12 +253,12 @@ DUNIT_TASK_DEFINITION(CLIENT2, StepFour)
auto regPtr0 = getHelper()->getRegion(regionNames[0]);
for (int index = 0; index < 5; index++) {
- char key[100] = {0};
- char value[100] = {0};
- ACE_OS::sprintf(key, "Key-%d", index);
- ACE_OS::sprintf(value, "Value-%d", index);
+ auto key = "Key-" + std::to_string(index);
+ auto value = "Value-" + std::to_string(index);
+
auto keyptr = CacheableKey::create(key);
auto valuePtr = CacheableString::create(value);
+
regPtr0->put(keyptr, valuePtr);
}
LOG("StepFour complete.");
@@ -303,12 +303,12 @@ DUNIT_TASK_DEFINITION(CLIENT2, StepSix)
auto regPtr1 = getHelper()->getRegion(regionNames[1]);
for (int index = 0; index < 5; index++) {
- char key[100] = {0};
- char value[100] = {0};
- ACE_OS::sprintf(key, "Key-%d", index);
- ACE_OS::sprintf(value, "Value-%d", index);
+ auto key = "Key-" + std::to_string(index);
+ auto value = "Value-" + std::to_string(index);
+
auto keyptr = CacheableKey::create(key);
auto valuePtr = CacheableString::create(value);
+
regPtr0->put(keyptr, valuePtr);
regPtr1->put(keyptr, valuePtr);
}
@@ -372,12 +372,12 @@ DUNIT_TASK_DEFINITION(CLIENT2, StepEight)
auto subregPtr1 = regPtr2->getSubregion(regionNames[4]);
for (int index = 0; index < 5; index++) {
- char key[100] = {0};
- char value[100] = {0};
- ACE_OS::sprintf(key, "Key-%d", index);
- ACE_OS::sprintf(value, "Value-%d", index);
+ auto key = "Key-" + std::to_string(index);
+ auto value = "Value-" + std::to_string(index);
+
auto keyptr = CacheableKey::create(key);
auto valuePtr = CacheableString::create(value);
+
regPtr2->put(keyptr, valuePtr);
subregPtr0->put(keyptr, valuePtr);
subregPtr1->put(keyptr, valuePtr);
@@ -395,10 +395,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, VerifySubRegionOps)
auto subregPtr1 = regPtr2->getSubregion(regionNames[4]);
for (int index = 0; index < 5; index++) {
- char key[100] = {0};
- char value[100] = {0};
- ACE_OS::sprintf(key, "Key-%d", index);
- ACE_OS::sprintf(value, "Value-%d", index);
+ auto key = "Key-" + std::to_string(index);
+ auto value = "Value-" + std::to_string(index);
+
auto keyptr = CacheableKey::create(key);
auto valuePtr = CacheableString::create(value);
diff --git a/cppcache/integration-test/ThinClientRegex.hpp b/cppcache/integration-test/ThinClientRegex.hpp
index 88aa0af..4a5e793 100644
--- a/cppcache/integration-test/ThinClientRegex.hpp
+++ b/cppcache/integration-test/ThinClientRegex.hpp
@@ -44,7 +44,7 @@ CacheHelper* cacheHelper = nullptr;
bool isLocalServer = false;
static bool isLocator = false;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
void initClient(const bool isthinClient) {
@@ -164,12 +164,12 @@ void _verifyEntry(const char* name, const char* key, const char* val,
LOG("Entry verified.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode, const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
diff --git a/cppcache/integration-test/ThinClientRegex2.hpp b/cppcache/integration-test/ThinClientRegex2.hpp
index 14b6a6f..9dae0da 100644
--- a/cppcache/integration-test/ThinClientRegex2.hpp
+++ b/cppcache/integration-test/ThinClientRegex2.hpp
@@ -45,7 +45,7 @@ bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
#include "LocatorHelper.hpp"
void initClient(const bool isthinClient) {
@@ -175,12 +175,12 @@ void createRegion(const char* name, bool ackMode,
ASSERT(regPtr != nullptr, "Failed to create region.");
LOG("Region created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode, const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
diff --git a/cppcache/integration-test/ThinClientRegex3.hpp b/cppcache/integration-test/ThinClientRegex3.hpp
index 865c30d..67d9f6a 100644
--- a/cppcache/integration-test/ThinClientRegex3.hpp
+++ b/cppcache/integration-test/ThinClientRegex3.hpp
@@ -53,7 +53,7 @@ bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
#include "LocatorHelper.hpp"
void initClient(const bool isthinClient) {
@@ -183,12 +183,12 @@ void createRegion(const char* name, bool ackMode, const char* endpoints,
ASSERT(regPtr != nullptr, "Failed to create region.");
LOG("Region created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode, const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
diff --git a/cppcache/integration-test/ThinClientRemoveAll.hpp b/cppcache/integration-test/ThinClientRemoveAll.hpp
index c8a44dc..378a70b 100644
--- a/cppcache/integration-test/ThinClientRemoveAll.hpp
+++ b/cppcache/integration-test/ThinClientRemoveAll.hpp
@@ -56,7 +56,7 @@ static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
const char* poolName = "__TESTPOOL1_";
@@ -113,12 +113,12 @@ void createRegionLocal(const char* name, bool ackMode, const char*,
LOG("Region created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode, const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
diff --git a/cppcache/integration-test/ThinClientSecurity.hpp b/cppcache/integration-test/ThinClientSecurity.hpp
index 9e77d62..32ccd93 100644
--- a/cppcache/integration-test/ThinClientSecurity.hpp
+++ b/cppcache/integration-test/ThinClientSecurity.hpp
@@ -33,7 +33,7 @@ using apache::geode::client::AuthenticatedView;
static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 1;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
void setCacheListener(const std::string& regName,
diff --git a/cppcache/integration-test/ThinClientSecurityHelper.hpp b/cppcache/integration-test/ThinClientSecurityHelper.hpp
index 9c5ef1f..62d3e88 100644
--- a/cppcache/integration-test/ThinClientSecurityHelper.hpp
+++ b/cppcache/integration-test/ThinClientSecurityHelper.hpp
@@ -20,7 +20,8 @@
#ifndef GEODE_INTEGRATION_TEST_THINCLIENTSECURITYHELPER_H_
#define GEODE_INTEGRATION_TEST_THINCLIENTSECURITYHELPER_H_
-#include <ace/Process.h>
+#include <boost/process.hpp>
+#include <boost/lexical_cast.hpp>
#include "fw_dunit.hpp"
#include "ThinClientHelper.hpp"
@@ -51,7 +52,7 @@ using apache::geode::client::testframework::security::opCodeList;
bool isLocator = false;
bool isLocalServer = false;
-const char* locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char* regionNamesAuth[] = {"DistRegionAck"};
@@ -59,7 +60,7 @@ std::shared_ptr<CredentialGenerator> credentialGeneratorHandler;
std::string getXmlPath() {
char xmlPath[1000] = {'\0'};
- const char* path = ACE_OS::getenv("TESTSRC");
+ const char* path = std::getenv("TESTSRC");
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
@@ -215,36 +216,39 @@ class putThread : public ACE_Task_Base {
}
}
- int svc(void) override {
+ int svc() override {
int ops = 0;
- auto pid = ACE_OS::getpid();
+ std::string key_str;
std::shared_ptr<CacheableKey> key;
std::shared_ptr<CacheableString> value;
std::vector<std::shared_ptr<CacheableKey>> keys0;
- char buf[32];
- char valbuf[32];
+
+ auto pid = boost::this_process::get_id();
if (m_regInt) {
m_reg->registerAllKeys(false, true);
}
if (m_waitTime != 0) {
- ACE_OS::sleep(m_waitTime);
+ std::this_thread::sleep_for(std::chrono::seconds{m_waitTime});
}
while (ops++ < m_numops) {
if (m_sameKey) {
- sprintf(buf, "key-%d", 1);
+ key_str = "key-1";
} else {
- sprintf(buf, "key-%d", ops);
+ key_str = "key-" + std::to_string(ops);
}
- key = CacheableKey::create(buf);
+
+ key = CacheableKey::create(key_str);
if (m_opcode == 0) {
+ std::string value_str;
+
if (m_isCallBack) {
auto boolptr = CacheableBoolean::create("true");
- snprintf(valbuf, sizeof(valbuf), "client1-value%d", ops);
- value = CacheableString::create(valbuf);
+ value_str = "client1-value" + std::to_string(ops);
+ value = CacheableString::create(value_str);
m_reg->put(key, value, boolptr);
} else {
- snprintf(valbuf, sizeof(valbuf), "client2-value%d", ops);
- value = CacheableString::create(valbuf);
+ value_str = "client2-value" + std::to_string(ops);
+ value = CacheableString::create(value_str);
m_reg->put(key, value);
}
} else if (m_opcode == 1) {
@@ -265,8 +269,9 @@ class putThread : public ACE_Task_Base {
m_reg->destroy(key);
}
} catch (Exception& ex) {
- printf("%d: %" PRIu64 " exception got and exception message = %s\n",
- pid, hacks::aceThreadId(ACE_OS::thr_self()), ex.what());
+ auto tid = boost::lexical_cast<std::string>(std::this_thread::get_id());
+ printf("%d: %s exception got and exception message = %s\n",
+ pid, tid.c_str(), ex.what());
}
}
}
diff --git a/cppcache/integration-test/ThinClientTXFailover.hpp b/cppcache/integration-test/ThinClientTXFailover.hpp
index 4233c72..4cd3a7e 100644
--- a/cppcache/integration-test/ThinClientTXFailover.hpp
+++ b/cppcache/integration-test/ThinClientTXFailover.hpp
@@ -32,7 +32,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT(google-build-namespaces)
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
@@ -49,7 +49,7 @@ CacheHelper* cacheHelper = nullptr;
#define SERVER2 s2p2
static bool isLocator = false;
// static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
void initClient(const bool isthinClient) {
@@ -128,7 +128,8 @@ void _verifyEntry(const char* name, const char* key, const char* val,
std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr));
ASSERT(checkPtr != nullptr, "Value Ptr should not be null.");
- LOG("In verify loop, get returned " + checkPtr->value() + " for key " + key);
+ LOG("In verify loop, get returned " + checkPtr->value() + " for key " +
+ key);
if (strcmp(checkPtr->value().c_str(), value) != 0) {
testValueCnt++;
@@ -163,12 +164,14 @@ void createRegion(const char* name, bool ackMode, const char* endpoints,
ASSERT(regPtr != nullptr, "Failed to create region.");
LOG("Region created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode,
+ const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
@@ -177,12 +180,14 @@ void createPooledRegion(const char* name, bool ackMode, const char* locators,
LOG("Pooled Region created.");
}
-void createPooledRegionSticky(const char* name, bool ackMode,
- const char* locators, const char* poolname,
+void createPooledRegionSticky(const std::string& name, bool ackMode,
+ const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
auto regPtr = getHelper()->createPooledRegionSticky(
name, ackMode, locators, poolname, cachingEnable,
diff --git a/cppcache/integration-test/ThinClientTransactions.hpp b/cppcache/integration-test/ThinClientTransactions.hpp
index 7ef5c15..b341950 100644
--- a/cppcache/integration-test/ThinClientTransactions.hpp
+++ b/cppcache/integration-test/ThinClientTransactions.hpp
@@ -58,7 +58,7 @@ static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
void initClient(const bool isthinClient) {
@@ -180,12 +180,14 @@ void createRegion(const char* name, bool ackMode, const char* endpoints,
ASSERT(regPtr != nullptr, "Failed to create region.");
LOG("Region created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode,
+ const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
@@ -194,12 +196,14 @@ void createPooledRegion(const char* name, bool ackMode, const char* locators,
LOG("Pooled Region created.");
}
-void createPooledRegionSticky(const char* name, bool ackMode,
- const char* locators, const char* poolname,
+void createPooledRegionSticky(const std::string& name, bool ackMode,
+ const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
auto regPtr = getHelper()->createPooledRegionSticky(
name, ackMode, locators, poolname, cachingEnable,
@@ -395,7 +399,7 @@ class SuspendTransactionThread : public ACE_Task_Base {
if (m_sleep) {
m_txEvent->wait();
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
}
m_suspendedTransaction = &txManager->suspend();
@@ -677,7 +681,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, SuspendTimeOut)
ASSERT(txManager->exists(tid2),
"In SuspendTimeOut - the transaction should exist");
- ACE_OS::sleep(65);
+ std::this_thread::sleep_for(std::chrono::seconds(65));
ASSERT(!txManager->tryResume(tid2),
"In SuspendTimeOut - the transaction should NOT have been resumed");
ASSERT(!txManager->isSuspended(tid2),
@@ -791,7 +795,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, SuspendResumeInThread)
SuspendTransactionThread* suspendTh =
new SuspendTransactionThread(false, &txEvent);
suspendTh->activate();
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
ResumeTransactionThread* resumeTh = new ResumeTransactionThread(
suspendTh->getSuspendedTx(), false, false, &txEvent);
resumeTh->activate();
@@ -808,7 +812,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, SuspendResumeInThread)
LOG(buf);
suspendTh = new SuspendTransactionThread(false, &txEvent);
suspendTh->activate();
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
resumeTh = new ResumeTransactionThread(suspendTh->getSuspendedTx(), true,
false, &txEvent);
resumeTh->activate();
@@ -828,7 +832,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, SuspendResumeInThread)
LOG(buf);
suspendTh = new SuspendTransactionThread(true, &txEvent);
suspendTh->activate();
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
resumeTh = new ResumeTransactionThread(suspendTh->getSuspendedTx(), false,
true, &txEvent);
resumeTh->activate();
@@ -847,7 +851,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, SuspendResumeInThread)
LOG(buf);
suspendTh = new SuspendTransactionThread(true, &txEvent);
suspendTh->activate();
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
sprintf(buf, "suspendTh->activate();");
LOG(buf);
diff --git a/cppcache/integration-test/ThinClientTransactionsXA.hpp b/cppcache/integration-test/ThinClientTransactionsXA.hpp
index 4594775..750e5b5 100644
--- a/cppcache/integration-test/ThinClientTransactionsXA.hpp
+++ b/cppcache/integration-test/ThinClientTransactionsXA.hpp
@@ -59,7 +59,7 @@ static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 0;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
void initClient(const bool isthinClient) {
@@ -181,12 +181,12 @@ void createRegion(const char* name, bool ackMode, const char* endpoints,
ASSERT(regPtr != nullptr, "Failed to create region.");
LOG("Region created.");
}
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
+void createPooledRegion(const std::string& name, bool ackMode, const std::string& locators,
+ const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
@@ -195,12 +195,12 @@ void createPooledRegion(const char* name, bool ackMode, const char* locators,
LOG("Pooled Region created.");
}
-void createPooledRegionSticky(const char* name, bool ackMode,
- const char* locators, const char* poolname,
+void createPooledRegionSticky(const std::string& name, bool ackMode,
+ const std::string& locators, const std::string& poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(), ackMode);
fflush(stdout);
auto regPtr = getHelper()->createPooledRegionSticky(
name, ackMode, locators, poolname, cachingEnable,
@@ -396,7 +396,7 @@ class SuspendTransactionThread : public ACE_Task_Base {
if (m_sleep) {
m_txEvent->wait();
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
}
m_suspendedTransaction = &txManager->suspend();
@@ -687,7 +687,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, SuspendTimeOut)
ASSERT(!regPtr0->containsKeyOnServer(keyPtr5),
"In SuspendTimeOut - Key should not have been found in region.");
- ACE_OS::sleep(65);
+ std::this_thread::sleep_for(std::chrono::seconds(65));
ASSERT(!txManager->tryResume(tid2),
"In SuspendTimeOut - the transaction should NOT have been resumed");
ASSERT(!txManager->isSuspended(tid2),
@@ -798,7 +798,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, SuspendResumeInThread)
SuspendTransactionThread* suspendTh =
new SuspendTransactionThread(false, &txEvent);
suspendTh->activate();
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
ResumeTransactionThread* resumeTh = new ResumeTransactionThread(
suspendTh->getSuspendedTx(), false, false, &txEvent);
resumeTh->activate();
@@ -814,7 +814,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, SuspendResumeInThread)
LOG(buf);
suspendTh = new SuspendTransactionThread(false, &txEvent);
suspendTh->activate();
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
resumeTh = new ResumeTransactionThread(suspendTh->getSuspendedTx(), true,
false, &txEvent);
resumeTh->activate();
@@ -833,7 +833,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, SuspendResumeInThread)
LOG(buf);
suspendTh = new SuspendTransactionThread(true, &txEvent);
suspendTh->activate();
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
resumeTh = new ResumeTransactionThread(suspendTh->getSuspendedTx(), false,
true, &txEvent);
resumeTh->activate();
@@ -851,7 +851,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, SuspendResumeInThread)
LOG(buf);
suspendTh = new SuspendTransactionThread(true, &txEvent);
suspendTh->activate();
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
sprintf(buf, "suspendTh->activate();");
LOG(buf);
diff --git a/cppcache/integration-test/ThinClientVersionedOps.hpp b/cppcache/integration-test/ThinClientVersionedOps.hpp
index c812b07..99b9f11 100644
--- a/cppcache/integration-test/ThinClientVersionedOps.hpp
+++ b/cppcache/integration-test/ThinClientVersionedOps.hpp
@@ -47,7 +47,7 @@ std::string gfendpoints2 = "localhost:";
bool isLocalServer1 = false;
static bool isLocator1 = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator1, isLocalServer1, 1);
std::shared_ptr<CacheableString> c1v11;
std::shared_ptr<CacheableString> c1v12;
diff --git a/cppcache/integration-test/TimeBomb.hpp b/cppcache/integration-test/TimeBomb.hpp
index 07ef800..ccb3b15 100644
--- a/cppcache/integration-test/TimeBomb.hpp
+++ b/cppcache/integration-test/TimeBomb.hpp
@@ -21,10 +21,12 @@
#define GEODE_INTEGRATION_TEST_TIMEBOMB_H_
#include <ace/Task.h>
-#include <ace/OS.h>
-#include <ace/Time_Value.h>
#include <assert.h>
+#include <thread>
+
+#include "Utils.hpp"
+
#define MAX_CLIENT 10
class ClientCleanup {
@@ -66,15 +68,16 @@ class TimeBomb : public ACE_Task_Base {
}
public:
- ACE_Time_Value m_sleep;
+ std::chrono::seconds m_sleep;
explicit TimeBomb(void (*cleanupFunc)() = nullptr)
: m_sleep(0) /* UNUSED , m_numberOfClient( -1 )*/
{
- char* sleepEnv = ACE_OS::getenv("TIMEBOMB");
- if (sleepEnv != nullptr) {
- m_sleep.sec(atol(sleepEnv));
+ std::string sleepEnv = apache::geode::client::Utils::getEnv("TIMEBOMB");
+ if (!sleepEnv.empty()) {
+ m_sleep = std::chrono::seconds{std::stoi(sleepEnv)};
}
+
m_cleanupCallback = cleanupFunc;
arm(); // starting
}
@@ -88,17 +91,20 @@ class TimeBomb : public ACE_Task_Base {
}
int svc() override {
- if (m_sleep == ACE_Time_Value(0)) {
+ if (m_sleep == std::chrono::seconds{}) {
printf("###### TIMEBOMB Disabled. ######\n");
fflush(stdout);
return 0;
}
- ACE_Time_Value start = ACE_OS::gettimeofday();
- ACE_Time_Value now = ACE_OS::gettimeofday();
+
+ auto start = std::chrono::steady_clock::now();
+ decltype(start) now;
+
do {
- ACE_OS::sleep(1);
- now = ACE_OS::gettimeofday();
- } while (now - start < m_sleep);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+ now = std::chrono::steady_clock::now();
+ } while ((now - start) < m_sleep);
+
printf("####### ERROR: TIMEBOMB WENT OFF, TEST TIMED OUT ########\n");
fflush(stdout);
diff --git a/cppcache/integration-test/fw_dunit.cpp b/cppcache/integration-test/fw_dunit.cpp
index aa7f8e8..5589a8c 100644
--- a/cppcache/integration-test/fw_dunit.cpp
+++ b/cppcache/integration-test/fw_dunit.cpp
@@ -1,3 +1,4 @@
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -30,14 +31,13 @@
#include <smrtheap.h>
#endif
-#include <ace/ACE.h>
-
-#include <typeinfo>
-
#include <string>
#include <list>
#include <map>
+#include <boost/asio.hpp>
+#include <boost/process.hpp>
+
// SW: Switching to framework BB on linux also since it is much faster.
#ifndef _WIN32
// On solaris, when ACE_Naming_Context maps file to memory using fixed mode, it
@@ -69,7 +69,7 @@ using apache::geode::client::testframework::BBNamingContextServer;
#define __DUNIT_NO_MAIN__
#include "fw_dunit.hpp"
-static ACE_TCHAR *g_programName = nullptr;
+static std::string g_programName;
static uint32_t g_coordinatorPid = 0;
ClientCleanup gClientCleanup;
@@ -124,12 +124,11 @@ class NamingContextImpl : virtual public NamingContext {
#else
ACE_Naming_Context
#endif
+
m_context;
void millisleep(int msec) {
- ACE_Time_Value sleepTime;
- sleepTime.msec(msec);
- ACE_OS::sleep(sleepTime);
+ std::this_thread::sleep_for(std::chrono::milliseconds{msec});
}
int checkResult(int result, const char *func) {
@@ -151,7 +150,7 @@ class NamingContextImpl : virtual public NamingContext {
~NamingContextImpl() noexcept override {
m_context.close();
- ACE_OS::unlink(ACE_OS::getenv("TESTNAME"));
+ std::remove(std::getenv("TESTNAME"));
}
/**
@@ -180,39 +179,37 @@ class NamingContextImpl : virtual public NamingContext {
* retreive a value by key, storing the result in the users buf. If the key
* is not found, the buf will contain the empty string "".
*/
- void getValue(const char *key, char *buf, size_t sizeOfBuf) override {
+ std::string getValue(const std::string &key) override {
#ifdef SOLARIS_USE_BB
- char value[VALUE_MAX] = {0};
+ std::string value;
char type[VALUE_MAX] = {0};
#else
- char *value = nullptr;
char *type = nullptr;
+ char *value = nullptr;
#endif
- int res = -1;
- // we should not increase attempts to avoid increasing test run times.
int attempts = 3;
- while ((res = m_context.resolve(key, value, type)) != 0 && attempts--) {
+ while (m_context.resolve(key.c_str(), value, type) != 0 && attempts--) {
// we should not increase sleep to avoid increasing test run times.
millisleep(5);
}
- if (res != 0) {
- strncpy(buf, "", sizeOfBuf);
- return;
+#ifndef SOLARIS_USE_BB
+ if (value == nullptr) {
+ return {};
}
- ACE_OS::strncpy(buf, value, sizeOfBuf);
+#endif
+
+ return value;
}
/**
* return the value by key, as an int using the string to int conversion
* rules of atoi.
*/
- int getIntValue(const char *key) override {
- char value[VALUE_MAX] = {0};
- getValue(key, value, sizeof(value));
- if (ACE_OS::strcmp(value, "") == 0) return 0;
- return ACE_OS::atoi(value);
+ int getIntValue(const std::string &key) override {
+ auto val = getValue(key);
+ return val.empty() ? 0 : std::stoi(val);
}
void open() {
@@ -223,26 +220,22 @@ class NamingContextImpl : virtual public NamingContext {
name_options->process_name(getContextName().c_str());
name_options->namespace_dir(".");
name_options->context(ACE_Naming_Context::PROC_LOCAL);
- name_options->database(ACE_OS::getenv("TESTNAME"));
+ name_options->database(std::getenv("TESTNAME"));
checkResult(m_context.open(name_options->context(), 0), "open");
#endif
LOGCOORDINATOR("Naming context opened.");
}
std::string getContextName() {
- char buf[1024] = {0};
- ACE_OS::sprintf(buf, "dunit.context.%s%d", ACE::basename(g_programName),
- g_coordinatorPid);
- std::string b_str(buf);
- return b_str;
+ return "dunit.context." +
+ boost::filesystem::path{g_programName}.filename().stem().string() +
+ std::to_string(g_coordinatorPid);
}
std::string getMutexName() {
- char buf[1024] = {0};
- ACE_OS::sprintf(buf, "dunit.mutex.%s%d", ACE::basename(g_programName),
- g_coordinatorPid);
- std::string b_str(buf);
- return b_str;
+ return "dunit.mutex." +
+ boost::filesystem::path{g_programName}.filename().stem().string() +
+ std::to_string(g_coordinatorPid);
}
/** print out all the entries' keys and values in the naming context. */
@@ -253,7 +246,7 @@ class NamingContextImpl : virtual public NamingContext {
ACE_BINDING_SET set;
if (this->m_context.list_name_entries(set, "") != 0) {
char buf[1000] = {0};
- ACE_OS::sprintf(buf, "There is nothing in the naming context.");
+ ::sprintf(buf, "There is nothing in the naming context.");
LOGCOORDINATOR(buf);
} else {
ACE_BINDING_ITERATOR set_iterator(set);
@@ -261,8 +254,8 @@ class NamingContextImpl : virtual public NamingContext {
set_iterator.advance()) {
ACE_Name_Binding binding(*entry);
char buf[1000] = {0};
- ACE_OS::sprintf(buf, "%s => %s", binding.name_.char_rep(),
- binding.value_.char_rep());
+ ::sprintf(buf, "%s => %s", binding.name_.char_rep(),
+ binding.value_.char_rep());
LOGCOORDINATOR(buf);
}
}
@@ -271,7 +264,7 @@ class NamingContextImpl : virtual public NamingContext {
void resetContext() {
char buf[30] = {0};
- sprintf(buf, "%d", ACE_OS::getpid());
+ sprintf(buf, "%d", boost::this_process::get_id());
int res1 = -1;
int attempts1 = 10;
@@ -408,9 +401,9 @@ class Dunit {
/** call this once just inside main... */
static void init(bool initContext = false) {
if (initContext) {
- ACE_OS::unlink("localnames");
- ACE_OS::unlink("name_space_localnames");
- ACE_OS::unlink("backing_store_localnames");
+ std::remove("localnames");
+ std::remove("name_space_localnames");
+ std::remove("backing_store_localnames");
}
singleton = new Dunit();
if (initContext) {
@@ -453,27 +446,21 @@ class Dunit {
bool getFailed() { return m_globals.getIntValue("Failure") ? true : false; }
void setWorkerState(WorkerId sId, int state) {
- char key[100] = {0};
- ACE_OS::sprintf(key, "ReadyWorker%d", sId.getId());
- m_globals.rebind(key, state);
+ m_globals.rebind(("ReadyWorker" + std::to_string(sId.getId())).c_str(),
+ state);
}
int getWorkerState(WorkerId sId) {
- char key[100] = {0};
- ACE_OS::sprintf(key, "ReadyWorker%d", sId.getId());
- return m_globals.getIntValue(key);
+ return m_globals.getIntValue("ReadyWorker" + std::to_string(sId.getId()));
}
void setWorkerTimeout(WorkerId sId, int seconds) {
- char key[100] = {0};
- ACE_OS::sprintf(key, "TimeoutWorker%d", sId.getId());
- m_globals.rebind(key, seconds);
+ m_globals.rebind(("TimeoutWorker" + std::to_string(sId.getId())).c_str(),
+ seconds);
}
int getWorkerTimeout(WorkerId sId) {
- char key[100] = {0};
- ACE_OS::sprintf(key, "TimeoutWorker%d", sId.getId());
- return m_globals.getIntValue(key);
+ return m_globals.getIntValue("TimeoutWorker" + std::to_string(sId.getId()));
}
/** return the NamingContext for global (amongst all processes) values. */
@@ -499,7 +486,7 @@ class TestProcess : virtual public dunit::Manager {
WorkerId m_sId;
public:
- TestProcess(const ACE_TCHAR *cmdline, uint32_t id)
+ TestProcess(const std::string &cmdline, uint32_t id)
: Manager(cmdline), m_sId(id) {}
WorkerId &getWorkerId() { return m_sId; }
@@ -524,7 +511,7 @@ class TestDriver {
TestDriver() {
#ifdef SOLARIS_USE_BB
m_bbNamingContextServer = new BBNamingContextServer();
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
fprintf(stdout, "Blackboard started\n");
fflush(stdout);
#endif
@@ -532,29 +519,33 @@ class TestDriver {
dunit::Dunit::init(true);
fprintf(stdout, "Coordinator starting workers.\n");
for (uint32_t i = 1; i < 5; i++) {
- ACE_TCHAR cmdline[2048] = {0};
- char *profilerCmd = ACE_OS::getenv("PROFILERCMD");
+ std::string cmdline;
+ auto profilerCmd = std::getenv("PROFILERCMD");
if (profilerCmd != nullptr && profilerCmd[0] != '$' &&
profilerCmd[0] != '\0') {
// replace %d's in profilerCmd with PID and worker ID
char cmdbuf[2048] = {0};
- ACE_OS::sprintf(cmdbuf, profilerCmd, ACE_OS::gettimeofday().msec(),
- g_coordinatorPid, i);
- ACE_OS::sprintf(cmdline, "%s %s -s%d -m%d", cmdbuf, g_programName, i,
- g_coordinatorPid);
+ auto now = std::chrono::time_point_cast<std::chrono::milliseconds>(
+ std::chrono::system_clock::now())
+ .time_since_epoch()
+ .count();
+ ::sprintf(cmdbuf, profilerCmd, now, g_coordinatorPid, i);
+ cmdline = std::string{cmdbuf} + ' ' + g_programName + " -s" +
+ std::to_string(i) + " -m" + std::to_string(g_coordinatorPid);
} else {
- ACE_OS::sprintf(cmdline, "%s -s%d -m%d", g_programName, i,
- g_coordinatorPid);
+ cmdline = g_programName + " -s" + std::to_string(i) + " -m" +
+ std::to_string(g_coordinatorPid);
}
- fprintf(stdout, "%s\n", cmdline);
+ fprintf(stdout, "%s\n", cmdline.c_str());
m_workers[i - 1] = new TestProcess(cmdline, i);
}
fflush(stdout);
// start each of the workers...
for (uint32_t j = 1; j < 5; j++) {
m_workers[j - 1]->doWork();
- ACE_OS::sleep(2); // do not increase this to avoid precheckin runs taking
- // much longer.
+ std::this_thread::sleep_for(
+ std::chrono::seconds(2)); // do not increase this to avoid precheckin
+ // runs taking much longer.
}
}
@@ -573,7 +564,8 @@ class TestDriver {
}
int begin() {
- fprintf(stdout, "Coordinator started with pid %d\n", ACE_OS::getpid());
+ fprintf(stdout, "Coordinator started with pid %d\n",
+ boost::this_process::get_id());
fflush(stdout);
waitForReady();
// dispatch task...
@@ -608,17 +600,13 @@ class TestDriver {
fprintf(stdout, "Waiting %d seconds for %s to finish task.\n", secs,
sId.getIdName());
fflush(stdout);
- ACE_Time_Value end = ACE_OS::gettimeofday();
- ACE_Time_Value offset(secs, 0);
- end += offset;
+ auto end = std::chrono::steady_clock::now() + std::chrono::seconds{secs};
while (DUNIT->getWorkerState(sId) != WORKER_STATE_TASK_COMPLETE) {
// sleep a bit..
if (DUNIT->getFailed()) return;
- ACE_Time_Value sleepTime;
- sleepTime.msec(100);
- ACE_OS::sleep(sleepTime);
+ std::this_thread::sleep_for(std::chrono::milliseconds{100});
checkWorkerDeath();
- ACE_Time_Value now = ACE_OS::gettimeofday();
+ auto now = std::chrono::steady_clock::now();
if (now >= end) {
handleTimeout(sId);
break;
@@ -646,18 +634,19 @@ class TestDriver {
fprintf(stdout, "Waiting %d seconds for all workers to be ready.\n",
TASK_TIMEOUT);
fflush(stdout);
- ACE_Time_Value end = ACE_OS::gettimeofday();
- ACE_Time_Value offset(TASK_TIMEOUT, 0);
- end += offset;
+ auto end =
+ std::chrono::steady_clock::now() + std::chrono::seconds{TASK_TIMEOUT};
uint32_t readyCount = 0;
while (readyCount < 4) {
fprintf(stdout, "Ready Count: %d\n", readyCount);
fflush(stdout);
- if (DUNIT->getFailed()) return;
- // sleep a bit..
- ACE_Time_Value sleepTime(1);
- // sleepTime.msec( 10 );
- ACE_OS::sleep(sleepTime);
+
+ if (DUNIT->getFailed()) {
+ return;
+ }
+
+ std::this_thread::sleep_for(std::chrono::seconds{1});
+
readyCount = 0;
for (uint32_t i = 1; i < 5; i++) {
int state = DUNIT->getWorkerState(WorkerId(i));
@@ -666,7 +655,7 @@ class TestDriver {
}
}
checkWorkerDeath();
- ACE_Time_Value now = ACE_OS::gettimeofday();
+ auto now = std::chrono::steady_clock::now();
if (now >= end) {
handleTimeout();
break;
@@ -679,16 +668,15 @@ class TestDriver {
fprintf(stdout, "Waiting %d seconds for all workers to complete.\n",
TASK_TIMEOUT);
fflush(stdout);
- ACE_Time_Value end = ACE_OS::gettimeofday();
- ACE_Time_Value offset(TASK_TIMEOUT, 0);
- end += offset;
+
uint32_t doneCount = 0;
+ auto end =
+ std::chrono::steady_clock::now() + std::chrono::seconds{TASK_TIMEOUT};
+
while (doneCount < 4) {
// if ( DUNIT->getFailed() ) return;
// sleep a bit..
- ACE_Time_Value sleepTime;
- sleepTime.msec(100);
- ACE_OS::sleep(sleepTime);
+ std::this_thread::sleep_for(std::chrono::milliseconds{100});
doneCount = 0;
for (uint32_t i = 1; i < 5; i++) {
int state = DUNIT->getWorkerState(WorkerId(i));
@@ -696,7 +684,7 @@ class TestDriver {
doneCount++;
}
}
- ACE_Time_Value now = ACE_OS::gettimeofday();
+ auto now = std::chrono::steady_clock::now();
if (now >= end) {
handleTimeout();
break;
@@ -741,7 +729,7 @@ class TestWorker {
void begin() {
fprintf(stdout, "Worker %s started with pid %d\n", m_sId.getIdName(),
- ACE_OS::getpid());
+ boost::this_process::get_id());
fflush(stdout);
WorkerId workerZero(0);
@@ -779,9 +767,8 @@ class TestWorker {
}
}
}
- ACE_Time_Value sleepTime;
- sleepTime.msec(100);
- ACE_OS::sleep(sleepTime);
+
+ std::this_thread::sleep_for(std::chrono::milliseconds{100});
}
}
@@ -796,11 +783,9 @@ WorkerId *TestWorker::procWorkerId = nullptr;
void sleep(int millis) {
if (millis == 0) {
- ACE_OS::thr_yield();
+ std::this_thread::yield();
} else {
- ACE_Time_Value sleepTime;
- sleepTime.msec(millis);
- ACE_OS::sleep(sleepTime);
+ std::this_thread::sleep_for(std::chrono::milliseconds{millis});
}
}
@@ -809,7 +794,7 @@ void logCoordinator(std::string s, int lineno, const char * /*filename*/) {
dunit::getTimeStr(buf, sizeof(buf));
fprintf(stdout, "[TEST coordinator:pid(%d)] %s at line: %d\n",
- ACE_OS::getpid(), s.c_str(), lineno);
+ boost::this_process::get_id(), s.c_str(), lineno);
fflush(stdout);
}
@@ -819,8 +804,8 @@ void log(std::string s, int lineno, const char * /*filename*/, int /*id*/) {
char buf[128] = {0};
dunit::getTimeStr(buf, sizeof(buf));
- fprintf(stdout, "[TEST 0:pid(%d)] %s at line: %d\n", ACE_OS::getpid(),
- s.c_str(), lineno);
+ fprintf(stdout, "[TEST 0:pid(%d)] %s at line: %d\n",
+ boost::this_process::get_id(), s.c_str(), lineno);
fflush(stdout);
}
@@ -833,13 +818,13 @@ void log(std::string s, int lineno, const char * /*filename*/) {
(dunit::TestWorker::procWorkerId
? dunit::TestWorker::procWorkerId->getIdName()
: "coordinator"),
- ACE_OS::getpid(), s.c_str(), lineno);
+ boost::this_process::get_id(), s.c_str(), lineno);
fflush(stdout);
}
void cleanup() { gClientCleanup.callClientCleanup(); }
-int dmain(int argc, ACE_TCHAR *argv[]) {
+int dmain(int argc, char *argv[]) {
#ifdef USE_SMARTHEAP
MemRegisterTask();
#endif
@@ -847,9 +832,7 @@ int dmain(int argc, ACE_TCHAR *argv[]) {
TimeBomb tb(&cleanup);
// tb->arm(); // leak this on purpose.
try {
- g_programName = new ACE_TCHAR[2048];
- ACE_OS::strncpy(g_programName, argv[0], 2048);
-
+ g_programName = argv[0];
const ACE_TCHAR options[] = ACE_TEXT("s:m:");
ACE_Get_Opt cmd_opts(argc, argv, options);
@@ -860,12 +843,12 @@ int dmain(int argc, ACE_TCHAR *argv[]) {
while ((option = cmd_opts()) != EOF) {
switch (option) {
case 's':
- workerId = ACE_OS::atoi(cmd_opts.opt_arg());
+ workerId = std::stoul(cmd_opts.opt_arg());
fprintf(stdout, "Using process id: %d\n", workerId);
fflush(stdout);
break;
case 'm':
- g_coordinatorPid = ACE_OS::atoi(cmd_opts.opt_arg());
+ g_coordinatorPid = std::stoul(cmd_opts.opt_arg());
fprintf(stdout, "Using coordinator id: %d\n", g_coordinatorPid);
fflush(stdout);
break;
@@ -898,7 +881,7 @@ int dmain(int argc, ACE_TCHAR *argv[]) {
// currently this is used for giving a unique per run id to shared
// resources.
if (g_coordinatorPid == 0) {
- g_coordinatorPid = ACE_OS::getpid();
+ g_coordinatorPid = boost::this_process::get_id();
}
if (workerId > 0) {
@@ -926,11 +909,14 @@ int dmain(int argc, ACE_TCHAR *argv[]) {
} catch (apache::geode::client::testframework::FwkException &fe) {
printf("Exception: %s\n", fe.what());
fflush(stdout);
+ } catch (std::exception &ex) {
+ printf("Exception: system exception reached main: %s.\n", ex.what());
+ fflush(stdout);
} catch (...) {
printf("Exception: unhandled/unidentified exception reached main.\n");
fflush(stdout);
- // return 1;
}
+
gClientCleanup.callClientCleanup();
return 1;
}
@@ -945,8 +931,10 @@ namespace perf {
TimeStamp::TimeStamp(int64_t msec) : m_msec(msec) {}
TimeStamp::TimeStamp() {
- ACE_Time_Value tmp = ACE_OS::gettimeofday();
- m_msec = tmp.msec();
+ m_msec = std::chrono::time_point_cast<std::chrono::milliseconds>(
+ std::chrono::system_clock::now())
+ .time_since_epoch()
+ .count();
}
TimeStamp::TimeStamp(const TimeStamp &other) : m_msec(other.m_msec) {}
@@ -1078,9 +1066,11 @@ void PerfSuite::save() {
/** load data saved in $ENV{'baselines'} named "<suite>_baseline.<host>" */
void PerfSuite::compare() {
- char hname[100] = {0};
- ACE_OS::hostname(hname, 100);
- std::string fname = m_suiteName + "_baseline." + hname;
+ /*
+ char hname[100] = {0};
+ ACE_OS::hostname(hname, 100);
+ std::string fname = m_suiteName + "_baseline." + hname;
+ */
}
ThreadLauncher::ThreadLauncher(int thrCount, Thread &thr)
diff --git a/cppcache/integration-test/fw_dunit.hpp b/cppcache/integration-test/fw_dunit.hpp
index 31f163b..aef1724 100644
--- a/cppcache/integration-test/fw_dunit.hpp
+++ b/cppcache/integration-test/fw_dunit.hpp
@@ -117,7 +117,6 @@ END_TASK(validate)
#include <string>
-#include <ace/ACE.h>
#include <signal.h>
#include "TimeBomb.hpp"
@@ -318,13 +317,13 @@ class NamingContext {
* is not found, the buf will contain the empty string "". Make sure the
* buffer is big enough to hold whatever has have bound.
*/
- virtual void getValue(const char* key, char* buf, size_t sizeOfBuf) = 0;
+ virtual std::string getValue(const std::string& key) = 0;
/**
* return the value by key, as an int using the string to int conversion
* rules of atoi.
*/
- virtual int getIntValue(const char* key) = 0;
+ virtual int getIntValue(const std::string& key) = 0;
/** dump the entire context in LOG messages. */
virtual void dump() = 0;
@@ -346,19 +345,19 @@ NamingContext* globals();
*/
class TestException {
public:
- TestException(const char* msg, int lineno, const char* filename)
- : m_message(const_cast<char*>(msg)),
+ TestException(const std::string& msg, int lineno, const std::string& filename)
+ : m_message(msg),
m_lineno(lineno),
- m_filename(const_cast<char*>(filename)) {}
+ m_filename(filename) {}
void print() {
fprintf(stdout, "#### TestException: %s in %s at line %d\n",
- m_message.c_str(), m_filename, m_lineno);
+ m_message.c_str(), m_filename.c_str(), m_lineno);
fflush(stdout);
}
std::string m_message;
int m_lineno;
- char* m_filename;
+ std::string m_filename;
};
int dmain(int argc, char* argv[]);
@@ -367,7 +366,7 @@ int dmain(int argc, char* argv[]);
#ifndef __DUNIT_NO_MAIN__
-int ACE_TMAIN(int argc, ACE_TCHAR* argv[]) { return dunit::dmain(argc, argv); }
+int main(int argc, char* argv[]) { return dunit::dmain(argc, argv); }
#endif // __DUNIT_NO_MAIN__
diff --git a/cppcache/integration-test/fw_helper.hpp b/cppcache/integration-test/fw_helper.hpp
index a2b1d43..5f89149 100644
--- a/cppcache/integration-test/fw_helper.hpp
+++ b/cppcache/integration-test/fw_helper.hpp
@@ -125,18 +125,18 @@ void setupCRTOutput(); // disable windows popups.
class TestException {
public:
- TestException(const char* msg, int lineno, const char* filename)
- : m_message(const_cast<char*>(msg)),
+ TestException(const std::string& msg, int lineno, const std::string& filename)
+ : m_message(msg),
m_lineno(lineno),
- m_filename(const_cast<char*>(filename)) {}
+ m_filename(filename) {}
void print() {
fprintf(stdout, "--->%sTestException: %s in %s at line %d<---\n", apache::geode::client::Log::formatLogLine(apache::geode::client::LogLevel::Error).c_str(),
- m_message.c_str(), m_filename, m_lineno);
+ m_message.c_str(), m_filename.c_str(), m_lineno);
}
std::string m_message;
int m_lineno;
- char* m_filename;
+ std::string m_filename;
};
// std::list holding names of all tests that failed.
diff --git a/cppcache/integration-test/fw_spawn.hpp b/cppcache/integration-test/fw_spawn.hpp
index 16ba989..c40bc25 100644
--- a/cppcache/integration-test/fw_spawn.hpp
+++ b/cppcache/integration-test/fw_spawn.hpp
@@ -22,13 +22,6 @@
// 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>
#if defined(_WIN32)
#if (FD_SETSIZE != 1024)
@@ -38,15 +31,15 @@
#include <ace/Process.h>
#include <ace/Log_Msg.h>
+#include <boost/iostreams/device/file_descriptor.hpp>
namespace dunit {
// Listing 1 code/ch10
class Manager : virtual public ACE_Process {
public:
- explicit Manager(const ACE_TCHAR *program_name) : ACE_Process() {
- ACE_OS::strncpy(programName_, program_name, sizeof(programName_));
- }
+ explicit Manager(const std::string &program_name)
+ : ACE_Process{}, programName_{program_name} {}
virtual int doWork(void) {
// Spawn the new process; prepare() hook is called first.
@@ -58,45 +51,9 @@
return pid;
}
- virtual int doWait(void) {
- // Wait forever for my child to exit.
- if (this->wait() == -1) {
- ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%p\n"), ACE_TEXT("wait")), -1);
- }
-
- // Dump whatever happened.
- this->dumpRun();
- return 0;
- }
- // Listing 1
-
protected:
- // Listing 3 code/ch10
- virtual int dumpRun(void) {
- if (ACE_OS::lseek(this->outputfd_, 0, SEEK_SET) == -1) {
- ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%p\n"), ACE_TEXT("lseek")), -1);
- }
-
- char buf[1024];
- int length = 0;
-
- // Read the contents of the error stream written
- // by the child and print it out.
- while ((length = static_cast<int>(
- ACE_OS::read(this->outputfd_, buf, sizeof(buf) - 1))) > 0) {
- buf[length] = 0;
- ACE_DEBUG((LM_DEBUG, ACE_TEXT("%C\n"), buf));
- }
-
- ACE_OS::close(this->outputfd_);
- return 0;
- }
- // Listing 3
-
- // Listing 2 code/ch10
- // prepare() is inherited from ACE_Process.
int prepare(ACE_Process_Options &options) override {
- options.command_line("%s", this->programName_);
+ options.command_line("%s", this->programName_.c_str());
if (this->setStdHandles(options) == -1 ||
this->setEnvVariable(options) == -1) {
return -1;
@@ -105,9 +62,22 @@
}
virtual int setStdHandles(ACE_Process_Options &options) {
- ACE_OS::unlink(this->programName_);
- this->outputfd_ = ACE_OS::open(this->programName_, O_RDWR | O_CREAT);
- return options.set_handles(ACE_STDIN, ACE_STDOUT, this->outputfd_);
+ boost::filesystem::path p{this->programName_};
+
+ std::string tmp = p.filename().string();
+ boost::replace_all(tmp, " ", "_");
+ boost::replace_all(tmp, "-", "_");
+
+ auto stderr_path = p.parent_path();
+ stderr_path += boost::filesystem::path::preferred_separator;
+ stderr_path += tmp;
+
+ std::string stderr_name = stderr_path.string();
+ std::remove(stderr_name.c_str());
+
+ outputfd_.open(stderr_name,
+ std::ios::in | std::ios::out | std::ios::trunc);
+ return options.set_handles(ACE_STDIN, ACE_STDOUT, outputfd_.handle());
}
virtual int setEnvVariable(ACE_Process_Options &options) {
@@ -120,8 +90,8 @@
~Manager() noexcept override = default;
private:
- ACE_HANDLE outputfd_;
- ACE_TCHAR programName_[2048];
+ std::string programName_;
+ boost::iostreams::file_descriptor outputfd_;
};
} // namespace dunit.
diff --git a/cppcache/integration-test/locator_globals.hpp b/cppcache/integration-test/locator_globals.hpp
index 9d16d29..a724ab8 100644
--- a/cppcache/integration-test/locator_globals.hpp
+++ b/cppcache/integration-test/locator_globals.hpp
@@ -27,7 +27,7 @@ using apache::geode::client::CacheHelper;
static int numberOfLocators = 1;
bool isLocalServer = false;
bool isLocator = false;
-const char* locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
} // namespace
diff --git a/cppcache/integration-test/testCacheless.cpp b/cppcache/integration-test/testCacheless.cpp
index aa52166..59dfd4f 100644
--- a/cppcache/integration-test/testCacheless.cpp
+++ b/cppcache/integration-test/testCacheless.cpp
@@ -107,7 +107,7 @@ class RegionWrapper {
static int numberOfLocators = 1;
bool isLocalServer = true;
bool isLocator = true;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
std::shared_ptr<TallyListener> listener;
@@ -123,7 +123,7 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(s1p1, CreateRegionNoCache)
{
- initClientWithPool(true, "__TEST_POOL1__", locHostPort, nullptr, nullptr, 0,
+ initClientWithPool(true, "__TEST_POOL1__", locHostPort, {}, nullptr, 0,
true);
LOG("Creating region in s1p1-pusher, no-ack, no-cache, no-listener");
getHelper()->createPooledRegion(REGIONNAME, false, locHostPort,
@@ -134,7 +134,7 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(s1p2, CreateNoCacheWListener)
{
LOG("Creating region in s1p2-listener, no-ack, no-cache, with-listener");
- initClientWithPool(true, "__TEST_POOL1__", locHostPort, nullptr, nullptr, 0,
+ initClientWithPool(true, "__TEST_POOL1__", locHostPort, {}, nullptr, 0,
true);
listener = std::make_shared<TallyListener>();
getHelper()->createPooledRegion(
@@ -148,7 +148,7 @@ DUNIT_TASK_DEFINITION(s2p1, CreateRegionCacheMirror)
{
LOG("Creating region in s2p1-storage, no-ack, cache, no-interestlist, "
"no-listener");
- initClientWithPool(true, "__TEST_POOL1__", locHostPort, nullptr, nullptr, 0,
+ initClientWithPool(true, "__TEST_POOL1__", locHostPort, {}, nullptr, 0,
true);
getHelper()->createPooledRegion(REGIONNAME, false, locHostPort,
"__TEST_POOL1__", true, true);
@@ -159,7 +159,7 @@ DUNIT_TASK_DEFINITION(s2p2, CreateRegionCache)
{
LOG("Creating region in s2p2-subset, no-ack, no-mirror, cache, "
"no-interestlist, with-listener");
- initClientWithPool(true, "__TEST_POOL1__", locHostPort, nullptr, nullptr, 0,
+ initClientWithPool(true, "__TEST_POOL1__", locHostPort, {}, nullptr, 0,
true);
listener = std::make_shared<TallyListener>();
getHelper()->createPooledRegion(
diff --git a/cppcache/integration-test/testCreateAndDestroyPool.cpp b/cppcache/integration-test/testCreateAndDestroyPool.cpp
index 682ed96..8df84fc 100644
--- a/cppcache/integration-test/testCreateAndDestroyPool.cpp
+++ b/cppcache/integration-test/testCreateAndDestroyPool.cpp
@@ -36,7 +36,7 @@ const char *poolNames[] = {"Pool1"};
void stepOne() {
initClient(true);
- createPoolAndDestroy(poolNames[0], locatorsG, nullptr, 0, false,
+ createPoolAndDestroy(poolNames[0], locatorsG, {}, 0, false,
std::chrono::seconds::zero(), 1);
LOG("StepOne complete.");
}
diff --git a/cppcache/integration-test/testExpiration.cpp b/cppcache/integration-test/testExpiration.cpp
index 7292c4c..a3678be 100644
--- a/cppcache/integration-test/testExpiration.cpp
+++ b/cppcache/integration-test/testExpiration.cpp
@@ -126,7 +126,7 @@ BEGIN_TEST(TEST_EXPIRATION)
doNPuts(R1, 100);
- ACE_OS::sleep(10);
+ std::this_thread::sleep_for(std::chrono::seconds(10));
n = getNumOfEntries(R1);
ASSERT(n == 100, "Expected 100 entries");
@@ -145,7 +145,7 @@ BEGIN_TEST(TEST_EXPIRATION)
LOG("Region R2 created");
doNPuts(R2, 1);
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
n = getNumOfEntries(R2);
ASSERT(n == 1, "Expected 1 entry");
@@ -162,7 +162,7 @@ BEGIN_TEST(TEST_EXPIRATION)
cacheImpl->createRegion("R3", attrs_3, R3);
ASSERT(R3 != nullptr, "Expected R3 to be NON-nullptr");
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
ASSERT(R3->isDestroyed() == false, "Expected R3 to be alive");
@@ -179,7 +179,7 @@ BEGIN_TEST(TEST_EXPIRATION)
doNPuts(R4, 1);
// This will be same as updating the object
- ACE_OS::sleep(10);
+ std::this_thread::sleep_for(std::chrono::seconds(10));
n = getNumOfEntries(R4);
ASSERT(n == 0, "Expected 0 entry");
@@ -198,18 +198,18 @@ BEGIN_TEST(TEST_EXPIRATION)
auto key_0 = do1Put(R5);
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
R5->get(key_0);
- ACE_OS::sleep(3);
+ std::this_thread::sleep_for(std::chrono::seconds(3));
n = getNumOfEntries(R5);
printf("n == %zd\n", n);
ASSERT(n == 1, "Expected 1 entry");
- // ACE_OS::sleep(3);
- ACE_OS::sleep(6);
+ // std::this_thread::sleep_for(std::chrono::seconds(3));
+ std::this_thread::sleep_for(std::chrono::seconds(6));
n = getNumOfEntries(R5);
ASSERT(n == 0, "Expected 0 entry");
@@ -227,11 +227,11 @@ BEGIN_TEST(TEST_EXPIRATION)
doNPuts(R6, 1);
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
doNPuts(R6, 1);
- ACE_OS::sleep(7);
+ std::this_thread::sleep_for(std::chrono::seconds(7));
ASSERT(R6->isDestroyed() == true, "Expected R6 to be dead");
@@ -247,11 +247,11 @@ BEGIN_TEST(TEST_EXPIRATION)
doNPuts(R7, 1);
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
doNPuts(R7, 1);
- ACE_OS::sleep(10);
+ std::this_thread::sleep_for(std::chrono::seconds(10));
ASSERT(R7->isDestroyed() == true, "Expected R7 to be dead");
@@ -267,11 +267,11 @@ BEGIN_TEST(TEST_EXPIRATION)
auto key = do1Put(R8);
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
R8->get(key);
- ACE_OS::sleep(6);
+ std::this_thread::sleep_for(std::chrono::seconds(6));
n = getNumOfEntries(R8);
ASSERT(n == 0, "Expected 1 entries");
@@ -288,11 +288,11 @@ BEGIN_TEST(TEST_EXPIRATION)
auto key_1 = do1Put(R9);
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
R9->get(key_1);
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
n = getNumOfEntries(R9);
ASSERT(n == 1, "Expected 1 entries");
@@ -311,12 +311,12 @@ BEGIN_TEST(TEST_EXPIRATION)
doNPuts(R10, 1);
- ACE_OS::sleep(10);
+ std::this_thread::sleep_for(std::chrono::seconds(10));
n = getNumOfEntries(R10);
ASSERT(n == 0, "Expected 0 entries");
- ACE_OS::sleep(11);
+ std::this_thread::sleep_for(std::chrono::seconds(11));
ASSERT(R10->isDestroyed() == true, "Expected R10 to be dead");
@@ -333,19 +333,19 @@ BEGIN_TEST(TEST_EXPIRATION)
auto k11 = do1Put(R11);
- ACE_OS::sleep(3);
+ std::this_thread::sleep_for(std::chrono::seconds(3));
n = getNumOfEntries(R11);
ASSERT(n == 1, "Expected 1 entries");
R11->get(k11);
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
ASSERT(R11->isDestroyed() == false,
"Expected R11 to be alive as the get has changed the access time");
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
ASSERT(R11->isDestroyed() == true, "Expected R11 to be dead");
@@ -361,7 +361,7 @@ BEGIN_TEST(TEST_EXPIRATION)
auto key_3 = do1Put(R12);
- ACE_OS::sleep(6);
+ std::this_thread::sleep_for(std::chrono::seconds(6));
n = getNumOfEntries(R12);
ASSERT(n == 0, "Expected 0 entries");
@@ -381,7 +381,7 @@ BEGIN_TEST(TEST_EXPIRATION)
doNPuts(R14, 1);
- ACE_OS::sleep(12);
+ std::this_thread::sleep_for(std::chrono::seconds(12));
ASSERT(R14->isDestroyed() == true, "Expected R14 to be dead");
@@ -397,11 +397,11 @@ BEGIN_TEST(TEST_EXPIRATION)
auto key_4 = do1Put(R15);
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
R15->destroy(key_4);
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
ASSERT(R15->isDestroyed() == false, "Expected R15 to be alive");
@@ -418,12 +418,12 @@ BEGIN_TEST(TEST_EXPIRATION)
doNPuts(R18, 1);
- ACE_OS::sleep(4);
+ std::this_thread::sleep_for(std::chrono::seconds(4));
n = getNumOfEntries(R18);
ASSERT(n == 1, "entry idle should be useless as ttl is > 0");
- ACE_OS::sleep(4);
+ std::this_thread::sleep_for(std::chrono::seconds(4));
n = getNumOfEntries(R18);
ASSERT(n == 0, "ttl is over so it should be 0");
@@ -437,16 +437,16 @@ BEGIN_TEST(TEST_EXPIRATION)
cacheImpl->createRegion("R19x", attrs_19, R19);
ASSERT(R19 != nullptr, "Expected R19 to be NON-nullptr");
- ACE_OS::sleep(4);
+ std::this_thread::sleep_for(std::chrono::seconds(4));
doNPuts(R19, 1);
- ACE_OS::sleep(4);
+ std::this_thread::sleep_for(std::chrono::seconds(4));
ASSERT(R19->isDestroyed() == false,
"Expected R19 to be alive as an entry was put");
- ACE_OS::sleep(4);
+ std::this_thread::sleep_for(std::chrono::seconds(4));
ASSERT(R19->isDestroyed() == true, "Expected R19 to be dead");
cache->close();
diff --git a/cppcache/integration-test/testFwPerf.cpp b/cppcache/integration-test/testFwPerf.cpp
index e5304e1..fa75d3d 100644
--- a/cppcache/integration-test/testFwPerf.cpp
+++ b/cppcache/integration-test/testFwPerf.cpp
@@ -30,7 +30,7 @@ class LocalPutTask : public perf::Thread {
}
void perftask() override {
- ACE_OS::sleep(1);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
fprintf(stdout, "perffunc done.\n");
fflush(stdout);
}
diff --git a/cppcache/integration-test/testOverflowPutGetSqLite.cpp b/cppcache/integration-test/testOverflowPutGetSqLite.cpp
index 6e35359..aaffb37 100644
--- a/cppcache/integration-test/testOverflowPutGetSqLite.cpp
+++ b/cppcache/integration-test/testOverflowPutGetSqLite.cpp
@@ -18,7 +18,8 @@
#include <string>
#include <iostream>
-#include <ace/OS.h>
+#include <boost/asio.hpp>
+#include <boost/process.hpp>
#include <geode/RegionShortcut.hpp>
#include <geode/RegionFactory.hpp>
@@ -351,17 +352,16 @@ void setSqLiteProperties(std::shared_ptr<Properties> &sqliteProperties,
// creation of subregion.
void createSubRegion(std::shared_ptr<Region> ®ionPtr,
- std::shared_ptr<Region> &subRegion, const char *regionName,
+ std::shared_ptr<Region> &subRegion,
+ const std::string ®ionName,
std::string pDir = sqlite_dir) {
RegionAttributes regionAttributesPtr;
setAttributes(regionAttributesPtr, pDir);
subRegion = regionPtr->createSubregion(regionName, regionAttributesPtr);
ASSERT(subRegion != nullptr, "Expected region to be NON-nullptr");
- char fileName[512];
- sprintf(fileName, "%s/%s/%s.db", pDir.c_str(), regionName, regionName);
- ACE_stat fileStat;
- ASSERT(ACE_OS::stat(fileName, &fileStat) == 0,
- "persistence file not present");
+
+ std::string fileName = pDir + '/' + regionName + '/' + regionName + ".db";
+ ASSERT(boost::filesystem::exists(fileName), "persistence file not present");
doNput(subRegion, 50);
doNget(subRegion, 50);
}
@@ -409,15 +409,12 @@ BEGIN_TEST(OverFlowTest)
subRegion->destroyRegion();
ASSERT(subRegion->isDestroyed(), "Expected region is not destroyed ");
subRegion = nullptr;
- ACE_TCHAR hname[MAXHOSTNAMELEN];
- ACE_OS::hostname(hname, sizeof(hname) - 1);
- char sqliteDirSubRgn[512];
- sprintf(sqliteDirSubRgn, "%s/%s_%u/_%s_SubRegion/file_0.db",
- sqlite_dir.c_str(), hname, ACE_OS::getpid(),
- regionPtr->getName().c_str());
-
- ACE_stat fileStat;
- ASSERT(ACE_OS::stat(sqliteDirSubRgn, &fileStat) == -1,
+
+ std::string sqliteDirSubRgn =
+ sqlite_dir + "/" + boost::asio::ip::host_name() + '_' +
+ std::to_string(boost::this_process::get_id()) + "/_" +
+ regionPtr->getName() + "_SubRegion/file_0.db";
+ ASSERT(!boost::filesystem::exists(sqliteDirSubRgn),
"persistence file still present");
}
// cache close
@@ -428,11 +425,10 @@ END_TEST(OverFlowTest)
BEGIN_TEST(OverFlowTest_absPath)
{
std::shared_ptr<RegionAttributes> attrsPtr;
- char currWDPath[512];
- char *wdPath = ACE_OS::getcwd(currWDPath, 512);
- ASSERT(wdPath != nullptr,
- "Expected current Working Directory to be NON-nullptr");
- std::string absPersistenceDir = std::string(wdPath) + "/absSqLite";
+ auto wdPath = boost::filesystem::current_path().string();
+ ASSERT(!wdPath.empty(),
+ "Expected current Working Directory to be not empty");
+ std::string absPersistenceDir = wdPath + "/absSqLite";
/** Creating a cache to manage regions. */
std::shared_ptr<Properties> sqliteProperties;
@@ -473,11 +469,9 @@ BEGIN_TEST(OverFlowTest_absPath)
subRegion->destroyRegion();
ASSERT(subRegion->isDestroyed(), "Expected region is not destroyed ");
subRegion = nullptr;
- char fileName[512];
- sprintf(fileName, "%s/%s/%s.db", absPersistenceDir.c_str(), "SubRegion",
- "SubRegion");
- ACE_stat fileStat;
- ASSERT(ACE_OS::stat(fileName, &fileStat) == -1,
+
+ std::string fileName = absPersistenceDir + "/SubRegion/SubRegion.db";
+ ASSERT(!boost::filesystem::exists(fileName),
"persistence file still present");
}
// cache close
@@ -569,18 +563,16 @@ BEGIN_TEST(OverFlowTest_HeapLRU)
setAttributes(regionAttributes);
subRegion = regionPtr->createSubregion("SubRegion", regionAttributes);
ASSERT(subRegion != nullptr, "Expected region to be NON-nullptr");
- char fileName[512];
- sprintf(fileName, "%s/%s/%s.db", sqlite_dir.c_str(), "SubRegion",
- "SubRegion");
- ACE_stat fileStat;
- ASSERT(ACE_OS::stat(fileName, &fileStat) == 0,
+
+ std::string fileName = sqlite_dir + "/SubRegion/SubRegion.db";
+ ASSERT(boost::filesystem::exists(fileName),
"persistence file not present");
doNput(subRegion, 50);
doNget(subRegion, 50);
subRegion->destroyRegion();
ASSERT(subRegion->isDestroyed(), "Expected region is not destroyed ");
subRegion = nullptr;
- ASSERT(ACE_OS::stat(fileName, &fileStat) == -1,
+ ASSERT(!boost::filesystem::exists(fileName),
"persistence file still present");
}
// cache close
diff --git a/cppcache/integration-test/testPdxMetadataCheckTest.cpp b/cppcache/integration-test/testPdxMetadataCheckTest.cpp
index d11d1f2..d800216 100644
--- a/cppcache/integration-test/testPdxMetadataCheckTest.cpp
+++ b/cppcache/integration-test/testPdxMetadataCheckTest.cpp
@@ -69,7 +69,7 @@ bool isLocator = false;
bool isLocalServer = false;
const char *poolNames[] = {"Pool1", "Pool2", "Pool3"};
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
bool isPoolConfig = false; // To track if pool case is running
// const char * qRegionNames[] = { "Portfolios", "Positions", "Portfolios2",
@@ -89,7 +89,7 @@ void initClient1(bool isPdxIgnoreUnreadFields = false) {
// Create just one pool and attach all regions to that.
initClient(true, isPdxIgnoreUnreadFields);
isPoolConfig = true;
- createPool(poolNames[0], locHostPort, nullptr, 0, false);
+ createPool(poolNames[0], locHostPort, {}, 0, false);
createRegionAndAttachPool("DistRegionAck", USE_ACK, poolNames[0],
true /*Caching enabled*/);
LOG("StepOne complete.");
@@ -99,7 +99,7 @@ void initClient2(bool isPdxIgnoreUnreadFields = false) {
// Create just one pool and attach all regions to that.
initClient(true, isPdxIgnoreUnreadFields);
isPoolConfig = true;
- createPool(poolNames[0], locHostPort, nullptr, 0,
+ createPool(poolNames[0], locHostPort, {}, 0,
true /*ClientNotification enabled*/);
createRegionAndAttachPool("DistRegionAck", USE_ACK, poolNames[0],
true /*Caching enabled*/);
diff --git a/cppcache/integration-test/testRegionAccessThreadSafe.cpp b/cppcache/integration-test/testRegionAccessThreadSafe.cpp
index e9e973c..3751fa2 100644
--- a/cppcache/integration-test/testRegionAccessThreadSafe.cpp
+++ b/cppcache/integration-test/testRegionAccessThreadSafe.cpp
@@ -93,7 +93,7 @@ class GetRegionThread : public ACE_Task_Base {
static int numberOfLocators = 1;
bool isLocalServer = true;
bool isLocator = true;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
GetRegionThread *getThread = nullptr;
std::shared_ptr<Region> regionPtr;
diff --git a/cppcache/integration-test/testSpinLock.cpp b/cppcache/integration-test/testSpinLock.cpp
index 1e99257..e5fb1ae 100644
--- a/cppcache/integration-test/testSpinLock.cpp
+++ b/cppcache/integration-test/testSpinLock.cpp
@@ -40,7 +40,7 @@ perf::Semaphore *triggerB;
perf::Semaphore *triggerM;
spinlock_mutex lock;
-ACE_Time_Value *btime;
+std::chrono::steady_clock::time_point btime;
class ThreadA : public ACE_Task_Base {
public:
@@ -66,7 +66,7 @@ class ThreadB : public ACE_Task_Base {
triggerB->acquire();
{
std::lock_guard<spinlock_mutex> lk(lock);
- btime = new ACE_Time_Value(ACE_OS::gettimeofday());
+ btime = std::chrono::steady_clock::now();
LOG("ThreadB: Acquired lock.");
triggerM->release();
}
@@ -89,7 +89,7 @@ DUNIT_TASK(s1p1, TwoThreads)
// A runs, locks the spinlock, and triggers me. B is idle.
triggerM->acquire();
// A is now idle, but holds lock. Tell B to acquire the lock
- ACE_Time_Value stime = ACE_OS::gettimeofday();
+ auto stime = std::chrono::steady_clock::now();
triggerB->release();
SLEEP(5000);
// B will be stuck until we tell A to release it.
@@ -99,11 +99,13 @@ DUNIT_TASK(s1p1, TwoThreads)
// Now diff btime (when B acquired the lock) and stime to see that it
// took longer than the 5000 seconds before A released it.
- ACE_Time_Value delta = *btime - stime;
- char msg[1024];
- sprintf(msg, "acquire delay was %lu\n", delta.msec());
+ auto delta =
+ std::chrono::duration_cast<std::chrono::milliseconds>(btime - stime)
+ .count();
+ std::string msg = "acquire delay was " + std::to_string(delta);
+
LOG(msg);
- ASSERT(delta.msec() >= 4900, "Expected 5 second or more spinlock delay");
+ ASSERT(delta >= 4900, "Expected 5 second or more spinlock delay");
// Note the test is against 4900 instead of 5000 as there are some
// measurement
// issues. Often delta comes back as 4999 on linux.
diff --git a/cppcache/integration-test/testSystemProperties.cpp b/cppcache/integration-test/testSystemProperties.cpp
index b8ac576..b60da7f 100644
--- a/cppcache/integration-test/testSystemProperties.cpp
+++ b/cppcache/integration-test/testSystemProperties.cpp
@@ -67,7 +67,7 @@ BEGIN_TEST(NEW_CONFIG)
{
// When the tests are run from the build script the environment variable
// TESTSRC is set.
- std::string testSource(ACE_OS::getenv("TESTSRC"));
+ std::string testSource(std::getenv("TESTSRC"));
std::string filePath = testSource + "/resources/system.properties";
// Make sure product can at least log to stdout.
diff --git a/cppcache/integration-test/testThinClientAfterRegionLive.cpp b/cppcache/integration-test/testThinClientAfterRegionLive.cpp
index 7944d11..9d6a2af 100644
--- a/cppcache/integration-test/testThinClientAfterRegionLive.cpp
+++ b/cppcache/integration-test/testThinClientAfterRegionLive.cpp
@@ -32,7 +32,7 @@ static bool isLocalServer = true;
static int numberOfLocators = 1;
static bool isRegionLive[4] = {false, false, false, false};
static bool isRegionDead[4] = {false, false, false, false};
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
class DisconnectCacheListioner : public CacheListener {
diff --git a/cppcache/integration-test/testThinClientBigValue.cpp b/cppcache/integration-test/testThinClientBigValue.cpp
index 5c2ad19..89e3ed2 100644
--- a/cppcache/integration-test/testThinClientBigValue.cpp
+++ b/cppcache/integration-test/testThinClientBigValue.cpp
@@ -96,7 +96,7 @@ void verify(std::shared_ptr<CacheableBytes> &valuePtr, int size) {
static int numberOfLocators = 1;
bool isLocalServer = true;
bool isLocator = true;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
DUNIT_TASK(SERVER1, StartServer)
diff --git a/cppcache/integration-test/testThinClientCacheableStringArray.cpp b/cppcache/integration-test/testThinClientCacheableStringArray.cpp
index 57807d8..255f13e 100644
--- a/cppcache/integration-test/testThinClientCacheableStringArray.cpp
+++ b/cppcache/integration-test/testThinClientCacheableStringArray.cpp
@@ -46,7 +46,7 @@ using apache::geode::client::IllegalStateException;
static int numberOfLocators = 1;
bool isLocalServer = true;
bool isLocator = true;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
const char *_regionNames[] = {"Portfolios", "Positions"};
@@ -123,13 +123,12 @@ DUNIT_TASK(CLIENT1, StepThree)
sprintf(buf, "results last count=%zd", count);
LOG(buf);
} catch (IllegalStateException &ise) {
- char isemsg[500] = {0};
- ACE_OS::snprintf(isemsg, 499, "IllegalStateException: %s", ise.what());
- LOG(isemsg);
- FAIL(isemsg);
+ std::string excpmsg = "IllegalStateException: " + std::string{ise.what()};
+
+ LOG(excpmsg);
+ FAIL(excpmsg);
} catch (Exception &excp) {
- char excpmsg[500] = {0};
- ACE_OS::snprintf(excpmsg, 499, "Exception: %s", excp.what());
+ std::string excpmsg = "Exception: " + std::string{excp.what()};
LOG(excpmsg);
FAIL(excpmsg);
} catch (...) {
diff --git a/cppcache/integration-test/testThinClientCacheablesLimits.cpp b/cppcache/integration-test/testThinClientCacheablesLimits.cpp
index e2bbfaa..f8f2147 100644
--- a/cppcache/integration-test/testThinClientCacheablesLimits.cpp
+++ b/cppcache/integration-test/testThinClientCacheablesLimits.cpp
@@ -39,7 +39,7 @@ using apache::geode::client::OutOfMemoryException;
static bool isLocator = false;
static bool isLocalServer = true;
static int numberOfLocators = 1;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
#include "LocatorHelper.hpp"
@@ -102,8 +102,7 @@ const char *_regionNames[] = {"DistRegionAck", "DistRegionNoAck"};
DUNIT_TASK_DEFINITION(CLIENT1, StepOne)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
- true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, {}, nullptr, 0, true);
getHelper()->createPooledRegion(_regionNames[1], NO_ACK, locatorsG,
"__TEST_POOL1__", false, false);
LOG("StepOne complete.");
diff --git a/cppcache/integration-test/testThinClientClearRegion.cpp b/cppcache/integration-test/testThinClientClearRegion.cpp
index b1dc869..c353b5d 100644
--- a/cppcache/integration-test/testThinClientClearRegion.cpp
+++ b/cppcache/integration-test/testThinClientClearRegion.cpp
@@ -53,7 +53,7 @@ class MyCacheListener : public CacheListener {
static int numberOfLocators = 1;
bool isLocalServer = true;
bool isLocator = true;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
DUNIT_TASK(SERVER1, StartServer)
diff --git a/cppcache/integration-test/testThinClientCq.cpp b/cppcache/integration-test/testThinClientCq.cpp
index fbfe409..3cf0368 100644
--- a/cppcache/integration-test/testThinClientCq.cpp
+++ b/cppcache/integration-test/testThinClientCq.cpp
@@ -55,7 +55,7 @@ using apache::geode::client::QueryService;
static bool m_isPdx = false;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *cqNames[MAX_LISTNER] = {"MyCq_0", "MyCq_1", "MyCq_2", "MyCq_3",
"MyCq_4", "MyCq_5", "MyCq_6", "MyCq_7"};
@@ -294,7 +294,7 @@ END_TASK_DEFINITION
void createServer_group(bool locator, const char *XML) {
LOG("Starting SERVER1...");
if (isLocalServer) {
- CacheHelper::initServer(1, XML, locator ? locHostPort : nullptr);
+ CacheHelper::initServer(1, XML, locator ? locHostPort : std::string{});
}
LOG("SERVER1 started");
}
@@ -302,7 +302,7 @@ void createServer_group(bool locator, const char *XML) {
void createServer_group2(bool locator, const char *XML) {
LOG("Starting SERVER2...");
if (isLocalServer) {
- CacheHelper::initServer(2, XML, locator ? locHostPort : nullptr);
+ CacheHelper::initServer(2, XML, locator ? locHostPort : std::string{});
}
LOG("SERVER2 started");
}
@@ -888,13 +888,15 @@ DUNIT_TASK_DEFINITION(CLIENT1, createCQ_Pool)
char KeyStr[256] = {0};
char valStr[256] = {0};
for (int i = 1; i <= 5; i++) {
- ACE_OS::snprintf(KeyStr, 256, "Key-%d ", i);
- ACE_OS::snprintf(valStr, 256, "val-%d ", i);
- auto keyport = CacheableKey::create(KeyStr);
- auto valport = CacheableString::create(valStr);
+ std::string key = "Key-" + std::to_string(i);
+ std::string value = "val-" + std::to_string(i);
+
+ auto keyport = CacheableKey::create(key);
+ auto valport = CacheableString::create(value);
+
regPtr0->put(keyport, valport);
regPtr1->put(keyport, valport);
- SLEEP(10 * 1000); // sleep a while to allow server query to complete
+ SLEEP(10000); // sleep a while to allow server query to complete
}
LOGINFO("putEntries complete");
@@ -1028,16 +1030,16 @@ DUNIT_TASK_DEFINITION(CLIENT1, putEntries)
auto regPtr0 = getHelper()->getRegion(regionName);
auto regPtr1 = getHelper()->getRegion(regionName1);
std::shared_ptr<Cacheable> val = nullptr;
- char KeyStr[256] = {0};
- char valStr[256] = {0};
for (int i = 1; i <= 5; i++) {
- ACE_OS::snprintf(KeyStr, 256, "Key-%d ", i);
- ACE_OS::snprintf(valStr, 256, "val-%d ", i);
- auto keyport = CacheableKey::create(KeyStr);
- auto valport = CacheableString::create(valStr);
+ std::string key = "Key-" + std::to_string(i);
+ std::string value = "val-" + std::to_string(i);
+
+ auto keyport = CacheableKey::create(key);
+ auto valport = CacheableString::create(value);
+
regPtr0->put(keyport, valport);
regPtr1->put(keyport, valport);
- SLEEP(10 * 1000); // sleep a while to allow server query to complete
+ SLEEP(10000); // sleep a while to allow server query to complete
}
LOGINFO("putEntries complete");
}
@@ -1096,15 +1098,15 @@ DUNIT_TASK_DEFINITION(CLIENT1, ProcessCQ)
auto regPtr0 = getHelper()->getRegion(regionName);
std::shared_ptr<Cacheable> val = nullptr;
- char KeyStr[256] = {0};
- char valStr[256] = {0};
for (int i = 1; i <= 5; i++) {
- ACE_OS::snprintf(KeyStr, 256, "Key-%d ", i);
- ACE_OS::snprintf(valStr, 256, "val-%d ", i);
- auto keyport = CacheableKey::create(KeyStr);
- auto valport = CacheableString::create(valStr);
+ std::string key = "Key-" + std::to_string(i);
+ std::string value = "val-" + std::to_string(i);
+
+ auto keyport = CacheableKey::create(key);
+ auto valport = CacheableString::create(value);
+
regPtr0->put(keyport, valport);
- SLEEP(10 * 1000); // sleep a while to allow server query to complete
+ SLEEP(10000); // sleep a while to allow server query to complete
}
LOGINFO("putEntries complete");
@@ -1155,12 +1157,14 @@ DUNIT_TASK_DEFINITION(CLIENT1, ProcessCQ)
myStatusCq2->clear();
for (int i = 1; i <= 5; i++) {
- ACE_OS::snprintf(KeyStr, 256, "Key-%d ", i);
- ACE_OS::snprintf(valStr, 256, "val-%d ", i);
- auto keyport = CacheableKey::create(KeyStr);
- auto valport = CacheableString::create(valStr);
+ std::string key = "Key-" + std::to_string(i);
+ std::string value = "val-" + std::to_string(i);
+
+ auto keyport = CacheableKey::create(key);
+ auto valport = CacheableString::create(value);
+
regPtr0->put(keyport, valport);
- SLEEP(10 * 1000); // sleep a while to allow server query to complete
+ SLEEP(10000); // sleep a while to allow server query to complete
}
LOGINFO("putEntries complete again");
diff --git a/cppcache/integration-test/testThinClientCqDelta.cpp b/cppcache/integration-test/testThinClientCqDelta.cpp
index eb3eaea..7eb6b1a 100644
--- a/cppcache/integration-test/testThinClientCqDelta.cpp
+++ b/cppcache/integration-test/testThinClientCqDelta.cpp
@@ -106,12 +106,14 @@ void cleanProc() {
}
}
-void createPooledRegion(const char *name, bool ackMode, const char *locators,
- const char *poolname,
+void createPooledRegion(const std::string &name, bool ackMode,
+ const std::string &locators,
+ const std::string &poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
diff --git a/cppcache/integration-test/testThinClientCqDurable.cpp b/cppcache/integration-test/testThinClientCqDurable.cpp
index 348687b..2730e58 100644
--- a/cppcache/integration-test/testThinClientCqDurable.cpp
+++ b/cppcache/integration-test/testThinClientCqDurable.cpp
@@ -171,7 +171,7 @@ void createServer(bool locator = false) {
LOG("Starting SERVER1...");
if (isLocalServer) {
CacheHelper::initServer(1, "remotequery.xml",
- locator ? locatorsG : nullptr);
+ locator ? locatorsG : std::string{});
}
LOG("SERVER1 started");
}
@@ -179,7 +179,7 @@ void createServer(bool locator = false) {
void createServer_XML() {
LOG("Starting SERVER...");
if (isLocalServer) {
- CacheHelper::initServer(1, "serverDurableClient.xml", nullptr);
+ CacheHelper::initServer(1, "serverDurableClient.xml");
}
LOG("SERVER started");
}
diff --git a/cppcache/integration-test/testThinClientCqFailover.cpp b/cppcache/integration-test/testThinClientCqFailover.cpp
index fcf7662..a0feb55 100644
--- a/cppcache/integration-test/testThinClientCqFailover.cpp
+++ b/cppcache/integration-test/testThinClientCqFailover.cpp
@@ -227,13 +227,13 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
SLEEP(15000);
} catch (IllegalStateException &ise) {
- char isemsg[500] = {0};
- ACE_OS::snprintf(isemsg, 499, "IllegalStateException: %s", ise.what());
- LOG(isemsg);
- FAIL(isemsg);
+ std::string excpmsg = "IllegalStateException: " + std::string{ise.what()};
+
+ LOG(excpmsg);
+ FAIL(excpmsg);
} catch (Exception &excp) {
- char excpmsg[500] = {0};
- ACE_OS::snprintf(excpmsg, 499, "Exception: %s", excp.what());
+ std::string excpmsg = "Exception: " + std::string{excp.what()};
+
LOG(excpmsg);
FAIL(excpmsg);
} catch (...) {
@@ -287,8 +287,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree3)
auto vl = cqAttr->getCqListeners();
cqLstner = vl[0];
} catch (Exception &excp) {
- char excpmsg[500] = {0};
- ACE_OS::snprintf(excpmsg, 499, "Exception: %s", excp.what());
+ std::string excpmsg = "Exception: " + std::string{excp.what()};
+
LOG(excpmsg);
ASSERT(false, "get listener failed");
}
@@ -374,8 +374,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, CloseCache1)
auto vl = cqAttr->getCqListeners();
cqLstner = vl[0];
} catch (Exception &excp) {
- char excpmsg[500] = {0};
- ACE_OS::snprintf(excpmsg, 499, "Exception: %s", excp.what());
+ std::string excpmsg = "Exception: " + std::string{excp.what()};
+
LOG(excpmsg);
ASSERT(false, "get listener failed");
}
diff --git a/cppcache/integration-test/testThinClientCqHAFailover.cpp b/cppcache/integration-test/testThinClientCqHAFailover.cpp
index d5bebbc..f53515e 100644
--- a/cppcache/integration-test/testThinClientCqHAFailover.cpp
+++ b/cppcache/integration-test/testThinClientCqHAFailover.cpp
@@ -249,13 +249,13 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
// ASSERT( count==0, "results traversal count incorrect!" );
SLEEP(15000);
} catch (IllegalStateException &ise) {
- char isemsg[500] = {0};
- ACE_OS::snprintf(isemsg, 499, "IllegalStateException: %s", ise.what());
- LOG(isemsg);
- FAIL(isemsg);
+ std::string excpmsg = "IllegalStateException: " + std::string{ise.what()};
+
+ LOG(excpmsg);
+ FAIL(excpmsg);
} catch (Exception &excp) {
- char excpmsg[500] = {0};
- ACE_OS::snprintf(excpmsg, 499, "Exception: %s", excp.what());
+ std::string excpmsg = "Exception: " + std::string{excp.what()};
+
LOG(excpmsg);
FAIL(excpmsg);
} catch (...) {
@@ -309,8 +309,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree3)
auto vl = cqAttr->getCqListeners();
cqLstner = vl[0];
} catch (Exception &excp) {
- char excpmsg[500] = {0};
- ACE_OS::snprintf(excpmsg, 499, "Exception: %s", excp.what());
+ std::string excpmsg = "Exception: " + std::string{excp.what()};
+
LOG(excpmsg);
ASSERT(false, "get listener failed");
}
@@ -396,8 +396,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, CloseCache1)
auto vl = cqAttr->getCqListeners();
cqLstner = vl[0];
} catch (Exception &excp) {
- char excpmsg[500] = {0};
- ACE_OS::snprintf(excpmsg, 499, "Exception: %s", excp.what());
+ std::string excpmsg = "Exception: " + std::string{excp.what()};
+
LOG(excpmsg);
ASSERT(false, "get listener failed");
}
diff --git a/cppcache/integration-test/testThinClientCqIR.cpp b/cppcache/integration-test/testThinClientCqIR.cpp
index 0d9b88f..2bf4489 100644
--- a/cppcache/integration-test/testThinClientCqIR.cpp
+++ b/cppcache/integration-test/testThinClientCqIR.cpp
@@ -87,7 +87,7 @@ void createServer(bool locator = false) {
LOG("Starting SERVER1...");
if (isLocalServer) {
CacheHelper::initServer(1, "remotequery.xml",
- locator ? locatorsG : nullptr);
+ locator ? locatorsG : std::string{});
}
LOG("SERVER1 started");
}
diff --git a/cppcache/integration-test/testThinClientDeltaWithNotification.cpp b/cppcache/integration-test/testThinClientDeltaWithNotification.cpp
index 9059e22..33cf250 100644
--- a/cppcache/integration-test/testThinClientDeltaWithNotification.cpp
+++ b/cppcache/integration-test/testThinClientDeltaWithNotification.cpp
@@ -36,7 +36,7 @@ CacheHelper *cacheHelper = nullptr;
bool isLocalServer = false;
static bool isLocator = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#define CLIENT1 s1p1
#define CLIENT2 s1p2
@@ -78,12 +78,14 @@ CacheHelper *getHelper() {
return cacheHelper;
}
-void createPooledRegion(const char *name, bool ackMode, const char *locators,
- const char *poolname,
+void createPooledRegion(const std::string &name, bool ackMode,
+ const std::string &locators,
+ const std::string &poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
@@ -101,8 +103,9 @@ void createPooledExpirationRegion(const char *name, const char *poolname) {
0, nullptr, ExpirationAction::LOCAL_INVALIDATE);
}
-void createPooledLRURegion(const char *name, bool ackMode, const char *locators,
- const char *poolname,
+void createPooledLRURegion(const std::string &name, bool ackMode,
+ const std::string &locators,
+ const std::string &poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG(" createPooledLRURegion entered");
diff --git a/cppcache/integration-test/testThinClientDisconnectionListioner.cpp b/cppcache/integration-test/testThinClientDisconnectionListioner.cpp
index 9dd1c34..4045db5 100644
--- a/cppcache/integration-test/testThinClientDisconnectionListioner.cpp
+++ b/cppcache/integration-test/testThinClientDisconnectionListioner.cpp
@@ -28,7 +28,7 @@ static bool isLocator = false;
static bool isLocalServer = true;
static int numberOfLocators = 1;
static int isDisconnected = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
class DisconnectCacheListioner : public CacheListener {
diff --git a/cppcache/integration-test/testThinClientFixedPartitionResolver.cpp b/cppcache/integration-test/testThinClientFixedPartitionResolver.cpp
index 784022e..c744a41 100644
--- a/cppcache/integration-test/testThinClientFixedPartitionResolver.cpp
+++ b/cppcache/integration-test/testThinClientFixedPartitionResolver.cpp
@@ -183,7 +183,7 @@ auto cptr3 = std::make_shared<CustomFixedPartitionResolver3>();
bool isLocalServer = false;
static bool isLocator = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
std::vector<char *> storeEndPoints(const char *points) {
diff --git a/cppcache/integration-test/testThinClientHADistOps.cpp b/cppcache/integration-test/testThinClientHADistOps.cpp
index 92f557b..e037090 100644
--- a/cppcache/integration-test/testThinClientHADistOps.cpp
+++ b/cppcache/integration-test/testThinClientHADistOps.cpp
@@ -39,7 +39,7 @@ CacheHelper *cacheHelper = nullptr;
bool isLocalServer = false;
static bool isLocator = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
static int clientWithRedundancy = 0;
diff --git a/cppcache/integration-test/testThinClientHAEventIDMap.cpp b/cppcache/integration-test/testThinClientHAEventIDMap.cpp
index f294fec..cff2d3f 100644
--- a/cppcache/integration-test/testThinClientHAEventIDMap.cpp
+++ b/cppcache/integration-test/testThinClientHAEventIDMap.cpp
@@ -93,7 +93,7 @@ static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 1;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
int g_redundancyLevel = 0;
diff --git a/cppcache/integration-test/testThinClientHAFailover.cpp b/cppcache/integration-test/testThinClientHAFailover.cpp
index 7435c9a..72c3e53 100644
--- a/cppcache/integration-test/testThinClientHAFailover.cpp
+++ b/cppcache/integration-test/testThinClientHAFailover.cpp
@@ -42,7 +42,7 @@ int g_redundancyLevel = 0;
static bool isLocator = false;
static int numberOfLocators = 1;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
void initClient(int redundancyLevel) {
diff --git a/cppcache/integration-test/testThinClientHAFailoverRegex.cpp b/cppcache/integration-test/testThinClientHAFailoverRegex.cpp
index c0ea44f..c1d865a 100644
--- a/cppcache/integration-test/testThinClientHAFailoverRegex.cpp
+++ b/cppcache/integration-test/testThinClientHAFailoverRegex.cpp
@@ -42,7 +42,7 @@ volatile int g_redundancyLevel = 0;
static bool isLocator = false;
static int numberOfLocators = 1;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
void initClient() {
diff --git a/cppcache/integration-test/testThinClientHAMixedRedundancy.cpp b/cppcache/integration-test/testThinClientHAMixedRedundancy.cpp
index abd2b52..efc9373 100644
--- a/cppcache/integration-test/testThinClientHAMixedRedundancy.cpp
+++ b/cppcache/integration-test/testThinClientHAMixedRedundancy.cpp
@@ -40,7 +40,7 @@ CacheHelper *cacheHelper = nullptr;
#define SERVERS s2p2
#define SERVER1 s2p2
static bool isLocator = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
bool g_poolConfig = false;
bool g_poolLocators = false;
diff --git a/cppcache/integration-test/testThinClientHAPeriodicAck.cpp b/cppcache/integration-test/testThinClientHAPeriodicAck.cpp
index 0ffcde9..b950cf4 100644
--- a/cppcache/integration-test/testThinClientHAPeriodicAck.cpp
+++ b/cppcache/integration-test/testThinClientHAPeriodicAck.cpp
@@ -97,7 +97,7 @@ CacheHelper *cacheHelper = nullptr;
static bool isLocator = false;
static bool isLocalServer = false;
static int numberOfLocators = 1;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
int g_redundancyLevel = 0;
bool g_poolConfig = false;
diff --git a/cppcache/integration-test/testThinClientHAQueryFailover.cpp b/cppcache/integration-test/testThinClientHAQueryFailover.cpp
index f71c43e..c53a48b 100644
--- a/cppcache/integration-test/testThinClientHAQueryFailover.cpp
+++ b/cppcache/integration-test/testThinClientHAQueryFailover.cpp
@@ -55,7 +55,7 @@ static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 1;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
class KillServerThread : public ACE_Task_Base {
@@ -258,13 +258,13 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
kst->stop();
} catch (IllegalStateException &ise) {
- char isemsg[500] = {0};
- ACE_OS::snprintf(isemsg, 499, "IllegalStateException: %s", ise.what());
- LOG(isemsg);
- FAIL(isemsg);
+ std::string excpmsg = "IllegalStateException: " + std::string{ise.what()};
+
+ LOG(excpmsg);
+ FAIL(excpmsg);
} catch (Exception &excp) {
- char excpmsg[500] = {0};
- ACE_OS::snprintf(excpmsg, 499, "Exception: %s", excp.what());
+ std::string excpmsg = "Exception: " + std::string{excp.what()};
+
LOG(excpmsg);
FAIL(excpmsg);
} catch (...) {
diff --git a/cppcache/integration-test/testThinClientInterest1Cacheless.cpp b/cppcache/integration-test/testThinClientInterest1Cacheless.cpp
index fee5666..e6f4fb5 100644
--- a/cppcache/integration-test/testThinClientInterest1Cacheless.cpp
+++ b/cppcache/integration-test/testThinClientInterest1Cacheless.cpp
@@ -38,10 +38,12 @@ class MyListener : public CacheListener {
inline void checkEntry(const EntryEvent &event) {
auto keyPtr = std::dynamic_pointer_cast<CacheableString>(event.getKey());
for (int i = 0; i < 5; i++) {
- if (!ACE_OS::strcmp(keys[i], keyPtr->value().c_str())) {
+ if (keyPtr->value() == keys[i]) {
auto valPtr =
std::dynamic_pointer_cast<CacheableString>(event.getNewValue());
- if (!ACE_OS::strcmp(vals[i], valPtr->value().c_str())) m_gotit[i] = 1;
+ if (valPtr->value() == vals[i]) {
+ m_gotit[i] = 1;
+ }
break;
}
}
diff --git a/cppcache/integration-test/testThinClientInterestNotify.cpp b/cppcache/integration-test/testThinClientInterestNotify.cpp
index 1fc0af2..9b670e9 100644
--- a/cppcache/integration-test/testThinClientInterestNotify.cpp
+++ b/cppcache/integration-test/testThinClientInterestNotify.cpp
@@ -261,8 +261,7 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER_AND_FEEDER, FeederUpAndFeed)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
- true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, {}, nullptr, 0, true);
getHelper()->createPooledRegion(regions[0], USE_ACK, locatorsG,
"__TEST_POOL1__", true, true);
getHelper()->createPooledRegion(regions[1], USE_ACK, locatorsG,
diff --git a/cppcache/integration-test/testThinClientLRUExpiration.cpp b/cppcache/integration-test/testThinClientLRUExpiration.cpp
index 8d06af5..1adb0f0 100644
--- a/cppcache/integration-test/testThinClientLRUExpiration.cpp
+++ b/cppcache/integration-test/testThinClientLRUExpiration.cpp
@@ -51,7 +51,7 @@ CacheHelper *cacheHelper = nullptr;
bool isLocalServer = false;
static bool isLocator = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *regionNames[] = {"DistRegionAck1", "DistRegionAck2",
@@ -303,7 +303,7 @@ END_TASK(StepTwoCase1)
DUNIT_TASK(CLIENT1, StepThreeCase1)
{
doRgnOperations(regionNames[0], 100);
- ACE_OS::sleep(1);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
auto n = getNumOfEntries(regionNames[0]);
ASSERT(n == 100, "Expected 100 entries");
LOG("StepThree complete.");
@@ -320,7 +320,7 @@ END_TASK(StepFourCase1)
DUNIT_TASK(CLIENT1, StepFiveCase1)
{
// wair 5 sec so all enteries gone
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
auto n = getNumOfEntries(regionNames[0]);
ASSERT(n == 0, "Expected 0 entries");
LOG("StepFive complete.");
@@ -328,7 +328,7 @@ DUNIT_TASK(CLIENT1, StepFiveCase1)
END_TASK(StepFiveCase1)
DUNIT_TASK(CLIENT2, StepSixCase1)
{
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
// all enteris has been deleted
// int n = getNumOfEntries(regionNames[0],true);
auto n = getNumOfEntries(regionNames[0]);
@@ -384,10 +384,10 @@ DUNIT_TASK(CLIENT2, StepFourCase2)
END_TASK(StepFourCase2)
DUNIT_TASK(CLIENT1, StepFiveCase2)
{
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
auto n = getNumOfEntries(regionNames[0]);
ASSERT(n == 100, "Expected 100 entries");
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
// value should be invalidate as passing true
n = getNumOfEntries(regionNames[0], true);
ASSERT(n == 0, "Expected 0 entries");
@@ -396,7 +396,7 @@ DUNIT_TASK(CLIENT1, StepFiveCase2)
END_TASK(StepFiveCase2)
DUNIT_TASK(CLIENT2, StepSixCase2)
{
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
auto n = getNumOfEntries(regionNames[0], true);
ASSERT(n == 100, "Expected 100 entries");
LOG("StepSixCase2 complete.");
@@ -455,7 +455,7 @@ DUNIT_TASK(CLIENT1, StepFiveCase3)
END_TASK(StepFiveCase3)
DUNIT_TASK(CLIENT2, StepSixCase3)
{
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
auto n = getNumOfEntries(regionNames[0]);
ASSERT(n == 10, "Expected 10 entries");
n = getNumOfEntries(regionNames[0], true);
@@ -512,12 +512,12 @@ DUNIT_TASK(CLIENT2, StepFourCase4)
END_TASK(StepFourCase4)
DUNIT_TASK(CLIENT1, StepFiveCase4)
{
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
auto n = getNumOfEntries(regionNames[0]);
ASSERT(n == 5, "Expected 5 entries");
n = getNumOfEntries(regionNames[0], true);
ASSERT(n == 5, "Expected 5 entries");
- ACE_OS::sleep(4);
+ std::this_thread::sleep_for(std::chrono::seconds(4));
n = getNumOfEntries(regionNames[0]);
ASSERT(n == 5, "Expected 5 entries");
LOG("StepFiveCase4 "
@@ -526,7 +526,7 @@ DUNIT_TASK(CLIENT1, StepFiveCase4)
END_TASK(StepFiveCase4)
DUNIT_TASK(CLIENT2, StepSixCase4)
{
- ACE_OS::sleep(1);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
auto n = getNumOfEntries(regionNames[0]);
ASSERT(n == 10, "Expected 10 entries");
n = getNumOfEntries(regionNames[0], true);
@@ -596,7 +596,7 @@ DUNIT_TASK(CLIENT2, StepFourCase5)
END_TASK(StepFourCase5)
DUNIT_TASK(CLIENT1, StepFiveCase5)
{
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
auto n = getNumOfEntries(regionNames[0]);
ASSERT(n == 5,
"Expected "
@@ -607,7 +607,7 @@ DUNIT_TASK(CLIENT1, StepFiveCase5)
"Expected "
"5 "
"entries");
- ACE_OS::sleep(4);
+ std::this_thread::sleep_for(std::chrono::seconds(4));
n = getNumOfEntries(regionNames[0]);
ASSERT(n == 0,
"Expected "
@@ -620,7 +620,7 @@ DUNIT_TASK(CLIENT1, StepFiveCase5)
END_TASK(StepFiveCase5)
DUNIT_TASK(CLIENT2, StepSixCase5)
{
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
auto n = getNumOfEntries(regionNames[0]);
ASSERT(n == 5,
"Expecte"
@@ -711,12 +711,12 @@ DUNIT_TASK(CLIENT2, StepFourCase6)
END_TASK(StepFourCase6)
DUNIT_TASK(CLIENT1, StepFiveCase6)
{
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
auto n = getNumOfEntries(regionNames[0]);
ASSERT(n == 5, "Expected 5 entries");
n = getNumOfEntries(regionNames[0], true);
ASSERT(n == 5, "Expected 5 entries");
- ACE_OS::sleep(4);
+ std::this_thread::sleep_for(std::chrono::seconds(4));
n = getNumOfEntries(regionNames[0]);
ASSERT(n == 5, "Expected 5 entries");
LOG("StepFiveCase6 complete.");
@@ -724,7 +724,7 @@ DUNIT_TASK(CLIENT1, StepFiveCase6)
END_TASK(StepFiveCase6)
DUNIT_TASK(CLIENT2, StepSixCase6)
{
- ACE_OS::sleep(1);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
auto n = getNumOfEntries(regionNames[0]);
ASSERT(n == 10, "Expected 10 entries");
n = getNumOfEntries(regionNames[0], true);
@@ -771,21 +771,21 @@ DUNIT_TASK(CLIENT2, StepFourCase7)
END_TASK(StepFourCase7)
DUNIT_TASK(CLIENT1, StepFiveCase7)
{
- ACE_OS::sleep(15);
+ std::this_thread::sleep_for(std::chrono::seconds(15));
ValidateDestroyRegion(regionNames[0]);
LOG("StepFiveCase7 complete.");
}
END_TASK(StepFiveCase7)
DUNIT_TASK(CLIENT2, StepSixCase7)
{
- ACE_OS::sleep(3);
+ std::this_thread::sleep_for(std::chrono::seconds(3));
ValidateDestroyRegion(regionNames[0]);
LOG("StepSixCase7 complete.");
}
END_TASK(StepSixCase7)
DUNIT_TASK(CLIENT1, StepOneCase8)
{
- ACE_OS::sleep(10);
+ std::this_thread::sleep_for(std::chrono::seconds(10));
// regionName, ettl, eit , rttl, rit,lel,endpoints,noOfEntry,rgnOpetation -
// [put-0/get-5/destroy-3] ,destroyRgn - [true/false]
// ,clientNotificationEnabled - [true/false] ,ExpirationAction
@@ -823,17 +823,17 @@ DUNIT_TASK(CLIENT2, StepFourCase8)
END_TASK(StepFourCase8)
DUNIT_TASK(CLIENT1, StepFiveCase8)
{
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
auto n = getNumOfEntries(regionNames[1]);
ASSERT(n == 10, "Expected 0 entries");
- ACE_OS::sleep(10);
+ std::this_thread::sleep_for(std::chrono::seconds(10));
ValidateDestroyRegion(regionNames[1]);
LOG("StepFiveCase8 complete.");
}
END_TASK(StepFiveCase8)
DUNIT_TASK(CLIENT2, StepSixCase8)
{
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
ValidateDestroyRegion(regionNames[1]);
LOG("StepSixCase8 complete.");
}
@@ -861,7 +861,7 @@ DUNIT_TASK(CLIENT2, StepTwoCase9)
END_TASK(StepTwoCase9)
DUNIT_TASK(CLIENT1, StepThreeCase9)
{
- ACE_OS::sleep(2);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
doRgnOperations(regionNames[2], 10);
auto n = getNumOfEntries(regionNames[2]);
ASSERT(n == 5, "Expected 5 entries");
@@ -878,17 +878,17 @@ DUNIT_TASK(CLIENT2, StepFourCase9)
END_TASK(StepFourCase9)
DUNIT_TASK(CLIENT1, StepFiveCase9)
{
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
auto n = getNumOfEntries(regionNames[2]);
ASSERT(n == 0, "Expected 0 entries");
- ACE_OS::sleep(8);
+ std::this_thread::sleep_for(std::chrono::seconds(8));
ValidateDestroyRegion(regionNames[2]);
LOG("StepFiveCase9 complete.");
}
END_TASK(StepFiveCase9)
DUNIT_TASK(CLIENT2, StepSixCase9)
{
- ACE_OS::sleep(3);
+ std::this_thread::sleep_for(std::chrono::seconds(3));
ValidateDestroyRegion(regionNames[2]);
LOG("StepSixCase9 complete.");
}
@@ -932,17 +932,17 @@ DUNIT_TASK(CLIENT2, StepFourCase10)
END_TASK(StepFourCase10)
DUNIT_TASK(CLIENT1, StepFiveCase10)
{
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
auto n = getNumOfEntries(regionNames[3]);
ASSERT(n == 0, "Expected 0 entries");
- ACE_OS::sleep(10);
+ std::this_thread::sleep_for(std::chrono::seconds(10));
ValidateDestroyRegion(regionNames[3]);
LOG("StepFiveCase10 complete.");
}
END_TASK(StepFiveCase10)
DUNIT_TASK(CLIENT2, StepSixCase10)
{
- ACE_OS::sleep(3);
+ std::this_thread::sleep_for(std::chrono::seconds(3));
ValidateDestroyRegion(regionNames[3]);
LOG("StepSixCase10 complete.");
}
@@ -1021,7 +1021,7 @@ DUNIT_TASK(CLIENT2, StepFourCase11)
END_TASK(StepFourCase11)
DUNIT_TASK(CLIENT1, StepFiveCase11)
{
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
auto n = getNumOfEntries(regionNames[4]);
ASSERT(regWriter->isWriterInvoked() == true, "Writer Should be invoked");
@@ -1058,7 +1058,7 @@ DUNIT_TASK(CLIENT2, StepSixCase11)
so expect 5 entries instead of 0 earlier. */
ASSERT(n == 5, "Expected 5 entries");
- ACE_OS::sleep(3);
+ std::this_thread::sleep_for(std::chrono::seconds(3));
LOG("StepSixCase11 complete.");
}
END_TASK(StepSixCase11)
@@ -1149,7 +1149,7 @@ DUNIT_TASK(CLIENT2, StepFourCase12)
END_TASK(StepFourCase12)
DUNIT_TASK(CLIENT1, StepFiveCase12)
{
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
auto n = getNumOfEntries(regionNames[5]);
ASSERT(regWriter->isWriterInvoked() == true, "Writer Should be invoked");
@@ -1168,7 +1168,7 @@ DUNIT_TASK(CLIENT1, StepFiveCase12)
END_TASK(StepFiveCase12)
DUNIT_TASK(CLIENT2, StepSixCase12)
{
- ACE_OS::sleep(3);
+ std::this_thread::sleep_for(std::chrono::seconds(3));
auto n = getNumOfEntries(regionNames[5]);
ASSERT(regWriter->isWriterInvoked() == false,
"Writer Should not be invoked");
@@ -1262,7 +1262,7 @@ DUNIT_TASK(CLIENT2, StepFourCase13)
END_TASK(StepFourCase13)
DUNIT_TASK(CLIENT1, StepFiveCase13)
{
- ACE_OS::sleep(5);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
auto n = getNumOfEntries(regionNames[5]);
ASSERT(regWriter->isWriterInvoked() == true, "Writer Should be invoked");
@@ -1281,7 +1281,7 @@ DUNIT_TASK(CLIENT1, StepFiveCase13)
END_TASK(StepFiveCase13)
DUNIT_TASK(CLIENT2, StepSixCase13)
{
- ACE_OS::sleep(3);
+ std::this_thread::sleep_for(std::chrono::seconds(3));
auto n = getNumOfEntries(regionNames[5]);
ASSERT(regWriter->isWriterInvoked() == false,
"Writer Should not be invoked");
diff --git a/cppcache/integration-test/testThinClientListenerCallbackArgTest.cpp b/cppcache/integration-test/testThinClientListenerCallbackArgTest.cpp
index 5a0d854..1d4101c 100644
--- a/cppcache/integration-test/testThinClientListenerCallbackArgTest.cpp
+++ b/cppcache/integration-test/testThinClientListenerCallbackArgTest.cpp
@@ -41,7 +41,7 @@ using apache::geode::client::testing::TallyWriter;
bool isLocalServer = true;
static bool isLocator = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#include "LocatorHelper.hpp"
diff --git a/cppcache/integration-test/testThinClientLocator.cpp b/cppcache/integration-test/testThinClientLocator.cpp
index 9cf7a02..929a30c 100644
--- a/cppcache/integration-test/testThinClientLocator.cpp
+++ b/cppcache/integration-test/testThinClientLocator.cpp
@@ -20,7 +20,7 @@
bool isLocalServer = false;
bool isLocator = false;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#define CLIENT1 s1p1
@@ -37,8 +37,12 @@ END_TASK(CreateLocator1)
DUNIT_TASK(SERVER12, CreateServer12)
{
// starting servers
- if (isLocalServer) CacheHelper::initServer(1, nullptr, locHostPort);
- if (isLocalServer) CacheHelper::initServer(2, nullptr, locHostPort);
+ if (isLocalServer) {
+ CacheHelper::initServer(1, {}, locHostPort);
+ }
+ if (isLocalServer) {
+ CacheHelper::initServer(2, {}, locHostPort);
+ }
LOG("Server12 started");
}
END_TASK(CreateServer12)
diff --git a/cppcache/integration-test/testThinClientLocatorFailover.cpp b/cppcache/integration-test/testThinClientLocatorFailover.cpp
index 6811c3b..996a41c 100644
--- a/cppcache/integration-test/testThinClientLocatorFailover.cpp
+++ b/cppcache/integration-test/testThinClientLocatorFailover.cpp
@@ -22,7 +22,7 @@ using apache::geode::client::NoAvailableLocatorsException;
bool isLocalServer = false;
bool isLocator = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 3);
#define CLIENT1 s1p1
#define CLIENT2 s1p2
@@ -41,7 +41,7 @@ END_TASK(CreateLocator_All)
DUNIT_TASK(SERVERS, CreateServer1_All)
{
// starting servers
- if (isLocalServer) CacheHelper::initServer(1, nullptr, locatorsG);
+ if (isLocalServer) CacheHelper::initServer(1, {}, locatorsG);
LOG("Server One started");
}
END_TASK(CreateServer1_All)
@@ -82,7 +82,7 @@ END_TASK(ConnectC2_All)
DUNIT_TASK(SERVERS, CreateServer2_All)
{
if (isLocalServer) {
- CacheHelper::initServer(2, nullptr, locatorsG);
+ CacheHelper::initServer(2, {}, locatorsG);
LOG("Server 2 started");
}
}
@@ -135,7 +135,7 @@ END_TASK(SwapLocators)
DUNIT_TASK(SERVERS, Re_CreateServer1_All)
{
if (isLocalServer) {
- CacheHelper::initServer(1, nullptr, locatorsG);
+ CacheHelper::initServer(1, {}, locatorsG);
LOG("Server 1 started");
SLEEP(30000);
}
@@ -199,7 +199,7 @@ END_TASK(Re_Close1_All_All)
DUNIT_TASK(SERVERS, StartServer2_All)
{
if (isLocalServer) {
- CacheHelper::initServer(2, nullptr, nullptr);
+ CacheHelper::initServer(2);
LOG("SERVER2 Started");
SLEEP(30000);
}
diff --git a/cppcache/integration-test/testThinClientMultiDS.cpp b/cppcache/integration-test/testThinClientMultiDS.cpp
index a700b43..1bab3db 100644
--- a/cppcache/integration-test/testThinClientMultiDS.cpp
+++ b/cppcache/integration-test/testThinClientMultiDS.cpp
@@ -63,9 +63,9 @@ void startServer(int instance, const char *xmlfile, const char *lochostport) {
DUNIT_TASK_DEFINITION(SERVER1, CreateServer1)
{
- CacheHelper::initServer(1, "cacheserver_notify_subscription.xml", nullptr,
+ CacheHelper::initServer(1, "cacheserver_notify_subscription.xml", {},
nullptr, false, true, true);
- CacheHelper::initServer(2, "cacheserver_notify_subscription2.xml", nullptr,
+ CacheHelper::initServer(2, "cacheserver_notify_subscription2.xml", {},
nullptr, false, true, true);
LOG("SERVER1 and server2 started");
}
@@ -73,9 +73,9 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER2, CreateServer2)
{
- CacheHelper::initServer(3, "cacheserver_notify_subscription3.xml", nullptr,
+ CacheHelper::initServer(3, "cacheserver_notify_subscription3.xml", {},
nullptr, false, true, true);
- CacheHelper::initServer(4, "cacheserver_notify_subscription4.xml", nullptr,
+ CacheHelper::initServer(4, "cacheserver_notify_subscription4.xml", {},
nullptr, false, true, true);
LOG("SERVER2 started");
}
diff --git a/cppcache/integration-test/testThinClientNotificationWithDeltaWithoutcache.cpp b/cppcache/integration-test/testThinClientNotificationWithDeltaWithoutcache.cpp
index 1eb1835..8a8ccda 100644
--- a/cppcache/integration-test/testThinClientNotificationWithDeltaWithoutcache.cpp
+++ b/cppcache/integration-test/testThinClientNotificationWithDeltaWithoutcache.cpp
@@ -81,12 +81,14 @@ CacheHelper *getHelper() {
return cacheHelper;
}
-void createPooledRegion(const char *name, bool ackMode, const char *locators,
- const char *poolname,
+void createPooledRegion(const std::string &name, bool ackMode,
+ const std::string &locators,
+ const std::string &poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
diff --git a/cppcache/integration-test/testThinClientPRPutAllFailover.cpp b/cppcache/integration-test/testThinClientPRPutAllFailover.cpp
index a40df90..ebff906 100644
--- a/cppcache/integration-test/testThinClientPRPutAllFailover.cpp
+++ b/cppcache/integration-test/testThinClientPRPutAllFailover.cpp
@@ -47,7 +47,7 @@ using apache::geode::client::testing::TallyListener;
std::shared_ptr<TallyListener> reg1Listener1;
bool isLocalServer = false;
static bool isLocator = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
void setCacheListener(const char *regName,
diff --git a/cppcache/integration-test/testThinClientPRSingleHop.cpp b/cppcache/integration-test/testThinClientPRSingleHop.cpp
index 4d71a66..ed8d4a1 100644
--- a/cppcache/integration-test/testThinClientPRSingleHop.cpp
+++ b/cppcache/integration-test/testThinClientPRSingleHop.cpp
@@ -57,49 +57,9 @@ bool isLocalServer = false;
const std::string endPoints = CacheHelper::getTcrEndpoints(isLocalServer, 3);
static bool isLocator = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
-std::string convertHostToCanonicalForm(const char *endpoints) {
- if (endpoints == nullptr) return nullptr;
- std::string hostString("");
- uint16_t port = 0;
- std::string endpointsStr(endpoints);
- std::string endpointsStr1(endpoints);
- // Parse this string to get all hostnames and port numbers.
- std::string endpoint;
- std::string::size_type length = endpointsStr.size();
- std::string::size_type pos = 0;
- ACE_TCHAR hostName[256], fullName[256];
- pos = endpointsStr.find(':', 0);
- if (pos != std::string::npos) {
- endpoint = endpointsStr.substr(0, pos);
- pos += 1; // skip ':'
- length -= (pos);
- endpointsStr = endpointsStr.substr(pos, length);
- } else {
- hostString = "";
- return "";
- }
- hostString = endpoint;
- port = atoi(endpointsStr.c_str());
- if (strcmp(hostString.c_str(), "localhost") == 0) {
- ACE_OS::hostname(hostName, sizeof(hostName) - 1);
- struct hostent *host;
- host = ACE_OS::gethostbyname(hostName);
- ACE_OS::snprintf(fullName, 256, "%s:%d", host->h_name, port);
- return fullName;
- }
- pos = endpointsStr1.find('.', 0);
- 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);
- return fullName;
- }
- return endpoints;
-}
-
template <typename T>
T randomValue(T maxValue) {
static thread_local std::default_random_engine generator(
@@ -1130,11 +1090,19 @@ DUNIT_TASK_DEFINITION(CLIENT1, CheckGetAllTask)
keysVector.push_back(keyPtr);
}
- ACE_Time_Value startTime = ACE_OS::gettimeofday();
+ auto startTime = std::chrono::steady_clock::now();
auto valuesMap = dataReg->getAll(keysVector);
- ACE_Time_Value interval = ACE_OS::gettimeofday() - startTime;
+ auto interval = std::chrono::steady_clock::now() - startTime;
+
+ auto interval_sec =
+ std::chrono::duration_cast<std::chrono::seconds>(interval).count();
+ auto interval_usec =
+ std::chrono::duration_cast<std::chrono::microseconds>(interval)
+ .count() %
+ 1000;
+
LOGDEBUG("NILKANTH: Time taken to execute getALL sec = %d and MSec = %d ",
- interval.sec(), interval.usec());
+ interval_sec, interval_usec);
ASSERT(valuesMap.size() == 100000, "GetAll returns wrong number of values");
valuesMap = dataReg->getAll(keysVector, CacheableInt32::create(10000));
diff --git a/cppcache/integration-test/testThinClientPRSingleHopServerGroup.cpp b/cppcache/integration-test/testThinClientPRSingleHopServerGroup.cpp
index fba653d..08518c5 100644
--- a/cppcache/integration-test/testThinClientPRSingleHopServerGroup.cpp
+++ b/cppcache/integration-test/testThinClientPRSingleHopServerGroup.cpp
@@ -51,7 +51,7 @@ using apache::geode::client::HashMapOfException;
bool isLocalServer = false;
static bool isLocator = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *group1 = "ABC";
diff --git a/cppcache/integration-test/testThinClientPdxDeltaWithNotification.cpp b/cppcache/integration-test/testThinClientPdxDeltaWithNotification.cpp
index f0b9b46..053d11c 100644
--- a/cppcache/integration-test/testThinClientPdxDeltaWithNotification.cpp
+++ b/cppcache/integration-test/testThinClientPdxDeltaWithNotification.cpp
@@ -35,7 +35,7 @@ CacheHelper *cacheHelper = nullptr;
bool isLocalServer = false;
static bool isLocator = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#define CLIENT1 s1p1
#define CLIENT2 s1p2
@@ -78,12 +78,14 @@ CacheHelper *getHelper() {
return cacheHelper;
}
-void createPooledRegion(const char *name, bool ackMode, const char *locators,
- const char *poolname,
+void createPooledRegion(const std::string &name, bool ackMode,
+ const std::string &locators,
+ const std::string &poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
@@ -92,7 +94,8 @@ void createPooledRegion(const char *name, bool ackMode, const char *locators,
LOG("Pooled Region created.");
}
-void createPooledExpirationRegion(const char *name, const char *poolname) {
+void createPooledExpirationRegion(const std::string &name,
+ const std::string &poolname) {
LOG("createPooledExpirationRegion() entered.");
// Entry time-to-live = 1 second.
auto regPtr = getHelper()->createPooledRegionDiscOverFlow(
@@ -101,8 +104,9 @@ void createPooledExpirationRegion(const char *name, const char *poolname) {
0, nullptr, ExpirationAction::LOCAL_INVALIDATE);
}
-void createPooledLRURegion(const char *name, bool ackMode, const char *locators,
- const char *poolname,
+void createPooledLRURegion(const std::string &name, bool ackMode,
+ const std::string &locators,
+ const std::string &poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG(" createPooledLRURegion entered");
@@ -114,10 +118,11 @@ void createPooledLRURegion(const char *name, bool ackMode, const char *locators,
LOG(" createPooledLRURegion exited");
}
-void createRegion(const char *name, bool ackMode,
+void createRegion(const std::string &name, bool ackMode,
bool clientNotificationEnabled = false) {
LOG("createRegion() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
// ack, caching
auto regPtr = getHelper()->createRegion(name, ackMode, true, nullptr,
@@ -126,7 +131,8 @@ void createRegion(const char *name, bool ackMode,
LOG("Region created.");
}
-void createLRURegion(const char *name, bool clientNotificationEnabled = false,
+void createLRURegion(const std::string &name,
+ bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG(" createPooledLRURegion entered");
auto regPtr = getHelper()->createRegionDiscOverFlow(
@@ -136,7 +142,7 @@ void createLRURegion(const char *name, bool clientNotificationEnabled = false,
LOG(" createPooledLRURegion exited");
}
-void createExpirationRegion(const char *name,
+void createExpirationRegion(const std::string &name,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG(" createPooledLRURegion entered");
diff --git a/cppcache/integration-test/testThinClientPdxEnum.cpp b/cppcache/integration-test/testThinClientPdxEnum.cpp
index 4438468..cd19a59 100644
--- a/cppcache/integration-test/testThinClientPdxEnum.cpp
+++ b/cppcache/integration-test/testThinClientPdxEnum.cpp
@@ -32,7 +32,7 @@ bool isLocalServer = false;
#define SERVER1 s2p1
static bool isLocator = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
DUNIT_TASK_DEFINITION(CLIENT1, SetupClientPoolLoc)
@@ -40,7 +40,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, SetupClientPoolLoc)
LOG("Starting Step One with Pool + Locator lists");
initClient(true);
- createPool("__TEST_POOL1__", locatorsG, nullptr, 0, true);
+ createPool("__TEST_POOL1__", locatorsG, {}, 0, true);
createRegionAndAttachPool("DistRegionAck", USE_ACK, "__TEST_POOL1__");
LOG("SetupClient complete.");
diff --git a/cppcache/integration-test/testThinClientPdxInstance.cpp b/cppcache/integration-test/testThinClientPdxInstance.cpp
index 1515d3c..85a5e8d 100644
--- a/cppcache/integration-test/testThinClientPdxInstance.cpp
+++ b/cppcache/integration-test/testThinClientPdxInstance.cpp
@@ -77,7 +77,7 @@ static bool isLocator = false;
const bool USE_ACK = true;
const bool NO_ACK = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *regionNames[] = {"DistRegionAck", "DistRegionNoAck"};
@@ -151,12 +151,14 @@ CacheHelper *getHelper() {
ASSERT(cacheHelper != nullptr, "No cacheHelper initialized.");
return cacheHelper;
}
-void createPooledRegion(const char *name, bool ackMode, const char *locators,
- const char *poolname,
+void createPooledRegion(const std::string &name, bool ackMode,
+ const std::string &locators,
+ const std::string &poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
@@ -1648,8 +1650,8 @@ DUNIT_TASK_DEFINITION(CLIENT2, modifyPdxInstance)
std::shared_ptr<CacheableDate> dateVal;
wpiPtr = pIPtr->createWriter();
time_t timeofday = 0;
- const ACE_Time_Value currentTime = ACE_OS::gettimeofday();
- timeofday = currentTime.sec();
+ timeofday =
+ std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
auto datePtr = CacheableDate::create(timeofday);
wpiPtr->setField("m_dateTime", datePtr);
rptr->put(keyport, wpiPtr);
@@ -2208,10 +2210,11 @@ DUNIT_TASK_DEFINITION(CLIENT2, modifyPdxInstanceAndCheckLocally)
std::shared_ptr<CacheableDate> dateVal;
wpiPtr = pIPtr->createWriter();
- time_t timeofday = 0;
- const ACE_Time_Value currentTime = ACE_OS::gettimeofday();
- timeofday = currentTime.sec();
+
+ auto timeofday =
+ std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
auto datePtr = CacheableDate::create(timeofday);
+
wpiPtr->setField("m_dateTime", datePtr);
rptr->put(keyport, wpiPtr);
newPiPtr = std::dynamic_pointer_cast<PdxInstance>(rptr->get(keyport));
diff --git a/cppcache/integration-test/testThinClientPdxTests.cpp b/cppcache/integration-test/testThinClientPdxTests.cpp
index e240686..0f706c0 100644
--- a/cppcache/integration-test/testThinClientPdxTests.cpp
+++ b/cppcache/integration-test/testThinClientPdxTests.cpp
@@ -107,7 +107,7 @@ bool isLocator = false;
bool isLocalServer = false;
const char *poolNames[] = {"Pool1", "Pool2", "Pool3"};
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
bool isPoolConfig = false; // To track if pool case is running
// const char * qRegionNames[] = { "Portfolios", "Positions", "Portfolios2",
diff --git a/cppcache/integration-test/testThinClientPoolAttrTest.cpp b/cppcache/integration-test/testThinClientPoolAttrTest.cpp
index d57f67c..83ef267 100644
--- a/cppcache/integration-test/testThinClientPoolAttrTest.cpp
+++ b/cppcache/integration-test/testThinClientPoolAttrTest.cpp
@@ -35,7 +35,7 @@ using apache::geode::client::IllegalStateException;
bool isLocalServer = false;
bool isLocator = false;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *poolRegNames[] = {"PoolRegion1"};
const char *poolName = "__TEST_POOL1__";
@@ -227,9 +227,8 @@ END_TASK(StartC1)
DUNIT_TASK(CLIENT2, StartC2)
{
auto props = Properties::create();
- std::string path = "cacheserver_pool_client.xml";
- std::string duplicateFile;
- CacheHelper::createDuplicateXMLFile(duplicateFile, path);
+ auto duplicateFile =
+ CacheHelper::createDuplicateXMLFile("cacheserver_pool_client.xml");
props->insert("cache-xml-file", duplicateFile.c_str());
@@ -238,10 +237,10 @@ DUNIT_TASK(CLIENT2, StartC2)
initClient(true, props);
LOG(" started client");
ASSERT(getHelper()
- ->getCache()
- ->getPoolManager()
- .find("clientPoolMultiUser")
- ->getMultiuserAuthentication() == true,
+ ->getCache()
+ ->getPoolManager()
+ .find("clientPoolMultiUser")
+ ->getMultiuserAuthentication(),
"MultiUser secure mode should be true for Pool");
} catch (const Exception &excp) {
LOG("Exception during client 2 XML creation");
diff --git a/cppcache/integration-test/testThinClientPoolExecuteFunctionThrowsException.cpp b/cppcache/integration-test/testThinClientPoolExecuteFunctionThrowsException.cpp
index 3516783..c70e887 100644
--- a/cppcache/integration-test/testThinClientPoolExecuteFunctionThrowsException.cpp
+++ b/cppcache/integration-test/testThinClientPoolExecuteFunctionThrowsException.cpp
@@ -47,7 +47,7 @@ bool isLocalServer = false;
bool isLocator = false;
bool isPoolWithEndpoint = false;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *poolRegNames[] = {"partition_region", "PoolRegion2"};
@@ -119,11 +119,15 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER, StartS12)
{
- const char *lhp = nullptr;
- if (!isPoolWithEndpoint) lhp = locHostPort;
+ std::string lhp;
+ if (!isPoolWithEndpoint) {
+ lhp = locHostPort;
+ }
+
if (isLocalServer) {
CacheHelper::initServer(1, "func_cacheserver1_pool.xml", lhp);
}
+
if (isLocalServer) {
CacheHelper::initServer(2, "func_cacheserver2_pool.xml", lhp);
}
diff --git a/cppcache/integration-test/testThinClientPoolExecuteHAFunction.cpp b/cppcache/integration-test/testThinClientPoolExecuteHAFunction.cpp
index 76c019a..595cea3 100644
--- a/cppcache/integration-test/testThinClientPoolExecuteHAFunction.cpp
+++ b/cppcache/integration-test/testThinClientPoolExecuteHAFunction.cpp
@@ -36,7 +36,7 @@ bool isLocalServer = false;
bool isLocator = false;
bool isPoolWithEndpoint = false;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *poolRegNames[] = {"partition_region", "PoolRegion2"};
const char *poolName = "__TEST_POOL1__";
@@ -116,8 +116,11 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER, StartS12)
{
- const char *lhp = nullptr;
- if (!isPoolWithEndpoint) lhp = locHostPort;
+ std::string lhp;
+ if (!isPoolWithEndpoint) {
+ lhp = locHostPort;
+ }
+
if (isLocalServer) {
CacheHelper::initServer(1, "func_cacheserver1_pool.xml", lhp);
}
@@ -129,8 +132,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER, StartS13)
{
- const char *lhp = nullptr;
- if (!isPoolWithEndpoint) lhp = locHostPort;
+ std::string lhp;
+ if (!isPoolWithEndpoint) {
+ lhp = locHostPort;
+ }
if (isLocalServer) {
CacheHelper::initServer(1, "func_cacheserver1_pool.xml", lhp);
}
diff --git a/cppcache/integration-test/testThinClientPoolExecuteHAFunctionPrSHOP.cpp b/cppcache/integration-test/testThinClientPoolExecuteHAFunctionPrSHOP.cpp
index 936ef90..a4c6d5e 100644
--- a/cppcache/integration-test/testThinClientPoolExecuteHAFunctionPrSHOP.cpp
+++ b/cppcache/integration-test/testThinClientPoolExecuteHAFunctionPrSHOP.cpp
@@ -34,7 +34,7 @@ using apache::geode::client::FunctionService;
bool isLocalServer = false;
bool isLocator = false;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *poolRegNames[] = {"partition_region", "PoolRegion2"};
const char *poolName = "__TEST_POOL1__";
diff --git a/cppcache/integration-test/testThinClientPoolLocator.cpp b/cppcache/integration-test/testThinClientPoolLocator.cpp
index 3c38346..12783db 100644
--- a/cppcache/integration-test/testThinClientPoolLocator.cpp
+++ b/cppcache/integration-test/testThinClientPoolLocator.cpp
@@ -24,9 +24,9 @@ using apache::geode::client::NotConnectedException;
bool isLocalServer = false;
bool isLocator = false;
-const char *locHostPort1 =
+const std::string locHostPort1 =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
-const char *locHostPort2 =
+const std::string locHostPort2 =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 2);
#define CLIENT1 s1p1
#define CLIENT2 s1p2
diff --git a/cppcache/integration-test/testThinClientPoolRedundancy.cpp b/cppcache/integration-test/testThinClientPoolRedundancy.cpp
index 59258b3..4d234f5 100644
--- a/cppcache/integration-test/testThinClientPoolRedundancy.cpp
+++ b/cppcache/integration-test/testThinClientPoolRedundancy.cpp
@@ -30,7 +30,7 @@
bool isLocalServer = false;
bool isLocator = false;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *poolRegNames[] = {"PoolRegion1", "PoolRegion2", "PoolRegion3"};
const char *poolNames[] = {"Pool1", "Pool2", "Pool3"};
diff --git a/cppcache/integration-test/testThinClientPoolRegInterest.cpp b/cppcache/integration-test/testThinClientPoolRegInterest.cpp
index 94284ad..35dc5b7 100644
--- a/cppcache/integration-test/testThinClientPoolRegInterest.cpp
+++ b/cppcache/integration-test/testThinClientPoolRegInterest.cpp
@@ -28,7 +28,7 @@
bool isLocalServer = false;
bool isLocator = false;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *poolRegNames[] = {"PoolRegion1", "PoolRegion2"};
const char *poolName = "__TEST_POOL1__";
diff --git a/cppcache/integration-test/testThinClientPoolServer.cpp b/cppcache/integration-test/testThinClientPoolServer.cpp
index f28590b..a565617 100644
--- a/cppcache/integration-test/testThinClientPoolServer.cpp
+++ b/cppcache/integration-test/testThinClientPoolServer.cpp
@@ -33,7 +33,7 @@ server-group having the region.
bool isLocalServer = false;
bool isLocator = false;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *poolRegNames[] = {"PoolRegion1", "PoolRegion2", "PoolRegion3"};
const char *poolName = "__TEST_POOL1__";
@@ -83,7 +83,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, StartClient2)
{
initClient(true);
// Create Pool with no server group
- getHelper()->createPool(poolName, locHostPort, nullptr);
+ getHelper()->createPool(poolName, locHostPort, {});
getHelper()->createRegionAndAttachPool(poolRegNames[0], USE_ACK,
"__TEST_POOL1__");
diff --git a/cppcache/integration-test/testThinClientPutAllPRSingleHop.cpp b/cppcache/integration-test/testThinClientPutAllPRSingleHop.cpp
index 541e211..3858dea 100644
--- a/cppcache/integration-test/testThinClientPutAllPRSingleHop.cpp
+++ b/cppcache/integration-test/testThinClientPutAllPRSingleHop.cpp
@@ -52,7 +52,7 @@ using apache::geode::client::HashMapOfCacheable;
bool isLocalServer = false;
static bool isLocator = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
DUNIT_TASK_DEFINITION(SERVER1, CreateServer1)
@@ -193,12 +193,18 @@ DUNIT_TASK_DEFINITION(CLIENT1, CheckPrSingleHopForIntKeysTask)
valMap.emplace(keyPtr, valPtr);
}
LOGINFO("TEST-1");
- ACE_Time_Value startTime = ACE_OS::gettimeofday();
+ auto startTime = std::chrono::steady_clock::now();
dataReg->putAll(valMap);
- ACE_Time_Value interval = ACE_OS::gettimeofday() - startTime;
+ auto interval = std::chrono::steady_clock::now() - startTime;
+ auto interval_sec =
+ std::chrono::duration_cast<std::chrono::seconds>(interval).count();
+ auto interval_usec =
+ std::chrono::duration_cast<std::chrono::microseconds>(interval)
+ .count() %
+ 1000;
LOGINFO("Time taken to execute putAll SH sec = %d and MSec = %d ",
- interval.sec(), interval.usec());
+ interval_sec, interval_usec);
bool networkhop = TestUtils::getCacheImpl(getHelper()->cachePtr)
->getAndResetNetworkHopFlag();
LOGINFO("CheckPrSingleHopForIntKeysTask2: putALL OP :: networkhop %d ",
@@ -250,12 +256,18 @@ DUNIT_TASK_DEFINITION(CLIENT1, CheckPrSingleHopRemoveAllForIntKeysTask)
keysVector.push_back(keyPtr);
}
LOGINFO("TEST-1");
- ACE_Time_Value startTime = ACE_OS::gettimeofday();
+ auto startTime = std::chrono::steady_clock::now();
dataReg->putAll(valMap);
- ACE_Time_Value interval = ACE_OS::gettimeofday() - startTime;
+ auto interval = std::chrono::steady_clock::now() - startTime;
+ auto interval_sec =
+ std::chrono::duration_cast<std::chrono::seconds>(interval).count();
+ auto interval_usec =
+ std::chrono::duration_cast<std::chrono::microseconds>(interval)
+ .count() %
+ 1000;
LOGINFO("Time taken to execute putAll SH sec = %d and MSec = %d ",
- interval.sec(), interval.usec());
+ interval_sec, interval_usec);
bool networkhop = TestUtils::getCacheImpl(getHelper()->cachePtr)
->getAndResetNetworkHopFlag();
LOGINFO("CheckPrSingleHopForIntKeysTask2: putALL OP :: networkhop %d ",
@@ -263,12 +275,18 @@ DUNIT_TASK_DEFINITION(CLIENT1, CheckPrSingleHopRemoveAllForIntKeysTask)
ASSERT(networkhop == false, "PutAll : Should not cause network hop");
LOGINFO("RemoveALL test");
- startTime = ACE_OS::gettimeofday();
+ startTime = std::chrono::steady_clock::now();
dataReg->removeAll(keysVector);
- interval = ACE_OS::gettimeofday() - startTime;
+ interval = std::chrono::steady_clock::now() - startTime;
+ interval_sec =
+ std::chrono::duration_cast<std::chrono::seconds>(interval).count();
+ interval_usec =
+ std::chrono::duration_cast<std::chrono::microseconds>(interval)
+ .count() %
+ 1000;
LOGINFO("Time taken to execute removeAll SH sec = %d and MSec = %d ",
- interval.sec(), interval.usec());
+ interval_sec, interval_usec);
networkhop = TestUtils::getCacheImpl(getHelper()->cachePtr)
->getAndResetNetworkHopFlag();
LOGINFO(
diff --git a/cppcache/integration-test/testThinClientPutWithDelta.cpp b/cppcache/integration-test/testThinClientPutWithDelta.cpp
index fee7eb7..aae7eb8 100644
--- a/cppcache/integration-test/testThinClientPutWithDelta.cpp
+++ b/cppcache/integration-test/testThinClientPutWithDelta.cpp
@@ -33,7 +33,7 @@ CacheHelper *cacheHelper = nullptr;
bool isLocalServer = false;
static bool isLocator = false;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#define CLIENT1 s1p1
#define CLIENT2 s1p2
@@ -76,12 +76,14 @@ CacheHelper *getHelper() {
return cacheHelper;
}
-void createPooledRegion(const char *name, bool ackMode, const char *locators,
- const char *poolname,
+void createPooledRegion(const std::string &name, bool ackMode,
+ const std::string &locators,
+ const std::string &poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
diff --git a/cppcache/integration-test/testThinClientRegionQueryDifferentServerConfigs.cpp b/cppcache/integration-test/testThinClientRegionQueryDifferentServerConfigs.cpp
index 8180af3..abcffb2 100644
--- a/cppcache/integration-test/testThinClientRegionQueryDifferentServerConfigs.cpp
+++ b/cppcache/integration-test/testThinClientRegionQueryDifferentServerConfigs.cpp
@@ -44,7 +44,7 @@ using apache::geode::client::QueryService;
bool isLocalServer = false;
bool isLocator = false;
const char *poolNames[] = {"Pool1", "Pool2", "Pool3"};
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *qRegionNames[] = {"Portfolios", "Positions"};
diff --git a/cppcache/integration-test/testThinClientRegionQueryExclusiveness.cpp b/cppcache/integration-test/testThinClientRegionQueryExclusiveness.cpp
index c28396d..8f9346b 100644
--- a/cppcache/integration-test/testThinClientRegionQueryExclusiveness.cpp
+++ b/cppcache/integration-test/testThinClientRegionQueryExclusiveness.cpp
@@ -50,7 +50,7 @@ using testobject::Position;
bool isLocator = false;
bool isLocalServer = false;
const char *poolNames[] = {"Pool1", "Pool2", "Pool3"};
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *qRegionNames[] = {"Portfolios", "Positions"};
@@ -71,7 +71,7 @@ void clientOperations() {
}
std::shared_ptr<Pool> pool1 = nullptr;
- pool1 = createPool(poolNames[0], locHostPort, nullptr, 0, true);
+ pool1 = createPool(poolNames[0], locHostPort, {}, 0, true);
createRegionAndAttachPool(qRegionNames[0], USE_ACK, poolNames[0]);
auto rptr = getHelper()->cachePtr->getRegion(qRegionNames[0]);
diff --git a/cppcache/integration-test/testThinClientRemoteQueryFailover.cpp b/cppcache/integration-test/testThinClientRemoteQueryFailover.cpp
index 7c89991..dc5052b 100644
--- a/cppcache/integration-test/testThinClientRemoteQueryFailover.cpp
+++ b/cppcache/integration-test/testThinClientRemoteQueryFailover.cpp
@@ -81,7 +81,7 @@ bool isLocalServer = false;
const char *qRegionNames[] = {"Portfolios", "Positions"};
KillServerThread *kst = nullptr;
const char *poolNames[] = {"Pool1", "Pool2", "Pool3"};
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
bool isPoolConfig = false; // To track if pool case is running
@@ -139,7 +139,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, RegisterTypesAndCreatePoolAndRegion)
}
isPoolConfig = true;
- createPool(poolNames[0], locHostPort, nullptr, 0, true);
+ createPool(poolNames[0], locHostPort, {}, 0, true);
createRegionAndAttachPool(qRegionNames[0], USE_ACK, poolNames[0]);
auto rptr = getHelper()->cachePtr->getRegion(qRegionNames[0]);
@@ -197,13 +197,13 @@ DUNIT_TASK_DEFINITION(CLIENT1, ValidateQueryExecutionAcrossServerFailure)
kst->stop();
} catch (IllegalStateException &ise) {
- char isemsg[500] = {0};
- ACE_OS::snprintf(isemsg, 499, "IllegalStateException: %s", ise.what());
- LOG(isemsg);
- FAIL(isemsg);
+ std::string excpmsg = "IllegalStateException: " + std::string{ise.what()};
+
+ LOG(excpmsg);
+ FAIL(excpmsg);
} catch (Exception &excp) {
- char excpmsg[500] = {0};
- ACE_OS::snprintf(excpmsg, 499, "Exception: %s", excp.what());
+ std::string excpmsg = "Exception: " + std::string{excp.what()};
+
LOG(excpmsg);
FAIL(excpmsg);
} catch (...) {
diff --git a/cppcache/integration-test/testThinClientRemoteQueryFailoverPdx.cpp b/cppcache/integration-test/testThinClientRemoteQueryFailoverPdx.cpp
index 8d09b94..dab4bb8 100644
--- a/cppcache/integration-test/testThinClientRemoteQueryFailoverPdx.cpp
+++ b/cppcache/integration-test/testThinClientRemoteQueryFailoverPdx.cpp
@@ -78,7 +78,7 @@ bool isLocalServer = false;
const char *qRegionNames[] = {"Portfolios", "Positions"};
KillServerThread *kst = nullptr;
const char *poolNames[] = {"Pool1", "Pool2", "Pool3"};
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
bool isPoolConfig = false; // To track if pool case is running
@@ -135,7 +135,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, RegisterTypesAndCreatePoolAndRegion)
}
isPoolConfig = true;
- createPool(poolNames[0], locHostPort, nullptr, 0, true);
+ createPool(poolNames[0], locHostPort, {}, 0, true);
createRegionAndAttachPool(qRegionNames[0], USE_ACK, poolNames[0]);
auto rptr = getHelper()->cachePtr->getRegion(qRegionNames[0]);
@@ -193,13 +193,13 @@ DUNIT_TASK_DEFINITION(CLIENT1, ValidateQueryExecutionAcrossServerFailure)
kst->stop();
} catch (IllegalStateException &ise) {
- char isemsg[500] = {0};
- ACE_OS::snprintf(isemsg, 499, "IllegalStateException: %s", ise.what());
- LOG(isemsg);
- FAIL(isemsg);
+ std::string excpmsg = "IllegalStateException: " + std::string{ise.what()};
+
+ LOG(excpmsg);
+ FAIL(excpmsg);
} catch (Exception &excp) {
- char excpmsg[500] = {0};
- ACE_OS::snprintf(excpmsg, 499, "Exception: %s", excp.what());
+ std::string excpmsg = "Exception: " + std::string{excp.what()};
+
LOG(excpmsg);
FAIL(excpmsg);
} catch (...) {
diff --git a/cppcache/integration-test/testThinClientRemoteQueryRS.cpp b/cppcache/integration-test/testThinClientRemoteQueryRS.cpp
index f47033a..967058d 100644
--- a/cppcache/integration-test/testThinClientRemoteQueryRS.cpp
+++ b/cppcache/integration-test/testThinClientRemoteQueryRS.cpp
@@ -58,7 +58,7 @@ bool isLocator = false;
bool isLocalServer = false;
const char *poolNames[] = {"Pool1", "Pool2", "Pool3"};
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
bool isPoolConfig = false; // To track if pool case is running
const char *qRegionNames[] = {"Portfolios", "Positions", "Portfolios2",
@@ -83,7 +83,7 @@ void stepOne() {
// ignore exception
}
isPoolConfig = true;
- createPool(poolNames[0], locHostPort, nullptr, 0, true);
+ createPool(poolNames[0], locHostPort, {}, 0, true);
createRegionAndAttachPool(qRegionNames[0], USE_ACK, poolNames[0]);
createRegionAndAttachPool(qRegionNames[1], USE_ACK, poolNames[0]);
createRegionAndAttachPool(qRegionNames[2], USE_ACK, poolNames[0]);
@@ -202,9 +202,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
auto qry = qs->newQuery(resultsetQueriesOPL[i].query());
auto results = qry->execute();
if (!qh->verifyRS(results, resultsetRowCountsOPL[i])) {
- char failmsg[100] = {0};
- ACE_OS::sprintf(failmsg, "Query verify failed for query index %d", i);
- ASSERT(false, failmsg);
+ ASSERT(false,
+ "Query verify failed for query index " + std::to_string(i));
}
auto rsptr = std::dynamic_pointer_cast<ResultSet>(results);
@@ -303,8 +302,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFive)
? resultsetRowCounts[i]
: resultsetRowCounts[i] *
qh->getPortfolioNumSets()))) {
- char failmsg[100] = {0};
- ACE_OS::sprintf(failmsg, "Query verify failed for query index %d", i);
+ std::string failmsg =
+ "Query verify failed for query index " + std::to_string(i);
ASSERT(false, failmsg);
}
@@ -414,8 +413,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepSix)
? resultsetRowCountsPQ[i]
: resultsetRowCountsPQ[i] *
qh->getPortfolioNumSets()))) {
- char failmsg[100] = {0};
- ACE_OS::sprintf(failmsg, "Query verify failed for query index %d", i);
+ std::string failmsg =
+ "Query verify failed for query index " + std::to_string(i);
ASSERT(false, failmsg);
}
@@ -505,10 +504,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, DoQueryRSError)
try {
auto results = qry->execute();
+ std::string failmsg =
+ "Query exception didnt occur for index " + std::to_string(i);
- char failmsg[100] = {0};
- ACE_OS::sprintf(failmsg, "Query exception didnt occur for index %d",
- i);
LOG(failmsg);
FAIL(failmsg);
} catch (apache::geode::client::QueryException &) {
diff --git a/cppcache/integration-test/testThinClientRemoteQuerySS.cpp b/cppcache/integration-test/testThinClientRemoteQuerySS.cpp
index c35fa9b..c630649 100644
--- a/cppcache/integration-test/testThinClientRemoteQuerySS.cpp
+++ b/cppcache/integration-test/testThinClientRemoteQuerySS.cpp
@@ -64,7 +64,7 @@ bool isLocator = false;
bool isLocalServer = false;
const char *poolNames[] = {"Pool1", "Pool2", "Pool3"};
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
bool isPoolConfig = false; // To track if pool case is running
const char *qRegionNames[] = {"Portfolios", "Positions", "Portfolios2",
@@ -248,7 +248,7 @@ void stepOne() {
}
isPoolConfig = true;
- createPool(poolNames[0], locHostPort, nullptr, 0, true);
+ createPool(poolNames[0], locHostPort, {}, 0, true);
createRegionAndAttachPool(qRegionNames[0], USE_ACK, poolNames[0]);
createRegionAndAttachPool(qRegionNames[1], USE_ACK, poolNames[0]);
createRegionAndAttachPool(qRegionNames[2], USE_ACK, poolNames[0]);
@@ -349,8 +349,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
auto results = qry->execute();
if (!qh->verifySS(results, structsetRowCountsOPL[i],
structsetFieldCountsOPL[i])) {
- char failmsg[100] = {0};
- ACE_OS::sprintf(failmsg, "Query verify failed for query index %d", i);
+ std::string failmsg =
+ "Query verify failed for query index " + std::to_string(i);
ASSERT(false, failmsg);
}
@@ -372,7 +372,6 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StepFive)
{
SLEEP(100);
- bool doAnyErrorOccured = false;
auto qh = &QueryHelper::getHelper();
std::shared_ptr<QueryService> qs = nullptr;
@@ -398,13 +397,13 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFive)
? structsetRowCounts[i]
: structsetRowCounts[i] * qh->getPortfolioNumSets()),
structsetFieldCounts[i])) {
- char failmsg[100] = {0};
- ACE_OS::sprintf(failmsg, "Query verify failed for query index %d", i);
+ std::string failmsg =
+ "Query verify failed for query index " + std::to_string(i);
ASSERT(false, failmsg);
}
auto ssptr = std::dynamic_pointer_cast<StructSet>(results);
- if ((ssptr) == nullptr) {
+ if (ssptr == nullptr) {
LOG("Zero records were expected and found. Moving onto next. ");
continue;
}
@@ -413,8 +412,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFive)
}
}
- if (!doAnyErrorOccured) printf("HURRAY !! We PASSED \n\n");
-
+ printf("HURRAY !! We PASSED \n\n");
LOG("StepFive complete.");
}
END_TASK_DEFINITION
@@ -461,8 +459,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepSix)
? structsetRowCountsPQ[i]
: structsetRowCountsPQ[i] * qh->getPortfolioNumSets()),
structsetFieldCountsPQ[i])) {
- char failmsg[100] = {0};
- ACE_OS::sprintf(failmsg, "Query verify failed for query index %d", i);
+ std::string failmsg =
+ "Query verify failed for query index " + std::to_string(i);
ASSERT(false, failmsg);
}
@@ -505,10 +503,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, GetAll)
for (size_t set = 1; set <= numSets; ++set) {
for (size_t current = 1; current <= setSize; ++current) {
- char posname[100] = {0};
- ACE_OS::sprintf(posname, "pos%zd-%zd", set, current);
+ std::string key =
+ "pos" + std::to_string(set) + '-' + std::to_string(current);
- auto posKey(CacheableKey::create(posname));
+ auto posKey = CacheableKey::create(key);
auto pos = std::make_shared<PositionPdx>(
secIds[current % numSecIds], static_cast<int32_t>(current * 100));
@@ -524,10 +522,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, GetAll)
numSets = qh.getPortfolioNumSets();
for (size_t set = 1; set <= numSets; ++set) {
for (size_t current = 1; current <= setSize; ++current) {
- char portname[100] = {0};
- ACE_OS::sprintf(portname, "port%zd-%zd", set, current);
+ std::string key =
+ "port" + std::to_string(set) + '-' + std::to_string(current);
- auto portKey = CacheableKey::create(portname);
+ auto portKey = CacheableKey::create(key);
auto port =
std::make_shared<PortfolioPdx>(static_cast<int32_t>(current), 1);
@@ -582,10 +580,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, DoQuerySSError)
try {
auto results = qry->execute();
+ std::string failmsg =
+ "Query exception didnt occur for index " + std::to_string(i);
- char failmsg[100] = {0};
- ACE_OS::sprintf(failmsg, "Query exception didnt occur for index %d",
- i);
LOG(failmsg);
FAIL(failmsg);
} catch (apache::geode::client::QueryException &ex) {
diff --git a/cppcache/integration-test/testThinClientRemoteQueryTimeout.cpp b/cppcache/integration-test/testThinClientRemoteQueryTimeout.cpp
index d1568ca..b59d3ec 100644
--- a/cppcache/integration-test/testThinClientRemoteQueryTimeout.cpp
+++ b/cppcache/integration-test/testThinClientRemoteQueryTimeout.cpp
@@ -56,7 +56,7 @@ using apache::geode::client::TimeoutException;
bool isLocalServer = false;
bool isLocator = false;
const char *poolNames[] = {"Pool1", "Pool2", "Pool3"};
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *qRegionNames[] = {"Portfolios", "Positions", "Portfolios2",
@@ -83,7 +83,7 @@ void stepOne() {
// ignore exception
}
isPoolConfig = true;
- createPool(poolNames[0], locHostPort, nullptr, 0, true);
+ createPool(poolNames[0], locHostPort, {}, 0, true);
createRegionAndAttachPool(qRegionNames[0], USE_ACK, poolNames[0]);
auto regptr = getHelper()->getRegion(qRegionNames[0]);
@@ -172,9 +172,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
results = qry->execute(std::chrono::seconds(3));
LOG("EXECUTE 1 STOP");
+ std::string logmsg = "Result size is " + std::to_string(results->size());
- char logmsg[50] = {0};
- ACE_OS::sprintf(logmsg, "Result size is %zd", results->size());
LOG(logmsg);
LOG("Didnt get expected timeout exception for first execute");
@@ -216,8 +215,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
LOG("EXECUTE 2 STOP");
- char logmsg[50] = {0};
- ACE_OS::sprintf(logmsg, "Result size is %zd", results->size());
+ std::string logmsg = "Result size is " + std::to_string(results->size());
LOG(logmsg);
} catch (Exception &excp) {
std::string failmsg = "";
@@ -254,11 +252,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFive)
results = qry->execute(std::chrono::seconds(2));
LOG("EXECUTE 3 STOP");
+ std::string logmsg = "Result size is " + std::to_string(results->size());
- char logmsg[50] = {0};
- ACE_OS::sprintf(logmsg, "Result size is %zd", results->size());
LOG(logmsg);
-
LOG("Didnt get expected timeout exception for third execute");
FAIL("Didnt get expected timeout exception for third execute");
} catch (const TimeoutException &excp) {
@@ -267,7 +263,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFive)
logmsg += excp.getName();
logmsg += ": ";
logmsg += excp.what();
- LOG(logmsg.c_str());
+ LOG(logmsg);
}
SLEEP(40000); // sleep to allow server query to complete
@@ -297,9 +293,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepSix)
results = qry->execute(std::chrono::seconds(850));
LOG("EXECUTE 4 STOP");
+ std::string logmsg = "Result size is " + std::to_string(results->size());
- char logmsg[50] = {0};
- ACE_OS::sprintf(logmsg, "Result size is %zd", results->size());
LOG(logmsg);
} catch (Exception &excp) {
std::string failmsg = "";
@@ -345,9 +340,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepSeven)
results = qry->execute(paramList, std::chrono::seconds(1));
LOG("EXECUTE Five STOP");
+ std::string logmsg = "Result size is " + std::to_string(results->size());
- char logmsg[50] = {0};
- ACE_OS::sprintf(logmsg, "Result size is %zd", results->size());
LOG(logmsg);
LOG("Didnt get expected timeout exception for fifth execute");
@@ -398,9 +392,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepEight)
results = qry->execute(paramList, std::chrono::seconds(850));
LOG("EXECUTE 6 STOP");
+ std::string logmsg = "Result size is " + std::to_string(results->size());
- char logmsg[50] = {0};
- ACE_OS::sprintf(logmsg, "Result size is %zd", results->size());
LOG(logmsg);
} catch (Exception &excp) {
std::string failmsg = "";
@@ -437,9 +430,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, verifyNegativeValueTimeout)
results = qry->execute(std::chrono::seconds(-3));
LOG("Task::verifyNegativeValueTimeout - EXECUTE 1 STOP");
+ std::string logmsg = "Result size is " + std::to_string(results->size());
- char logmsg[50] = {0};
- ACE_OS::sprintf(logmsg, "Result size is %zd", results->size());
LOG(logmsg);
LOG("Didnt get expected timeout exception for first execute");
@@ -482,9 +474,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, verifyLargeValueTimeout)
results = qry->execute(std::chrono::seconds(2147500));
LOG("Task:: verifyLargeValueTimeout - EXECUTE 1 STOP");
+ std::string logmsg = "Result size is " + std::to_string(results->size());
- char logmsg[50] = {0};
- ACE_OS::sprintf(logmsg, "Result size is %zd", results->size());
LOG(logmsg);
LOG("Didnt get expected timeout exception for first execute");
diff --git a/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp b/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp
index 781ecb7..5b8cf10 100644
--- a/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp
+++ b/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp
@@ -49,7 +49,7 @@ bool isLocalServer = false;
bool isLocator = false;
const char* poolNames[] = {"Pool1", "Pool2", "Pool3"};
-const char* locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
static bool m_isPdx = false;
const char* qRegionNames[] = {"Portfolios", "Positions", "Portfolios2",
@@ -90,6 +90,7 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StepOnePoolLocator)
{
initClient(true);
+ LOG("StepOnePoolLocator");
try {
auto serializationRegistry =
CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
@@ -106,13 +107,12 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepOnePoolLocator)
} catch (const IllegalStateException&) {
// ignore exception
}
- createPool(poolNames[0], locHostPort, nullptr, 0, true);
+ createPool(poolNames[0], locHostPort, {}, 0, true);
createRegionAndAttachPool(qRegionNames[0], USE_ACK, poolNames[0]);
createRegionAndAttachPool(qRegionNames[1], USE_ACK, poolNames[0]);
createRegionAndAttachPool(qRegionNames[2], USE_ACK, poolNames[0]);
-
- createPool(poolNames[1], locHostPort, nullptr, 0, true);
+ createPool(poolNames[1], locHostPort, {}, 0, true);
createRegionAndAttachPool(qRegionNames[3], USE_ACK, poolNames[1]);
auto regptr = getHelper()->getRegion(qRegionNames[0]);
@@ -171,7 +171,6 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
{
bool doAnyErrorOccured = false;
-
auto region = getHelper()->getRegion(qRegionNames[0]);
for (int i = 0; i < QueryStrings::RQsize(); i++) {
@@ -188,14 +187,13 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
continue;
}
- auto results = region->query((regionQueries[i].query()));
+ auto results = region->query(regionQueries[i].query());
if (results->size() != regionQueryRowCounts[i]) {
- char failmsg[100] = {0};
- ACE_OS::sprintf(
- failmsg,
- "FAIL: Query # %d expected result size is %zd, actual is %zd", i,
- regionQueryRowCounts[i], results->size());
+ std::string failmsg = "FAIL: Query #" + std::to_string(i) +
+ " expected result size is " +
+ std::to_string(regionQueryRowCounts[i]) +
+ ", actual is " + std::to_string(results->size());
doAnyErrorOccured = true;
LOG(failmsg);
continue;
@@ -263,11 +261,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
bool expectedResult = regionQueryRowCounts[i] > 0 ? true : false;
if (existsValue != expectedResult) {
- char failmsg[100] = {0};
- ACE_OS::sprintf(
- failmsg,
- "FAIL: Query # %d existsValue expected is %s, actual is %s", i,
- expectedResult ? "true" : "false", existsValue ? "true" : "false");
+ std::string failmsg = "FAIL: Query #" + std::to_string(i) +
+ " existsValue expected is " +
+ (expectedResult ? "true" : "false") +
+ ", actual is " + (existsValue ? "true" : "false");
ASSERT(false, failmsg);
}
}
@@ -323,45 +320,26 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFive)
}
try {
- auto result = region->selectValue((regionQueries[i].query()));
-
- /*
- if (result == nullptr)
- {
- char logmsg[100] = {0};
- ACE_OS::sprintf(logmsg, "Query # %d query selectValue result is
- nullptr", i);
- LOG(logmsg);
- }
- else
- {
- char logmsg[100] = {0};
- ACE_OS::sprintf(logmsg, "Query # %d query selectValue result
- size
- is not nullptr", i);
- LOG(logmsg);
- }
- */
+ auto result = region->selectValue(regionQueries[i].query());
if (!(regionQueryRowCounts[i] == 0 || regionQueryRowCounts[i] == 1)) {
- char logmsg[100] = {0};
- ACE_OS::sprintf(
- logmsg, "FAIL: Query # %d expected query exception did not occur",
- i);
+ std::string logmsg = "FAIL: Query #" + std::to_string(i) +
+ " expected query exception did not occur";
+
LOG(logmsg);
doAnyErrorOccured = true;
}
} catch (const QueryException&) {
if (regionQueryRowCounts[i] == 0 || regionQueryRowCounts[i] == 1) {
- char logmsg[100] = {0};
- ACE_OS::sprintf(
- logmsg, "FAIL: Query # %d unexpected query exception occured", i);
+ std::string logmsg = "FAIL: Query #" + std::to_string(i) +
+ " unexpected query exception occurred";
+
LOG(logmsg);
doAnyErrorOccured = true;
}
} catch (...) {
- char logmsg[100] = {0};
- ACE_OS::sprintf(logmsg,
- "FAIL: Query # %d unexpected exception occurred", i);
+ std::string logmsg = "FAIL: Query #" + std::to_string(i) +
+ " unexpected exception occurred";
+
LOG(logmsg);
FAIL(logmsg);
}
@@ -429,10 +407,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, QueryError)
}
try {
- auto results = region->query((regionQueries[i].query()));
+ auto results = region->query(regionQueries[i].query());
+ std::string failmsg =
+ "Query exception didnt occur for index " + std::to_string(i);
- char failmsg[100] = {0};
- ACE_OS::sprintf(failmsg, "Query exception didnt occur for index %d", i);
LOG(failmsg);
FAIL(failmsg);
} catch (apache::geode::client::QueryException&) {
diff --git a/cppcache/integration-test/testThinClientRemoveOps.cpp b/cppcache/integration-test/testThinClientRemoveOps.cpp
index 336df7a..51af047 100644
--- a/cppcache/integration-test/testThinClientRemoveOps.cpp
+++ b/cppcache/integration-test/testThinClientRemoveOps.cpp
@@ -51,7 +51,7 @@ static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 0;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
void initClient(const bool isthinClient) {
@@ -188,12 +188,14 @@ void createRegion(const char *name, bool ackMode,
LOG("Region created.");
}
-void createPooledRegion(const char *name, bool ackMode, const char *locators,
- const char *poolname,
+void createPooledRegion(const std::string &name, bool ackMode,
+ const std::string &locators,
+ const std::string &poolname,
bool clientNotificationEnabled = false,
bool cachingEnable = true) {
LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name.c_str(),
+ ackMode);
fflush(stdout);
auto regPtr =
getHelper()->createPooledRegion(name, ackMode, locators, poolname,
diff --git a/cppcache/integration-test/testThinClientSecurityAuthentication.cpp b/cppcache/integration-test/testThinClientSecurityAuthentication.cpp
index 6dc29c3..9da1d77 100644
--- a/cppcache/integration-test/testThinClientSecurityAuthentication.cpp
+++ b/cppcache/integration-test/testThinClientSecurityAuthentication.cpp
@@ -28,14 +28,14 @@
using apache::geode::client::testframework::security::CredentialGenerator;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *regionNamesAuth[] = {"DistRegionAck", "DistRegionNoAck"};
std::shared_ptr<CredentialGenerator> credentialGeneratorHandler;
std::string getXmlPath() {
char xmlPath[1000] = {'\0'};
- const char *path = ACE_OS::getenv("TESTSRC");
+ const char *path = std::getenv("TESTSRC");
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
diff --git a/cppcache/integration-test/testThinClientSecurityAuthenticationMU.cpp b/cppcache/integration-test/testThinClientSecurityAuthenticationMU.cpp
index a72fb5c..a920a53 100644
--- a/cppcache/integration-test/testThinClientSecurityAuthenticationMU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityAuthenticationMU.cpp
@@ -31,14 +31,14 @@
using apache::geode::client::testframework::security::CredentialGenerator;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *regionNamesAuth[] = {"DistRegionAck", "DistRegionNoAck"};
std::shared_ptr<CredentialGenerator> credentialGeneratorHandler;
std::string getXmlPath() {
char xmlPath[1000] = {'\0'};
- const char *path = ACE_OS::getenv("TESTSRC");
+ const char *path = std::getenv("TESTSRC");
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
diff --git a/cppcache/integration-test/testThinClientSecurityAuthenticationSetAuthInitialize.cpp b/cppcache/integration-test/testThinClientSecurityAuthenticationSetAuthInitialize.cpp
index 7198bf5..d6e0ff8 100644
--- a/cppcache/integration-test/testThinClientSecurityAuthenticationSetAuthInitialize.cpp
+++ b/cppcache/integration-test/testThinClientSecurityAuthenticationSetAuthInitialize.cpp
@@ -29,14 +29,14 @@ using apache::geode::client::AuthInitialize;
using apache::geode::client::Cacheable;
using apache::geode::client::testframework::security::CredentialGenerator;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *regionNamesAuth[] = {"DistRegionAck", "DistRegionNoAck"};
std::shared_ptr<CredentialGenerator> credentialGeneratorHandler;
std::string getXmlPath() {
char xmlPath[1000] = {'\0'};
- const char *path = ACE_OS::getenv("TESTSRC");
+ const char *path = std::getenv("TESTSRC");
ASSERT(path != NULL,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
@@ -120,7 +120,7 @@ DUNIT_TASK_DEFINITION(LOCATORSERVER, CreateServer1)
printf("Input to server cmd is --> %s",
cmdServerAuthenticator.c_str());
CacheHelper::initServer(
- 1, nullptr, locHostPort,
+ 1, {}, locHostPort,
const_cast<char *>(cmdServerAuthenticator.c_str()));
LOG("Server1 started");
}
diff --git a/cppcache/integration-test/testThinClientSecurityAuthorization.cpp b/cppcache/integration-test/testThinClientSecurityAuthorization.cpp
index cf4aca3..9072576 100644
--- a/cppcache/integration-test/testThinClientSecurityAuthorization.cpp
+++ b/cppcache/integration-test/testThinClientSecurityAuthorization.cpp
@@ -49,13 +49,13 @@ using apache::geode::client::testframework::security::OP_UNREGISTER_INTEREST;
using apache::geode::client::testframework::security::OP_UPDATE;
using apache::geode::client::testframework::security::opCodeList;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
std::shared_ptr<CredentialGenerator> credentialGeneratorHandler;
std::string getXmlPath() {
char xmlPath[1000] = {'\0'};
- const char *path = ACE_OS::getenv("TESTSRC");
+ const char *path = std::getenv("TESTSRC");
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
diff --git a/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp b/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
index 2d2262d..f91f47e 100644
--- a/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
@@ -57,7 +57,7 @@ using apache::geode::client::testframework::security::OP_UNREGISTER_INTEREST;
using apache::geode::client::testframework::security::OP_UPDATE;
using apache::geode::client::testframework::security::opCodeList;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
std::shared_ptr<CredentialGenerator> credentialGeneratorHandler;
@@ -66,7 +66,7 @@ const char *exFuncNameSendException = "executeFunction_SendException";
std::string getXmlPath() {
char xmlPath[1000] = {'\0'};
- const char *path = ACE_OS::getenv("TESTSRC");
+ const char *path = std::getenv("TESTSRC");
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
diff --git a/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp b/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
index 3a388c5..78ba57d 100644
--- a/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
@@ -53,7 +53,7 @@ using apache::geode::client::Exception;
using apache::geode::client::IllegalStateException;
using apache::geode::client::QueryService;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
std::shared_ptr<CredentialGenerator> credentialGeneratorHandler;
#define CLIENT1 s1p1
@@ -139,7 +139,7 @@ class MyCqListener : public CqListener {
std::string getXmlPath() {
char xmlPath[1000] = {'\0'};
- const char *path = ACE_OS::getenv("TESTSRC");
+ const char *path = std::getenv("TESTSRC");
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
@@ -188,7 +188,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, CreateServer1)
"authenticator:authorizer:authorizerPP", getXmlPath());
printf("string %s", cmdServerAuthenticator.c_str());
CacheHelper::initServer(
- 1, "remotequery.xml", nullptr,
+ 1, "remotequery.xml", {},
const_cast<char *>(cmdServerAuthenticator.c_str()));
LOG("Server1 started");
}
diff --git a/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp b/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
index 1b73cd9..6e530e1 100644
--- a/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
@@ -52,7 +52,7 @@ using apache::geode::client::IllegalStateException;
using apache::geode::client::QueryService;
using apache::geode::client::testframework::security::CredentialGenerator;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
std::shared_ptr<CredentialGenerator> credentialGeneratorHandler;
@@ -140,7 +140,7 @@ class MyCqListener : public CqListener {
std::string getXmlPath() {
char xmlPath[1000] = {'\0'};
- const char *path = ACE_OS::getenv("TESTSRC");
+ const char *path = std::getenv("TESTSRC");
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
diff --git a/cppcache/integration-test/testThinClientSecurityPostAuthorization.cpp b/cppcache/integration-test/testThinClientSecurityPostAuthorization.cpp
index a92e224..2ca9f72 100644
--- a/cppcache/integration-test/testThinClientSecurityPostAuthorization.cpp
+++ b/cppcache/integration-test/testThinClientSecurityPostAuthorization.cpp
@@ -36,7 +36,7 @@ using apache::geode::client::HashMapOfCacheable;
using apache::geode::client::HashMapOfException;
using apache::geode::client::NotAuthorizedException;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
#define HANDLE_NO_NOT_AUTHORIZED_EXCEPTION \
@@ -110,17 +110,17 @@ const char *getServerSecurityParams() {
"org.apache.geode.internal.security.FilterPostAuthorization.create "
"log-level=fine security-log-level=finest";
- char *ldapSrv = ACE_OS::getenv("LDAP_SERVER");
+ char *ldapSrv = std::getenv("LDAP_SERVER");
serverSecurityParams += std::string(" security-ldap-server=") +
(ldapSrv != nullptr ? ldapSrv : "ldap");
- char *ldapRoot = ACE_OS::getenv("LDAP_BASEDN");
+ char *ldapRoot = std::getenv("LDAP_BASEDN");
serverSecurityParams +=
std::string(" security-ldap-basedn=") +
(ldapRoot != nullptr ? ldapRoot
: "ou=ldapTesting,dc=ldap,dc=apache,dc=org");
- char *ldapSSL = ACE_OS::getenv("LDAP_USESSL");
+ char *ldapSSL = std::getenv("LDAP_USESSL");
serverSecurityParams += std::string(" security-ldap-usessl=") +
(ldapSSL != nullptr ? ldapSSL : "false");
}
diff --git a/cppcache/integration-test/testThinClientWriterException.cpp b/cppcache/integration-test/testThinClientWriterException.cpp
index 95277ed..4eaf055 100644
--- a/cppcache/integration-test/testThinClientWriterException.cpp
+++ b/cppcache/integration-test/testThinClientWriterException.cpp
@@ -45,7 +45,7 @@ using apache::geode::client::testing::TallyWriter;
std::shared_ptr<TallyListener> regListener;
std::shared_ptr<TallyWriter> regWriter;
-const char *locHostPort =
+const std::string locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
const char *regionNamesAuth[] = {"DistRegionAck"};
@@ -53,7 +53,7 @@ std::shared_ptr<CredentialGenerator> credentialGeneratorHandler;
std::string getXmlPath() {
char xmlPath[1000] = {'\0'};
- const char *path = ACE_OS::getenv("TESTSRC");
+ const char *path = std::getenv("TESTSRC");
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
diff --git a/cppcache/integration-test/testTimedSemaphore.cpp b/cppcache/integration-test/testTimedSemaphore.cpp
index 0c8f542..3cdfb2d 100644
--- a/cppcache/integration-test/testTimedSemaphore.cpp
+++ b/cppcache/integration-test/testTimedSemaphore.cpp
@@ -15,9 +15,12 @@
* limitations under the License.
*/
-#include "fw_helper.hpp"
+#include <iostream>
+
#include <ace/Synch.h>
+#include "fw_helper.hpp"
+
class ThreadAcquire : public ACE_Task_Base {
public:
ThreadAcquire(ACE_Thread_Semaphore &sema, int acquireSecs)
@@ -27,19 +30,30 @@ class ThreadAcquire : public ACE_Task_Base {
m_status(0) {}
int svc() override {
- ACE_Time_Value start = ACE_OS::gettimeofday();
- ACE_Time_Value interval(m_acquireSecs, 0); // 10 seconds
- ACE_Time_Value expireAt = start + interval;
+ auto start = std::chrono::steady_clock::now();
+ ACE_Time_Value expireAt =
+ ACE_Time_Value{time(nullptr)} + ACE_Time_Value{m_acquireSecs};
+
+ std::cout << "Thread acquiring lock at "
+ << std::chrono::time_point_cast<std::chrono::milliseconds>(start)
+ .time_since_epoch()
+ .count()
+ << "msecs" << std::endl;
- printf("Thread acquiring lock at %ld msecs.\n", start.msec());
if (m_sema.acquire(expireAt) == 0) {
- interval = ACE_OS::gettimeofday() - start;
- printf("Thread acquired lock after %ld msecs.\n", interval.msec());
+ auto interval = std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::steady_clock::now() - start)
+ .count();
+ std::cout << "Thread acquired lock after " << interval << "msecs"
+ << std::endl;
m_status = 0;
} else {
- interval = ACE_OS::gettimeofday() - start;
- printf("Thread failed to acquire lock after %ld msecs.\n",
- interval.msec());
+ auto interval = std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::steady_clock::now() - start)
+ .count();
+
+ std::cout << "Thread failed to acquire lock after " << interval << "msecs"
+ << std::endl;
m_status = -1;
}
return m_status;
@@ -62,7 +76,7 @@ BEGIN_TEST(CheckTimedAcquire)
thread->activate();
LOG("Sleeping for 8 secs.");
- ACE_OS::sleep(8);
+ std::this_thread::sleep_for(std::chrono::seconds(8));
ASSERT(thread->thr_count() == 1, "Expected thread to be running.");
sema.release();
SLEEP(50); // Sleep for a few millis for the thread to end.
@@ -82,9 +96,9 @@ BEGIN_TEST(CheckTimedAcquireFail)
thread->activate();
LOG("Sleeping for 8 secs.");
- ACE_OS::sleep(8);
+ std::this_thread::sleep_for(std::chrono::seconds(8));
ASSERT(thread->thr_count() == 1, "Expected thread to be running.");
- ACE_OS::sleep(3);
+ std::this_thread::sleep_for(std::chrono::seconds(3));
ASSERT(thread->thr_count() == 0, "Expected no thread to be running.");
ASSERT(thread->wait() == 0, "Expected successful end of thread.");
ASSERT(thread->getStatus() == -1,
@@ -102,7 +116,7 @@ BEGIN_TEST(CheckNoWait)
sema.release();
thread->activate();
- ACE_OS::sleep(1);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
ASSERT(thread->thr_count() == 0, "Expected no thread to be running.");
ASSERT(thread->wait() == 0, "Expected successful end of thread.");
ASSERT(thread->getStatus() == 0, "Expected zero exit status from thread.");
@@ -117,7 +131,7 @@ BEGIN_TEST(CheckResetAndTimedAcquire)
ThreadAcquire *thread = new ThreadAcquire(sema, 10);
sema.acquire();
- ACE_OS::sleep(1);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
sema.release();
sema.release();
sema.release();
@@ -126,7 +140,7 @@ BEGIN_TEST(CheckResetAndTimedAcquire)
thread->activate();
LOG("Sleeping for 8 secs.");
- ACE_OS::sleep(8);
+ std::this_thread::sleep_for(std::chrono::seconds(8));
ASSERT(thread->thr_count() == 1, "Expected thread to be running.");
sema.release();
SLEEP(50); // Sleep for a few millis for the thread to end.
diff --git a/cppcache/integration-test/testXmlCacheCreationWithOverFlow.cpp b/cppcache/integration-test/testXmlCacheCreationWithOverFlow.cpp
index ea9a1b9..d4e0c46 100644
--- a/cppcache/integration-test/testXmlCacheCreationWithOverFlow.cpp
+++ b/cppcache/integration-test/testXmlCacheCreationWithOverFlow.cpp
@@ -36,7 +36,7 @@ int testXmlCacheCreationWithOverflow() {
const uint32_t totalSubRegionsRoot1 = 2;
const uint32_t totalRootRegions = 2;
- char *path = ACE_OS::getenv("TESTSRC");
+ char *path = std::getenv("TESTSRC");
std::string directory(path);
std::cout << "create DistributedSytem with name=XML_CACHE_CREATION_TEST"
diff --git a/cppcache/integration-test/testXmlCacheCreationWithPools.cpp b/cppcache/integration-test/testXmlCacheCreationWithPools.cpp
index 6f7ef01..52c6580 100644
--- a/cppcache/integration-test/testXmlCacheCreationWithPools.cpp
+++ b/cppcache/integration-test/testXmlCacheCreationWithPools.cpp
@@ -40,7 +40,7 @@ static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 1;
const char *endPoints = nullptr;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
using std::string;
@@ -273,12 +273,11 @@ int testXmlCacheCreationWithPools() {
<< std::endl;
try {
- std::string filePath = "valid_cache_pool.xml";
- std::string duplicateFile;
- CacheHelper::createDuplicateXMLFile(duplicateFile, filePath);
+ auto duplicateFile =
+ CacheHelper::createDuplicateXMLFile("valid_cache_pool.xml");
cptr = std::make_shared<Cache>(
cacheFactory.set("cache-xml-file", duplicateFile).create());
- if (cptr->getPdxIgnoreUnreadFields() != true) {
+ if (!cptr->getPdxIgnoreUnreadFields()) {
std::cout << "getPdxIgnoreUnreadFields should return true." << std::endl;
return -1;
} else {
@@ -417,9 +416,8 @@ int testXmlCacheCreationWithPools() {
try {
std::cout << "Testing invalid pool xml 1" << std::endl;
- std::string filePath = "invalid_cache_pool.xml";
- std::string duplicateFile;
- CacheHelper::createDuplicateXMLFile(duplicateFile, filePath);
+ auto duplicateFile =
+ CacheHelper::createDuplicateXMLFile("invalid_cache_pool.xml");
Cache cache = cacheFactory.set("cache-xml-file", duplicateFile).create();
return -1;
} catch (Exception &ex) {
@@ -430,9 +428,8 @@ int testXmlCacheCreationWithPools() {
try {
std::cout << "Testing invalid pool xml 2" << std::endl;
- std::string filePath = "invalid_cache_pool2.xml";
- std::string duplicateFile;
- CacheHelper::createDuplicateXMLFile(duplicateFile, filePath);
+ auto duplicateFile =
+ CacheHelper::createDuplicateXMLFile("invalid_cache_pool2.xml");
Cache cache = cacheFactory.set("cache-xml-file", duplicateFile).create();
return -1;
} catch (Exception &ex) {
@@ -443,9 +440,8 @@ int testXmlCacheCreationWithPools() {
try {
std::cout << "Testing invalid pool xml 3" << std::endl;
- std::string filePath = "invalid_cache_pool3.xml";
- std::string duplicateFile;
- CacheHelper::createDuplicateXMLFile(duplicateFile, filePath);
+ auto duplicateFile =
+ CacheHelper::createDuplicateXMLFile("invalid_cache_pool3.xml");
Cache cache = cacheFactory.set("cache-xml-file", duplicateFile).create();
return -1;
} catch (Exception &ex) {
@@ -456,9 +452,8 @@ int testXmlCacheCreationWithPools() {
try {
std::cout << "Testing invalid pool xml 4" << std::endl;
- std::string filePath = "invalid_cache_pool4.xml";
- std::string duplicateFile;
- CacheHelper::createDuplicateXMLFile(duplicateFile, filePath);
+ auto duplicateFile =
+ CacheHelper::createDuplicateXMLFile("invalid_cache_pool4.xml");
Cache cache = cacheFactory.set("cache-xml-file", duplicateFile).create();
return -1;
} catch (Exception &ex) {
diff --git a/cppcache/integration-test/testXmlCacheCreationWithRefid.cpp b/cppcache/integration-test/testXmlCacheCreationWithRefid.cpp
index 5d12af4..01e3448 100644
--- a/cppcache/integration-test/testXmlCacheCreationWithRefid.cpp
+++ b/cppcache/integration-test/testXmlCacheCreationWithRefid.cpp
@@ -34,7 +34,7 @@ int testXmlCacheCreationWithRefid(const char *fileName) {
auto cacheFactory = CacheFactory();
std::shared_ptr<Cache> cptr;
- char *path = ACE_OS::getenv("TESTSRC");
+ char *path = std::getenv("TESTSRC");
std::string directory(path);
std::cout << "create DistributedSytem with name=XML_CACHE_CREATION_TEST"
diff --git a/cppcache/integration-test/testXmlCacheInitialization.cpp b/cppcache/integration-test/testXmlCacheInitialization.cpp
index 21b3030..bbad55a 100644
--- a/cppcache/integration-test/testXmlCacheInitialization.cpp
+++ b/cppcache/integration-test/testXmlCacheInitialization.cpp
@@ -38,7 +38,7 @@ static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 1;
const char *endPoints = nullptr;
-const char *locatorsG =
+const std::string locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
#include "LocatorHelper.hpp"
@@ -47,7 +47,7 @@ int testXmlDeclarativeCacheCreation() {
auto cacheFactory = CacheFactory();
std::shared_ptr<Cache> cptr;
- std::string directory(ACE_OS::getenv("TESTSRC"));
+ std::string directory(std::getenv("TESTSRC"));
std::cout
<< "create DistributedSytem with name=XML_DECLARATIVE_CACHE_CREATION_TEST"
@@ -122,9 +122,8 @@ int testSetCacheXmlThenGetRegion() {
<< std::endl;
try {
- std::string filePath = "valid_cache_pool.xml";
- std::string duplicateFile;
- CacheHelper::createDuplicateXMLFile(duplicateFile, filePath);
+ auto duplicateFile =
+ CacheHelper::createDuplicateXMLFile("valid_cache_pool.xml");
cptr = std::make_shared<Cache>(
cacheFactory.set("enable-time-statistics", "false")
diff --git a/cppcache/src/DistributedSystemImpl.cpp b/cppcache/src/DistributedSystemImpl.cpp
index ef9ebb8..778c61e 100644
--- a/cppcache/src/DistributedSystemImpl.cpp
+++ b/cppcache/src/DistributedSystemImpl.cpp
@@ -79,11 +79,8 @@ void DistributedSystemImpl::logSystemInformation() const {
LOGCONFIG("Source revision: %s", PRODUCT_SOURCE_REVISION);
LOGCONFIG("Source repository: %s", PRODUCT_SOURCE_REPOSITORY);
- ACE_utsname u;
- ACE_OS::uname(&u);
- LOGCONFIG(
- "Running on: SystemName=%s Machine=%s Host=%s Release=%s Version=%s",
- u.sysname, u.machine, u.nodename, u.release, u.version);
+ auto sysinfo = Utils::getSystemInfo();
+ LOGCONFIG("Running on: %s", sysinfo.c_str());
LOGCONFIG("Current directory: %s",
boost::filesystem::current_path().string().c_str());
LOGCONFIG("Current value of PATH: %s", Utils::getEnv("PATH").c_str());
diff --git a/cppcache/src/ReadWriteLock.cpp b/cppcache/src/ReadWriteLock.cpp
index 6502668..18668ba 100644
--- a/cppcache/src/ReadWriteLock.cpp
+++ b/cppcache/src/ReadWriteLock.cpp
@@ -17,6 +17,8 @@
#include "ReadWriteLock.hpp"
+#include <thread>
+
namespace apache {
namespace geode {
namespace client {
@@ -29,7 +31,7 @@ TryReadGuard::TryReadGuard(ACE_RW_Thread_Mutex& lock,
isAcquired_ = true;
break;
}
- ACE_OS::thr_yield();
+ std::this_thread::yield();
} while (!exitCondition);
}
@@ -41,7 +43,7 @@ TryWriteGuard::TryWriteGuard(ACE_RW_Thread_Mutex& lock,
isAcquired_ = true;
break;
}
- ACE_OS::thr_yield();
+ std::this_thread::yield();
} while (!exitCondition);
}
diff --git a/cppcache/src/TcrEndpoint.cpp b/cppcache/src/TcrEndpoint.cpp
index 6b3f75d..5ec3c3c 100644
--- a/cppcache/src/TcrEndpoint.cpp
+++ b/cppcache/src/TcrEndpoint.cpp
@@ -721,19 +721,23 @@ inline bool TcrEndpoint::compareTransactionIds(int32_t reqTransId,
inline bool TcrEndpoint::handleIOException(const std::string& message,
TcrConnection*& conn, bool) {
- int32_t lastError = ACE_OS::last_error();
- if (lastError == ECONNRESET || lastError == EPIPE || lastError == ENOTCONN) {
+ auto last_error = Utils::getLastError();
+ auto last_error_val = last_error.value();
+ if (last_error_val == ECONNRESET || last_error_val == EPIPE ||
+ last_error_val == ENOTCONN) {
_GEODE_SAFE_DELETE(conn);
} else {
closeConnection(conn);
}
+
LOGFINE(
"IO error during send for endpoint %s "
"[errno: %d: %s]: %s",
- m_name.c_str(), lastError, ACE_OS::strerror(lastError), message.c_str());
+ m_name.c_str(), last_error.value(), last_error.message().c_str(),
+ message.c_str());
// EAGAIN =11, EWOULDBLOCK = 10035L, EPIPE = 32, ECONNRESET =10054L(An
// existing connection was forcibly closed by the remote host.)
- if (!(lastError == EAGAIN || lastError == EWOULDBLOCK /*||
+ if (!(last_error_val == EAGAIN || last_error_val == EWOULDBLOCK /*||
lastError == ECONNRESET */
/*|| lastError == EPIPE*/)) {
// break from enclosing loop without retries
@@ -741,6 +745,7 @@ inline bool TcrEndpoint::handleIOException(const std::string& message,
m_needToConnectInLock = true;
return false;
}
+
std::this_thread::sleep_for(std::chrono::milliseconds(10));
return true;
}
diff --git a/cppcache/src/Utils.cpp b/cppcache/src/Utils.cpp
index f20d15f..5bbc806 100644
--- a/cppcache/src/Utils.cpp
+++ b/cppcache/src/Utils.cpp
@@ -27,6 +27,9 @@
#include <boost/asio.hpp>
#include <boost/dll/import.hpp>
#include <boost/dll/runtime_symbol_info.hpp>
+#include <boost/process/detail/config.hpp>
+
+#include "config.h"
namespace apache {
namespace geode {
@@ -40,6 +43,14 @@ std::string Utils::getEnv(const char* varName) {
return env;
}
+std::error_code Utils::getLastError() {
+ if (errno != 0) {
+ return std::error_code(errno, std::system_category());
+ }
+
+ return boost::process::detail::get_last_error();
+}
+
void Utils::parseEndpointString(const char* endpoints, std::string& host,
uint16_t& port) {
std::string endpointsStr(endpoints);
@@ -92,14 +103,11 @@ std::string Utils::convertHostToCanonicalForm(const char* endpoints) {
return "";
}
hostString = endpoint;
- port = atoi(endpointsStr.c_str());
- if (strcmp(hostString.c_str(), "localhost") == 0) {
- ACE_OS::hostname(hostName, sizeof(hostName) - 1);
- struct hostent* host;
- host = ACE_OS::gethostbyname(hostName);
- if (host) {
- std::snprintf(fullName, sizeof(fullName), "%s:%d", host->h_name, port);
- return fullName;
+ port = std::stoi(endpointsStr);
+ if (hostString == "localhost") {
+ auto hostname = boost::asio::ip::host_name();
+ if (auto host = ::gethostbyname(hostname.c_str())) {
+ return std::string{host->h_name} + ':' + std::to_string(port);
}
} else {
pos = endpointsStr1.find('.', 0);
@@ -240,6 +248,88 @@ void Utils::updateStatOpTime(statistics::Statistics* m_regionStats,
m_regionStats->incLong(statId, startStatOpTime() - start);
}
+std::string Utils::getSystemInfo() {
+ std::string sysname{"Unknown"};
+ std::string machine{"Unknown"};
+ std::string nodename{"Unknown"};
+ std::string release{"Unknown"};
+ std::string version{"Unknown"};
+
+#if defined(HAVE_uname)
+ struct utsname name;
+ auto rc = ::uname(&name);
+ if (rc == 0) {
+ sysname = name.sysname;
+ machine = name.machine;
+ nodename = name.nodename;
+ release = name.release;
+ version = name.version;
+ }
+#elif defined(_WIN32) /* HAVE_uname */
+ sysname = "Win32";
+
+/* Since MS found it necessary to deprecate these. */
+#pragma warning(push)
+#pragma warning(disable : 4996)
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif /* __clang__ */
+ OSVERSIONINFOA vinfo;
+ vinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
+ ::GetVersionExA(&vinfo);
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif /* __clang__ */
+#pragma warning(pop)
+
+ if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
+ // Get information from the two structures
+ release = "Windows NT " + std::to_string(vinfo.dwMajorVersion) + '.' +
+ std::to_string(vinfo.dwMinorVersion);
+ version = "Build " + std::to_string(vinfo.dwBuildNumber) + ' ' +
+ vinfo.szCSDVersion;
+ }
+
+ {
+ HKEY key;
+ DWORD size = 0;
+ DWORD type = 0;
+ auto key_name = "ProcessorNameString";
+ auto key_path = "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0";
+ auto rc = ::RegOpenKeyExA(HKEY_LOCAL_MACHINE, key_path, 0, KEY_READ, &key);
+ if (rc == ERROR_SUCCESS) {
+ rc = ::RegQueryValueExA(key, key_name, nullptr, &type, nullptr, &size);
+ if (rc == ERROR_SUCCESS && type == REG_SZ && size > 0) {
+ std::vector<char> buffer(size, 0);
+ auto ptr = reinterpret_cast<LPBYTE>(buffer.data());
+ rc = ::RegQueryValueExA(key, key_name, nullptr, &type, ptr, &size);
+ if (rc == ERROR_SUCCESS && buffer[0] != '\0') {
+ machine = buffer.data();
+ }
+ }
+
+ ::RegCloseKey(key);
+ }
+ }
+
+ nodename = boost::asio::ip::host_name();
+#endif /* _WIN32 */
+
+ std::string info = "SystemName=";
+ info += sysname;
+ info += " Machine=";
+ info += machine;
+ info += " Host=";
+ info += nodename;
+ info += " Release=";
+ info += release;
+ info += " Version=";
+ info += version;
+
+ return info;
+}
+
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/Utils.hpp b/cppcache/src/Utils.hpp
index ac9727f..bf61958 100644
--- a/cppcache/src/Utils.hpp
+++ b/cppcache/src/Utils.hpp
@@ -59,6 +59,8 @@ class APACHE_GEODE_EXPORT Utils {
*/
static std::string getEnv(const char* varName);
+ static std::error_code getLastError();
+
#ifdef __GNUC__
inline static char* _gnuDemangledName(const char* typeIdName, size_t& len) {
int status;
@@ -156,6 +158,8 @@ class APACHE_GEODE_EXPORT Utils {
static std::string convertHostToCanonicalForm(const char* endpoints);
+ static std::string getSystemInfo();
+
static char* copyString(const char* str);
/**
diff --git a/cppcache/src/config.h.in b/cppcache/src/config.h.in
index 3fb636a..fa51c86 100644
--- a/cppcache/src/config.h.in
+++ b/cppcache/src/config.h.in
@@ -29,6 +29,7 @@
#cmakedefine HAVE_pthread_setname_np
#endif
+#cmakedefine HAVE_uname
#cmakedefine HAVE_SIGSTKFLT
#cmakedefine HAVE_ACE_Select_Reactor
diff --git a/dependencies/boost/CMakeLists.txt b/dependencies/boost/CMakeLists.txt
index 11f20b5..c6ea853 100644
--- a/dependencies/boost/CMakeLists.txt
+++ b/dependencies/boost/CMakeLists.txt
@@ -28,6 +28,7 @@ set(B2_FLAGS
--prefix=<INSTALL_DIR>/$<CONFIG>
--with-system
--with-log
+ --with-iostreams
--layout=system
address-model=${BUILD_BITS}
link=static
@@ -135,6 +136,7 @@ find_package(Threads REQUIRED)
add_boost_library(system DEPENDENCIES Boost::boost)
add_boost_library(atomic DEPENDENCIES Boost::boost)
+add_boost_library(iostreams DEPENDENCIES Boost::boost)
add_boost_library(thread DEPENDENCIES Threads::Threads Boost::atomic Boost::boost)
add_boost_library(filesystem DEPENDENCIES Boost::system Boost::boost)
add_boost_library(log DEPENDENCIES Boost::thread Boost::filesystem Boost::boost)