geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From echobr...@apache.org
Subject [10/27] geode-native git commit: GEODE-2729: Remove global variables
Date Thu, 10 Aug 2017 15:20:18 GMT
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PoolManager.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PoolManager.cpp b/src/cppcache/src/PoolManager.cpp
index 49a6425..7ad036b 100644
--- a/src/cppcache/src/PoolManager.cpp
+++ b/src/cppcache/src/PoolManager.cpp
@@ -14,84 +14,116 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include <mutex>
+
 #include <geode/PoolManager.hpp>
-#include <ace/Recursive_Thread_Mutex.h>
-#include <ace/Guard_T.h>
 
 using namespace apache::geode::client;
 
-// TODO: make this a member of TcrConnectionManager.
-HashMapOfPools* connectionPools = nullptr; /*new HashMapOfPools( )*/
-ACE_Recursive_Thread_Mutex connectionPoolsLock;
+class PoolManager::Impl {
+ public:
+  Impl(const Cache& cache) : m_cache(cache) {}
+  void removePool(const char* name);
 
-void removePool(const char* name) {
-  ACE_Guard<ACE_Recursive_Thread_Mutex> guard(connectionPoolsLock);
-  connectionPools->erase(name);
-}
+  PoolFactoryPtr createFactory();
 
-PoolFactoryPtr PoolManager::createFactory() {
-  if (connectionPools == nullptr) {
-    ACE_Guard<ACE_Recursive_Thread_Mutex> guard(connectionPoolsLock);
-    if (connectionPools == nullptr) {
-      connectionPools = new HashMapOfPools();
-    }
-  }
-  return PoolFactoryPtr(new PoolFactory());
+  void close(bool keepAlive);
+
+  PoolPtr find(const char* name);
+
+  PoolPtr find(RegionPtr region);
+
+  const HashMapOfPools& getAll();
+
+  void addPool(const char* name, const PoolPtr& pool);
+
+  PoolPtr getDefaultPool();
+
+ private:
+  HashMapOfPools m_connectionPools;
+  std::recursive_mutex m_connectionPoolsLock;
+  PoolPtr m_defaultPool;
+  const Cache& m_cache;
+};
+
+void PoolManager::Impl::removePool(const char* name) {
+  std::lock_guard<std::recursive_mutex> guard(m_connectionPoolsLock);
+  m_connectionPools.erase(name);
 }
 
-void PoolManager::close(bool keepAlive) {
-  ACE_Guard<ACE_Recursive_Thread_Mutex> guard(connectionPoolsLock);
+PoolFactoryPtr PoolManager::Impl::createFactory() {
+  return std::shared_ptr<PoolFactory>(new PoolFactory(m_cache));
+}
 
-  if (connectionPools == nullptr) {
-    return;
-  }
+void PoolManager::Impl::close(bool keepAlive) {
+  std::lock_guard<std::recursive_mutex> guard(m_connectionPoolsLock);
 
   std::vector<PoolPtr> poolsList;
 
-  for (const auto& c : *connectionPools) {
+  for (const auto& c : m_connectionPools) {
     poolsList.push_back(c.second);
   }
 
   for (const auto& iter : poolsList) {
     iter->destroy(keepAlive);
   }
-
-  GF_SAFE_DELETE(connectionPools);
 }
 
-PoolPtr PoolManager::find(const char* name) {
-  ACE_Guard<ACE_Recursive_Thread_Mutex> guard(connectionPoolsLock);
-
-  if (connectionPools == nullptr) {
-    connectionPools = new HashMapOfPools();
-  }
+PoolPtr PoolManager::Impl::find(const char* name) {
+  std::lock_guard<std::recursive_mutex> guard(m_connectionPoolsLock);
 
   if (name) {
-    const auto& iter = connectionPools->find(name);
+    const auto& iter = m_connectionPools.find(name);
 
     PoolPtr poolPtr = nullptr;
 
-    if (iter != connectionPools->end()) {
+    if (iter != m_connectionPools.end()) {
       poolPtr = iter->second;
       GF_DEV_ASSERT(poolPtr != nullptr);
     }
 
     return poolPtr;
   } else {
-    return nullptr;
+    return m_connectionPools.empty() ? nullptr
+                                     : m_connectionPools.begin()->second;
   }
 }
 
-PoolPtr PoolManager::find(RegionPtr region) {
+PoolPtr PoolManager::Impl::find(RegionPtr region) {
   return find(region->getAttributes()->getPoolName());
 }
 
-const HashMapOfPools& PoolManager::getAll() {
-  if (connectionPools == nullptr) {
-    ACE_Guard<ACE_Recursive_Thread_Mutex> guard(connectionPoolsLock);
-    if (connectionPools == nullptr) {
-      connectionPools = new HashMapOfPools();
-    }
+const HashMapOfPools& PoolManager::Impl::getAll() { return m_connectionPools; }
+
+void PoolManager::Impl::addPool(const char* name, const PoolPtr& pool) {
+  std::lock_guard<std::recursive_mutex> guard(m_connectionPoolsLock);
+
+  if (!m_defaultPool) {
+    m_defaultPool = pool;
   }
-  return *connectionPools;
+
+  m_connectionPools.emplace(name, pool);
 }
+
+PoolPtr PoolManager::Impl::getDefaultPool() { return m_defaultPool; }
+
+PoolManager::PoolManager(const Cache& cache)
+    : m_pimpl(new Impl(cache), [](Impl* impl) { delete impl; }) {}
+
+void PoolManager::removePool(const char* name) { m_pimpl->removePool(name); }
+
+PoolFactoryPtr PoolManager::createFactory() { return m_pimpl->createFactory(); }
+
+void PoolManager::close(bool keepAlive) { m_pimpl->close(keepAlive); }
+
+PoolPtr PoolManager::find(const char* name) { return m_pimpl->find(name); }
+
+PoolPtr PoolManager::find(RegionPtr region) { return m_pimpl->find(region); }
+
+const HashMapOfPools& PoolManager::getAll() { return m_pimpl->getAll(); }
+
+void PoolManager::addPool(const char* name, const PoolPtr& pool) {
+  m_pimpl->addPool(name, pool);
+}
+
+PoolPtr PoolManager::getDefaultPool() { return m_pimpl->getDefaultPool(); }

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PoolStatistics.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PoolStatistics.cpp b/src/cppcache/src/PoolStatistics.cpp
index 9aa477a..e5f5188 100644
--- a/src/cppcache/src/PoolStatistics.cpp
+++ b/src/cppcache/src/PoolStatistics.cpp
@@ -36,233 +36,136 @@ using statistics::StatisticsFactory;
 using statistics::StatisticsManager;
 using util::concurrent::spinlock_mutex;
 
-////////////////////////////////////////////////////////////////////////////////
-
-PoolStatType* PoolStatType::single = nullptr;
-spinlock_mutex PoolStatType::m_singletonLock;
-spinlock_mutex PoolStatType::m_statTypeLock;
-
-void PoolStatType::clean() {
-  std::lock_guard<spinlock_mutex> guard(m_singletonLock);
-  if (single) {
-    delete single;
-    single = nullptr;
-  }
-}
-
-StatisticsType* PoolStatType::getStatType() {
-  std::lock_guard<spinlock_mutex> guard(m_statTypeLock);
-  StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
-  GF_D_ASSERT(!!factory);
+constexpr const char* PoolStats::STATS_NAME;
+constexpr const char* PoolStats::STATS_DESC;
 
-  StatisticsType* statsType = factory->findType("PoolStatistics");
+PoolStats::PoolStats(StatisticsFactory* factory, const std::string& poolName) {
+  auto statsType = factory->findType(STATS_NAME);
 
   if (statsType == nullptr) {
-    m_stats[0] = factory->createIntGauge(
+    auto stats = new StatisticDescriptor*[27];
+
+    stats[0] = factory->createIntGauge(
         "locators", "Current number of locators discovered", "locators");
-    m_stats[1] = factory->createIntGauge(
+    stats[1] = factory->createIntGauge(
         "servers", "Current number of servers discovered", "servers");
-    m_stats[2] = factory->createIntGauge(
+    stats[2] = factory->createIntGauge(
         "subscriptionServers",
         "Number of servers hosting this clients subscriptions", "servers");
-    m_stats[3] = factory->createLongCounter(
+    stats[3] = factory->createLongCounter(
         "locatorRequests",
         "Number of requests from this connection pool to a locator",
         "requests");
-    m_stats[4] = factory->createLongCounter(
+    stats[4] = factory->createLongCounter(
         "locatorResponses",
         "Number of responses from the locator to this connection pool",
         "responses");
-    m_stats[5] = factory->createIntGauge(
+    stats[5] = factory->createIntGauge(
         "poolConnections", "Current number of pool connections", "connections");
-    m_stats[6] = factory->createIntCounter(
+    stats[6] = factory->createIntCounter(
         "connects", "Total number of times a connection has been created.",
         "connects");
-    m_stats[7] = factory->createIntCounter(
+    stats[7] = factory->createIntCounter(
         "disconnects", "Total number of times a connection has been destroyed.",
         "disconnects");
-    m_stats[8] = factory->createIntCounter(
+    stats[8] = factory->createIntCounter(
         "minPoolSizeConnects",
         "Total number of connects done to maintain minimum pool size.",
         "connects");
-    m_stats[9] = factory->createIntCounter(
+    stats[9] = factory->createIntCounter(
         "loadConditioningConnects",
         "Total number of connects done due to load conditioning.", "connects");
-    m_stats[10] = factory->createIntCounter(
+    stats[10] = factory->createIntCounter(
         "idleDisconnects",
         "Total number of disconnects done due to idle expiration.",
         "disconnects");
-    m_stats[11] = factory->createIntCounter(
+    stats[11] = factory->createIntCounter(
         "loadConditioningDisconnects",
         "Total number of disconnects done due to load conditioning expiration.",
         "disconnects");
-    m_stats[12] = factory->createIntGauge(
+    stats[12] = factory->createIntGauge(
         "connectionWaitsInProgress",
         "Current number of threads waiting for a connection", "threads");
-    m_stats[13] = factory->createIntCounter(
+    stats[13] = factory->createIntCounter(
         "connectionWaits",
         "Total number of times a thread completed waiting for a connection (by "
         "timing out or by getting a connection).",
         "waits");
-    m_stats[14] = factory->createLongCounter(
+    stats[14] = factory->createLongCounter(
         "connectionWaitTime",
         "Total time (nanoseconds) spent waiting for a connection.",
         "nanoseconds");
-    m_stats[15] = factory->createIntGauge(
+    stats[15] = factory->createIntGauge(
         "clientOpsInProgress", "Current number of clientOps being executed",
         "clientOps");
-    m_stats[16] = factory->createIntCounter(
+    stats[16] = factory->createIntCounter(
         "clientOps", "Total number of clientOps completed successfully",
         "clientOps");
-    m_stats[17] = factory->createLongCounter(
+    stats[17] = factory->createLongCounter(
         "clientOpTime",
         "Total amount of time, in nanoseconds spent doing clientOps",
         "nanoseconds");
-    m_stats[18] = factory->createIntCounter(
+    stats[18] = factory->createIntCounter(
         "clientOpFailures",
         "Total number of clientOp attempts that have failed", "clientOps");
-    m_stats[19] = factory->createIntCounter(
+    stats[19] = factory->createIntCounter(
         "clientOpTimeouts",
         "Total number of clientOp attempts that have timed out", "clientOps");
-    m_stats[20] = factory->createLongCounter(
+    stats[20] = factory->createLongCounter(
         "receivedBytes", "Total number of bytes received from the server.",
         "bytes");
-    m_stats[21] = factory->createLongCounter(
+    stats[21] = factory->createLongCounter(
         "messagesBeingReceived",
         "Total number of message being received off the network.", "messages");
-    m_stats[22] = factory->createLongCounter(
+    stats[22] = factory->createLongCounter(
         "processedDeltaMessages",
         "Total number of delta message processed successfully", "messages");
-    m_stats[23] = factory->createLongCounter(
+    stats[23] = factory->createLongCounter(
         "deltaMessageFailures", "Total number of failures in processing delta",
         "messages");
-    m_stats[24] = factory->createLongCounter(
+    stats[24] = factory->createLongCounter(
         "processedDeltaMessagesTime", "Total time spent while processing Delta",
         "nanoseconds");
-    m_stats[25] = factory->createIntCounter("queryExecutions",
-                                            "Total number of queryExecutions",
-                                            "queryExecutions");
-    m_stats[26] = factory->createLongCounter(
+    stats[25] = factory->createIntCounter("queryExecutions",
+                                          "Total number of queryExecutions",
+                                          "queryExecutions");
+    stats[26] = factory->createLongCounter(
         "queryExecutionTime",
         "Total time spent while processing queryExecution", "nanoseconds");
 
-    statsType = factory->createType("PoolStatistics",
-                                    "Statistics for this pool", m_stats, 27);
-
-    m_locatorsId = statsType->nameToId("locators");
-    m_serversId = statsType->nameToId("servers");
-    m_subsServsId = statsType->nameToId("subscriptionServers");
-    m_locReqsId = statsType->nameToId("locatorRequests");
-    m_locRespsId = statsType->nameToId("locatorResponses");
-    m_poolConnsId = statsType->nameToId("poolConnections");
-    m_connectsId = statsType->nameToId("connects");
-    m_disconnectsId = statsType->nameToId("disconnects");
-    m_minPoolConnectsId = statsType->nameToId("minPoolSizeConnects");
-    m_loadCondConnectsId = statsType->nameToId("loadConditioningConnects");
-    m_idleDisconnectsId = statsType->nameToId("idleDisconnects");
-    m_loadCondDisconnectsId =
-        statsType->nameToId("loadConditioningDisconnects");
-    m_waitingConnectionsId = statsType->nameToId("connectionWaitsInProgress");
-    m_totalWaitingConnsId = statsType->nameToId("connectionWaits");
-    m_totalWaitingConnTimeId = statsType->nameToId("connectionWaitTime");
-    m_curClientOpsId = statsType->nameToId("clientOpsInProgress");
-    m_clientOpsSuccessId = statsType->nameToId("clientOps");
-    m_clientOpsSuccessTimeId = statsType->nameToId("clientOpTime");
-    m_clientOpsFailedId = statsType->nameToId("clientOpFailures");
-    m_clientOpsTimeoutId = statsType->nameToId("clientOpTimeouts");
-    m_receivedBytesId = statsType->nameToId("receivedBytes");
-    m_messagesBeingReceivedId = statsType->nameToId("messagesBeingReceived");
-    m_processedDeltaMessagesId = statsType->nameToId("processedDeltaMessages");
-    m_deltaMessageFailuresId = statsType->nameToId("deltaMessageFailures");
-    m_processedDeltaMessagesTimeId =
-        statsType->nameToId("processedDeltaMessagesTime");
-    m_queryExecutionsId = statsType->nameToId("queryExecutions");
-    m_queryExecutionTimeId = statsType->nameToId("queryExecutionTime");
-  }
-
-  return statsType;
-}
-
-PoolStatType* PoolStatType::getInstance() {
-  std::lock_guard<spinlock_mutex> guard(m_singletonLock);
-  if (!single) {
-    single = new PoolStatType();
+    statsType = factory->createType(STATS_NAME, STATS_DESC, stats, 27);
   }
-  return single;
-}
-
-PoolStatType::PoolStatType()
-    : m_locatorsId(0),
-      m_serversId(0),
-      m_subsServsId(0),
-      m_locReqsId(0),
-      m_locRespsId(0),
-      m_poolConnsId(0),
-      m_connectsId(0),
-      m_disconnectsId(0),
-      m_minPoolConnectsId(0),
-      m_loadCondConnectsId(0),
-      m_idleDisconnectsId(0),
-      m_loadCondDisconnectsId(0),
-      m_waitingConnectionsId(0),
-      m_totalWaitingConnsId(0),
-      m_totalWaitingConnTimeId(0),
-      m_curClientOpsId(0),
-      m_clientOpsSuccessId(0),
-      m_clientOpsSuccessTimeId(0),
-      m_clientOpsFailedId(0),
-      m_clientOpsTimeoutId(0),
-      m_receivedBytesId(0),
-      m_messagesBeingReceivedId(0),
-      m_processedDeltaMessagesId(0),
-      m_deltaMessageFailuresId(0),
-      m_processedDeltaMessagesTimeId(0),
-      m_queryExecutionsId(0),
-      m_queryExecutionTimeId(0) {
-  memset(m_stats, 0, sizeof(m_stats));
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-PoolStats::PoolStats(const char* poolName) {
-  PoolStatType* poolStatType = PoolStatType::getInstance();
-
-  StatisticsType* statsType = poolStatType->getStatType();
-
-  GF_D_ASSERT(statsType != nullptr);
-
-  StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
+  m_locatorsId = statsType->nameToId("locators");
+  m_serversId = statsType->nameToId("servers");
+  m_subsServsId = statsType->nameToId("subscriptionServers");
+  m_locReqsId = statsType->nameToId("locatorRequests");
+  m_locRespsId = statsType->nameToId("locatorResponses");
+  m_poolConnsId = statsType->nameToId("poolConnections");
+  m_connectsId = statsType->nameToId("connects");
+  m_disconnectsId = statsType->nameToId("disconnects");
+  m_minPoolConnectsId = statsType->nameToId("minPoolSizeConnects");
+  m_loadCondConnectsId = statsType->nameToId("loadConditioningConnects");
+  m_idleDisconnectsId = statsType->nameToId("idleDisconnects");
+  m_loadCondDisconnectsId = statsType->nameToId("loadConditioningDisconnects");
+  m_waitingConnectionsId = statsType->nameToId("connectionWaitsInProgress");
+  m_totalWaitingConnsId = statsType->nameToId("connectionWaits");
+  m_totalWaitingConnTimeId = statsType->nameToId("connectionWaitTime");
+  m_curClientOpsId = statsType->nameToId("clientOpsInProgress");
+  m_clientOpsSuccessId = statsType->nameToId("clientOps");
+  m_clientOpsSuccessTimeId = statsType->nameToId("clientOpTime");
+  m_clientOpsFailedId = statsType->nameToId("clientOpFailures");
+  m_clientOpsTimeoutId = statsType->nameToId("clientOpTimeouts");
+  m_receivedBytesId = statsType->nameToId("receivedBytes");
+  m_messagesBeingReceivedId = statsType->nameToId("messagesBeingReceived");
+  m_processedDeltaMessagesId = statsType->nameToId("processedDeltaMessages");
+  m_deltaMessageFailuresId = statsType->nameToId("deltaMessageFailures");
+  m_processedDeltaMessagesTimeId =
+      statsType->nameToId("processedDeltaMessagesTime");
+  m_queryExecutionsId = statsType->nameToId("queryExecutions");
+  m_queryExecutionTimeId = statsType->nameToId("queryExecutionTime");
 
-  m_poolStats = factory->createAtomicStatistics(statsType, poolName);
+  m_poolStats = factory->createAtomicStatistics(statsType, poolName.c_str());
 
-  m_locatorsId = poolStatType->getLocatorsId();
-  m_serversId = poolStatType->getServersId();
-  m_subsServsId = poolStatType->getSubscriptionServersId();
-  m_locReqsId = poolStatType->getLocatorRequestsId();
-  m_locRespsId = poolStatType->getLocatorResposesId();
-  m_poolConnsId = poolStatType->getPoolConnectionsId();
-  m_connectsId = poolStatType->getConnectsId();
-  m_disconnectsId = poolStatType->getDisconnectsId();
-  m_minPoolConnectsId = poolStatType->getMinPoolSizeConnectsId();
-  m_loadCondConnectsId = poolStatType->getLoadCondConnectsId();
-  m_idleDisconnectsId = poolStatType->getIdleDisconnectsId();
-  m_loadCondDisconnectsId = poolStatType->getLoadCondDisconnectsId();
-  m_waitingConnectionsId = poolStatType->getWaitingConnectionsId();
-  m_totalWaitingConnsId = poolStatType->getTotalWaitingConnsId();
-  m_totalWaitingConnTimeId = poolStatType->getTotalWaitingConnTimeId();
-  m_curClientOpsId = poolStatType->getCurClientOpsId();
-  m_clientOpsSuccessId = poolStatType->getClientOpsSucceededId();
-  m_clientOpsSuccessTimeId = poolStatType->getClientOpsSucceededTimeId();
-  m_clientOpsFailedId = poolStatType->getClientOpsFailedId();
-  m_clientOpsTimeoutId = poolStatType->getClientOpsTimeoutId();
-  m_receivedBytesId = poolStatType->getReceivedBytesId();
-  m_messagesBeingReceivedId = poolStatType->getMessagesBeingReceivedId();
-  m_processedDeltaMessagesId = poolStatType->getProcessedDeltaMessagesId();
-  m_deltaMessageFailuresId = poolStatType->getDeltaMessageFailuresId();
-  m_processedDeltaMessagesTimeId =
-      poolStatType->getProcessedDeltaMessagesTimeId();
-  m_queryExecutionsId = poolStatType->getQueryExecutionId();
-  m_queryExecutionTimeId = poolStatType->getQueryExecutionTimeId();
   getStats()->setInt(m_locatorsId, 0);
   getStats()->setInt(m_serversId, 0);
   getStats()->setInt(m_subsServsId, 0);
@@ -290,8 +193,6 @@ PoolStats::PoolStats(const char* poolName) {
   getStats()->setInt(m_processedDeltaMessagesTimeId, 0);
   getStats()->setInt(m_queryExecutionsId, 0);
   getStats()->setLong(m_queryExecutionTimeId, 0);
-
-  StatisticsManager::getExistingInstance()->forceSample();
 }
 
 PoolStats::~PoolStats() {

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PoolStatistics.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PoolStatistics.hpp b/src/cppcache/src/PoolStatistics.hpp
index c882cfc..ae16a9d 100644
--- a/src/cppcache/src/PoolStatistics.hpp
+++ b/src/cppcache/src/PoolStatistics.hpp
@@ -1,5 +1,4 @@
 /*
- * 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
@@ -20,27 +19,13 @@
 #ifndef GEODE_POOLSTATISTICS_H_
 #define GEODE_POOLSTATISTICS_H_
 
-/*
- * 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 <string>
 
 #include <geode/geode_globals.hpp>
 #include <geode/statistics/Statistics.hpp>
 #include <geode/statistics/StatisticsFactory.hpp>
-#include <statistics/StatisticsManager.hpp>
-#include "util/concurrent/spinlock_mutex.hpp"
+
+#include "statistics/StatisticsManager.hpp"
 
 namespace apache {
 namespace geode {
@@ -54,15 +39,12 @@ using util::concurrent::spinlock_mutex;
 class PoolStats {
  public:
   /** hold statistics for a pool.. */
-  PoolStats(const char* poolName);
+  PoolStats(statistics::StatisticsFactory* factory, const std::string& poolName);
 
   /** disable stat collection for this item. */
   virtual ~PoolStats();
 
-  void close() {
-    getStats()->close();
-    statistics::StatisticsManager::getExistingInstance()->forceSample();
-  }
+  void close() { getStats()->close(); }
 
   void setLocators(int32_t curVal) { getStats()->setInt(m_locatorsId, curVal); }
 
@@ -147,6 +129,11 @@ class PoolStats {
   inline apache::geode::statistics::Statistics* getStats() {
     return m_poolStats;
   }
+  inline int32_t getTotalWaitingConnTimeId() {
+    return m_totalWaitingConnTimeId;
+  }
+
+  inline int32_t getQueryExecutionTimeId() { return m_queryExecutionTimeId; }
 
  private:
   // volatile apache::geode::statistics::Statistics* m_poolStats;
@@ -179,92 +166,9 @@ class PoolStats {
   int32_t m_processedDeltaMessagesTimeId;
   int32_t m_queryExecutionsId;
   int32_t m_queryExecutionTimeId;
-};
-
-class PoolStatType {
- private:
-  static PoolStatType* single;
-  static spinlock_mutex m_singletonLock;
-  static spinlock_mutex m_statTypeLock;
-
- public:
-  static PoolStatType* getInstance();
-
-  statistics::StatisticsType* getStatType();
-
-  static void clean();
 
- private:
-  PoolStatType();
-  statistics::StatisticDescriptor* m_stats[27];
-
-  int32_t m_locatorsId;
-  int32_t m_serversId;
-  int32_t m_subsServsId;
-  int32_t m_locReqsId;
-  int32_t m_locRespsId;
-  int32_t m_poolConnsId;
-  int32_t m_connectsId;
-  int32_t m_disconnectsId;
-  int32_t m_minPoolConnectsId;
-  int32_t m_loadCondConnectsId;
-  int32_t m_idleDisconnectsId;
-  int32_t m_loadCondDisconnectsId;
-  int32_t m_waitingConnectionsId;
-  int32_t m_totalWaitingConnsId;
-  int32_t m_totalWaitingConnTimeId;
-  int32_t m_curClientOpsId;
-  int32_t m_clientOpsSuccessId;
-  int32_t m_clientOpsSuccessTimeId;
-  int32_t m_clientOpsFailedId;
-  int32_t m_clientOpsTimeoutId;
-  int32_t m_receivedBytesId;
-  int32_t m_messagesBeingReceivedId;
-  int32_t m_processedDeltaMessagesId;
-  int32_t m_deltaMessageFailuresId;
-  int32_t m_processedDeltaMessagesTimeId;
-  int32_t m_queryExecutionsId;
-  int32_t m_queryExecutionTimeId;
-
- public:
-  int32_t getLocatorsId() { return m_locatorsId; }
-
-  int32_t getServersId() { return m_serversId; }
-
-  int32_t getSubscriptionServersId() { return m_subsServsId; }
-
-  int32_t getLocatorRequestsId() { return m_locReqsId; }
-
-  int32_t getLocatorResposesId() { return m_locRespsId; }
-
-  int32_t getPoolConnectionsId() { return m_poolConnsId; }
-
-  int32_t getConnectsId() { return m_connectsId; }
-
-  int32_t getDisconnectsId() { return m_disconnectsId; }
-
-  int32_t getMinPoolSizeConnectsId() { return m_minPoolConnectsId; }
-
-  int32_t getLoadCondConnectsId() { return m_loadCondConnectsId; }
-  int32_t getIdleDisconnectsId() { return m_idleDisconnectsId; }
-  int32_t getLoadCondDisconnectsId() { return m_loadCondDisconnectsId; }
-  int32_t getWaitingConnectionsId() { return m_waitingConnectionsId; }
-  int32_t getTotalWaitingConnsId() { return m_totalWaitingConnsId; }
-  int32_t getTotalWaitingConnTimeId() { return m_totalWaitingConnTimeId; }
-  int32_t getCurClientOpsId() { return m_curClientOpsId; }
-  int32_t getClientOpsSucceededId() { return m_clientOpsSuccessId; }
-  int32_t getClientOpsSucceededTimeId() { return m_clientOpsSuccessTimeId; }
-  int32_t getClientOpsFailedId() { return m_clientOpsFailedId; }
-  int32_t getClientOpsTimeoutId() { return m_clientOpsTimeoutId; }
-  int32_t getReceivedBytesId() { return m_receivedBytesId; }
-  int32_t getMessagesBeingReceivedId() { return m_messagesBeingReceivedId; }
-  int32_t getProcessedDeltaMessagesId() { return m_processedDeltaMessagesId; }
-  int32_t getDeltaMessageFailuresId() { return m_deltaMessageFailuresId; }
-  int32_t getProcessedDeltaMessagesTimeId() {
-    return m_processedDeltaMessagesTimeId;
-  }
-  int32_t getQueryExecutionId() { return m_queryExecutionsId; }
-  int32_t getQueryExecutionTimeId() { return m_queryExecutionTimeId; }
+  static constexpr const char* STATS_NAME = "PoolStatistics";
+  static constexpr const char* STATS_DESC = "Statistics for this pool";
 };
 }  // namespace client
 }  // namespace geode

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PoolXmlCreation.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PoolXmlCreation.cpp b/src/cppcache/src/PoolXmlCreation.cpp
index ecb42d6..45216c0 100644
--- a/src/cppcache/src/PoolXmlCreation.cpp
+++ b/src/cppcache/src/PoolXmlCreation.cpp
@@ -15,6 +15,9 @@
  * limitations under the License.
  */
 
+#include <geode/Cache.hpp>
+#include <geode/PoolManager.hpp>
+
 #include "PoolXmlCreation.hpp"
 
 using namespace apache::geode::client;
@@ -33,7 +36,7 @@ void PoolXmlCreation::addServer(const char * host, const char * port)
 }
 */
 
-PoolPtr PoolXmlCreation::create() {
+PoolPtr PoolXmlCreation::create(Cache& cache) {
   return poolFactory->create(poolName.c_str());
 }
 

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PoolXmlCreation.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PoolXmlCreation.hpp b/src/cppcache/src/PoolXmlCreation.hpp
index c6a3446..d3cb455 100644
--- a/src/cppcache/src/PoolXmlCreation.hpp
+++ b/src/cppcache/src/PoolXmlCreation.hpp
@@ -82,7 +82,7 @@ class CPPCACHE_EXPORT PoolXmlCreation {
    * @throws UnknownException otherwise
    *
    */
-  PoolPtr create();
+  PoolPtr create(Cache &cache);
 };
 }  // namespace client
 }  // namespace geode

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PreservedDataExpiryHandler.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PreservedDataExpiryHandler.cpp b/src/cppcache/src/PreservedDataExpiryHandler.cpp
index 550edf6..5126020 100644
--- a/src/cppcache/src/PreservedDataExpiryHandler.cpp
+++ b/src/cppcache/src/PreservedDataExpiryHandler.cpp
@@ -33,14 +33,16 @@
 using namespace apache::geode::client;
 
 PreservedDataExpiryHandler::PreservedDataExpiryHandler(
-    PdxSerializablePtr pdxObjectPtr, uint32_t duration)
+	const std::shared_ptr<PdxTypeRegistry>& pdxTypeRegistry,
+    const PdxSerializablePtr& pdxObjectPtr, uint32_t duration)
     :  // UNUSED m_duration(duration),
-      m_pdxObjectPtr(pdxObjectPtr) {}
+      m_pdxObjectPtr(pdxObjectPtr),
+	  m_pdxTypeRegistry(pdxTypeRegistry) {}
 
 int PreservedDataExpiryHandler::handle_timeout(
     const ACE_Time_Value& current_time, const void* arg) {
-  WriteGuard guard(PdxTypeRegistry::getPreservedDataLock());
-  auto map = PdxTypeRegistry::getPreserveDataMap();
+  WriteGuard guard(m_pdxTypeRegistry->getPreservedDataLock());
+  auto map = m_pdxTypeRegistry->getPreserveDataMap();
   LOGDEBUG(
       "Entered PreservedDataExpiryHandler "
       "PdxTypeRegistry::getPreserveDataMap().size() = %d",

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PreservedDataExpiryHandler.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PreservedDataExpiryHandler.hpp b/src/cppcache/src/PreservedDataExpiryHandler.hpp
index ce85a87..e8aafc9 100644
--- a/src/cppcache/src/PreservedDataExpiryHandler.hpp
+++ b/src/cppcache/src/PreservedDataExpiryHandler.hpp
@@ -53,7 +53,8 @@ class CPPCACHE_EXPORT PreservedDataExpiryHandler : public ACE_Event_Handler {
   /**
    * Constructor
    */
-  PreservedDataExpiryHandler(PdxSerializablePtr pdxObjectPtr,
+  PreservedDataExpiryHandler(const std::shared_ptr<PdxTypeRegistry>& pdxTypeRegistry,
+                             const PdxSerializablePtr& pdxObjectPtr,
                              uint32_t duration);
 
   /** This task object will be registered with the Timer Queue.
@@ -69,6 +70,7 @@ class CPPCACHE_EXPORT PreservedDataExpiryHandler : public ACE_Event_Handler {
   // Duration after which the task should be reset in case of
   // modification.
   // UNUSED uint32_t m_duration;
+  std::shared_ptr<PdxTypeRegistry> m_pdxTypeRegistry;
   PdxSerializablePtr m_pdxObjectPtr;
 };
 }  // namespace client

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ProxyCache.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ProxyCache.cpp b/src/cppcache/src/ProxyCache.cpp
index 978919c..2d03a8b 100644
--- a/src/cppcache/src/ProxyCache.cpp
+++ b/src/cppcache/src/ProxyCache.cpp
@@ -69,7 +69,8 @@ void ProxyCache::close() {
     m_userAttributes->unSetCredentials();
     // send message to server
     PoolPtr userAttachedPool = m_userAttributes->getPool();
-    PoolPtr pool = PoolManager::find(userAttachedPool->getName());
+    PoolPtr pool = m_cacheImpl->getCache()->getPoolManager().find(
+        userAttachedPool->getName());
     if (pool != nullptr && pool.get() == userAttachedPool.get()) {
       auto poolDM = std::static_pointer_cast<ThinClientPoolDM>(pool);
       if (!poolDM->isDestroyed()) {
@@ -86,15 +87,15 @@ RegionPtr ProxyCache::getRegion(const char* path) {
 
   if (!m_isProxyCacheClosed) {
     RegionPtr result;
-    CachePtr realCache = CacheFactory::getAnyInstance();
 
-    if (realCache != nullptr && !realCache->isClosed()) {
-      CacheRegionHelper::getCacheImpl(realCache.get())->getRegion(path, result);
+    if (m_cacheImpl != nullptr && !m_cacheImpl->isClosed()) {
+      m_cacheImpl->getRegion(path, result);
     }
 
     if (result != nullptr) {
       PoolPtr userAttachedPool = m_userAttributes->getPool();
-      PoolPtr pool = PoolManager::find(result->getAttributes()->getPoolName());
+      PoolPtr pool = m_cacheImpl->getCache()->getPoolManager().find(
+          result->getAttributes()->getPoolName());
       if (pool != nullptr && pool.get() == userAttachedPool.get() &&
           !pool->isDestroyed()) {
         return std::make_shared<ProxyRegion>(shared_from_this(), result);
@@ -134,13 +135,12 @@ void ProxyCache::rootRegions(VectorOfRegion& regions) {
 
   if (!m_isProxyCacheClosed) {
     RegionPtr result;
-    CachePtr realCache = CacheFactory::getAnyInstance();
 
-    if (realCache != nullptr && !realCache->isClosed()) {
+    if (m_cacheImpl != nullptr && !m_cacheImpl->isClosed()) {
       VectorOfRegion tmp;
       // this can cause issue when pool attached with region in multiuserSecure
       // mode
-      realCache->rootRegions(tmp);
+      m_cacheImpl->rootRegions(tmp);
 
       if (tmp.size() > 0) {
         for (int32_t i = 0; i < tmp.size(); i++) {
@@ -157,15 +157,22 @@ void ProxyCache::rootRegions(VectorOfRegion& regions) {
   }
 }
 
-ProxyCache::ProxyCache(PropertiesPtr credentials, PoolPtr pool) {
-  m_remoteQueryService = nullptr;
-  m_isProxyCacheClosed = false;
-  m_userAttributes = std::make_shared<UserAttributes>(credentials, pool, this);
-}
+ProxyCache::ProxyCache(PropertiesPtr credentials, PoolPtr pool,
+                       CacheImpl* cacheImpl)
+    : m_remoteQueryService(nullptr),
+      m_isProxyCacheClosed(false),
+      m_userAttributes(
+          std::make_shared<UserAttributes>(credentials, pool, this)),
+      m_cacheImpl(cacheImpl) {}
 
 ProxyCache::~ProxyCache() {}
 
 PdxInstanceFactoryPtr ProxyCache::createPdxInstanceFactory(
     const char* className) {
-  return std::make_shared<PdxInstanceFactoryImpl>(className);
+  return std::make_shared<PdxInstanceFactoryImpl>(
+      className, &(m_cacheImpl->getCachePerfStats()),
+      m_cacheImpl->getPdxTypeRegistry(), m_cacheImpl->getCache(),
+      m_cacheImpl->getDistributedSystem()
+          .getSystemProperties()
+          .getEnableTimeStatistics());
 }

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ProxyCache.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ProxyCache.hpp b/src/cppcache/src/ProxyCache.hpp
index 23d085c..acbc295 100644
--- a/src/cppcache/src/ProxyCache.hpp
+++ b/src/cppcache/src/ProxyCache.hpp
@@ -86,28 +86,28 @@ class CPPCACHE_EXPORT ProxyCache
   virtual RegionPtr getRegion(const char* path);
 
   /**
-  * Gets the QueryService from which a new Query can be obtained.
-  *
-  * @returns A smart pointer to the QueryService.
-  */
+   * Gets the QueryService from which a new Query can be obtained.
+   *
+   * @returns A smart pointer to the QueryService.
+   */
   virtual QueryServicePtr getQueryService();
 
   /**
-  * Returns a set of root regions in the cache. This set is a snapshot and
-  * is not backed by the Cache. The vector passed in is cleared and the
-  * regions are added to it.
-  *
-  * @param regions the returned set of
-  * regions
-  */
+   * Returns a set of root regions in the cache. This set is a snapshot and
+   * is not backed by the Cache. The vector passed in is cleared and the
+   * regions are added to it.
+   *
+   * @param regions the returned set of
+   * regions
+   */
   virtual void rootRegions(VectorOfRegion& regions);
 
   /**
-    * @brief destructor
-    */
+   * @brief destructor
+   */
   virtual ~ProxyCache();
 
-  ProxyCache(PropertiesPtr credentials, PoolPtr pool);
+  ProxyCache(PropertiesPtr credentials, PoolPtr pool, CacheImpl* cacheImpl);
 
   /**
    * Returns a factory that can create a {@link PdxInstance}.
@@ -126,6 +126,7 @@ class CPPCACHE_EXPORT ProxyCache
   UserAttributesPtr m_userAttributes;
   bool m_isProxyCacheClosed;
   QueryServicePtr m_remoteQueryService;
+  CacheImpl* m_cacheImpl;
   friend class Pool;
   friend class ProxyRegion;
   friend class ProxyRemoteQueryService;
@@ -134,6 +135,7 @@ class CPPCACHE_EXPORT ProxyCache
   friend class FunctionServiceImpl;
   friend class FunctionService;
   friend class GuardUserAttribures;
+  friend class CacheRegionHelper;
 };
 }  // namespace client
 }  // namespace geode

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ProxyRegion.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ProxyRegion.hpp b/src/cppcache/src/ProxyRegion.hpp
index d0b77bc..d4d5940 100644
--- a/src/cppcache/src/ProxyRegion.hpp
+++ b/src/cppcache/src/ProxyRegion.hpp
@@ -1495,21 +1495,22 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
 
   virtual const PoolPtr& getPool() { return m_realRegion->getPool(); }
 
-  ProxyRegion(const ProxyCachePtr& proxyCache, const RegionPtr& realRegion) {
+  ProxyRegion(const ProxyCachePtr& proxyCache, const RegionPtr& realRegion)
+      : Region(realRegion->getCache()) {
     m_proxyCache = proxyCache;
     m_realRegion = realRegion;
   }
 
   virtual ~ProxyRegion() {}
 
+  ProxyRegion(const ProxyRegion&) = delete;
+  ProxyRegion& operator=(const ProxyRegion&) = delete;
+
  private:
   void unSupportedOperation(const char* operationName) const;
 
   ProxyCachePtr m_proxyCache;
   RegionPtr m_realRegion;
-  // Disallow copy constructor and assignment operator.
-  ProxyRegion(const ProxyRegion&);
-  ProxyRegion& operator=(const ProxyRegion&);
   friend class FunctionService;
 
   FRIEND_STD_SHARED_PTR(ProxyRegion)

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ProxyRemoteQueryService.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ProxyRemoteQueryService.cpp b/src/cppcache/src/ProxyRemoteQueryService.cpp
index da66e0b..25aec8a 100644
--- a/src/cppcache/src/ProxyRemoteQueryService.cpp
+++ b/src/cppcache/src/ProxyRemoteQueryService.cpp
@@ -25,7 +25,8 @@ ProxyRemoteQueryService::ProxyRemoteQueryService(ProxyCachePtr cptr)
 QueryPtr ProxyRemoteQueryService::newQuery(const char* querystring) {
   if (!m_proxyCache->isClosed()) {
     auto userAttachedPool = m_proxyCache->m_userAttributes->getPool();
-    auto pool = PoolManager::find(userAttachedPool->getName());
+    auto pool = m_proxyCache->m_cacheImpl->getCache()->getPoolManager().find(
+        userAttachedPool->getName());
     if (pool != nullptr && pool.get() == userAttachedPool.get() &&
         !pool->isDestroyed()) {
       GuardUserAttribures gua(m_proxyCache);
@@ -53,7 +54,8 @@ CqQueryPtr ProxyRemoteQueryService::newCq(const char* querystr,
                                           bool isDurable) {
   if (!m_proxyCache->isClosed()) {
     auto userAttachedPool = m_proxyCache->m_userAttributes->getPool();
-    auto pool = PoolManager::find(userAttachedPool->getName());
+    auto pool = m_proxyCache->m_cacheImpl->getCache()->getPoolManager().find(
+        userAttachedPool->getName());
     if (pool != nullptr && pool.get() == userAttachedPool.get() &&
         !pool->isDestroyed()) {
       GuardUserAttribures gua(m_proxyCache);
@@ -81,7 +83,8 @@ CqQueryPtr ProxyRemoteQueryService::newCq(const char* name,
                                           bool isDurable) {
   if (!m_proxyCache->isClosed()) {
     auto userAttachedPool = m_proxyCache->m_userAttributes->getPool();
-    auto pool = PoolManager::find(userAttachedPool->getName());
+    auto pool = m_proxyCache->m_cacheImpl->getCache()->getPoolManager().find(
+        userAttachedPool->getName());
     if (pool != nullptr && pool.get() == userAttachedPool.get() &&
         !pool->isDestroyed()) {
       GuardUserAttribures gua(m_proxyCache);
@@ -114,12 +117,12 @@ void ProxyRemoteQueryService::closeCqs(bool keepAlive) {
         cqImpl->close(false);
       }
     } catch (QueryException& qe) {
-      Log::fine(("Failed to close the CQ, CqName : " + cqName + " Error : " +
-                 qe.getMessage())
+      Log::fine(("Failed to close the CQ, CqName : " + cqName +
+                 " Error : " + qe.getMessage())
                     .c_str());
     } catch (CqClosedException& cce) {
-      Log::fine(("Failed to close the CQ, CqName : " + cqName + " Error : " +
-                 cce.getMessage())
+      Log::fine(("Failed to close the CQ, CqName : " + cqName +
+                 " Error : " + cce.getMessage())
                     .c_str());
     }
   }
@@ -133,7 +136,8 @@ void ProxyRemoteQueryService::getCqs(query_container_type& vec) {
 CqQueryPtr ProxyRemoteQueryService::getCq(const char* name) {
   if (!m_proxyCache->isClosed()) {
     auto userAttachedPool = m_proxyCache->m_userAttributes->getPool();
-    auto pool = PoolManager::find(userAttachedPool->getName());
+    auto pool = m_proxyCache->m_cacheImpl->getCache()->getPoolManager().find(
+        userAttachedPool->getName());
     if (pool != nullptr && pool.get() == userAttachedPool.get() &&
         !pool->isDestroyed()) {
       GuardUserAttribures gua(m_proxyCache);
@@ -155,12 +159,12 @@ void ProxyRemoteQueryService::executeCqs() {
     try {
       q->execute();
     } catch (QueryException& qe) {
-      Log::fine(("Failed to excecue the CQ, CqName : " + cqName + " Error : " +
-                 qe.getMessage())
+      Log::fine(("Failed to excecue the CQ, CqName : " + cqName +
+                 " Error : " + qe.getMessage())
                     .c_str());
     } catch (CqClosedException& cce) {
-      Log::fine(("Failed to excecue the CQ, CqName : " + cqName + " Error : " +
-                 cce.getMessage())
+      Log::fine(("Failed to excecue the CQ, CqName : " + cqName +
+                 " Error : " + cce.getMessage())
                     .c_str());
     }
   }
@@ -174,12 +178,12 @@ void ProxyRemoteQueryService::stopCqs() {
     try {
       q->stop();
     } catch (QueryException& qe) {
-      Log::fine(("Failed to stop the CQ, CqName : " + cqName + " Error : " +
-                 qe.getMessage())
+      Log::fine(("Failed to stop the CQ, CqName : " + cqName +
+                 " Error : " + qe.getMessage())
                     .c_str());
     } catch (CqClosedException& cce) {
-      Log::fine(("Failed to stop the CQ, CqName : " + cqName + " Error : " +
-                 cce.getMessage())
+      Log::fine(("Failed to stop the CQ, CqName : " + cqName +
+                 " Error : " + cce.getMessage())
                     .c_str());
     }
   }

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/Region.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/Region.cpp b/src/cppcache/src/Region.cpp
index eab6760..fa1ce3e 100644
--- a/src/cppcache/src/Region.cpp
+++ b/src/cppcache/src/Region.cpp
@@ -20,7 +20,7 @@
 namespace apache {
 namespace geode {
 namespace client {
-Region::Region() {}
+Region::Region(const CachePtr& cache) : m_cache(cache) {}
 Region::~Region() {}
 }  // namespace client
 }  // namespace geode

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionCommit.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionCommit.cpp b/src/cppcache/src/RegionCommit.cpp
index 62e26c8..3bef90c 100644
--- a/src/cppcache/src/RegionCommit.cpp
+++ b/src/cppcache/src/RegionCommit.cpp
@@ -38,9 +38,11 @@ void RegionCommit::fromData(DataInput& input) {
     input.readBoolean(&largeModCount);
     DSMemberForVersionStampPtr dsMember;
     input.readObject(dsMember);
-    uint16_t memId = CacheImpl::getMemberListForVersionStamp()->add(dsMember);
+
+    auto memId = m_memberListForVersionStamp.add(dsMember);
     for (int i = 0; i < size; i++) {
-      auto entryOp = std::make_shared<FarSideEntryOp>(this);
+      auto entryOp =
+          std::make_shared<FarSideEntryOp>(this, m_memberListForVersionStamp);
       entryOp->fromData(input, largeModCount, memId);
       m_farSideEntryOps.push_back(entryOp);
     }

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionCommit.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionCommit.hpp b/src/cppcache/src/RegionCommit.hpp
index 9458bee..0d24dfb 100644
--- a/src/cppcache/src/RegionCommit.hpp
+++ b/src/cppcache/src/RegionCommit.hpp
@@ -38,10 +38,12 @@ namespace geode {
 namespace client {
 
 _GF_PTR_DEF_(RegionCommit, RegionCommitPtr);
+_GF_PTR_DEF_(FarSideEntryOp, FarSideEntryOpPtr);
 
 class RegionCommit {
  public:
-  RegionCommit(){};
+  RegionCommit(MemberListForVersionStamp& memberListForVersionStamp): m_memberListForVersionStamp(memberListForVersionStamp)
+  {};
   virtual ~RegionCommit(){};
 
   void fromData(DataInput& input);
@@ -55,6 +57,7 @@ class RegionCommit {
   CacheableStringPtr m_regionPath;
   CacheableStringPtr m_parentRegionPath;
   std::vector< std::shared_ptr<FarSideEntryOp> > m_farSideEntryOps;
+  MemberListForVersionStamp& m_memberListForVersionStamp;
 };
 }  // namespace client
 }  // namespace geode

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionExpiryHandler.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionExpiryHandler.cpp b/src/cppcache/src/RegionExpiryHandler.cpp
index 66e74c5..ba97f16 100644
--- a/src/cppcache/src/RegionExpiryHandler.cpp
+++ b/src/cppcache/src/RegionExpiryHandler.cpp
@@ -62,14 +62,17 @@ int RegionExpiryHandler::handle_timeout(const ACE_Time_Value& current_time,
       // (lastAccessTime + entryExpiryDuration - curr_time) in seconds
       LOGDEBUG("Resetting expiry task for region [%s] after %d sec",
                m_regionPtr->getFullPath(), -sec);
-      CacheImpl::expiryTaskManager->resetTask(m_expiryTaskId, -sec);
+      m_regionPtr->getCacheImpl()->getExpiryTaskManager().resetTask(
+          m_expiryTaskId, -sec);
       return 0;
     }
+    LOGDEBUG("Removing expiry task for region [%s]",
+             m_regionPtr->getFullPath());
+    m_regionPtr->getCacheImpl()->getExpiryTaskManager().resetTask(
+        m_expiryTaskId, 0);
   } catch (...) {
     // Ignore whatever exception comes
   }
-  LOGDEBUG("Removing expiry task for region [%s]", m_regionPtr->getFullPath());
-  CacheImpl::expiryTaskManager->resetTask(m_expiryTaskId, 0);
   //  we now delete the handler in GF_Timer_Heap_ImmediateReset_T
   // and always return success.
   return 0;

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionFactory.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionFactory.cpp b/src/cppcache/src/RegionFactory.cpp
index a25b7e3..6d2b41a 100644
--- a/src/cppcache/src/RegionFactory.cpp
+++ b/src/cppcache/src/RegionFactory.cpp
@@ -35,10 +35,11 @@ namespace apache {
 namespace geode {
 namespace client {
 
-RegionFactory::RegionFactory(RegionShortcut preDefinedRegion) {
-  m_preDefinedRegion = preDefinedRegion;
-  m_attributeFactory = std::make_shared<AttributesFactory>();
-  ;
+RegionFactory::RegionFactory(RegionShortcut preDefinedRegion,
+                             CacheImpl* cacheImpl)
+    : m_preDefinedRegion(preDefinedRegion),
+      m_attributeFactory(std::make_shared<AttributesFactory>()),
+      m_cacheImpl(cacheImpl) {
   setRegionShortcut();
 }
 
@@ -47,36 +48,38 @@ RegionFactory::~RegionFactory() {}
 RegionPtr RegionFactory::create(const char* name) {
   RegionPtr retRegionPtr = nullptr;
   RegionAttributesPtr regAttr = m_attributeFactory->createRegionAttributes();
-
-  // assuming pool name is not DEFAULT_POOL_NAME
-  if (regAttr->getPoolName() != nullptr && strlen(regAttr->getPoolName()) > 0) {
-    // poolname is set
-    CachePtr cache = CacheFactory::getAnyInstance();
-    CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache.get());
-    cacheImpl->createRegion(name, regAttr, retRegionPtr);
-  } else {
-    // need to look default Pool
-    ACE_Guard<ACE_Recursive_Thread_Mutex> connectGuard(*g_disconnectLock);
-    // if local region no need to create default pool
-    if (m_preDefinedRegion != LOCAL) {
-      PoolPtr pool = CacheFactory::createOrGetDefaultPool();
-      if (pool == nullptr) {
-        throw IllegalStateException("Pool is not defined create region.");
-      }
-      m_attributeFactory->setPoolName(pool->getName());
+  if (m_preDefinedRegion != LOCAL && (regAttr->getPoolName() == nullptr ||
+                                      strlen(regAttr->getPoolName()) == 0)) {
+    auto pool = m_cacheImpl->getPoolManager().getDefaultPool();
+    if (!pool) {
+      throw IllegalStateException("No pool for non-local region.");
     }
-
+    m_attributeFactory->setPoolName(pool->getName());
     regAttr = m_attributeFactory->createRegionAttributes();
-    CachePtr cache = CacheFactory::getAnyInstance();
-    CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache.get());
-    cacheImpl->createRegion(name, regAttr, retRegionPtr);
   }
+  m_cacheImpl->createRegion(name, regAttr, retRegionPtr);
 
   return retRegionPtr;
 }
 
 void RegionFactory::setRegionShortcut() {
-  CacheImpl::setRegionShortcut(m_attributeFactory, m_preDefinedRegion);
+  switch (m_preDefinedRegion) {
+    case PROXY: {
+      m_attributeFactory->setCachingEnabled(false);
+    } break;
+    case CACHING_PROXY: {
+      m_attributeFactory->setCachingEnabled(true);
+    } break;
+    case CACHING_PROXY_ENTRY_LRU: {
+      m_attributeFactory->setCachingEnabled(true);
+      m_attributeFactory->setLruEntriesLimit(DEFAULT_LRU_MAXIMUM_ENTRIES);
+    } break;
+    case LOCAL: {
+    } break;
+    case LOCAL_ENTRY_LRU: {
+      m_attributeFactory->setLruEntriesLimit(DEFAULT_LRU_MAXIMUM_ENTRIES);
+    } break;
+  }
 }
 
 RegionFactoryPtr RegionFactory::setCacheLoader(

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionInternal.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionInternal.cpp b/src/cppcache/src/RegionInternal.cpp
index 0dc47cb..860acfe 100644
--- a/src/cppcache/src/RegionInternal.cpp
+++ b/src/cppcache/src/RegionInternal.cpp
@@ -37,8 +37,9 @@ const CacheEventFlags CacheEventFlags::CACHE_CLOSE(
 const CacheEventFlags CacheEventFlags::NOCACHEWRITER(
     CacheEventFlags::GF_NOCACHEWRITER);
 
-RegionInternal::RegionInternal(const RegionAttributesPtr& attributes)
-    : m_regionAttributes(attributes) {}
+RegionInternal::RegionInternal(const CachePtr& cache,
+                               const RegionAttributesPtr& attributes)
+    : Region(cache), m_regionAttributes(attributes) {}
 
 RegionInternal::~RegionInternal() {}
 

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionInternal.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionInternal.hpp b/src/cppcache/src/RegionInternal.hpp
index 1b8c639..4b30bca 100644
--- a/src/cppcache/src/RegionInternal.hpp
+++ b/src/cppcache/src/RegionInternal.hpp
@@ -82,26 +82,40 @@ class CacheEventFlags {
     return (m_flags == flags.m_flags);
   }
 
-  inline bool isNormal() const { return (m_flags & GF_NORMAL); }
+  inline bool isNormal() const {
+    return (m_flags & GF_NORMAL) > 0 ? true : false;
+  }
 
-  inline bool isLocal() const { return (m_flags & GF_LOCAL); }
+  inline bool isLocal() const {
+    return (m_flags & GF_LOCAL) > 0 ? true : false;
+  }
 
-  inline bool isNotification() const { return (m_flags & GF_NOTIFICATION); }
+  inline bool isNotification() const {
+    return (m_flags & GF_NOTIFICATION) > 0 ? true : false;
+  }
 
   inline bool isNotificationUpdate() const {
-    return (m_flags & GF_NOTIFICATION_UPDATE);
+    return (m_flags & GF_NOTIFICATION_UPDATE) > 0 ? true : false;
   }
 
-  inline bool isEviction() const { return (m_flags & GF_EVICTION); }
+  inline bool isEviction() const {
+    return (m_flags & GF_EVICTION) > 0 ? true : false;
+  }
 
-  inline bool isExpiration() const { return (m_flags & GF_EXPIRATION); }
+  inline bool isExpiration() const {
+    return (m_flags & GF_EXPIRATION) > 0 ? true : false;
+  }
 
-  inline bool isCacheClose() const { return (m_flags & GF_CACHE_CLOSE); }
+  inline bool isCacheClose() const {
+    return (m_flags & GF_CACHE_CLOSE) > 0 ? true : false;
+  }
 
-  inline bool isNoCacheWriter() const { return (m_flags & GF_NOCACHEWRITER); }
+  inline bool isNoCacheWriter() const {
+    return (m_flags & GF_NOCACHEWRITER) > 0 ? true : false;
+  }
 
   inline bool isEvictOrExpire() const {
-    return (m_flags & (GF_EVICTION | GF_EXPIRATION));
+    return (m_flags & (GF_EVICTION | GF_EXPIRATION)) > 0 ? true : false;
   }
 
   // special optimized method for CacheWriter invocation condition
@@ -254,7 +268,7 @@ class RegionInternal : public Region {
   /**
    * @brief constructor
    */
-  RegionInternal(const RegionAttributesPtr& attributes);
+  RegionInternal(const CachePtr& cache, const RegionAttributesPtr& attributes);
 
   void setLruEntriesLimit(uint32_t limit);
   void setRegionTimeToLiveExpirationAction(ExpirationAction::Action action);
@@ -286,10 +300,8 @@ class RegionInternal : public Region {
     return m_regionAttributes->getRegionExpiryEnabled();
   }
 
- private:
-  // Disallow copy constructor and assignment operator.
-  RegionInternal(const RegionInternal&);
-  RegionInternal& operator=(const RegionInternal&);
+  RegionInternal(const RegionInternal&) = delete;
+  RegionInternal& operator=(const RegionInternal&) = delete;
 };
 
 typedef std::shared_ptr<RegionInternal> RegionInternalPtr;

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionStats.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionStats.cpp b/src/cppcache/src/RegionStats.cpp
index e8f8004..3c6192c 100644
--- a/src/cppcache/src/RegionStats.cpp
+++ b/src/cppcache/src/RegionStats.cpp
@@ -15,22 +15,13 @@
  * limitations under the License.
  */
 
-#include <geode/geode_globals.hpp>
-
-#include "RegionStats.hpp"
-//#include "StatisticsFactory.hpp"
-
 #include <ace/Thread_Mutex.h>
 #include <ace/Singleton.h>
 
-#include <mutex>
-
-#include "util/concurrent/spinlock_mutex.hpp"
-
-const char* statsName = "RegionStatistics";
-const char* statsDesc = "Statistics for this region";
+#include <geode/geode_globals.hpp>
+#include <util/concurrent/spinlock_mutex.hpp>
 
-////////////////////////////////////////////////////////////////////////////////
+#include "RegionStats.hpp"
 
 namespace apache {
 namespace geode {
@@ -39,124 +30,111 @@ namespace client {
 using statistics::StatisticsFactory;
 using util::concurrent::spinlock_mutex;
 
-////////////////////////////////////////////////////////////////////////////////
-
-RegionStatType* RegionStatType::single = nullptr;
-spinlock_mutex RegionStatType::m_singletonLock;
-spinlock_mutex RegionStatType::m_statTypeLock;
+constexpr const char* RegionStats::STATS_NAME;
+constexpr const char* RegionStats::STATS_DESC;
 
-void RegionStatType::clean() {
-  std::lock_guard<spinlock_mutex> guard(m_singletonLock);
-  if (single) {
-    delete single;
-    single = nullptr;
-  }
-}
+RegionStats::RegionStats(StatisticsFactory* factory,
+                         const std::string& regionName) {
+  auto statsType = factory->findType(STATS_NAME);
 
-StatisticsType* RegionStatType::getStatType() {
-  const bool largerIsBetter = true;
-  std::lock_guard<spinlock_mutex> guard(m_statTypeLock);
-  StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
-  GF_D_ASSERT(!!factory);
-
-  StatisticsType* statsType = factory->findType("RegionStatistics");
-
-  if (statsType == nullptr) {
-    m_stats[0] = factory->createIntCounter(
+  if (!statsType) {
+    const bool largerIsBetter = true;
+    auto stats = new StatisticDescriptor*[25];
+    stats[0] = factory->createIntCounter(
         "creates", "The total number of cache creates for this region",
         "entries", largerIsBetter);
-    m_stats[1] = factory->createIntCounter(
+    stats[1] = factory->createIntCounter(
         "puts", "The total number of cache puts for this region", "entries",
         largerIsBetter);
-    m_stats[2] = factory->createIntCounter(
+    stats[2] = factory->createIntCounter(
         "gets", "The total number of cache gets for this region", "entries",
         largerIsBetter);
-    m_stats[3] = factory->createIntCounter(
+    stats[3] = factory->createIntCounter(
         "hits", "The total number of cache hits for this region", "entries",
         largerIsBetter);
-    m_stats[4] = factory->createIntCounter(
+    stats[4] = factory->createIntCounter(
         "misses", "The total number of cache misses for this region", "entries",
         !largerIsBetter);
-    m_stats[5] = factory->createIntGauge(
+    stats[5] = factory->createIntGauge(
         "entries", "The current number of cache entries for this region",
         "entries", largerIsBetter);
-    m_stats[6] = factory->createIntCounter(
+    stats[6] = factory->createIntCounter(
         "destroys", "The total number of cache destroys for this region",
         "entries", largerIsBetter);
-    m_stats[7] =
+    stats[7] =
         factory->createIntCounter("overflows",
                                   "The total number of cache overflows for "
                                   "this region to persistence backup",
                                   "entries", largerIsBetter);
-    m_stats[8] =
+    stats[8] =
         factory->createIntCounter("retrieves",
                                   "The total number of cache entries fetched "
                                   "from persistence backup into the cache",
                                   "entries", largerIsBetter);
-    m_stats[9] =
+    stats[9] =
         factory->createIntCounter("metaDataRefreshCount",
                                   "The total number of times matadata is "
                                   "refreshed due to hoping observed",
                                   "entries", !largerIsBetter);
-    m_stats[10] = factory->createIntCounter(
+    stats[10] = factory->createIntCounter(
         "getAll", "The total number of cache getAll for this region", "entries",
         largerIsBetter);
-    m_stats[11] = factory->createIntCounter(
+    stats[11] = factory->createIntCounter(
         "putAll", "The total number of cache putAll for this region", "entries",
         largerIsBetter);
-    m_stats[12] = factory->createLongCounter(
+    stats[12] = factory->createLongCounter(
         "getTime", "Total time spent doing get operations for this region",
         "Nanoseconds", !largerIsBetter);
-    m_stats[13] = factory->createLongCounter(
+    stats[13] = factory->createLongCounter(
         "putTime", "Total time spent doing puts operations for this region",
         "Nanoseconds", !largerIsBetter);
-    m_stats[14] = factory->createLongCounter(
+    stats[14] = factory->createLongCounter(
         "putAllTime",
         "Total time spent doing putAlls operations for this region",
         "Nanoseconds", !largerIsBetter);
-    m_stats[15] = factory->createLongCounter(
+    stats[15] = factory->createLongCounter(
         "getAllTime",
         "Total time spent doing the getAlls operations for this region",
         "Nanoseconds", !largerIsBetter);
 
-    m_stats[16] = factory->createIntCounter(
+    stats[16] = factory->createIntCounter(
         "cacheLoaderCallsCompleted",
         "Total number of times a load has completed for this region", "entries",
         largerIsBetter);
-    m_stats[17] = factory->createLongCounter(
+    stats[17] = factory->createLongCounter(
         "cacheLoaderCallTIme",
         "Total time spent invoking the loaders for this region", "Nanoseconds",
         !largerIsBetter);
-    m_stats[18] =
+    stats[18] =
         factory->createIntCounter("cacheWriterCallsCompleted",
                                   "Total number of times a cache writer call "
                                   "has completed for this region",
                                   "entries", largerIsBetter);
-    m_stats[19] = factory->createLongCounter(
+    stats[19] = factory->createLongCounter(
         "cacheWriterCallTime", "Total time spent doing cache writer calls",
         "Nanoseconds", !largerIsBetter);
-    m_stats[20] =
+    stats[20] =
         factory->createIntCounter("cacheListenerCallsCompleted",
                                   "Total number of times a cache listener call "
                                   "has completed for this region",
                                   "entries", largerIsBetter);
-    m_stats[21] = factory->createLongCounter(
+    stats[21] = factory->createLongCounter(
         "cacheListenerCallTime",
         "Total time spent doing cache listener calls for this region",
         "Nanoseconds", !largerIsBetter);
-    m_stats[22] =
+    stats[22] =
         factory->createIntCounter("clears",
                                   "The total number of times a clear has been "
                                   "done on this cache for this region",
                                   "entries", !largerIsBetter);
-    m_stats[23] = factory->createIntCounter(
+    stats[23] = factory->createIntCounter(
         "removeAll", "The total number of cache removeAll for this region",
         "entries", largerIsBetter);
-    m_stats[24] = factory->createLongCounter(
+    stats[24] = factory->createLongCounter(
         "removeAllTime",
         "Total time spent doing removeAlls operations for this region",
         "Nanoseconds", !largerIsBetter);
-    statsType = factory->createType(statsName, statsDesc, m_stats, 25);
+    statsType = factory->createType(STATS_NAME, STATS_DESC, stats, 25);
   }
 
   m_destroysId = statsType->nameToId("destroys");
@@ -186,87 +164,8 @@ StatisticsType* RegionStatType::getStatType() {
   m_ListenerCallTimeId = statsType->nameToId("cacheListenerCallTime");
   m_clearsId = statsType->nameToId("clears");
 
-  return statsType;
-}
-
-RegionStatType* RegionStatType::getInstance() {
-  std::lock_guard<spinlock_mutex> guard(m_singletonLock);
-  if (!single) {
-    single = new RegionStatType();
-  }
-  return single;
-}
-
-RegionStatType::RegionStatType()
-    : m_destroysId(0),
-      m_createsId(0),
-      m_putsId(0),
-      m_putTimeId(0),
-      m_putAllId(0),
-      m_putAllTimeId(0),
-      m_removeAllId(0),
-      m_removeAllTimeId(0),
-      m_getsId(0),
-      m_getTimeId(0),
-      m_getAllId(0),
-      m_getAllTimeId(0),
-      m_hitsId(0),
-      m_missesId(0),
-      m_entriesId(0),
-      m_overflowsId(0),
-      m_retrievesId(0),
-      m_metaDataRefreshId(0),
-      m_LoaderCallsCompletedId(0),
-      m_LoaderCallTimeId(0),
-      m_WriterCallsCompletedId(0),
-      m_WriterCallTimeId(0),
-      m_ListenerCallsCompletedId(0),
-      m_ListenerCallTimeId(0),
-      m_clearsId(0) {}
-
-////////////////////////////////////////////////////////////////////////////////
-
-// typedef ACE_Singleton<RegionStatsInit, ACE_Thread_Mutex> TheRegionStatsInit;
-
-////////////////////////////////////////////////////////////////////////////////
-
-RegionStats::RegionStats(const char* regionName) {
-  RegionStatType* regStatType = RegionStatType::getInstance();
-
-  StatisticsType* statsType = regStatType->getStatType();
-
-  GF_D_ASSERT(statsType != nullptr);
-
-  StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
-
-  m_regionStats =
-      factory->createAtomicStatistics(statsType, const_cast<char*>(regionName));
-
-  m_destroysId = regStatType->getDestroysId();
-  m_createsId = regStatType->getCreatesId();
-  m_putsId = regStatType->getPutsId();
-  m_putTimeId = regStatType->getPutTimeId();
-  m_getsId = regStatType->getGetsId();
-  m_getTimeId = regStatType->getGetTimeId();
-  m_getAllId = regStatType->getGetAllId();
-  m_getAllTimeId = regStatType->getGetAllTimeId();
-  m_putAllId = regStatType->getPutAllId();
-  m_putAllTimeId = regStatType->getPutAllTimeId();
-  m_removeAllId = regStatType->getRemoveAllId();
-  m_removeAllTimeId = regStatType->getRemoveAllTimeId();
-  m_hitsId = regStatType->getHitsId();
-  m_missesId = regStatType->getMissesId();
-  m_entriesId = regStatType->getEntriesId();
-  m_overflowsId = regStatType->getOverflowsId();
-  m_retrievesId = regStatType->getRetrievesId();
-  m_metaDataRefreshId = regStatType->getMetaDataRefreshCount();
-  m_LoaderCallsCompletedId = regStatType->getLoaderCallsCompletedId();
-  m_LoaderCallTimeId = regStatType->getLoaderCallTimeId();
-  m_WriterCallsCompletedId = regStatType->getWriterCallsCompletedId();
-  m_WriterCallTimeId = regStatType->getWriterCallTimeId();
-  m_ListenerCallsCompletedId = regStatType->getListenerCallsCompletedId();
-  m_ListenerCallTimeId = regStatType->getListenerCallTimeId();
-  m_clearsId = regStatType->getClearsId();
+  m_regionStats = factory->createAtomicStatistics(
+      statsType, const_cast<char*>(regionName.c_str()));
 
   m_regionStats->setInt(m_destroysId, 0);
   m_regionStats->setInt(m_createsId, 0);

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionStats.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionStats.hpp b/src/cppcache/src/RegionStats.hpp
index f37ca1b..0bedfde 100644
--- a/src/cppcache/src/RegionStats.hpp
+++ b/src/cppcache/src/RegionStats.hpp
@@ -20,10 +20,11 @@
 #ifndef GEODE_REGIONSTATS_H_
 #define GEODE_REGIONSTATS_H_
 
+#include <string>
+
 #include <geode/geode_globals.hpp>
 #include <geode/statistics/Statistics.hpp>
 #include <geode/statistics/StatisticsFactory.hpp>
-#include "util/concurrent/spinlock_mutex.hpp"
 
 namespace apache {
 namespace geode {
@@ -32,12 +33,11 @@ namespace client {
 using statistics::StatisticDescriptor;
 using statistics::StatisticsType;
 using statistics::Statistics;
-using util::concurrent::spinlock_mutex;
 
 class CPPCACHE_EXPORT RegionStats {
  public:
   /** hold statistics for a region.. */
-  RegionStats(const char* regionName);
+  RegionStats(statistics::StatisticsFactory* factory, const std::string& regionName);
 
   /** disable stat collection for this item. */
   virtual ~RegionStats();
@@ -88,56 +88,32 @@ class CPPCACHE_EXPORT RegionStats {
 
   inline void incClears() { m_regionStats->incInt(m_clearsId, 1); }
 
+  inline void updateGetTime() { m_regionStats->incInt(m_clearsId, 1); }
+
   inline apache::geode::statistics::Statistics* getStat() {
     return m_regionStats;
   }
 
- private:
-  apache::geode::statistics::Statistics* m_regionStats;
+  inline int32_t getGetTimeId() { return m_getTimeId; }
 
-  int32_t m_destroysId;
-  int32_t m_createsId;
-  int32_t m_putsId;
-  int32_t m_putTimeId;
-  int32_t m_putAllId;
-  int32_t m_putAllTimeId;
-  int32_t m_removeAllId;
-  int32_t m_removeAllTimeId;
-  int32_t m_getsId;
-  int32_t m_getTimeId;
-  int32_t m_getAllId;
-  int32_t m_getAllTimeId;
-  int32_t m_hitsId;
-  int32_t m_missesId;
-  int32_t m_entriesId;
-  int32_t m_overflowsId;
-  int32_t m_retrievesId;
-  int32_t m_metaDataRefreshId;
-  int32_t m_LoaderCallsCompletedId;
-  int32_t m_LoaderCallTimeId;
-  int32_t m_WriterCallsCompletedId;
-  int32_t m_WriterCallTimeId;
-  int32_t m_ListenerCallsCompletedId;
-  int32_t m_ListenerCallTimeId;
-  int32_t m_clearsId;
-};
+  inline int32_t getPutTimeId() { return m_putTimeId; }
 
-class RegionStatType {
- private:
-  static RegionStatType* single;
-  static spinlock_mutex m_singletonLock;
-  static spinlock_mutex m_statTypeLock;
+  inline int32_t getGetAllTimeId() { return m_getAllTimeId; }
 
- public:
-  static RegionStatType* getInstance();
+  inline int32_t getPutAllTimeId() { return m_putAllTimeId; }
+
+  inline int32_t getRemoveAllTimeId() { return m_removeAllTimeId; }
 
-  statistics::StatisticsType* getStatType();
+  inline int32_t getLoaderCallTimeId() { return m_LoaderCallTimeId; }
 
-  static void clean();
+  inline int32_t getWriterCallTimeId() { return m_WriterCallTimeId; }
+
+  inline int32_t getListenerCallTimeId() { return m_ListenerCallTimeId; }
+
+  inline int32_t getClearsId() { return m_clearsId; }
 
  private:
-  RegionStatType();
-  statistics::StatisticDescriptor* m_stats[25];
+  apache::geode::statistics::Statistics* m_regionStats;
 
   int32_t m_destroysId;
   int32_t m_createsId;
@@ -165,63 +141,10 @@ class RegionStatType {
   int32_t m_ListenerCallTimeId;
   int32_t m_clearsId;
 
- public:
-  inline int32_t getDestroysId() { return m_destroysId; }
-
-  inline int32_t getCreatesId() { return m_createsId; }
-
-  inline int32_t getPutsId() { return m_putsId; }
-
-  inline int32_t getPutTimeId() { return m_putTimeId; }
-
-  inline int32_t getPutAllId() { return m_putAllId; }
-
-  inline int32_t getPutAllTimeId() { return m_putAllTimeId; }
-
-  inline int32_t getRemoveAllId() { return m_removeAllId; }
-
-  inline int32_t getRemoveAllTimeId() { return m_removeAllTimeId; }
-
-  inline int32_t getGetsId() { return m_getsId; }
-
-  inline int32_t getGetTimeId() { return m_getTimeId; }
-
-  inline int32_t getGetAllId() { return m_getAllId; }
-
-  inline int32_t getGetAllTimeId() { return m_getAllTimeId; }
-
-  inline int32_t getHitsId() { return m_hitsId; }
-
-  inline int32_t getMissesId() { return m_missesId; }
-
-  inline int32_t getEntriesId() { return m_entriesId; }
-
-  inline int32_t getOverflowsId() { return m_overflowsId; }
-
-  inline int32_t getRetrievesId() { return m_retrievesId; }
-
-  inline int32_t getMetaDataRefreshCount() { return m_metaDataRefreshId; }
-
-  inline int32_t getLoaderCallsCompletedId() {
-    return m_LoaderCallsCompletedId;
-  }
-
-  inline int32_t getLoaderCallTimeId() { return m_LoaderCallTimeId; }
-
-  inline int32_t getWriterCallsCompletedId() {
-    return m_WriterCallsCompletedId;
-  }
-
-  inline int32_t getWriterCallTimeId() { return m_WriterCallTimeId; }
-
-  inline int32_t getListenerCallsCompletedId() {
-    return m_ListenerCallsCompletedId;
-  }
-
-  inline int32_t getListenerCallTimeId() { return m_ListenerCallTimeId; }
-
-  inline int32_t getClearsId() { return m_clearsId; }
+  static constexpr const char* STATS_NAME = "RegionStatistics";
+  static constexpr const char* STATS_DESC = "Statistics for this region";
 };
+
 }  // namespace client
 }  // namespace geode
 }  // namespace apache

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionXmlCreation.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionXmlCreation.cpp b/src/cppcache/src/RegionXmlCreation.cpp
index 37de2e0..8b234d0 100644
--- a/src/cppcache/src/RegionXmlCreation.cpp
+++ b/src/cppcache/src/RegionXmlCreation.cpp
@@ -20,9 +20,9 @@
 #include "RegionXmlCreation.hpp"
 #include "CacheImpl.hpp"
 using namespace apache::geode::client;
-extern bool Cache_CreatedFromCacheFactory;
 
-void RegionXmlCreation::addSubregion(RegionXmlCreation* regionPtr) {
+void RegionXmlCreation::addSubregion(
+    std::shared_ptr<RegionXmlCreation> regionPtr) {
   subRegions.push_back(regionPtr);
 }
 
@@ -33,11 +33,8 @@ void RegionXmlCreation::setAttributes(RegionAttributesPtr attrsPtr) {
 RegionAttributesPtr RegionXmlCreation::getAttributes() { return regAttrs; }
 
 void RegionXmlCreation::fillIn(RegionPtr regionPtr) {
-  std::vector<RegionXmlCreation*>::iterator start = subRegions.begin();
-  while (start != subRegions.end()) {
-    RegionXmlCreation* regXmlCreation = *start;
+  for (const auto& regXmlCreation : subRegions) {
     regXmlCreation->create(regionPtr);
-    start++;
   }
 }
 
@@ -45,23 +42,6 @@ void RegionXmlCreation::createRoot(Cache* cache) {
   GF_D_ASSERT(this->isRoot);
   RegionPtr rootRegPtr = nullptr;
 
-  if (Cache_CreatedFromCacheFactory) {
-    //  if(cache->m_cacheImpl->getDefaultPool() == nullptr)
-    {
-      // we may need to initialize default pool
-      if (regAttrs->getEndpoints() == nullptr) {
-        if (regAttrs->getPoolName() == nullptr) {
-          PoolPtr pool = CacheFactory::createOrGetDefaultPool();
-
-          if (pool == nullptr) {
-            throw IllegalStateException("Pool is not defined create region.");
-          }
-          regAttrs->setPoolName(pool->getName());
-        }
-      }
-    }
-  }
-
   CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache);
   cacheImpl->createRegion(regionName.c_str(), regAttrs, rootRegPtr);
   fillIn(rootRegPtr);
@@ -83,15 +63,6 @@ RegionXmlCreation::RegionXmlCreation(char* name, bool isRootRegion)
   attrId = "";
 }
 
-RegionXmlCreation::~RegionXmlCreation() {
-  std::vector<RegionXmlCreation*>::iterator start = subRegions.begin();
-  while (start != subRegions.end()) {
-    delete *start;
-    *start = nullptr;
-    ++start;
-  }
-}
-
 std::string RegionXmlCreation::getAttrId() const { return attrId; }
 
 void RegionXmlCreation::setAttrId(const std::string& pattrId) {

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionXmlCreation.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionXmlCreation.hpp b/src/cppcache/src/RegionXmlCreation.hpp
index 0c31425..a0bd853 100644
--- a/src/cppcache/src/RegionXmlCreation.hpp
+++ b/src/cppcache/src/RegionXmlCreation.hpp
@@ -57,7 +57,7 @@ class CPPCACHE_EXPORT RegionXmlCreation {
   RegionAttributesPtr regAttrs;
 
   /** This region's subregions */
-  std::vector<RegionXmlCreation*> subRegions;
+  std::vector<std::shared_ptr<RegionXmlCreation>> subRegions;
 
  public:
   /**
@@ -69,7 +69,7 @@ class CPPCACHE_EXPORT RegionXmlCreation {
   void fillIn(RegionPtr region);
 
  public:
-  ~RegionXmlCreation();
+  ~RegionXmlCreation() = default;
   /**
    * Creates a new <code>RegionCreation</code> with the given name.
    */
@@ -78,7 +78,7 @@ class CPPCACHE_EXPORT RegionXmlCreation {
   /**
    * Adds a subregion with the given name to this region
    */
-  void addSubregion(RegionXmlCreation* regionPtr);
+  void addSubregion(std::shared_ptr<RegionXmlCreation> regionPtr);
 
   /**
    * Sets the attributes of this region

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RemoteQuery.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RemoteQuery.cpp b/src/cppcache/src/RemoteQuery.cpp
index 2c37595..b8450f5 100644
--- a/src/cppcache/src/RemoteQuery.cpp
+++ b/src/cppcache/src/RemoteQuery.cpp
@@ -70,7 +70,13 @@ SelectResultsPtr RemoteQuery::execute(uint32_t timeout, const char* func,
     pool->getStats().incQueryExecutionId();
   }
   /*get the start time for QueryExecutionTime stat*/
-  int64_t sampleStartNanos = Utils::startStatOpTime();
+  bool enableTimeStatistics = pool->getConnectionManager()
+                                  .getCacheImpl()
+                                  ->getDistributedSystem()
+                                  .getSystemProperties()
+                                  .getEnableTimeStatistics();
+  int64_t sampleStartNanos =
+      enableTimeStatistics ? Utils::startStatOpTime() : 0;
   TcrMessageReply reply(true, tcdm);
   ChunkedQueryResponse* resultCollector = (new ChunkedQueryResponse(reply));
   reply.setChunkedResultHandler(
@@ -105,11 +111,10 @@ SelectResultsPtr RemoteQuery::execute(uint32_t timeout, const char* func,
   }
 
   /*update QueryExecutionTime stat */
-  if (pool != nullptr) {
-    Utils::updateStatOpTime(
-        pool->getStats().getStats(),
-        PoolStatType::getInstance()->getQueryExecutionTimeId(),
-        sampleStartNanos);
+  if (pool != nullptr && enableTimeStatistics) {
+    Utils::updateStatOpTime(pool->getStats().getStats(),
+                            pool->getStats().getQueryExecutionTimeId(),
+                            sampleStartNanos);
   }
   delete resultCollector;
   return sr;
@@ -130,6 +135,10 @@ GfErrType RemoteQuery::executeNoThrow(uint32_t timeout, TcrMessageReply& reply,
   if (paramList != nullptr) {
     // QUERY_WITH_PARAMETERS
     TcrMessageQueryWithParameters msg(
+        m_tccdm->getConnectionManager()
+            .getCacheImpl()
+            ->getCache()
+            ->createDataOutput(),
         m_queryString, nullptr, paramList,
         static_cast<int>(timeout * 1000) /* in milli second */, tcdm);
     msg.setTimeout(timeout);
@@ -152,7 +161,11 @@ GfErrType RemoteQuery::executeNoThrow(uint32_t timeout, TcrMessageReply& reply,
     }
     return err;
   } else {
-    TcrMessageQuery msg(m_queryString,
+    TcrMessageQuery msg(m_tccdm->getConnectionManager()
+                            .getCacheImpl()
+                            ->getCache()
+                            ->createDataOutput(),
+                        m_queryString,
                         static_cast<int>(timeout * 1000) /* in milli second */,
                         tcdm);
     msg.setTimeout(timeout);

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RemoteQueryService.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RemoteQueryService.cpp b/src/cppcache/src/RemoteQueryService.cpp
index 095c7e7..d46e1b3 100644
--- a/src/cppcache/src/RemoteQueryService.cpp
+++ b/src/cppcache/src/RemoteQueryService.cpp
@@ -21,20 +21,23 @@
 #include "CqServiceVsdStats.hpp"
 #include "ThinClientPoolDM.hpp"
 #include "UserAttributes.hpp"
+#include "statistics/StatisticsManager.hpp"
 
 using namespace apache::geode::client;
 
-RemoteQueryService::RemoteQueryService(CacheImpl* cptr,
+RemoteQueryService::RemoteQueryService(CacheImpl* cache,
                                        ThinClientPoolDM* poolDM)
-    : m_invalid(true), m_cqService(nullptr) {
+    : m_invalid(true),
+      m_cqService(nullptr),
+      m_statisticsFactory(cache->getDistributedSystem()
+                              .getStatisticsManager()
+                              ->getStatisticsFactory()) {
   if (poolDM) {
     m_tccdm = poolDM;
   } else {
     m_tccdm =
-        new ThinClientCacheDistributionManager(cptr->tcrConnectionManager());
+        new ThinClientCacheDistributionManager(cache->tcrConnectionManager());
   }
-  // m_cqService = new CqService(m_tccdm);
-  // m_tccdm->init();
   LOGFINEST("Initialized m_tccdm");
 }
 
@@ -242,10 +245,10 @@ CqServiceStatisticsPtr RemoteQueryService::getCqServiceStatistics() {
         "QueryService::getCqServiceStatistics: Cache has been closed.");
   }
   // If cqService has not started, then no cq exists
-  if (m_cqService != nullptr) {
+  if (m_cqService) {
     return m_cqService->getCqServiceStatistics();
   }
-  return std::make_shared<CqServiceVsdStats>();
+  return nullptr;
 }
 
 void RemoteQueryService::receiveNotification(TcrMessage* msg) {

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RemoteQueryService.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RemoteQueryService.hpp b/src/cppcache/src/RemoteQueryService.hpp
index ec9567d..feca89c 100644
--- a/src/cppcache/src/RemoteQueryService.hpp
+++ b/src/cppcache/src/RemoteQueryService.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_REMOTEQUERYSERVICE_H_
-#define GEODE_REMOTEQUERYSERVICE_H_
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -19,14 +14,20 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+#pragma once
+
+#ifndef GEODE_REMOTEQUERYSERVICE_H_
+#define GEODE_REMOTEQUERYSERVICE_H_
+
+#include <ace/Recursive_Thread_Mutex.h>
 #include <geode/geode_globals.hpp>
 #include <memory>
-#include "CqService.hpp"
-
 #include <geode/QueryService.hpp>
-#include "ThinClientCacheDistributionManager.hpp"
 
-#include <ace/Recursive_Thread_Mutex.h>
+#include "CqService.hpp"
+#include "ThinClientCacheDistributionManager.hpp"
+#include "statistics/StatisticsManager.hpp"
 
 namespace apache {
 namespace geode {
@@ -73,7 +74,7 @@ class CPPCACHE_EXPORT RemoteQueryService
   inline void initCqService() {
     if (m_cqService == nullptr) {
       LOGFINE("RemoteQueryService: starting cq service");
-      m_cqService = std::make_shared<CqService>(m_tccdm);
+      m_cqService = std::make_shared<CqService>(m_tccdm, m_statisticsFactory);
       LOGFINE("RemoteQueryService: started cq service");
     }
   }
@@ -85,6 +86,7 @@ class CPPCACHE_EXPORT RemoteQueryService
   ThinClientBaseDM* m_tccdm;
   CqServicePtr m_cqService;
   CqPoolsConnected m_CqPoolsConnected;
+  statistics::StatisticsFactory* m_statisticsFactory;
 };
 
 typedef std::shared_ptr<RemoteQueryService> RemoteQueryServicePtr;

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/Serializable.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/Serializable.cpp b/src/cppcache/src/Serializable.cpp
index db2d17a..143385d 100644
--- a/src/cppcache/src/Serializable.cpp
+++ b/src/cppcache/src/Serializable.cpp
@@ -20,6 +20,7 @@
 #include <SerializationRegistry.hpp>
 #include <Utils.hpp>
 #include <geode/CacheableString.hpp>
+#include "CacheImpl.hpp"
 
 namespace apache {
 namespace geode {
@@ -42,18 +43,6 @@ int8_t Serializable::DSFID() const {
 
 uint32_t Serializable::objectSize() const { return 0; }
 
-void Serializable::registerType(TypeFactoryMethod creationFunction) {
-  SerializationRegistry::addType(creationFunction);
-}
-
-void Serializable::registerPdxType(TypeFactoryMethodPdx creationFunction) {
-  SerializationRegistry::addPdxType(creationFunction);
-}
-
-void Serializable::registerPdxSerializer(PdxSerializerPtr pdxSerializer) {
-  SerializationRegistry::setPdxSerializer(pdxSerializer);
-}
-
 CacheableStringPtr Serializable::toString() const {
   return Utils::demangleTypeName(typeid(*this).name());
 }


Mime
View raw message