You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2017/03/15 17:51:35 UTC
[34/34] geode-native git commit: GEODE-2552: Removed NanoTimer
GEODE-2552: Removed NanoTimer
- Replaced millisleep with std::this_thread::sleep_for.
Project: http://git-wip-us.apache.org/repos/asf/geode-native/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode-native/commit/e0145ace
Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/e0145ace
Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/e0145ace
Branch: refs/heads/feature/GEODE-2602
Commit: e0145aced70d9659b286df4762a00940dccefa4d
Parents: 786fff8
Author: Jacob Barrett <jb...@pivotal.io>
Authored: Sun Feb 26 15:12:18 2017 -0800
Committer: Jacob Barrett <jb...@pivotal.io>
Committed: Wed Mar 15 10:44:24 2017 -0700
----------------------------------------------------------------------
src/cppcache/include/geode/geode_globals.hpp | 2 -
.../integration-test/ThinClientDurable.hpp | 23 +++++----
.../ThinClientDurableFailover.hpp | 21 ++++----
.../ThinClientDurableInterest.hpp | 15 +++---
.../testThinClientConflation.cpp | 11 ++--
.../testThinClientCqDurable.cpp | 10 ++--
.../testThinClientHAEventIDMap.cpp | 22 ++++----
.../testThinClientHAPeriodicAck.cpp | 18 ++++---
src/cppcache/src/EvictionController.cpp | 19 ++++---
src/cppcache/src/LocalRegion.cpp | 21 ++++----
src/cppcache/src/Log.cpp | 6 ++-
src/cppcache/src/NanoTimer.cpp | 53 --------------------
src/cppcache/src/NanoTimer.hpp | 39 --------------
src/cppcache/src/TcrConnectionManager.cpp | 14 ++++--
src/cppcache/src/TcrEndpoint.cpp | 18 +++++--
src/cppcache/src/Utils.cpp | 9 +++-
src/cppcache/src/Utils.hpp | 1 -
src/cppcache/test/NanoTimerTest.cpp | 30 -----------
src/quickstart/cpp/DurableClient.cpp | 2 +-
19 files changed, 127 insertions(+), 207 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/include/geode/geode_globals.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/geode_globals.hpp b/src/cppcache/include/geode/geode_globals.hpp
index 2ca7e3d..95d62a5 100644
--- a/src/cppcache/include/geode/geode_globals.hpp
+++ b/src/cppcache/include/geode/geode_globals.hpp
@@ -122,8 +122,6 @@ namespace apache {
namespace geode {
namespace client {
-extern void CPPCACHE_EXPORT millisleep(uint32_t millis);
-
#ifdef _WIN32
extern void CPPCACHE_EXPORT setNewAndDelete(pNew, pDelete);
#endif
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/integration-test/ThinClientDurable.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientDurable.hpp b/src/cppcache/integration-test/ThinClientDurable.hpp
index 4b08cbc..5270b67 100644
--- a/src/cppcache/integration-test/ThinClientDurable.hpp
+++ b/src/cppcache/integration-test/ThinClientDurable.hpp
@@ -29,6 +29,9 @@
#include "fw_dunit.hpp"
#include "ThinClientHelper.hpp"
+#include <thread>
+#include <chrono>
+
/* Testing Parameters Param's Value
Termination : Keepalive = true/ false, Client crash / Netdown
Restart Time: Before Timeout / After Timeout
@@ -61,7 +64,7 @@ class OperMonitor : public CacheListener {
CacheableInt32Ptr value = NULLPTR;
try {
value = dynCast<CacheableInt32Ptr>(event.getNewValue());
- } catch (Exception) {
+ } catch (Exception&) {
// do nothing.
}
@@ -203,22 +206,22 @@ void feederUpdate(int value, int ignoreR2 = false) {
continue;
}
createIntEntry(regionNames[regIdx], mixKeys[0], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
createIntEntry(regionNames[regIdx], mixKeys[1], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
createIntEntry(regionNames[regIdx], mixKeys[2], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
createIntEntry(regionNames[regIdx], mixKeys[3], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
destroyEntry(regionNames[regIdx], mixKeys[0]);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
destroyEntry(regionNames[regIdx], mixKeys[1]);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
destroyEntry(regionNames[regIdx], mixKeys[2]);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
destroyEntry(regionNames[regIdx], mixKeys[3]);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
@@ -320,7 +323,7 @@ DUNIT_TASK_DEFINITION(FEEDER, FeederUpdate1)
feederUpdate(1);
// Wait 5 seconds for events to be removed from ha queues.
- apache::geode::client::millisleep(5000);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
LOG("FeederUpdate1 complete.");
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/integration-test/ThinClientDurableFailover.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientDurableFailover.hpp b/src/cppcache/integration-test/ThinClientDurableFailover.hpp
index f06510e..10a0a31 100644
--- a/src/cppcache/integration-test/ThinClientDurableFailover.hpp
+++ b/src/cppcache/integration-test/ThinClientDurableFailover.hpp
@@ -29,6 +29,9 @@
#include "fw_dunit.hpp"
#include "ThinClientHelper.hpp"
+#include <thread>
+#include <chrono>
+
/* Testing Parameters Param's Value
Termination : Keepalive = true/ false, Client crash
Restart Time: Before Timeout / After Timeout
@@ -59,7 +62,7 @@ class OperMonitor : public CacheListener {
CacheableInt32Ptr value = NULLPTR;
try {
value = dynCast<CacheableInt32Ptr>(event.getNewValue());
- } catch (Exception) {
+ } catch (Exception&) {
// do nothing.
}
@@ -177,21 +180,21 @@ void initClientCache(int redundancy, int durableTimeout, OperMonitorPtr& mon,
// for R =1 it will get a redundancy error
try {
regPtr0->registerRegex(testRegex[0], true);
- } catch (Exception) {
+ } catch (Exception&) {
// do nothing.
}
try {
regPtr0->registerRegex(testRegex[1], false);
- } catch (Exception) {
+ } catch (Exception&) {
// do nothing.
}
}
void feederUpdate(int value) {
createIntEntry(regionNames[0], mixKeys[0], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
createIntEntry(regionNames[0], mixKeys[1], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
/* Close Client 1 with option keep alive = true*/
@@ -226,7 +229,7 @@ DUNIT_TASK_DEFINITION(SERVER1, StartServer2)
}
// sleep for 3 seconds to allow redundancy monitor to detect new server.
- apache::geode::client::millisleep(3000);
+ std::this_thread::sleep_for(std::chrono::seconds(3));
LOG("SERVER started");
}
END_TASK_DEFINITION
@@ -254,7 +257,7 @@ DUNIT_TASK_DEFINITION(FEEDER, FeederUpdate1)
feederUpdate(1);
// Wait 5 seconds for events to be removed from ha queues.
- apache::geode::client::millisleep(5000);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
LOG("FeederUpdate1 complete.");
}
@@ -265,7 +268,7 @@ DUNIT_TASK_DEFINITION(FEEDER, FeederUpdate2)
feederUpdate(2);
// Wait 5 seconds for events to be removed from ha queues.
- apache::geode::client::millisleep(5000);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
LOG("FeederUpdate2 complete.");
}
@@ -314,7 +317,7 @@ DUNIT_TASK_DEFINITION(SERVER1, CloseServer1)
{
CacheHelper::closeServer(1);
// Wait 2 seconds to allow client failover.
- apache::geode::client::millisleep(2000);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
LOG("SERVER closed");
}
END_TASK_DEFINITION
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/integration-test/ThinClientDurableInterest.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientDurableInterest.hpp b/src/cppcache/integration-test/ThinClientDurableInterest.hpp
index 24c75e4..e6286b6 100644
--- a/src/cppcache/integration-test/ThinClientDurableInterest.hpp
+++ b/src/cppcache/integration-test/ThinClientDurableInterest.hpp
@@ -29,6 +29,9 @@
#include "fw_dunit.hpp"
#include "ThinClientHelper.hpp"
+#include <thread>
+#include <chrono>
+
/* This is to test
1- If client doesn't do explicit registration on reconnect, durable events shud
be recieved.
@@ -186,21 +189,21 @@ void initClientRemoveIntrest(int ClientIdx, OperMonitorPtr mon) {
void feederUpdate(int value) {
createIntEntry(regionNames[0], mixKeys[0], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
createIntEntry(regionNames[0], mixKeys[1], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
void feederUpdate1(int value) {
createIntEntry(regionNames[0], mixKeys[0], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
createIntEntry(regionNames[0], mixKeys[1], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
createIntEntry(regionNames[1], mixKeys[2], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
createIntEntry(regionNames[1], mixKeys[3], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
DUNIT_TASK_DEFINITION(FEEDER, FeederInit)
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/integration-test/testThinClientConflation.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientConflation.cpp b/src/cppcache/integration-test/testThinClientConflation.cpp
index 7b0a08a..57b2297 100644
--- a/src/cppcache/integration-test/testThinClientConflation.cpp
+++ b/src/cppcache/integration-test/testThinClientConflation.cpp
@@ -18,6 +18,9 @@
#include "fw_dunit.hpp"
#include "ThinClientHelper.hpp"
+#include <thread>
+#include <chrono>
+
/* Testing Parameters Param's Value
Server Conflation: on / off
Client side conflation setting on/ off / server / not set
@@ -176,7 +179,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, ValidateClient1Conflation)
{
// Client Already Initiated , Send Client Ready and wait
getHelper()->cachePtr->readyForEvents();
- apache::geode::client::millisleep(5000);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
mon1C1->validate(true);
LOG("Client 1 region 1 verified for conflation = true");
@@ -191,7 +194,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, ValidateClient2Conflation)
{
// Client Already Initiated , Send Client Ready and wait
getHelper()->cachePtr->readyForEvents();
- apache::geode::client::millisleep(5000);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
mon1C2->validate(false);
LOG("Client 2 region 1 verified for conflation = false");
@@ -227,7 +230,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, ValidateClient1Server)
{
// Client Already Initiated , Send Client Ready and wait
getHelper()->cachePtr->readyForEvents();
- apache::geode::client::millisleep(5000);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
mon1C1->validate(true);
LOG("Client 1 region 1 verified for conflation = server");
@@ -242,7 +245,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, ValidateClient2None)
{
// Client Already Initiated , Send Client Ready and wait
getHelper()->cachePtr->readyForEvents();
- apache::geode::client::millisleep(5000);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
mon1C2->validate(true);
LOG("Client 2 region 1 verified for no conflation setting");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/integration-test/testThinClientCqDurable.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientCqDurable.cpp b/src/cppcache/integration-test/testThinClientCqDurable.cpp
index 862795a..6ed73a1 100644
--- a/src/cppcache/integration-test/testThinClientCqDurable.cpp
+++ b/src/cppcache/integration-test/testThinClientCqDurable.cpp
@@ -24,6 +24,8 @@
#include <ace/OS.h>
#include <ace/High_Res_Timer.h>
#include <string>
+#include <thread>
+#include <chrono>
#define ROOT_SCOPE DISTRIBUTED_ACK
@@ -216,7 +218,7 @@ void RunDurableCqClient() {
// execute Cq Query
qry->execute();
- apache::geode::client::millisleep(10000);
+ std::this_thread::sleep_for(std::chrono::seconds(10));
LOGINFO("Executed new CqQuery");
@@ -227,7 +229,7 @@ void RunDurableCqClient() {
LOGINFO("Sent ReadyForEvents message to server");
// wait for some time to recieve events
- apache::geode::client::millisleep(10000);
+ std::this_thread::sleep_for(std::chrono::seconds(10));
// Close the Geode Cache with keepalive = true. Server will queue events
// for
@@ -263,7 +265,7 @@ void RunFeederClient() {
regionPtr->put(keyPtr, valPtr);
}
- apache::geode::client::millisleep(10000);
+ std::this_thread::sleep_for(std::chrono::seconds(10));
LOGINFO("put on 0-10 keys done.");
// Close the Geode Cache
@@ -296,7 +298,7 @@ void RunFeederClient1() {
regionPtr->put(keyPtr, valPtr);
}
- apache::geode::client::millisleep(10000);
+ std::this_thread::sleep_for(std::chrono::seconds(10));
LOGINFO("put on 0-10 keys done.");
// Close the Geode Cache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/integration-test/testThinClientHAEventIDMap.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientHAEventIDMap.cpp b/src/cppcache/integration-test/testThinClientHAEventIDMap.cpp
index 449a95a..167ea1f 100644
--- a/src/cppcache/integration-test/testThinClientHAEventIDMap.cpp
+++ b/src/cppcache/integration-test/testThinClientHAEventIDMap.cpp
@@ -20,6 +20,8 @@
#include <ace/OS.h>
#include <string>
+#include <thread>
+#include <chrono>
#define ROOT_NAME "testThinClientHAEventIDMap"
#define ROOT_SCOPE DISTRIBUTED_ACK
@@ -485,21 +487,21 @@ DUNIT_TASK_DEFINITION(CLIENT1, CreateEntries)
{
for (int value = 1; value <= 100; value++) {
createIntEntry(regionNames[0], keys[0], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
createIntEntry(regionNames[0], keys[1], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
createIntEntry(regionNames[0], keys[2], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
createIntEntry(regionNames[0], keys[3], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
createIntEntry(regionNames[1], keys[0], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
createIntEntry(regionNames[1], keys[1], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
createIntEntry(regionNames[1], keys[2], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
createIntEntry(regionNames[1], keys[3], value);
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
END_TASK_DEFINITION
@@ -515,8 +517,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, VerifyClient2Entries)
{
- apache::geode::client::millisleep(
- 30000); // wait 30 sec for notifications to complete
+ // wait 30 sec for notifications to complete
+ std::this_thread::sleep_for(std::chrono::seconds(30));
verifyIntEntry(regionNames[0], keys[0], 100);
verifyIntEntry(regionNames[0], keys[1], 100);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/integration-test/testThinClientHAPeriodicAck.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientHAPeriodicAck.cpp b/src/cppcache/integration-test/testThinClientHAPeriodicAck.cpp
index 6b4a82a..0ae6a40 100644
--- a/src/cppcache/integration-test/testThinClientHAPeriodicAck.cpp
+++ b/src/cppcache/integration-test/testThinClientHAPeriodicAck.cpp
@@ -20,6 +20,8 @@
#include <ace/OS.h>
#include <string>
+#include <thread>
+#include <chrono>
#define ROOT_NAME "testThinClientHAPeriodicAck"
#define ROOT_SCOPE DISTRIBUTED_ACK
@@ -489,21 +491,21 @@ DUNIT_TASK_DEFINITION(CLIENT1, CreateEntries)
{
for (int value = 1; value <= 100; value++) {
createIntEntry(regionNames[0], keys[0], value);
- apache::geode::client::millisleep(50);
+ std::this_thread::sleep_for(std::chrono::milliseconds(50));
createIntEntry(regionNames[0], keys[1], value);
- apache::geode::client::millisleep(50);
+ std::this_thread::sleep_for(std::chrono::milliseconds(50));
createIntEntry(regionNames[0], keys[2], value);
- apache::geode::client::millisleep(50);
+ std::this_thread::sleep_for(std::chrono::milliseconds(50));
createIntEntry(regionNames[0], keys[3], value);
- apache::geode::client::millisleep(50);
+ std::this_thread::sleep_for(std::chrono::milliseconds(50));
createIntEntry(regionNames[1], keys[0], value);
- apache::geode::client::millisleep(50);
+ std::this_thread::sleep_for(std::chrono::milliseconds(50));
createIntEntry(regionNames[1], keys[1], value);
- apache::geode::client::millisleep(50);
+ std::this_thread::sleep_for(std::chrono::milliseconds(50));
createIntEntry(regionNames[1], keys[2], value);
- apache::geode::client::millisleep(50);
+ std::this_thread::sleep_for(std::chrono::milliseconds(50));
createIntEntry(regionNames[1], keys[3], value);
- apache::geode::client::millisleep(50);
+ std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
}
END_TASK_DEFINITION
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/src/EvictionController.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/EvictionController.cpp b/src/cppcache/src/EvictionController.cpp
index dada43f..24da390 100644
--- a/src/cppcache/src/EvictionController.cpp
+++ b/src/cppcache/src/EvictionController.cpp
@@ -23,7 +23,9 @@
#include "ReadWriteLock.hpp"
#include <string>
-using namespace apache::geode::client;
+namespace apache {
+namespace geode {
+namespace client {
const char* EvictionController::NC_EC_Thread = "NC EC Thread";
EvictionController::EvictionController(size_t maxHeapSize,
@@ -54,7 +56,7 @@ int EvictionController::svc() {
int64_t pendingEvictions = 0;
while (m_run) {
int64_t readInfo = 0;
- readInfo = (int64_t)m_queue.get(1500);
+ readInfo = m_queue.get(1500);
if (readInfo == 0) continue;
processHeapInfo(readInfo, pendingEvictions);
@@ -62,7 +64,7 @@ int EvictionController::svc() {
int32_t size = m_queue.size();
for (int i = 0; i < size; i++) {
int64_t readInfo = 0;
- readInfo = (int64_t)m_queue.get();
+ readInfo = m_queue.get();
if (readInfo == 0) continue;
processHeapInfo(readInfo, pendingEvictions);
}
@@ -104,8 +106,6 @@ void EvictionController::processHeapInfo(int64_t& readInfo,
pendingEvictions += bytesToEvict;
if (evictionPercentage > 100) evictionPercentage = 100;
orderEvictions(evictionPercentage);
- // Sleep for 10 seconds to allow the evictions to catch up
- // apache::geode::client::millisleep(10); //taken this out for now
}
}
@@ -120,7 +120,7 @@ void EvictionController::deregisterRegion(std::string& name) {
// Iterate over regions vector and remove the one that we need to remove
WriteGuard guard(m_regionLock);
for (size_t i = 0; i < m_regions.size(); i++) {
- std::string str = (std::string)m_regions.at(i);
+ std::string str = m_regions.at(i);
if (str == name) {
std::vector<std::string>::iterator iter = m_regions.begin();
m_regions.erase(iter + i);
@@ -149,12 +149,12 @@ void EvictionController::evict(int32_t percentage) {
{
ReadGuard guard(m_regionLock);
for (size_t i = 0; i < m_regions.size(); i++) {
- regionTmpVector.push_back((std::string)m_regions.at(i));
+ regionTmpVector.push_back(m_regions.at(i));
}
}
for (size_t i = 0; i < regionTmpVector.size(); i++) {
- std::string str = (std::string)regionTmpVector.at(i);
+ std::string str = regionTmpVector.at(i);
RegionPtr rptr;
m_cacheImpl->getRegion(str.c_str(), rptr);
if (rptr != NULLPTR) {
@@ -165,3 +165,6 @@ void EvictionController::evict(int32_t percentage) {
}
}
}
+} // namespace client
+} // namespace geode
+} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/src/LocalRegion.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/LocalRegion.cpp b/src/cppcache/src/LocalRegion.cpp
index 5e61580..4fe4ab0 100644
--- a/src/cppcache/src/LocalRegion.cpp
+++ b/src/cppcache/src/LocalRegion.cpp
@@ -21,7 +21,6 @@
#include "CacheImpl.hpp"
#include "CacheRegionHelper.hpp"
#include "CacheableToken.hpp"
-#include "NanoTimer.hpp"
#include "Utils.hpp"
#include "EntryExpiryHandler.hpp"
@@ -34,7 +33,9 @@
#include <vector>
#include <geode/PoolManager.hpp>
-using namespace apache::geode::client;
+namespace apache {
+namespace geode {
+namespace client {
LocalRegion::LocalRegion(const std::string& name, CacheImpl* cache,
RegionInternal* rPtr,
@@ -648,7 +649,7 @@ void LocalRegion::setRegionExpiryTask() {
uint32_t duration = getRegionExpiryDuration();
RegionExpiryHandler* handler =
new RegionExpiryHandler(rptr, getRegionExpiryAction(), duration);
- long expiryTaskId =
+ int64_t expiryTaskId =
CacheImpl::expiryTaskManager->scheduleExpiryTask(handler, duration, 0);
handler->setExpiryTaskId(expiryTaskId);
LOGFINE(
@@ -667,7 +668,7 @@ void LocalRegion::registerEntryExpiryTask(MapEntryImplPtr& entry) {
uint32_t duration = getEntryExpiryDuration();
EntryExpiryHandler* handler =
new EntryExpiryHandler(rptr, entry, getEntryExpirationAction(), duration);
- long id =
+ int64_t id =
CacheImpl::expiryTaskManager->scheduleExpiryTask(handler, duration, 0);
if (Log::finestEnabled()) {
CacheableKeyPtr key;
@@ -1034,9 +1035,6 @@ GfErrType LocalRegion::getAllNoThrow(const VectorOfCacheableKey& keys,
return err;
}
-namespace apache {
-namespace geode {
-namespace client {
// encapsulates actions that need to be taken for a put() operation
class PutActions {
public:
@@ -1603,9 +1601,6 @@ class InvalidateActions {
private:
LocalRegion& m_region;
};
-} // namespace client
-} // namespace geode
-} // namespace apache
template <typename TAction>
GfErrType LocalRegion::updateNoThrow(const CacheableKeyPtr& key,
@@ -3107,7 +3102,7 @@ void LocalRegion::evict(int32_t percentage) {
if (m_released || m_destroyPending) return;
if (m_entries != NULL) {
int32_t size = m_entries->size();
- int32_t entriesToEvict = (int32_t)(percentage * size) / 100;
+ int32_t entriesToEvict = (percentage * size) / 100;
// only invoked from EvictionController so static_cast is always safe
LRUEntriesMap* lruMap = static_cast<LRUEntriesMap*>(m_entries);
LOGINFO("Evicting %d entries. Current entry count is %d", entriesToEvict,
@@ -3160,3 +3155,7 @@ CacheablePtr LocalRegion::handleReplay(GfErrType& err,
}
TombstoneListPtr LocalRegion::getTombstoneList() { return m_tombstoneList; }
+
+} // namespace client
+} // namespace geode
+} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/src/Log.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/Log.cpp b/src/cppcache/src/Log.cpp
index 894f041..ce8d66b 100644
--- a/src/cppcache/src/Log.cpp
+++ b/src/cppcache/src/Log.cpp
@@ -21,6 +21,8 @@
#include <string>
#include <utility>
#include <vector>
+#include <thread>
+#include <chrono>
#include <ace/ACE.h>
#include <ace/Guard_T.h>
@@ -370,7 +372,7 @@ void Log::init(LogLevel level, const char* logFileName, int32_t logFileLimit,
break;
}
// continue after some sleep
- apache::geode::client::millisleep(200);
+ std::this_thread::sleep_for(std::chrono::milliseconds(200));
}
/* (don't throw exception; try appending to existing file instead)
if (renameResult < 0) {
@@ -435,7 +437,7 @@ void Log::writeBanner() {
break;
}
// continue after some sleep
- apache::geode::client::millisleep(200);
+ std::this_thread::sleep_for(std::chrono::milliseconds(200));
}
if (!g_log) {
g_isLogFileOpened = false;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/src/NanoTimer.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/NanoTimer.cpp b/src/cppcache/src/NanoTimer.cpp
deleted file mode 100644
index 25ec2e4..0000000
--- a/src/cppcache/src/NanoTimer.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "NanoTimer.hpp"
-#include <ace/OS.h>
-#include <ace/Time_Value.h>
-#include <ace/High_Res_Timer.h>
-
-// @TODO: Make these actually nano granularity when possible.
-
-namespace apache {
-namespace geode {
-namespace client {
-
-int64_t NanoTimer::now() {
- ACE_Time_Value now = ACE_High_Res_Timer::gettimeofday_hr();
- return (now.sec() * 1000000000ll) /* convert secs to nanosecs */
- + (now.usec() * 1000ll); /* convert microsecs to nanosecs */
-}
-
-void NanoTimer::sleep(uint32_t nanos) {
- timespec spec;
- spec.tv_sec = 0L;
- spec.tv_nsec = nanos;
- timespec remaining;
- remaining.tv_sec = 0L;
- remaining.tv_nsec = 0L;
- ACE_OS::nanosleep(&spec, &remaining);
-}
-
-void millisleep(uint32_t millis) {
- time_t secs = millis / 1000;
- suseconds_t usecs = (millis % 1000) * 1000;
- ACE_Time_Value duration(secs, usecs);
- ACE_OS::sleep(duration);
-}
-} // namespace client
-} // namespace geode
-} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/src/NanoTimer.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/NanoTimer.hpp b/src/cppcache/src/NanoTimer.hpp
deleted file mode 100644
index 8dbf4d8..0000000
--- a/src/cppcache/src/NanoTimer.hpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#pragma once
-
-#ifndef GEODE_NANOTIMER_H_
-#define GEODE_NANOTIMER_H_
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <geode/geode_globals.hpp>
-
-namespace apache {
-namespace geode {
-namespace client {
-
-class CPPCACHE_EXPORT NanoTimer {
- public:
- static int64_t now();
-
- static void sleep(uint32_t nanos);
-};
-} // namespace client
-} // namespace geode
-} // namespace apache
-
-#endif // GEODE_NANOTIMER_H_
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/src/TcrConnectionManager.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcrConnectionManager.cpp b/src/cppcache/src/TcrConnectionManager.cpp
index 67d7d01..a16482b 100644
--- a/src/cppcache/src/TcrConnectionManager.cpp
+++ b/src/cppcache/src/TcrConnectionManager.cpp
@@ -33,7 +33,12 @@
#include "ServerLocation.hpp"
#include <ace/INET_Addr.h>
#include <set>
-using namespace apache::geode::client;
+#include <thread>
+#include <chrono>
+
+namespace apache {
+namespace geode {
+namespace client {
volatile bool TcrConnectionManager::isNetDown = false;
volatile bool TcrConnectionManager::TEST_DURABLE_CLIENT_CRASH = false;
@@ -475,7 +480,7 @@ void TcrConnectionManager::netDown() {
isNetDown = true;
// sleep for 15 seconds to allow ping and redundancy threads to pause.
- apache::geode::client::millisleep(15000);
+ std::this_thread::sleep_for(std::chrono::seconds(15));
{
ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_endpoints.mutex());
@@ -498,7 +503,7 @@ void TcrConnectionManager::revive() {
// sleep for 15 seconds to allow redundancy thread to reestablish
// connections.
- apache::geode::client::millisleep(15000);
+ std::this_thread::sleep_for(std::chrono::seconds(15));
}
int TcrConnectionManager::redundancy(volatile bool &isRunning) {
@@ -601,3 +606,6 @@ GfErrType TcrConnectionManager::sendSyncRequestRegisterInterest(
return m_redundancyManager->sendSyncRequestRegisterInterest(
request, reply, attemptFailover, endpoint, theHADM, region);
}
+} // namespace client
+} // namespace geode
+} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/src/TcrEndpoint.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcrEndpoint.cpp b/src/cppcache/src/TcrEndpoint.cpp
index cfe0900..eed827e 100644
--- a/src/cppcache/src/TcrEndpoint.cpp
+++ b/src/cppcache/src/TcrEndpoint.cpp
@@ -24,7 +24,13 @@
#include "Utils.hpp"
#include "DistributedSystemImpl.hpp"
-using namespace apache::geode::client;
+#include <thread>
+#include <chrono>
+
+namespace apache {
+namespace geode {
+namespace client {
+
#define throwException(ex) \
{ \
LOGFINEST("%s: %s", ex.getName(), ex.getMessage()); \
@@ -236,7 +242,7 @@ GfErrType TcrEndpoint::createNewConnection(
LOGINFO("Timeout in handshake with endpoint[%s]", m_name.c_str());
err = GF_TIMOUT;
m_needToConnectInLock = true; // while creating the connection
- apache::geode::client::millisleep(50);
+ std::this_thread::sleep_for(std::chrono::milliseconds(50));
} catch (const GeodeIOException& ex) {
LOGINFO("IO error[%d] in handshake with endpoint[%s]: %s",
ACE_OS::last_error(), m_name.c_str(), ex.getMessage());
@@ -774,7 +780,7 @@ inline bool TcrEndpoint::handleIOException(const std::string& message,
m_needToConnectInLock = true;
return false;
}
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
return true;
}
@@ -987,7 +993,7 @@ GfErrType TcrEndpoint::sendRequestWithRetry(
connection only when not a sticky connection.
closeConnection( conn );
}*/
- apache::geode::client::millisleep(10);
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
int32_t type = request.getMessageType();
epFailure = (type != TcrMessage::QUERY && type != TcrMessage::PUTALL &&
type != TcrMessage::PUT_ALL_WITH_CALLBACK &&
@@ -1334,3 +1340,7 @@ void TcrEndpoint::sendRequestForChunkedResponse(const TcrMessage& request,
void TcrEndpoint::closeFailedConnection(TcrConnection*& conn) {
closeConnection(conn);
}
+
+} // namespace client
+} // namespace geode
+} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/src/Utils.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/Utils.cpp b/src/cppcache/src/Utils.cpp
index ac3449a..e954f6c 100644
--- a/src/cppcache/src/Utils.cpp
+++ b/src/cppcache/src/Utils.cpp
@@ -17,13 +17,14 @@
#include "Utils.hpp"
#include "ace/OS.h"
-#include "NanoTimer.hpp"
#include <ace/Recursive_Thread_Mutex.h>
#include <ace/INET_Addr.h>
#include <cstdio>
#include <chrono>
-using namespace apache::geode::client;
+namespace apache {
+namespace geode {
+namespace client {
#ifdef _WIN32
@@ -289,3 +290,7 @@ int32_t Utils::logWideString(char* buf, size_t maxLen, const wchar_t* wStr) {
return ACE_OS::snprintf(buf, maxLen, "null");
}
}
+
+} // namespace client
+} // namespace geode
+} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/src/Utils.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/Utils.hpp b/src/cppcache/src/Utils.hpp
index b95c7e8..2cc1473 100644
--- a/src/cppcache/src/Utils.hpp
+++ b/src/cppcache/src/Utils.hpp
@@ -29,7 +29,6 @@
#include <geode/ExceptionTypes.hpp>
#include <geode/CacheableString.hpp>
#include <geode/DataOutput.hpp>
-#include "NanoTimer.hpp"
#include <geode/statistics/Statistics.hpp>
#include <geode/SystemProperties.hpp>
#include <geode/DistributedSystem.hpp>
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/cppcache/test/NanoTimerTest.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/test/NanoTimerTest.cpp b/src/cppcache/test/NanoTimerTest.cpp
deleted file mode 100644
index 7c10ab5..0000000
--- a/src/cppcache/test/NanoTimerTest.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <gtest/gtest.h>
-
-#include <NanoTimer.hpp>
-
-using namespace apache::geode::client;
-
-TEST(NanoTimerTest, ValidateSleep) {
- const int64_t before = NanoTimer::now();
- NanoTimer::sleep(3000000UL /* nano-seconds */);
- const int64_t after = NanoTimer::now();
- EXPECT_LE(3000000L /* nano-seconds */, (after - before))
- << "Slept at least three milli-seconds";
-}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/e0145ace/src/quickstart/cpp/DurableClient.cpp
----------------------------------------------------------------------
diff --git a/src/quickstart/cpp/DurableClient.cpp b/src/quickstart/cpp/DurableClient.cpp
index 909172a..b406237 100644
--- a/src/quickstart/cpp/DurableClient.cpp
+++ b/src/quickstart/cpp/DurableClient.cpp
@@ -83,7 +83,7 @@ void RunDurableClient() {
LOGINFO("Sent ReadyForEvents message to server");
// wait for some time to recieve events
- apache::geode::client::millisleep(1000);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
// Close the Geode Cache with keepalive = true. Server will queue events
// for