You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ec...@apache.org on 2017/08/10 15:20:22 UTC

[14/27] geode-native git commit: GEODE-2729: Remove global variables

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheImpl.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheImpl.cpp b/src/cppcache/src/CacheImpl.cpp
index 4995d60..a7c5157 100644
--- a/src/cppcache/src/CacheImpl.cpp
+++ b/src/cppcache/src/CacheImpl.cpp
@@ -14,56 +14,48 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-#include "CacheImpl.hpp"
 #include <string>
+#include <string>
+
+#include <ace/OS.h>
 #include <geode/CacheStatistics.hpp>
+#include <geode/PoolManager.hpp>
+#include <geode/SystemProperties.hpp>
+#include <geode/PoolManager.hpp>
+#include <geode/RegionAttributes.hpp>
+#include <geode/PersistenceManager.hpp>
+
+#include "CacheImpl.hpp"
 #include "Utils.hpp"
 #include "LocalRegion.hpp"
 #include "ExpiryTaskManager.hpp"
-#include <geode/PersistenceManager.hpp>
 #include "RegionExpiryHandler.hpp"
 #include "TcrMessage.hpp"
 #include "ThinClientRegion.hpp"
 #include "ThinClientHARegion.hpp"
 #include "ThinClientPoolRegion.hpp"
 #include "ThinClientPoolDM.hpp"
-#include <geode/PoolManager.hpp>
-#include <geode/SystemProperties.hpp>
 #include "Version.hpp"
 #include "ClientProxyMembershipID.hpp"
 #include "AutoDelete.hpp"
-#include <string>
-#include "ace/OS.h"
-#include <geode/PoolManager.hpp>
-#include <geode/RegionAttributes.hpp>
 #include "ThinClientPoolHADM.hpp"
 #include "InternalCacheTransactionManager2PCImpl.hpp"
 #include "PdxTypeRegistry.hpp"
+#include "SerializationRegistry.hpp"
+#include "ThreadPool.hpp"
 
 using namespace apache::geode::client;
 
-ExpiryTaskManager* CacheImpl::expiryTaskManager = nullptr;
-CacheImpl* CacheImpl::s_instance = nullptr;
-volatile bool CacheImpl::s_networkhop = false;
-volatile int CacheImpl::s_blacklistBucketTimeout = 0;
-ACE_Recursive_Thread_Mutex CacheImpl::s_nwHopLock;
-volatile int8_t CacheImpl::s_serverGroupFlag = 0;
-
-#define DEFAULT_LRU_MAXIMUM_ENTRIES 100000
-
-ExpiryTaskManager* getCacheImplExpiryTaskManager() {
-  return CacheImpl::expiryTaskManager;
-}
-
-CacheImpl::CacheImpl(Cache* c, const char* name, DistributedSystemPtr sys,
-                     const char* id_data, bool iPUF, bool readPdxSerialized)
-    : m_defaultPool(nullptr),
+CacheImpl::CacheImpl(Cache* c, const std::string& name,
+                     std::unique_ptr<DistributedSystem> sys, bool iPUF,
+                     bool readPdxSerialized)
+    : m_name(name),
+      m_defaultPool(nullptr),
       m_ignorePdxUnreadFields(iPUF),
       m_readPdxSerialized(readPdxSerialized),
       m_closed(false),
       m_initialized(false),
-      m_distributedSystem(sys),
+      m_distributedSystem(std::move(sys)),
       m_implementee(c),
       m_cond(m_mutex),
       m_attributes(nullptr),
@@ -72,88 +64,42 @@ CacheImpl::CacheImpl(Cache* c, const char* name, DistributedSystemPtr sys,
       m_remoteQueryServicePtr(nullptr),
       m_destroyPending(false),
       m_initDone(false),
-      m_adminRegion(nullptr) {
+      m_adminRegion(nullptr),
+      m_memberListForVersionStamp(
+          *(std::make_shared<MemberListForVersionStamp>())),
+      m_serializationRegistry(std::make_shared<SerializationRegistry>()),
+      m_pdxTypeRegistry(std::make_shared<PdxTypeRegistry>(c)),
+      m_expiryTaskManager(
+          std::unique_ptr<ExpiryTaskManager>(new ExpiryTaskManager())),
+      m_clientProxyMembershipIDFactory(m_distributedSystem->getName()),
+      m_threadPool(new ThreadPool(
+          m_distributedSystem->getSystemProperties().threadPoolSize())) {
   m_cacheTXManager = InternalCacheTransactionManager2PCPtr(
       new InternalCacheTransactionManager2PCImpl(c));
 
-  m_name = Utils::copyString(name);
-
-  if (!DistributedSystem::isConnected()) {
-    throw IllegalArgumentException("DistributedSystem is not up");
-  }
   m_regions = new MapOfRegionWithLock();
-  SystemProperties* prop = DistributedSystem::getSystemProperties();
-  if (prop && prop->heapLRULimitEnabled()) {
-    m_evictionControllerPtr = new EvictionController(
-        prop->heapLRULimit(), prop->heapLRUDelta(), this);
+  auto& prop = m_distributedSystem->getSystemProperties();
+  if (prop.heapLRULimitEnabled()) {
+    m_evictionControllerPtr =
+        new EvictionController(prop.heapLRULimit(), prop.heapLRUDelta(), this);
     m_evictionControllerPtr->start();
     LOGINFO("Heap LRU eviction controller thread started");
   }
-  /*
-  else {
-    LOGFINE("Eviction controller is nullptr");
-  }
-  */
 
-  ClientProxyMembershipID::init(sys->getName());
+  m_cacheStats = new CachePerfStats(m_distributedSystem.get()
+                                        ->getStatisticsManager()
+                                        ->getStatisticsFactory());
+  m_expiryTaskManager->begin();
 
-  m_cacheStats = new CachePerfStats;
-
-  s_instance = this;
   m_initialized = true;
-}
 
-CacheImpl::CacheImpl(Cache* c, const char* name, DistributedSystemPtr sys,
-                     bool iPUF, bool readPdxSerialized)
-    : m_defaultPool(nullptr),
-      m_ignorePdxUnreadFields(iPUF),
-      m_readPdxSerialized(readPdxSerialized),
-      m_closed(false),
-      m_initialized(false),
-      m_distributedSystem(sys),
-      m_implementee(c),
-      m_cond(m_mutex),
-      m_attributes(nullptr),
-      m_evictionControllerPtr(nullptr),
-      m_tcrConnectionManager(nullptr),
-      m_remoteQueryServicePtr(nullptr),
-      m_destroyPending(false),
-      m_initDone(false),
-      m_adminRegion(nullptr) {
-  m_cacheTXManager = InternalCacheTransactionManager2PCPtr(
-      new InternalCacheTransactionManager2PCImpl(c));
-
-  m_name = Utils::copyString(name);
-  if (!DistributedSystem::isConnected()) {
-    throw IllegalArgumentException("DistributedSystem is not connected");
-  }
-  m_regions = new MapOfRegionWithLock();
-  SystemProperties* prop = DistributedSystem::getSystemProperties();
-  if (prop && prop->heapLRULimitEnabled()) {
-    m_evictionControllerPtr = new EvictionController(
-        prop->heapLRULimit(), prop->heapLRUDelta(), this);
-    m_evictionControllerPtr->start();
-    LOGINFO("Heap LRU eviction controller thread started");
-  }
-  /*
-  else {
-    LOGFINE("Eviction controller is nullptr");
-  }
-  */
-
-  ClientProxyMembershipID::init(sys->getName());
-
-  m_cacheStats = new CachePerfStats;
-
-  s_instance = this;
-  m_initialized = true;
+  m_poolManager = std::unique_ptr<PoolManager>(new PoolManager(*m_implementee));
 }
 
 void CacheImpl::initServices() {
   m_tcrConnectionManager = new TcrConnectionManager(this);
-  PdxTypeRegistry::init();
   if (!m_initDone && m_attributes != nullptr && m_attributes->getEndpoints()) {
-    if (PoolManager::getAll().size() > 0 && getCacheMode()) {
+    if (getCache()->getPoolManager().getAll().size() > 0 && getCacheMode()) {
       LOGWARN(
           "At least one pool has been created so ignoring cache level "
           "redundancy setting");
@@ -161,37 +107,18 @@ void CacheImpl::initServices() {
     m_tcrConnectionManager->init();
     m_remoteQueryServicePtr = std::make_shared<RemoteQueryService>(this);
     // StartAdminRegion
-    SystemProperties* prop = DistributedSystem::getSystemProperties();
-    if (prop && prop->statisticsEnabled()) {
+    auto& prop = m_distributedSystem->getSystemProperties();
+    if (prop.statisticsEnabled()) {
       m_adminRegion = AdminRegion::create(this);
     }
     m_initDone = true;
   }
 }
 
-int CacheImpl::blackListBucketTimeouts() { return s_blacklistBucketTimeout; }
-
-void CacheImpl::setBlackListBucketTimeouts() { s_blacklistBucketTimeout += 1; }
-
-bool CacheImpl::getAndResetNetworkHopFlag() {
-  ACE_Guard<ACE_Recursive_Thread_Mutex> _lock(s_nwHopLock);
-  bool networkhop = CacheImpl::s_networkhop;
-  CacheImpl::s_networkhop = false;
-  // This log should only appear in tests
-  LOGDEBUG("networkhop flag = %d", networkhop);
-  return networkhop;
-}
-
-int8_t CacheImpl::getAndResetServerGroupFlag() {
-  int8_t serverGroupFlag = CacheImpl::s_serverGroupFlag;
-  CacheImpl::s_serverGroupFlag = 0;
-  return serverGroupFlag;
-}
-
 void CacheImpl::netDown() {
   m_tcrConnectionManager->netDown();
 
-  for (const auto& itr : PoolManager::getAll()) {
+  for (const auto& itr : getCache()->getPoolManager().getAll()) {
     auto currPool = itr.second;
     if (auto poolHADM =
             std::dynamic_pointer_cast<ThinClientPoolHADM>(currPool)) {
@@ -223,7 +150,7 @@ CacheImpl::RegionKind CacheImpl::getRegionKind(
       regionKind = THINCLIENT_REGION;
     }
   } else if (rattrs->getPoolName()) {
-    PoolPtr pPtr = PoolManager::find(rattrs->getPoolName());
+    PoolPtr pPtr = getCache()->getPoolManager().find(rattrs->getPoolName());
     if ((pPtr != nullptr && (pPtr->getSubscriptionRedundancy() > 0 ||
                              pPtr->getSubscriptionEnabled())) ||
         m_tcrConnectionManager->isDurable()) {
@@ -269,7 +196,7 @@ QueryServicePtr CacheImpl::getQueryService(const char* poolName) {
   if (poolName == nullptr || strlen(poolName) == 0) {
     throw IllegalArgumentException("PoolName is nullptr or not defined..");
   }
-  PoolPtr pool = PoolManager::find(poolName);
+  PoolPtr pool = getCache()->getPoolManager().find(poolName);
 
   if (pool != nullptr) {
     if (pool->isDestroyed()) {
@@ -289,13 +216,9 @@ CacheImpl::~CacheImpl() {
   if (m_regions != nullptr) {
     delete m_regions;
   }
-
-  if (m_name != nullptr) {
-    delete[] m_name;
-  }
 }
 
-const char* CacheImpl::getName() const {
+const std::string& CacheImpl::getName() const {
   if (m_closed || m_destroyPending) {
     throw CacheClosedException("Cache::getName: cache closed");
   }
@@ -310,15 +233,12 @@ void CacheImpl::setAttributes(const CacheAttributesPtr& attrs) {
   }
 }
 
-void CacheImpl::getDistributedSystem(DistributedSystemPtr& dptr) const {
-  if (m_closed || m_destroyPending) {
-    throw CacheClosedException("Cache::getDistributedSystem: cache closed");
-  }
-  dptr = m_distributedSystem;
+DistributedSystem& CacheImpl::getDistributedSystem() const {
+  return *m_distributedSystem;
 }
 
 void CacheImpl::sendNotificationCloseMsgs() {
-  for (const auto& iter : PoolManager::getAll()) {
+  for (const auto& iter : getPoolManager().getAll()) {
     if (const auto& pool =
             std::dynamic_pointer_cast<ThinClientPoolHADM>(iter.second)) {
       pool->sendNotificationCloseMsgs();
@@ -387,11 +307,10 @@ void CacheImpl::close(bool keepalive) {
     m_cacheStats->close();
   }
 
-  PoolManager::close(keepalive);
+  m_poolManager->close(keepalive);
 
   LOGFINE("Closed pool manager with keepalive %s",
           keepalive ? "true" : "false");
-  PdxTypeRegistry::cleanup();
 
   // Close CachePef Stats
   if (m_cacheStats) {
@@ -403,6 +322,9 @@ void CacheImpl::close(bool keepalive) {
 
   GF_SAFE_DELETE(m_tcrConnectionManager);
   m_cacheTXManager = nullptr;
+
+  m_expiryTaskManager->stopExpiryTaskManager();
+
   m_closed = true;
 
   LOGFINE("Cache closed.");
@@ -410,10 +332,6 @@ void CacheImpl::close(bool keepalive) {
 
 bool CacheImpl::isCacheDestroyPending() const { return m_destroyPending; }
 
-void CacheImpl::setDefaultPool(PoolPtr pool) { m_defaultPool = pool; }
-
-PoolPtr CacheImpl::getDefaultPool() { return m_defaultPool; }
-
 void CacheImpl::validateRegionAttributes(
     const char* name, const RegionAttributesPtr& attrs) const {
   RegionKind kind = getRegionKind(attrs);
@@ -440,8 +358,8 @@ void CacheImpl::createRegion(const char* name,
       if (!(aRegionAttributes->getPoolName())) {
         m_tcrConnectionManager->init();
         m_remoteQueryServicePtr = std::make_shared<RemoteQueryService>(this);
-        SystemProperties* prop = DistributedSystem::getSystemProperties();
-        if (prop && prop->statisticsEnabled()) {
+        auto& prop = m_distributedSystem->getSystemProperties();
+        if (prop.statisticsEnabled()) {
           m_adminRegion = AdminRegion::create(this);
         }
       }
@@ -535,11 +453,11 @@ void CacheImpl::createRegion(const char* name,
     // When region is created, added that region name in client meta data
     // service to fetch its
     // metadata for single hop.
-    SystemProperties* props = DistributedSystem::getSystemProperties();
-    if (!props->isGridClient()) {
+    auto& props = m_distributedSystem->getSystemProperties();
+    if (!props.isGridClient()) {
       const char* poolName = aRegionAttributes->getPoolName();
       if (poolName != nullptr) {
-        PoolPtr pool = PoolManager::find(poolName);
+        PoolPtr pool = getCache()->getPoolManager().find(poolName);
         if (pool != nullptr && !pool->isDestroyed() &&
             pool->getPRSingleHopEnabled()) {
           ThinClientPoolDM* poolDM =
@@ -644,7 +562,7 @@ std::shared_ptr<RegionInternal> CacheImpl::createRegion_internal(
   }*/
 
   if (poolName != nullptr) {
-    PoolPtr pool = PoolManager::find(poolName);
+    PoolPtr pool = getCache()->getPoolManager().find(poolName);
     if (pool != nullptr && !pool->isDestroyed()) {
       bool isMultiUserSecureMode = pool->getMultiuserAuthentication();
       if (isMultiUserSecureMode && (attrs->getCachingEnabled())) {
@@ -718,7 +636,7 @@ EvictionController* CacheImpl::getEvictionController() {
 
 void CacheImpl::readyForEvents() {
   bool autoReadyForEvents =
-      DistributedSystem::getSystemProperties()->autoReadyForEvents();
+      m_distributedSystem->getSystemProperties().autoReadyForEvents();
   bool isDurable = m_tcrConnectionManager->isDurable();
 
   if (!isDurable && autoReadyForEvents) {
@@ -738,7 +656,7 @@ void CacheImpl::readyForEvents() {
     return;
   }
 
-  const auto& pools = PoolManager::getAll();
+  const auto& pools = getCache()->getPoolManager().getAll();
   if (pools.empty()) throw IllegalStateException("No pools found.");
   for (const auto& itr : pools) {
     const auto& currPool = itr.second;
@@ -756,7 +674,7 @@ void CacheImpl::readyForEvents() {
 }
 
 bool CacheImpl::getEndpointStatus(const std::string& endpoint) {
-  const auto& pools = PoolManager::getAll();
+  const auto& pools = getCache()->getPoolManager().getAll();
   std::string fullName = endpoint;
 
   if (pools.empty()) {
@@ -792,7 +710,8 @@ void CacheImpl::processMarker() {
     if (!q.int_id_->isDestroyed()) {
       if (const auto tcrHARegion =
               std::dynamic_pointer_cast<ThinClientHARegion>(q.int_id_)) {
-        auto regionMsg = new TcrMessageClientMarker(true);
+        auto regionMsg = new TcrMessageClientMarker(
+            this->getCache()->createDataOutput(), true);
         tcrHARegion->receiveNotification(regionMsg);
         VectorOfRegion subregions;
         tcrHARegion->subregions(true, subregions);
@@ -800,7 +719,8 @@ void CacheImpl::processMarker() {
           if (!iter->isDestroyed()) {
             if (const auto subregion =
                     std::dynamic_pointer_cast<ThinClientHARegion>(iter)) {
-              regionMsg = new TcrMessageClientMarker(true);
+              regionMsg = new TcrMessageClientMarker(
+                  this->getCache()->createDataOutput(), true);
               subregion->receiveNotification(regionMsg);
             }
           }
@@ -811,7 +731,7 @@ void CacheImpl::processMarker() {
 }
 
 int CacheImpl::getPoolSize(const char* poolName) {
-  if (const auto pool = PoolManager::find(poolName)) {
+  if (const auto pool = getCache()->getPoolManager().find(poolName)) {
     if (const auto dm = std::dynamic_pointer_cast<ThinClientPoolDM>(pool)) {
       return dm->m_poolSize;
     }
@@ -821,28 +741,7 @@ int CacheImpl::getPoolSize(const char* poolName) {
 
 RegionFactoryPtr CacheImpl::createRegionFactory(
     RegionShortcut preDefinedRegion) {
-  return std::make_shared<RegionFactory>(preDefinedRegion);
-}
-
-void CacheImpl::setRegionShortcut(AttributesFactoryPtr attrFact,
-                                  RegionShortcut preDefinedRegionAttr) {
-  switch (preDefinedRegionAttr) {
-    case PROXY: {
-      attrFact->setCachingEnabled(false);
-    } break;
-    case CACHING_PROXY: {
-      attrFact->setCachingEnabled(true);
-    } break;
-    case CACHING_PROXY_ENTRY_LRU: {
-      attrFact->setCachingEnabled(true);
-      attrFact->setLruEntriesLimit(DEFAULT_LRU_MAXIMUM_ENTRIES);
-    } break;
-    case LOCAL: {
-    } break;
-    case LOCAL_ENTRY_LRU: {
-      attrFact->setLruEntriesLimit(DEFAULT_LRU_MAXIMUM_ENTRIES);
-    } break;
-  }
+  return std::make_shared<RegionFactory>(preDefinedRegion, this);
 }
 
 std::map<std::string, RegionAttributesPtr> CacheImpl::getRegionShortcut() {
@@ -886,6 +785,16 @@ std::map<std::string, RegionAttributesPtr> CacheImpl::getRegionShortcut() {
   return preDefined;
 }
 
+PdxTypeRegistryPtr CacheImpl::getPdxTypeRegistry() const {
+  return m_pdxTypeRegistry;
+}
+
+SerializationRegistryPtr CacheImpl::getSerializationRegistry() const {
+  return m_serializationRegistry;
+}
+
+ThreadPool* CacheImpl::getThreadPool() { return m_threadPool; }
+
 CacheTransactionManagerPtr CacheImpl::getCacheTransactionManager() {
   return m_cacheTXManager;
 }

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheImpl.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheImpl.hpp b/src/cppcache/src/CacheImpl.hpp
index 6de340e..e6da435 100644
--- a/src/cppcache/src/CacheImpl.hpp
+++ b/src/cppcache/src/CacheImpl.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_CACHEIMPL_H_
-#define GEODE_CACHEIMPL_H_
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -20,6 +15,13 @@
  * limitations under the License.
  */
 
+#pragma once
+
+#ifndef GEODE_CACHEIMPL_H_
+#define GEODE_CACHEIMPL_H_
+
+#include <atomic>
+
 #include <geode/geode_globals.hpp>
 #include <memory>
 
@@ -28,7 +30,6 @@
 #include <geode/DistributedSystem.hpp>
 #include "MapWithLock.hpp"
 #include <ace/ACE.h>
-#include <ace/Condition_Recursive_Thread_Mutex.h>
 #include <ace/Time_Value.h>
 #include <ace/Guard_T.h>
 #include <ace/Recursive_Thread_Mutex.h>
@@ -40,13 +41,14 @@
 #include "CachePerfStats.hpp"
 #include "PdxTypeRegistry.hpp"
 #include "MemberListForVersionStamp.hpp"
+#include "ClientProxyMembershipIDFactory.hpp"
 
 #include <string>
 #include <string>
 #include <map>
 
 #include "NonCopyable.hpp"
-
+#define DEFAULT_LRU_MAXIMUM_ENTRIES 100000
 /** @todo period '.' consistency */
 /** @todo fix returns to param documentation of result ptr... */
 
@@ -58,14 +60,18 @@ namespace apache {
 namespace geode {
 namespace client {
 
+class ThreadPool;
 class CacheFactory;
 class ExpiryTaskManager;
+class PdxTypeRegistry;
+class SerializationRegistry;
+typedef std::shared_ptr<SerializationRegistry> SerializationRegistryPtr;
 
 /**
  * @class Cache Cache.hpp
  * Geode's implementation of a distributed C++ Cache.
  *
- * Caches are obtained from static methods on the {@link CacheFactory} class.
+ * Caches are obtained from methods on the {@link CacheFactory} class.
  * <p>
  * When a cache is created a {@link DistributedSystem} must be specified.
  * This system tells the cache where to find other caches on the network
@@ -92,26 +98,28 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
   void setClientCrashTEST() { m_tcrConnectionManager->setClientCrashTEST(); }
 
   // For PrSingleHop C++unit testing.
-  static ACE_Recursive_Thread_Mutex s_nwHopLock;
-  static void setNetworkHopFlag(bool networkhopflag) {
-    ACE_Guard<ACE_Recursive_Thread_Mutex> _lock(s_nwHopLock);
-    CacheImpl::s_networkhop = networkhopflag;
-  }
-  static bool getAndResetNetworkHopFlag();
+  void setNetworkHopFlag(bool networkhopflag) {
+    m_networkhop = networkhopflag;
+  };
+
+  bool getAndResetNetworkHopFlag() { return m_networkhop.exchange(false); }
+
+  int getBlackListBucketTimeouts() { return m_blacklistBucketTimeout; }
+
+  void incBlackListBucketTimeouts() { ++m_blacklistBucketTimeout; }
 
-  static int blackListBucketTimeouts();
-  static void setBlackListBucketTimeouts();
+  int8_t getAndResetServerGroupFlag() { return m_serverGroupFlag.exchange(0); }
 
-  static void setServerGroupFlag(int8_t serverGroupFlag) {
-    CacheImpl::s_serverGroupFlag = serverGroupFlag;
+  void setServerGroupFlag(int8_t serverGroupFlag) {
+    m_serverGroupFlag = serverGroupFlag;
   }
-  static int8_t getAndResetServerGroupFlag();
-  static MemberListForVersionStampPtr getMemberListForVersionStamp();
+
+  MemberListForVersionStampPtr getMemberListForVersionStamp();
 
   /** Returns the name of this cache.
    * @return the string name of this cache
    */
-  const char* getName() const;
+  const std::string& getName() const;
 
   /**
    * Indicates if this cache has been closed.
@@ -133,7 +141,7 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
    * Returns the distributed system that this cache was
    * {@link CacheFactory::create created} with.
    */
-  void getDistributedSystem(DistributedSystemPtr& dptr) const;
+  DistributedSystem& getDistributedSystem() const;
 
   /**
    * Terminates this object cache and releases all the local resources.
@@ -206,15 +214,19 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
   /**
    * @brief constructors
    */
-  CacheImpl(Cache* c, const char* name, DistributedSystemPtr sys,
-            bool ignorePdxUnreadFields, bool readPdxSerialized);
-  CacheImpl(Cache* c, const char* name, DistributedSystemPtr sys,
-            const char* id_data, bool ignorePdxUnreadFields,
+  CacheImpl(Cache* c, const std::string& name,
+            std::unique_ptr<DistributedSystem> sys, bool ignorePdxUnreadFields,
             bool readPdxSerialized);
+
   void initServices();
   EvictionController* getEvictionController();
 
-  static ExpiryTaskManager* expiryTaskManager;
+  ExpiryTaskManager& getExpiryTaskManager() { return *m_expiryTaskManager; }
+
+  ClientProxyMembershipIDFactory& getClientProxyMembershipIDFactory() {
+    return m_clientProxyMembershipIDFactory;
+  }
+
   Cache* getCache() const { return m_implementee; }
   TcrConnectionManager& tcrConnectionManager() {
     return *m_tcrConnectionManager;
@@ -243,12 +255,7 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
   void processMarker();
 
   // Pool helpers for unit tests
-  static int getPoolSize(const char* poolName);
-
-  // CachePerfStats
-  CachePerfStats* m_cacheStats;
-
-  static inline CacheImpl* getInstance() { return s_instance; };
+  int getPoolSize(const char* poolName);
 
   bool getCacheMode() {
     return m_attributes == nullptr ? false : m_attributes->m_cacheMode;
@@ -264,22 +271,30 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
   bool getPdxReadSerialized() { return m_readPdxSerialized; }
   bool isCacheDestroyPending() const;
 
-  void setDefaultPool(PoolPtr pool);
+  static std::map<std::string, RegionAttributesPtr> getRegionShortcut();
 
-  PoolPtr getDefaultPool();
+  PdxTypeRegistryPtr getPdxTypeRegistry() const;
 
-  static void setRegionShortcut(AttributesFactoryPtr attrFact,
-                                RegionShortcut preDefinedRegionAttr);
+  SerializationRegistryPtr getSerializationRegistry() const;
+  inline CachePerfStats& getCachePerfStats() { return *m_cacheStats; };
 
-  static std::map<std::string, RegionAttributesPtr> getRegionShortcut();
+  PoolManager& getPoolManager() { return *m_poolManager; }
+
+  ThreadPool* getThreadPool();
 
  private:
-  static volatile bool s_networkhop;
-  static volatile int s_blacklistBucketTimeout;
-  static volatile int8_t s_serverGroupFlag;
+  std::atomic<bool> m_networkhop;
+  std::atomic<int> m_blacklistBucketTimeout;
+  std::atomic<int8_t> m_serverGroupFlag;
   PoolPtr m_defaultPool;
   bool m_ignorePdxUnreadFields;
   bool m_readPdxSerialized;
+  std::unique_ptr<ExpiryTaskManager> m_expiryTaskManager;
+
+  // CachePerfStats
+  CachePerfStats* m_cacheStats;
+
+  std::unique_ptr<PoolManager> m_poolManager;
 
   enum RegionKind {
     CPP_REGION,
@@ -303,11 +318,12 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
       srm.bind((*p).ext_id_, (*p).int_id_);
     }
   }
-  char* m_name;
+  std::string m_name;
   bool m_closed;
   bool m_initialized;
 
-  DistributedSystemPtr m_distributedSystem;
+  std::unique_ptr<DistributedSystem> m_distributedSystem;
+  ClientProxyMembershipIDFactory m_clientProxyMembershipIDFactory;
   MapOfRegionWithLock* m_regions;
   Cache* m_implementee;
   ACE_Recursive_Thread_Mutex m_mutex;
@@ -319,11 +335,15 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
   ACE_RW_Thread_Mutex m_destroyCacheMutex;
   volatile bool m_destroyPending;
   volatile bool m_initDone;
-  static CacheImpl* s_instance;
   ACE_Thread_Mutex m_initDoneLock;
   AdminRegionPtr m_adminRegion;
   CacheTransactionManagerPtr m_cacheTXManager;
 
+  MemberListForVersionStamp& m_memberListForVersionStamp;
+  SerializationRegistryPtr m_serializationRegistry;
+  PdxTypeRegistryPtr m_pdxTypeRegistry;
+  ThreadPool* m_threadPool;
+
   friend class CacheFactory;
   friend class Cache;
 };

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CachePerfStats.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CachePerfStats.hpp b/src/cppcache/src/CachePerfStats.hpp
index adfda8b..e22d5cd 100644
--- a/src/cppcache/src/CachePerfStats.hpp
+++ b/src/cppcache/src/CachePerfStats.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_CACHEPERFSTATS_H_
-#define GEODE_CACHEPERFSTATS_H_
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -20,10 +15,17 @@
  * limitations under the License.
  */
 
+#pragma once
+
+#ifndef GEODE_CACHEPERFSTATS_H_
+#define GEODE_CACHEPERFSTATS_H_
+
 #include <geode/geode_globals.hpp>
 #include <geode/statistics/Statistics.hpp>
 #include <geode/statistics/StatisticsFactory.hpp>
 
+#include "statistics/StatisticsManager.hpp"
+
 namespace apache {
 namespace geode {
 namespace client {
@@ -33,11 +35,8 @@ using namespace apache::geode::statistics;
 /** hold statistics for cache.. */
 class CPPCACHE_EXPORT CachePerfStats {
  public:
-  CachePerfStats() {
-    StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
-    GF_D_ASSERT(!!factory);
-
-    StatisticsType* statsType = factory->findType("CachePerfStats");
+  CachePerfStats(StatisticsFactory* factory) {
+    auto statsType = factory->findType("CachePerfStats");
 
     if (statsType == nullptr) {
       const bool largerIsBetter = true;

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheRegionHelper.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheRegionHelper.cpp b/src/cppcache/src/CacheRegionHelper.cpp
new file mode 100644
index 0000000..a685d11
--- /dev/null
+++ b/src/cppcache/src/CacheRegionHelper.cpp
@@ -0,0 +1,48 @@
+/*
+ * 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 "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+#include "ProxyCache.hpp"
+
+namespace apache {
+namespace geode {
+namespace client {
+
+CacheImpl* CacheRegionHelper::getCacheImpl(const Cache* cache) {
+  return cache->m_cacheImpl.get();
+}
+
+CacheImpl* CacheRegionHelper::getCacheImpl(const ProxyCache* proxyCache) {
+  return proxyCache->m_cacheImpl;
+}
+
+CacheImpl* CacheRegionHelper::getCacheImpl(const RegionService* regionService) {
+  if (const auto proxyCache = dynamic_cast<const ProxyCache*>(regionService)) {
+    return getCacheImpl(proxyCache);
+  }
+
+  if (const auto cache = dynamic_cast<const Cache*>(regionService)) {
+    return getCacheImpl(cache);
+  }
+
+  return nullptr;
+}
+
+}  // namespace client
+}  // namespace geode
+}  // namespace apache

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheRegionHelper.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheRegionHelper.hpp b/src/cppcache/src/CacheRegionHelper.hpp
index 7e26e1a..a101060 100644
--- a/src/cppcache/src/CacheRegionHelper.hpp
+++ b/src/cppcache/src/CacheRegionHelper.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_CACHEREGIONHELPER_H_
-#define GEODE_CACHEREGIONHELPER_H_
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -20,32 +15,30 @@
  * limitations under the License.
  */
 
-/**
- * @file
- */
+#pragma once
+
+#ifndef GEODE_CACHEREGIONHELPER_H_
+#define GEODE_CACHEREGIONHELPER_H_
+
 #include <geode/geode_globals.hpp>
-#include <geode/Region.hpp>
 #include <geode/Cache.hpp>
-#include "CacheImpl.hpp"
-#include <geode/DistributedSystem.hpp>
 
 namespace apache {
 namespace geode {
 namespace client {
 
-class CacheRegionHelper {
+class CacheImpl;
+class ProxyCache;
+
+class CPPCACHE_EXPORT CacheRegionHelper {
   /**
    * CacheHelper
    *
    */
  public:
-  inline static CacheImpl* getCacheImpl(const Cache* cache) {
-    return cache->m_cacheImpl.get();
-  }
-
-  inline static DistributedSystemImpl* getDistributedSystemImpl() {
-    return DistributedSystem::m_impl;
-  }
+  static CacheImpl* getCacheImpl(const Cache* cache);
+  static CacheImpl* getCacheImpl(const ProxyCache* cache);
+  static CacheImpl* getCacheImpl(const RegionService* cache);
 };
 }  // namespace client
 }  // namespace geode

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheTransactionManagerImpl.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheTransactionManagerImpl.cpp b/src/cppcache/src/CacheTransactionManagerImpl.cpp
index b5c633d..4a795e6 100644
--- a/src/cppcache/src/CacheTransactionManagerImpl.cpp
+++ b/src/cppcache/src/CacheTransactionManagerImpl.cpp
@@ -25,13 +25,15 @@
 #include "CacheTransactionManagerImpl.hpp"
 #include <geode/TransactionId.hpp>
 #include <geode/ExceptionTypes.hpp>
+#include <geode/PoolManager.hpp>
+
 #include "TSSTXStateWrapper.hpp"
 #include "TcrMessage.hpp"
 #include "ThinClientBaseDM.hpp"
 #include "ThinClientPoolDM.hpp"
 #include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
 #include "TssConnectionWrapper.hpp"
-#include <geode/PoolManager.hpp>
 #include "TXCleaner.hpp"
 
 namespace apache {
@@ -63,7 +65,7 @@ void CacheTransactionManagerImpl::commit() {
         GF_CACHE_ILLEGAL_STATE_EXCEPTION);
   }
 
-  TcrMessageCommit request;
+  TcrMessageCommit request(m_cache->createDataOutput());
   TcrMessageReply reply(true, nullptr);
 
   ThinClientPoolDM* tcr_dm = getDM();
@@ -112,8 +114,7 @@ void CacheTransactionManagerImpl::commit() {
   }
 
   TXCommitMessagePtr commit =
-      std::static_pointer_cast<TXCommitMessage>(
-          reply.getValue());
+      std::static_pointer_cast<TXCommitMessage>(reply.getValue());
   txCleaner.clean();
   commit->apply(m_cache);
 
@@ -277,7 +278,7 @@ void CacheTransactionManagerImpl::rollback() {
 
 GfErrType CacheTransactionManagerImpl::rollback(TXState* txState,
                                                 bool callListener) {
-  TcrMessageRollback request;
+  TcrMessageRollback request(m_cache->createDataOutput());
   TcrMessageReply reply(true, nullptr);
   GfErrType err = GF_NOERR;
   ThinClientPoolDM* tcr_dm = getDM();
@@ -360,11 +361,13 @@ TransactionIdPtr CacheTransactionManagerImpl::suspend() {
   txState->releaseStickyConnection();
 
   // set the expiry handler for the suspended transaction
-  SystemProperties* sysProp = DistributedSystem::getSystemProperties();
+  auto& sysProp = m_cache->getDistributedSystem().getSystemProperties();
   SuspendedTxExpiryHandler* handler = new SuspendedTxExpiryHandler(
-      this, txState->getTransactionId(), sysProp->suspendedTxTimeout());
-  long id = CacheImpl::expiryTaskManager->scheduleExpiryTask(
-      handler, sysProp->suspendedTxTimeout() * 60, 0, false);
+      this, txState->getTransactionId(), sysProp.suspendedTxTimeout());
+  long id = CacheRegionHelper::getCacheImpl(m_cache)
+                ->getExpiryTaskManager()
+                .scheduleExpiryTask(handler, sysProp.suspendedTxTimeout() * 60,
+                                    0, false);
   txState->setSuspendedExpiryTaskId(id);
 
   // add the transaction state to the list of suspended transactions
@@ -451,11 +454,11 @@ void CacheTransactionManagerImpl::resumeTxUsingTxState(TXState* txState,
 
   if (cancelExpiryTask) {
     // cancel the expiry task for the transaction
-    CacheImpl::expiryTaskManager->cancelTask(
+    CacheRegionHelper::getCacheImpl(m_cache)->getExpiryTaskManager().cancelTask(
         txState->getSuspendedExpiryTaskId());
   } else {
-    CacheImpl::expiryTaskManager->resetTask(txState->getSuspendedExpiryTaskId(),
-                                            0);
+    CacheRegionHelper::getCacheImpl(m_cache)->getExpiryTaskManager().resetTask(
+        txState->getSuspendedExpiryTaskId(), 0);
   }
 
   // set the current state as the state of the suspended transaction

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheTransactionManagerImpl.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheTransactionManagerImpl.hpp b/src/cppcache/src/CacheTransactionManagerImpl.hpp
index a3b220c..e0b8cb4 100644
--- a/src/cppcache/src/CacheTransactionManagerImpl.hpp
+++ b/src/cppcache/src/CacheTransactionManagerImpl.hpp
@@ -60,14 +60,6 @@ class CacheTransactionManagerImpl
 
   virtual TransactionIdPtr getTransactionId();
 
-
-//  inline static int32_t hasher(const SharedBasePtr& p) {
-//    return static_cast<int32_t>(reinterpret_cast<intptr_t>(p.get()));
-//  }
-//
-//  inline static bool equal_to(const SharedBasePtr& x, const SharedBasePtr& y) {
-//    return x.get() == y.get();
-//  }
   TXState* getSuspendedTx(int32_t txId);
 
  protected:
@@ -86,6 +78,7 @@ class CacheTransactionManagerImpl
   void addTx(int32_t txId);
   bool removeTx(int32_t txId);
   bool findTx(int32_t txId);
+
   std::map<int32_t, TXState*> m_suspendedTXs;
   ACE_Recursive_Thread_Mutex m_suspendedTxLock;
   std::vector<int32_t> m_TXs;

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheXmlCreation.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheXmlCreation.cpp b/src/cppcache/src/CacheXmlCreation.cpp
index c140d24..541bcf8 100644
--- a/src/cppcache/src/CacheXmlCreation.cpp
+++ b/src/cppcache/src/CacheXmlCreation.cpp
@@ -22,11 +22,13 @@
 
 using namespace apache::geode::client;
 
-void CacheXmlCreation::addRootRegion(RegionXmlCreation* root) {
+void CacheXmlCreation::addRootRegion(std::shared_ptr<RegionXmlCreation> root) {
   rootRegions.push_back(root);
 }
 
-void CacheXmlCreation::addPool(PoolXmlCreation* pool) { pools.push_back(pool); }
+void CacheXmlCreation::addPool(std::shared_ptr<PoolXmlCreation> pool) {
+  pools.push_back(pool);
+}
 
 void CacheXmlCreation::create(Cache* cache) {
   m_cache = cache;
@@ -34,16 +36,12 @@ void CacheXmlCreation::create(Cache* cache) {
   m_cache->m_cacheImpl->setPdxReadSerialized(m_readPdxSerialized);
   // Create any pools before creating any regions.
 
-  std::vector<PoolXmlCreation*>::iterator pool = pools.begin();
-  while (pool != pools.end()) {
-    (*pool)->create();
-    ++pool;
+  for (const auto& pool : pools) {
+    pool->create(*m_cache);
   }
 
-  std::vector<RegionXmlCreation*>::iterator start = rootRegions.begin();
-  while (start != rootRegions.end()) {
-    (*start)->createRoot(cache);
-    ++start;
+  for (const auto& rootRegion : rootRegions) {
+    rootRegion->createRoot(cache);
   }
 }
 
@@ -63,18 +61,3 @@ CacheXmlCreation::CacheXmlCreation()
   m_pdxIgnoreUnreadFields = false;
   m_readPdxSerialized = false;
 }
-
-CacheXmlCreation::~CacheXmlCreation() {
-  std::vector<RegionXmlCreation*>::iterator start = rootRegions.begin();
-  while (start != rootRegions.end()) {
-    delete *start;
-    *start = nullptr;
-    ++start;
-  }
-  std::vector<PoolXmlCreation*>::iterator pool = pools.begin();
-  while (pool != pools.end()) {
-    delete *pool;
-    *pool = nullptr;
-    ++pool;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheXmlCreation.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheXmlCreation.hpp b/src/cppcache/src/CacheXmlCreation.hpp
index ed1813a..754674c 100644
--- a/src/cppcache/src/CacheXmlCreation.hpp
+++ b/src/cppcache/src/CacheXmlCreation.hpp
@@ -47,10 +47,10 @@ class CPPCACHE_EXPORT CacheXmlCreation {
   /**
    * Adds a root region to the cache
    */
-  void addRootRegion(RegionXmlCreation* root);
+  void addRootRegion(std::shared_ptr<RegionXmlCreation> root);
 
   /** Adds a pool to the cache */
-  void addPool(PoolXmlCreation* pool);
+  void addPool(std::shared_ptr<PoolXmlCreation> pool);
 
   /**
    * Fills in the contents of a {@link Cache} based on this creation
@@ -79,14 +79,14 @@ class CPPCACHE_EXPORT CacheXmlCreation {
 
   bool getPdxReadSerialized(bool val) { return m_readPdxSerialized; }
 
-  ~CacheXmlCreation();
+  ~CacheXmlCreation() = default;
 
  private:
   /** This cache's roots */
-  std::vector<RegionXmlCreation*> rootRegions;
+  std::vector<std::shared_ptr<RegionXmlCreation>> rootRegions;
 
   /** This cache's pools */
-  std::vector<PoolXmlCreation*> pools;
+  std::vector<std::shared_ptr<PoolXmlCreation>> pools;
 
   Cache* m_cache;
   bool m_pdxIgnoreUnreadFields;

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheXmlParser.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheXmlParser.cpp b/src/cppcache/src/CacheXmlParser.cpp
index 552a0e1..52ee603 100644
--- a/src/cppcache/src/CacheXmlParser.cpp
+++ b/src/cppcache/src/CacheXmlParser.cpp
@@ -266,7 +266,7 @@ LibraryPersistenceManagerFn CacheXmlParser::managedPersistenceManagerFn =
 
 //////////////////////////////////////////////////////////////////
 
-CacheXmlParser::CacheXmlParser()
+CacheXmlParser::CacheXmlParser(Cache* cache)
     : m_cacheCreation(nullptr),
       m_nestedRegions(0),
       m_config(nullptr),
@@ -275,7 +275,8 @@ CacheXmlParser::CacheXmlParser()
       m_flagIllegalStateException(false),
       m_flagAnyOtherException(false),
       m_flagExpirationAttribute(false),
-      m_poolFactory(nullptr) {
+      m_poolFactory(nullptr),
+      m_cache(cache) {
   static xmlSAXHandler saxHandler = {
       nullptr,                  /* internalSubset */
       nullptr,                  /* isStandalone */
@@ -388,9 +389,9 @@ void CacheXmlParser::handleParserErrors(int res) {
  *         If xml file is well-flrmed but not valid
  * @throws UnknownException otherwise
  */
-CacheXmlParser* CacheXmlParser::parse(const char* cacheXml) {
+CacheXmlParser* CacheXmlParser::parse(const char* cacheXml, Cache* cache) {
   CacheXmlParser* handler;
-  GF_NEW(handler, CacheXmlParser());
+  GF_NEW(handler, CacheXmlParser(cache));
   // use RAII to delete the handler object in case of exceptions
   DeleteObject<CacheXmlParser> delHandler(handler);
 
@@ -517,14 +518,13 @@ void CacheXmlParser::endPdx() {}
 void CacheXmlParser::startLocator(const xmlChar** atts) {
   int attrsCount = 0;
   if (!atts) {
-
     std::string s =
         "XML:No attributes provided for <locator>. "
         "A locator requires a host and port";
     throw CacheXmlException(s.c_str());
   }
+  m_poolFactory = std::static_pointer_cast<PoolFactory>(_stack.top());
 
-  m_poolFactory = reinterpret_cast<PoolFactory*>(_stack.top());
   const char* host = nullptr;
   const char* port = nullptr;
 
@@ -554,14 +554,13 @@ void CacheXmlParser::startLocator(const xmlChar** atts) {
 void CacheXmlParser::startServer(const xmlChar** atts) {
   int attrsCount = 0;
   if (!atts) {
-
     std::string s =
         "XML:No attributes provided for <server>. A server requires a host and "
         "port";
     throw CacheXmlException(s.c_str());
   }
+  auto factory = std::static_pointer_cast<PoolFactory>(_stack.top());
 
-  PoolFactory* factory = reinterpret_cast<PoolFactory*>(_stack.top());
   const char* host = nullptr;
   const char* port = nullptr;
 
@@ -596,8 +595,8 @@ void CacheXmlParser::startPool(const xmlChar** atts) {
         "A pool cannot be created without a name";
     throw CacheXmlException(s.c_str());
   }
+  PoolFactoryPtr factory = m_cache->getPoolManager().createFactory();
 
-  PoolFactoryPtr factory = PoolManager::createFactory();
   const char* poolName = nullptr;
 
   while (atts[attrsCount] != nullptr) {
@@ -619,15 +618,15 @@ void CacheXmlParser::startPool(const xmlChar** atts) {
     throw CacheXmlException(s.c_str());
   }
 
-  PoolXmlCreation* poolxml = new PoolXmlCreation(poolName, factory);
+  auto poolxml = std::make_shared<PoolXmlCreation>(poolName, factory);
 
   _stack.push(poolxml);
-  _stack.push(factory.get());
+  _stack.push(factory);
 }
 
 void CacheXmlParser::endPool() {
   _stack.pop();  // remove factory
-  PoolXmlCreation* poolxml = reinterpret_cast<PoolXmlCreation*>(_stack.top());
+  auto poolxml = std::static_pointer_cast<PoolXmlCreation>(_stack.top());
   _stack.pop();  // remove pool
   m_cacheCreation->addPool(poolxml);
 }
@@ -747,7 +746,7 @@ void CacheXmlParser::startRegion(const xmlChar** atts, bool isRoot) {
     throw CacheXmlException(s.c_str());
   }
 
-  RegionXmlCreation* region = new RegionXmlCreation(regionName, isRoot);
+  auto region = std::make_shared<RegionXmlCreation>(regionName, isRoot);
   if (!region) {
     throw UnknownException("CacheXmlParser::startRegion:Out of memeory");
   }
@@ -784,7 +783,7 @@ void CacheXmlParser::startRootRegion(const xmlChar** atts) {
 void CacheXmlParser::startRegionAttributes(const xmlChar** atts) {
   bool isDistributed = false;
   bool isTCR = false;
-  AttributesFactory* attrsFactory = nullptr;
+  std::shared_ptr<AttributesFactory> attrsFactory = nullptr;
   if (atts) {
     int attrsCount = 0;
     while (atts[attrsCount] != nullptr) ++attrsCount;
@@ -813,8 +812,8 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) {
         }
 
         if (strcmp((char*)atts[i - 1], ID) == 0) {
-          RegionXmlCreation* region =
-              reinterpret_cast<RegionXmlCreation*>(_stack.top());
+          auto region =
+              std::static_pointer_cast<RegionXmlCreation>(_stack.top());
           region->setAttrId(std::string((char*)atts[i]));
         } else if (strcmp((char*)atts[i - 1], REFID) == 0) {
           refid = (char*)atts[i];
@@ -823,14 +822,15 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) {
     }
 
     if (refid == nullptr) {
-      RegionXmlCreation* region =
-          reinterpret_cast<RegionXmlCreation*>(_stack.top());
-      attrsFactory = new AttributesFactory(region->getAttributes());
+      auto region = std::static_pointer_cast<RegionXmlCreation>(_stack.top());
+      attrsFactory =
+          std::make_shared<AttributesFactory>(region->getAttributes());
     } else {
       std::string refidStr(refid);
 
       if (namedRegions.find(refidStr) != namedRegions.end()) {
-        attrsFactory = new AttributesFactory(namedRegions[refidStr]);
+        attrsFactory =
+            std::make_shared<AttributesFactory>(namedRegions[refidStr]);
       } else {
         std::string s =
             "XML:referenced named attribute '" + refidStr + "' does not exist.";
@@ -990,9 +990,8 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) {
     }  // for loop
   }    // atts is nullptr
   else {
-    RegionXmlCreation* region =
-        reinterpret_cast<RegionXmlCreation*>(_stack.top());
-    attrsFactory = new AttributesFactory(region->getAttributes());
+    auto region = std::static_pointer_cast<RegionXmlCreation>(_stack.top());
+    attrsFactory = std::make_shared<AttributesFactory>(region->getAttributes());
     _stack.push(attrsFactory);
   }
 
@@ -1004,8 +1003,7 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) {
 }
 
 void CacheXmlParser::endRegionAttributes() {
-  AttributesFactory* attrsFactory =
-      reinterpret_cast<AttributesFactory*>(_stack.top());
+  auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
   _stack.pop();
   if (!attrsFactory) {
     throw UnknownException(
@@ -1015,8 +1013,7 @@ void CacheXmlParser::endRegionAttributes() {
   RegionAttributesPtr regionAttributesPtr =
       attrsFactory->createRegionAttributes();
 
-  RegionXmlCreation* regionPtr =
-      reinterpret_cast<RegionXmlCreation*>(_stack.top());
+  auto regionPtr = std::static_pointer_cast<RegionXmlCreation>(_stack.top());
   if (!regionPtr) {
     throw UnknownException("CacheXmlParser::endRegion:Region is null");
   }
@@ -1070,7 +1067,8 @@ void CacheXmlParser::startExpirationAttributes(const xmlChar** atts) {
         std::string s =
             "XML:The attribute <action> of <expiration-attributes> cannot be "
             "set to empty string. It should either have a value or the "
-            "attribute should be removed. In the latter case the default value "
+            "attribute should be removed. In the latter case the default "
+            "value "
             "will be set";
         throw CacheXmlException(s.c_str());
       } else if (strcmp(INVALIDATE, action) == 0) {
@@ -1100,12 +1098,12 @@ void CacheXmlParser::startExpirationAttributes(const xmlChar** atts) {
   }
   if (timeOut == nullptr || strcmp(timeOut, "") == 0) {
     std::string s =
-        "XML:The attribute <timeout> not specified in <expiration-attributes>.";
+        "XML:The attribute <timeout> not specified in "
+        "<expiration-attributes>.";
     throw CacheXmlException(s.c_str());
   }
 
-  ExpirationAttributes* expireAttr =
-      new ExpirationAttributes(timeOutInt, expire);
+  auto expireAttr = std::make_shared<ExpirationAttributes>(timeOutInt, expire);
   if (!expireAttr) {
     throw UnknownException(
         "CacheXmlParser::startExpirationAttributes:Out of memeory");
@@ -1123,7 +1121,8 @@ void CacheXmlParser::startPersistenceManager(const xmlChar** atts) {
   while (atts[attrsCount] != nullptr) ++attrsCount;
   if (attrsCount > 4) {
     std::string s =
-        "XML:Incorrect number of attributes provided for <persistence-manager>";
+        "XML:Incorrect number of attributes provided for "
+        "<persistence-manager>";
     throw CacheXmlException(s.c_str());
   }
   char* libraryName = nullptr;
@@ -1142,9 +1141,11 @@ void CacheXmlParser::startPersistenceManager(const xmlChar** atts) {
 
       if (libraryName == nullptr) {
         std::string s =
-            "XML:The attribute <library-name> of <persistence-manager> cannot "
+            "XML:The attribute <library-name> of <persistence-manager> "
+            "cannot "
             "be set to an empty string. It should either have a value or the "
-            "attribute should be removed. In the latter case the default value "
+            "attribute should be removed. In the latter case the default "
+            "value "
             "will be set";
         throw CacheXmlException(s.c_str());
       }
@@ -1169,14 +1170,16 @@ void CacheXmlParser::startPersistenceManager(const xmlChar** atts) {
       char* name = (char*)atts[i];
       std::string temp(name);
       std::string s =
-          "XML:Incorrect attribute name specified in <persistence-manager>: " +
+          "XML:Incorrect attribute name specified in "
+          "<persistence-manager>: " +
           temp;
       throw CacheXmlException(s.c_str());
     }
   }
   if (libraryFunctionName == nullptr) {
     std::string s =
-        "XML:Library function name not specified in the <persistence-manager>";
+        "XML:Library function name not specified in the "
+        "<persistence-manager>";
     throw CacheXmlException(s.c_str());
   }
 
@@ -1192,8 +1195,8 @@ void CacheXmlParser::startPersistenceManager(const xmlChar** atts) {
     throw CacheXmlException(ex.getMessage());
   }
 
-  _stack.push(libraryName);
-  _stack.push(libraryFunctionName);
+  _stack.push(std::make_shared<std::string>(std::string(libraryName)));
+  _stack.push(std::make_shared<std::string>(std::string(libraryFunctionName)));
 }
 
 void CacheXmlParser::startPersistenceProperties(const xmlChar** atts) {
@@ -1275,9 +1278,11 @@ void CacheXmlParser::startCacheLoader(const xmlChar** atts) {
       libraryName = (char*)atts[i];
       if (libraryName == nullptr || strcmp(libraryName, "") == 0) {
         std::string s =
-            "XML:The attribute <library-name> of <cache-loader> cannot be set "
+            "XML:The attribute <library-name> of <cache-loader> cannot be "
+            "set "
             "to an empty string. It should either have a value or the "
-            "attribute should be removed. In the latter case the default value "
+            "attribute should be removed. In the latter case the default "
+            "value "
             "will be set";
         throw CacheXmlException(s.c_str());
       }
@@ -1316,8 +1321,7 @@ void CacheXmlParser::startCacheLoader(const xmlChar** atts) {
     throw CacheXmlException(ex.getMessage());
   }
 
-  AttributesFactory* attrsFactory =
-      reinterpret_cast<AttributesFactory*>(_stack.top());
+  auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
   attrsFactory->setCacheLoader(libraryName, libraryFunctionName);
 }
 
@@ -1384,8 +1388,7 @@ void CacheXmlParser::startCacheListener(const xmlChar** atts) {
     throw CacheXmlException(ex.getMessage());
   }
 
-  AttributesFactory* attrsFactory =
-      reinterpret_cast<AttributesFactory*>(_stack.top());
+  auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
   attrsFactory->setCacheListener(libraryName, libraryFunctionName);
 }
 
@@ -1400,7 +1403,8 @@ void CacheXmlParser::startPartitionResolver(const xmlChar** atts) {
   while (atts[attrsCount] != nullptr) ++attrsCount;
   if (attrsCount > 4) {
     std::string s =
-        "XML:Incorrect number of attributes provided for <partition-resolver>";
+        "XML:Incorrect number of attributes provided for "
+        "<partition-resolver>";
     throw CacheXmlException(s.c_str());
   }
 
@@ -1410,7 +1414,8 @@ void CacheXmlParser::startPartitionResolver(const xmlChar** atts) {
       libraryName = (char*)atts[i];
       if (libraryName == nullptr || strcmp(libraryName, "") == 0) {
         std::string s =
-            "XML:The attribute <library-name> of the <partition-resolver> tag "
+            "XML:The attribute <library-name> of the <partition-resolver> "
+            "tag "
             "cannot be set to an empty string. It should either have a value "
             "or the attribute should be removed. In the latter case the "
             "default value will be set";
@@ -1429,7 +1434,8 @@ void CacheXmlParser::startPartitionResolver(const xmlChar** atts) {
       char* name = (char*)atts[i];
       std::string temp(name);
       std::string s =
-          "XML:Incorrect attribute name specified in <partition-resolver> : " +
+          "XML:Incorrect attribute name specified in <partition-resolver> "
+          ": " +
           temp;
       throw CacheXmlException(s.c_str());
     }
@@ -1452,8 +1458,7 @@ void CacheXmlParser::startPartitionResolver(const xmlChar** atts) {
     throw CacheXmlException(ex.getMessage());
   }
 
-  AttributesFactory* attrsFactory =
-      reinterpret_cast<AttributesFactory*>(_stack.top());
+  auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
   attrsFactory->setPartitionResolver(libraryName, libraryFunctionName);
 }
 
@@ -1478,9 +1483,11 @@ void CacheXmlParser::startCacheWriter(const xmlChar** atts) {
       libraryName = (char*)atts[i];
       if (libraryName == nullptr || strcmp(libraryName, "") == 0) {
         std::string s =
-            "XML:The attribute <library-name> of <cache-writer> cannot be set "
+            "XML:The attribute <library-name> of <cache-writer> cannot be "
+            "set "
             "to an empty string. It should either have a value or the "
-            "attribute should be removed. In the latter case the default value "
+            "attribute should be removed. In the latter case the default "
+            "value "
             "will be set";
         throw CacheXmlException(s.c_str());
       }
@@ -1519,8 +1526,7 @@ void CacheXmlParser::startCacheWriter(const xmlChar** atts) {
     throw CacheXmlException(ex.getMessage());
   }
 
-  AttributesFactory* attrsFactory =
-      reinterpret_cast<AttributesFactory*>(_stack.top());
+  auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
   attrsFactory->setCacheWriter(libraryName, libraryFunctionName);
 }
 
@@ -1530,8 +1536,7 @@ void CacheXmlParser::startCacheWriter(const xmlChar** atts) {
  * <code>RegionXmlCreation</code>, then it is the parent region.
  */
 void CacheXmlParser::endRegion(bool isRoot) {
-  RegionXmlCreation* regionPtr =
-      reinterpret_cast<RegionXmlCreation*>(_stack.top());
+  auto regionPtr = std::static_pointer_cast<RegionXmlCreation>(_stack.top());
   _stack.pop();
   if (isRoot) {
     if (!_stack.empty()) {
@@ -1549,8 +1554,7 @@ void CacheXmlParser::endRegion(bool isRoot) {
       std::string s = "Xml file has incorrectly nested region tags";
       throw CacheXmlException(s.c_str());
     }
-    RegionXmlCreation* parent =
-        reinterpret_cast<RegionXmlCreation*>(_stack.top());
+    auto parent = std::static_pointer_cast<RegionXmlCreation>(_stack.top());
     parent->addSubregion(regionPtr);
   }
 }
@@ -1578,12 +1582,11 @@ void CacheXmlParser::endRegionTimeToLive() {
     throw CacheXmlException(s.c_str());
   }
 
-  ExpirationAttributes* expireAttr =
-      reinterpret_cast<ExpirationAttributes*>(_stack.top());
+  auto expireAttr =
+      std::static_pointer_cast<ExpirationAttributes>(_stack.top());
   _stack.pop();
 
-  AttributesFactory* attrsFactory =
-      reinterpret_cast<AttributesFactory*>(_stack.top());
+  auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
   attrsFactory->setRegionTimeToLive(expireAttr->getAction(),
                                     expireAttr->getTimeout());
   m_flagExpirationAttribute = false;
@@ -1601,11 +1604,10 @@ void CacheXmlParser::endRegionIdleTime() {
         "XML: <region-idle-time> cannot be without <expiration-attributes>";
     throw CacheXmlException(s.c_str());
   }
-  ExpirationAttributes* expireAttr =
-      reinterpret_cast<ExpirationAttributes*>(_stack.top());
+  auto expireAttr =
+      std::static_pointer_cast<ExpirationAttributes>(_stack.top());
   _stack.pop();
-  AttributesFactory* attrsFactory =
-      reinterpret_cast<AttributesFactory*>(_stack.top());
+  auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
 
   attrsFactory->setRegionIdleTimeout(expireAttr->getAction(),
                                      expireAttr->getTimeout());
@@ -1625,11 +1627,10 @@ void CacheXmlParser::endEntryTimeToLive() {
         "<expiration-attributes>";
     throw CacheXmlException(s.c_str());
   }
-  ExpirationAttributes* expireAttr =
-      reinterpret_cast<ExpirationAttributes*>(_stack.top());
+  auto expireAttr =
+      std::static_pointer_cast<ExpirationAttributes>(_stack.top());
   _stack.pop();
-  AttributesFactory* attrsFactory =
-      reinterpret_cast<AttributesFactory*>(_stack.top());
+  auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
 
   attrsFactory->setEntryTimeToLive(expireAttr->getAction(),
                                    expireAttr->getTimeout());
@@ -1648,11 +1649,10 @@ void CacheXmlParser::endEntryIdleTime() {
         "XML: <entry-idle-time> cannot be without <expiration-attributes>";
     throw CacheXmlException(s.c_str());
   }
-  ExpirationAttributes* expireAttr =
-      reinterpret_cast<ExpirationAttributes*>(_stack.top());
+  auto expireAttr =
+      std::static_pointer_cast<ExpirationAttributes>(_stack.top());
   _stack.pop();
-  AttributesFactory* attrsFactory =
-      reinterpret_cast<AttributesFactory*>(_stack.top());
+  auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
   attrsFactory->setEntryIdleTimeout(expireAttr->getAction(),
                                     expireAttr->getTimeout());
   m_flagExpirationAttribute = false;
@@ -1663,23 +1663,21 @@ void CacheXmlParser::endEntryIdleTime() {
  * factory.
  */
 void CacheXmlParser::endPersistenceManager() {
-  char* libraryFunctionName = reinterpret_cast<char*>(_stack.top());
+  std::shared_ptr<std::string> libraryFunctionName =
+      std::static_pointer_cast<std::string>(_stack.top());
   _stack.pop();
-  char* libraryName = reinterpret_cast<char*>(_stack.top());
+  std::shared_ptr<std::string> libraryName =
+      std::static_pointer_cast<std::string>(_stack.top());
   _stack.pop();
-  AttributesFactory* attrsFactory =
-      reinterpret_cast<AttributesFactory*>(_stack.top());
+  auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
   if (m_config != nullptr) {
-    attrsFactory->setPersistenceManager(libraryName, libraryFunctionName,
-                                        m_config);
+    attrsFactory->setPersistenceManager(libraryName->c_str(),
+                                        libraryFunctionName->c_str(), m_config);
     m_config = nullptr;
   } else {
-    attrsFactory->setPersistenceManager(libraryName, libraryFunctionName);
+    attrsFactory->setPersistenceManager(libraryName->c_str(),
+                                        libraryFunctionName->c_str());
   }
-  // Free memory allocated in startPersistenceManager, already checked for
-  // nullptr
-  free(libraryName);
-  free(libraryFunctionName);
 }
 
 CacheXmlParser::~CacheXmlParser() { GF_SAFE_DELETE(m_cacheCreation); }

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheXmlParser.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheXmlParser.hpp b/src/cppcache/src/CacheXmlParser.hpp
index b86c479..025c83a 100644
--- a/src/cppcache/src/CacheXmlParser.hpp
+++ b/src/cppcache/src/CacheXmlParser.hpp
@@ -55,7 +55,7 @@ typedef PersistenceManager* (*LibraryPersistenceManagerFn)(
 
 class CPPCACHE_EXPORT CacheXmlParser : public CacheXml {
  private:
-  std::stack<void*> _stack;
+  std::stack<std::shared_ptr<void>> _stack;
   xmlSAXHandler m_saxHandler;
   CacheXmlCreation* m_cacheCreation;
   std::string m_error;
@@ -67,8 +67,9 @@ class CPPCACHE_EXPORT CacheXmlParser : public CacheXml {
   bool m_flagAnyOtherException;
   bool m_flagExpirationAttribute;
   std::map<std::string, RegionAttributesPtr> namedRegions;
-  PoolFactory* m_poolFactory;
+  std::shared_ptr<PoolFactory> m_poolFactory;
 
+  Cache* m_cache;
   /** Pool helper */
   void setPoolInfo(PoolFactory* poolFactory, const char* name,
                    const char* value);
@@ -76,9 +77,9 @@ class CPPCACHE_EXPORT CacheXmlParser : public CacheXml {
   void handleParserErrors(int res);
 
  public:
-  CacheXmlParser();
+  CacheXmlParser(Cache* cache);
   ~CacheXmlParser();
-  static CacheXmlParser* parse(const char* cachexml);
+  static CacheXmlParser* parse(const char* cachexml, Cache* cache);
   void parseFile(const char* filename);
   void parseMemory(const char* buffer, int size);
   void setAttributes(Cache* cache);

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheableEnum.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheableEnum.cpp b/src/cppcache/src/CacheableEnum.cpp
index 7795de5..5e76483 100644
--- a/src/cppcache/src/CacheableEnum.cpp
+++ b/src/cppcache/src/CacheableEnum.cpp
@@ -19,6 +19,7 @@
 #include <PdxHelper.hpp>
 #include <GeodeTypeIdsImpl.hpp>
 #include <EnumInfo.hpp>
+#include "CacheRegionHelper.hpp"
 
 namespace apache {
 namespace geode {
@@ -40,8 +41,9 @@ CacheableEnum::CacheableEnum(const char* enumClassName, const char* enumName,
 }
 
 void CacheableEnum::toData(apache::geode::client::DataOutput& output) const {
-  int enumVal = PdxHelper::getEnumValue(m_enumClassName->asChar(),
-                                        m_enumName->asChar(), m_ordinal);
+  int enumVal = PdxHelper::getEnumValue(
+      m_enumClassName->asChar(), m_enumName->asChar(), m_ordinal,
+      CacheRegionHelper::getCacheImpl(output.getCache())->getPdxTypeRegistry());
   output.write(static_cast<int8_t>(GeodeTypeIds::CacheableEnum));
   output.write(int8_t(enumVal >> 24));
   output.writeArrayLen(enumVal & 0xFFFFFF);
@@ -53,7 +55,9 @@ Serializable* CacheableEnum::fromData(apache::geode::client::DataInput& input) {
   int32_t arrLen;
   input.readArrayLen(&arrLen);
   int enumId = (dsId << 24) | (arrLen & 0xFFFFFF);
-  EnumInfoPtr enumVal = PdxHelper::getEnum(enumId);
+  EnumInfoPtr enumVal = PdxHelper::getEnum(
+      enumId,
+      CacheRegionHelper::getCacheImpl(input.getCache())->getPdxTypeRegistry());
 
   m_enumClassName = enumVal->getEnumClassName();
   m_enumName = enumVal->getEnumName();

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheableObjectPartList.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheableObjectPartList.hpp b/src/cppcache/src/CacheableObjectPartList.hpp
index cbc241b..35e9d39 100644
--- a/src/cppcache/src/CacheableObjectPartList.hpp
+++ b/src/cppcache/src/CacheableObjectPartList.hpp
@@ -72,6 +72,17 @@ class CacheableObjectPartList : public Cacheable {
         m_destroyTracker(0),
         m_addToLocalCache(false) {}
 
+  inline CacheableObjectPartList(ThinClientRegion* region)
+      : m_keys(nullptr),
+        m_keysOffset(nullptr),
+        m_values(nullptr),
+        m_exceptions(nullptr),
+        m_resultKeys(nullptr),
+        m_region(region),
+        m_updateCountMap(nullptr),
+        m_destroyTracker(0),
+        m_addToLocalCache(false) {}
+
   // never implemented.
   CacheableObjectPartList& operator=(const CacheableObjectPartList& other);
   CacheableObjectPartList(const CacheableObjectPartList& other);

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheableString.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheableString.cpp b/src/cppcache/src/CacheableString.cpp
index 85fac8d..eddba1c 100644
--- a/src/cppcache/src/CacheableString.cpp
+++ b/src/cppcache/src/CacheableString.cpp
@@ -25,6 +25,8 @@
 #include <cstdlib>
 #include <ace/ACE.h>
 #include <ace/OS.h>
+#include "DataOutputInternal.hpp"
+#include "SerializationRegistry.hpp"
 
 using namespace apache::geode::client;
 
@@ -196,7 +198,7 @@ char* CacheableString::getASCIIString(const wchar_t* value, int32_t& len,
     }
     len -= clen;
   } else {
-    DataOutput out;
+    DataOutputInternal out;
     const wchar_t* pvalue = value;
     while ((currentChar = *pvalue) != 0) {
       c = getASCIIChar(currentChar, isASCII, encodedLen);

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ClientMetadata.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientMetadata.hpp b/src/cppcache/src/ClientMetadata.hpp
index 37a025e..b6ab281 100644
--- a/src/cppcache/src/ClientMetadata.hpp
+++ b/src/cppcache/src/ClientMetadata.hpp
@@ -20,6 +20,7 @@
  * limitations under the License.
  */
 
+#include <geode/Log.hpp>
 #include <geode/PartitionResolver.hpp>
 #include "ServerLocation.hpp"
 #include "BucketServerLocation.hpp"

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ClientMetadataService.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientMetadataService.cpp b/src/cppcache/src/ClientMetadataService.cpp
index 1939f16..20b611f 100644
--- a/src/cppcache/src/ClientMetadataService.cpp
+++ b/src/cppcache/src/ClientMetadataService.cpp
@@ -54,8 +54,12 @@ ClientMetadataService::ClientMetadataService(Pool* pool)
 {
   m_regionQueue = new Queue<std::string>(false);
   m_pool = pool;
-  m_bucketWaitTimeout =
-      DistributedSystem::getSystemProperties()->bucketWaitTimeout();
+
+  ThinClientPoolDM* tcrdm = dynamic_cast<ThinClientPoolDM*>(m_pool);
+  CacheImpl* cacheImpl = tcrdm->getConnectionManager().getCacheImpl();
+  m_bucketWaitTimeout = cacheImpl->getDistributedSystem()
+                            .getSystemProperties()
+                            .bucketWaitTimeout();
 }
 
 int ClientMetadataService::svc() {
@@ -128,7 +132,11 @@ void ClientMetadataService::getClientPRMetadata(const char* regionFullPath) {
   ClientMetadataPtr newCptr = nullptr;
 
   if (cptr == nullptr) {
-    TcrMessageGetClientPartitionAttributes request(regionFullPath);
+    TcrMessageGetClientPartitionAttributes request(tcrdm->getConnectionManager()
+                                                       .getCacheImpl()
+                                                       ->getCache()
+                                                       ->createDataOutput(),
+                                                   regionFullPath);
     GfErrType err = tcrdm->sendSyncRequest(request, reply);
     if (err == GF_NOERR &&
         reply.getMessageType() ==
@@ -182,7 +190,11 @@ ClientMetadataPtr ClientMetadataService::SendClientPRMetadata(
     throw IllegalArgumentException(
         "ClientMetaData: pool cast to ThinClientPoolDM failed");
   }
-  TcrMessageGetClientPrMetadata request(regionPath);
+  TcrMessageGetClientPrMetadata request(tcrdm->getConnectionManager()
+                                            .getCacheImpl()
+                                            ->getCache()
+                                            ->createDataOutput(),
+                                        regionPath);
   TcrMessageReply reply(true, nullptr);
   // send this message to server and get metadata from server.
   LOGFINE("Now sending GET_CLIENT_PR_METADATA for getting from server: %s",
@@ -251,10 +263,9 @@ void ClientMetadataService::getBucketServerLocation(
             "The RoutingObject returned by PartitionResolver is null.");
       }
     }
-    FixedPartitionResolverPtr fpResolver(
-        dynamic_cast<FixedPartitionResolver*>(resolver.get()));
-    if (fpResolver != nullptr) {
-      const char* partition = fpResolver->getPartitionName(event);
+    if (const auto fpResolver =
+            std::dynamic_pointer_cast<FixedPartitionResolver>(resolver)) {
+      const auto partition = fpResolver->getPartitionName(event);
       if (partition == nullptr) {
         throw IllegalStateException(
             "partition name returned by Partition resolver is null.");
@@ -313,13 +324,13 @@ void ClientMetadataService::enqueueForMetadataRefresh(
         "ClientMetaData: pool cast to ThinClientPoolDM failed");
   }
   RegionPtr region;
-  tcrdm->getConnectionManager().getCacheImpl()->getRegion(regionFullPath,
-                                                          region);
-  LocalRegion* lregion = dynamic_cast<LocalRegion*>(region.get());
+
+  auto cache = tcrdm->getConnectionManager().getCacheImpl();
+  cache->getRegion(regionFullPath, region);
 
   std::string serverGroup = tcrdm->getServerGroup();
   if (serverGroup.length() != 0) {
-    CacheImpl::setServerGroupFlag(serverGroupFlag);
+    cache->setServerGroupFlag(serverGroupFlag);
     if (serverGroupFlag == 2) {
       LOGFINER(
           "Network hop but, from within same server-group, so no metadata "
@@ -337,7 +348,7 @@ void ClientMetadataService::enqueueForMetadataRefresh(
         return;
       }
       LOGFINE("Network hop so fetching single hop metadata from the server");
-      CacheImpl::setNetworkHopFlag(true);
+      cache->setNetworkHopFlag(true);
       tcrRegion->setMetaDataRefreshed(true);
       std::string* tempRegionPath = new std::string(regionFullPath);
       m_regionQueue->put(tempRegionPath);
@@ -855,15 +866,13 @@ bool ClientMetadataService::isBucketMarkedForTimeout(const char* regionFullPath,
 
   ReadGuard guard(m_PRbucketStatusLock);
 
-  std::map<std::string, PRbuckets*>::iterator bs =
-      m_bucketStatus.find(regionFullPath);
-
+  const auto& bs = m_bucketStatus.find(regionFullPath);
   if (bs != m_bucketStatus.end()) {
     bool m = bs->second->isBucketTimedOut(bucketid, m_bucketWaitTimeout);
-    if (m == true) {
+    if (m) {
       ThinClientPoolDM* tcrdm = dynamic_cast<ThinClientPoolDM*>(m_pool);
       CacheImpl* cache = tcrdm->getConnectionManager().getCacheImpl();
-      cache->setBlackListBucketTimeouts();
+      cache->incBlackListBucketTimeouts();
     }
     LOGFINE("isBucketMarkedForTimeout:: for bucket %d returning = %d", bucketid,
             m);

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ClientProxyMembershipID.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientProxyMembershipID.cpp b/src/cppcache/src/ClientProxyMembershipID.cpp
index 41f0f6e..cbf7d6b 100644
--- a/src/cppcache/src/ClientProxyMembershipID.cpp
+++ b/src/cppcache/src/ClientProxyMembershipID.cpp
@@ -22,8 +22,10 @@
 #include <geode/GeodeTypeIds.hpp>
 #include "GeodeTypeIdsImpl.hpp"
 #include <geode/CacheableBuiltins.hpp>
+#include "DataOutputInternal.hpp"
 #include "Version.hpp"
 #include <string>
+#include <memory>
 
 #define ADDRSIZE 4
 #define DCPORT 12334
@@ -50,73 +52,9 @@ static class RandomInitializer {
 } oneTimeRandomInitializer;
 }  // namespace
 
-std::string ClientProxyMembershipID::g_dsName("DSName");
-std::string ClientProxyMembershipID::g_randString("GFNative");
-#define RAND_STRING_LEN 10
 const int ClientProxyMembershipID::VERSION_MASK = 0x8;
 const int8_t ClientProxyMembershipID::TOKEN_ORDINAL = -1;
 
-// initialize random string data and DistributedSystem name
-void ClientProxyMembershipID::init(const std::string& dsName) {
-  if (dsName.size() > 0) {
-    const char selectChars[] =
-        "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
-    const uint32_t numChars = (sizeof(selectChars) / sizeof(char)) - 1;
-
-    g_dsName = dsName;
-    bool randDone = false;
-    char randString[RAND_STRING_LEN + 1];
-    int pid = ACE_OS::getpid();
-    // try /dev/urandom first
-    FILE* urandom = ACE_OS::fopen("/dev/urandom", "rb");
-    if (urandom) {
-      LOGFINE("Opened /dev/urandom for ClientProxyMembershipID random data");
-      uint8_t readBytes[RAND_STRING_LEN];
-      size_t readLen = ACE_OS::fread(readBytes, RAND_STRING_LEN, 1, urandom);
-      if (readLen == 1) {
-        for (uint32_t index = 0; index < RAND_STRING_LEN; ++index) {
-          randString[index] = selectChars[readBytes[index] % numChars];
-        }
-        randString[RAND_STRING_LEN] = '\0';
-        randDone = true;
-      }
-      ACE_OS::fclose(urandom);
-    }
-    if (!randDone) {
-      for (uint32_t index = 0; index < RAND_STRING_LEN; ++index) {
-        randString[index] = selectChars[ACE_OS::rand() % numChars];
-      }
-      randString[RAND_STRING_LEN] = '\0';
-    }
-    char ps[15] = {0};
-    ACE_OS::snprintf(ps, 15, "%d", pid);
-    g_randString = "GFNative_";
-    g_randString.append(randString).append(ps);
-    LOGINFO("Using %s as random data for ClientProxyMembershipID",
-            g_randString.c_str());
-  }
-}
-const std::string& ClientProxyMembershipID::getRandStringId() {
-  return g_randString;
-}
-/*
-// Commenting this function as this is not getting used anywhere.
-ClientProxyMembershipID::ClientProxyMembershipID(const char *durableClientId,
-                                                 const uint32_t
-durableClntTimeOut)
-{
-  if( durableClientId != nullptr && durableClntTimeOut != 0 ) {
-    DataOutput  m_memID;
-    m_memID.write((int8_t)GeodeTypeIds::CacheableASCIIString);
-    m_memID.writeASCII(durableClientId);
-    CacheableInt32Ptr int32ptr = CacheableInt32::create(durableClntTimeOut);
-    int32ptr->toData(m_memID);
-    uint32_t len;
-    char* buf = (char*)m_memID.getBuffer(&len);
-    m_memIDStr.append(buf, len);
-  }
-}
-*/
 ClientProxyMembershipID::ClientProxyMembershipID()
     : m_hostPort(0),
       m_hostAddr(nullptr)
@@ -133,13 +71,14 @@ ClientProxyMembershipID::~ClientProxyMembershipID() {
 }
 
 ClientProxyMembershipID::ClientProxyMembershipID(
-    const char* hostname, uint32_t hostAddr, uint32_t hostPort,
-    const char* durableClientId, const uint32_t durableClntTimeOut) {
+    std::string dsName, std::string randString, const char* hostname,
+    uint32_t hostAddr, uint32_t hostPort, const char* durableClientId,
+    const uint32_t durableClntTimeOut)
+    : m_hostAddrAsUInt32(hostAddr) {
   int32_t vmPID = ACE_OS::getpid();
-
-  initObjectVars(hostname, reinterpret_cast<uint8_t*>(&hostAddr), 4, false,
-                 hostPort, durableClientId, durableClntTimeOut, DCPORT, vmPID,
-                 VMKIND, 0, g_dsName.c_str(), g_randString.c_str(), 0);
+  initObjectVars(hostname, reinterpret_cast<uint8_t*>(&m_hostAddrAsUInt32), 4,
+                 false, hostPort, durableClientId, durableClntTimeOut, DCPORT,
+                 vmPID, VMKIND, 0, dsName.c_str(), randString.c_str(), 0);
 }
 
 // This is only for unit tests and should not be used for any other purpose. See
@@ -157,7 +96,7 @@ void ClientProxyMembershipID::initObjectVars(
     const uint32_t durableClntTimeOut, int32_t dcPort, int32_t vPID,
     int8_t vmkind, int8_t splitBrainFlag, const char* dsname,
     const char* uniqueTag, uint32_t vmViewId) {
-  DataOutput m_memID;
+  DataOutputInternal m_memID;
   if (dsname == nullptr) {
     m_dsname = std::string("");
   } else {
@@ -212,9 +151,7 @@ void ClientProxyMembershipID::initObjectVars(
 
   char PID[15] = {0};
   char Synch_Counter[15] = {0};
-  // ACE_OS::snprintf(PID, 15, "%d",vPID);
   ACE_OS::itoa(vPID, PID, 10);
-  // ACE_OS::snprintf(Synch_Counter, 15, "%d",synch_counter);
   ACE_OS::itoa(synch_counter, Synch_Counter, 10);
   clientID.append(hostname);
   clientID.append("(");
@@ -273,74 +210,6 @@ const std::string& ClientProxyMembershipID::getDSMemberIdForThinClientUse() {
 
 std::string ClientProxyMembershipID::getHashKey() { return m_hashKey; }
 
-void ClientProxyMembershipID::getClientProxyMembershipID() {
-  // Implement LonerDistributionManager::generateMemberId() and store result in
-  // dsMemberId,dsMemberIdLength
-  const char* hex = "0123456789ABCDEF";
-  std::string DSMemberId = "";
-  ACE_TCHAR host[MAXHOSTNAMELEN];
-  std::string hostName = " ";
-  char buf[50];
-  char dsName[50];
-  DistributedSystemPtr dsPtr;
-  dsPtr = DistributedSystem::getInstance();
-
-  ACE_OS::hostname(host, sizeof(host) - 1);
-  hostName = host;
-  pid_t pid;
-  pid = ACE_OS::getpid();
-
-  /* adongre
-   * CID 28814: Resource leak (RESOURCE_LEAK)
-   * Following allocation is not used anywhere
-   * commenting the same.
-   */
-
-  /*int* random = new int[8];
-  for (int i = 0; i < 8; i++) {
-  random[i]=ACE_OS::rand()%16;
-  } */
-  char* hname = host;
-
-  // ACE_OS::sprintf(hname,"%s",hostName);
-  uint32_t len = static_cast<uint32_t>(hostName.length());
-  DataOutput m_dsmemID;
-  m_dsmemID.writeBytesOnly(reinterpret_cast<int8_t*>(hname), len);
-  // DSMemberId = DSMemberId.append(host);
-  // DSMemberId= DSMemberId.append("(");
-  m_dsmemID.write(static_cast<int8_t>('('));
-  int lenPid = ACE_OS::snprintf(buf, 50, "%d", pid);
-  // DSMemberId.append(buf);
-  // m_dsmemID.writeInt((int32_t)pid);
-  m_dsmemID.writeBytesOnly(reinterpret_cast<int8_t*>(buf), lenPid);
-  // DSMemberId.append("):");
-  m_dsmemID.write(static_cast<int8_t>(')'));
-  m_dsmemID.write(static_cast<int8_t>(':'));
-
-  char hexBuf[20];
-  for (int j = 0; j < 8; j++) {
-    //  Hardcoding random number for Thin Client
-    // hexBuf[j] = hex[random[j]%16];
-    hexBuf[j] = hex[1];
-  }
-  // DSMemberId = DSMemberId.append(hexBuf);
-  m_dsmemID.writeBytesOnly(reinterpret_cast<int8_t*>(hexBuf), 8);
-  m_dsmemID.write(static_cast<int8_t>(':'));
-  // DSMemberId = DSMemberId.append(":");
-  ACE_OS::snprintf(dsName, 50, "%s", dsPtr->getName());
-  // DSMemberId.append(dsName);
-  uint32_t dsLen = static_cast<uint32_t>(strlen(dsName));
-  m_dsmemID.writeBytesOnly(reinterpret_cast<int8_t*>(dsName), dsLen);
-  m_dsmemIDStr += (char*)m_dsmemID.getBuffer();
-  uint32_t strLen;
-  char* strBuf = (char*)m_dsmemID.getBuffer(&strLen);
-  m_dsmemIDStr.append(strBuf, strLen);
-  // dsMemberIdLength = DSMemberId.length();
-  // dsMemberId= (char*)ACE_OS::malloc(dsMemberIdLength+1);
-  // ACE_OS::strcpy(dsMemberId,DSMemberId.c_str());
-  // return m_dsmemID;
-}
-
 void ClientProxyMembershipID::toData(DataOutput& output) const {
   throw IllegalStateException("Member ID toData() not implemented.");
 }

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ClientProxyMembershipID.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientProxyMembershipID.hpp b/src/cppcache/src/ClientProxyMembershipID.hpp
index d7a29c9..4e86423 100644
--- a/src/cppcache/src/ClientProxyMembershipID.hpp
+++ b/src/cppcache/src/ClientProxyMembershipID.hpp
@@ -37,7 +37,9 @@ class ClientProxyMembershipID : public DSMemberForVersionStamp {
  public:
   const char* getDSMemberId(uint32_t& mesgLength) const;
   const char* getDSMemberIdForCS43(uint32_t& mesgLength) const;
-  ClientProxyMembershipID(const char* hostname, uint32_t hostAddr,
+
+  ClientProxyMembershipID(std::string dsName, std::string randString,
+                          const char* hostname, uint32_t hostAddr,
                           uint32_t hostPort,
                           const char* durableClientId = nullptr,
                           const uint32_t durableClntTimeOut = 0);
@@ -51,11 +53,6 @@ class ClientProxyMembershipID : public DSMemberForVersionStamp {
   // uint32_t durableClntTimeOut = 0);
   ClientProxyMembershipID();
   ~ClientProxyMembershipID();
-  void getClientProxyMembershipID();
-  // Initialize for random data and set the DS name.
-  // This method is not thread-safe.
-  static void init(const std::string& dsName);
-  static const std::string& getRandStringId();
   static void increaseSynchCounter();
   static Serializable* createDeserializable() {
     return new ClientProxyMembershipID();
@@ -111,15 +108,13 @@ class ClientProxyMembershipID : public DSMemberForVersionStamp {
  private:
   std::string m_memIDStr;
   std::string m_dsmemIDStr;
-  // static data
-  static std::string g_dsName;
-  static std::string g_randString;
   std::string clientID;
 
   std::string m_dsname;
   uint32_t m_hostPort;
   uint8_t* m_hostAddr;
   uint32_t m_hostAddrLen;
+  uint32_t m_hostAddrAsUInt32;
   std::string m_uniqueTag;
   std::string m_hashKey;
   bool m_hostAddrLocalMem;

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ClientProxyMembershipIDFactory.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientProxyMembershipIDFactory.cpp b/src/cppcache/src/ClientProxyMembershipIDFactory.cpp
new file mode 100644
index 0000000..f9bf982
--- /dev/null
+++ b/src/cppcache/src/ClientProxyMembershipIDFactory.cpp
@@ -0,0 +1,44 @@
+#include <algorithm>
+#include <iterator>
+#include <random>
+
+#include "ClientProxyMembershipIDFactory.hpp"
+
+namespace apache {
+namespace geode {
+namespace client {
+
+ClientProxyMembershipIDFactory::ClientProxyMembershipIDFactory(
+    std::string dsName)
+    : dsName(dsName) {
+  static const auto alphabet =
+      "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
+  static const auto numChars = (sizeof(alphabet) / sizeof(char)) - 2;
+
+  std::random_device rd;
+  std::default_random_engine rng(rd());
+  std::uniform_int_distribution<> dist(0, numChars);
+
+  randString.reserve(7 + 10 + 15);
+  randString.append("Native_");
+  std::generate_n(std::back_inserter(randString), 10,
+                  [&]() { return alphabet[dist(rng)]; });
+
+  auto pid = ACE_OS::getpid();
+  randString.append(std::to_string(pid));
+
+  LOGINFO("Using %s as random data for ClientProxyMembershipID",
+          randString.c_str());
+}
+
+std::unique_ptr<ClientProxyMembershipID> ClientProxyMembershipIDFactory::create(
+    const char* hostname, uint32_t hostAddr, uint32_t hostPort,
+    const char* durableClientId, const uint32_t durableClntTimeOut) {
+  return std::unique_ptr<ClientProxyMembershipID>(new ClientProxyMembershipID(
+      dsName, randString, hostname, hostAddr, hostPort, durableClientId,
+      durableClntTimeOut));
+}
+
+}  // namespace client
+}  // namespace geode
+}  // namespace apache
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ClientProxyMembershipIDFactory.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientProxyMembershipIDFactory.hpp b/src/cppcache/src/ClientProxyMembershipIDFactory.hpp
new file mode 100644
index 0000000..a24abbf
--- /dev/null
+++ b/src/cppcache/src/ClientProxyMembershipIDFactory.hpp
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#ifndef GEODE_CLIENTPROXYMEMBERSHIPIDFACTORY_H_
+#define GEODE_CLIENTPROXYMEMBERSHIPIDFACTORY_H_
+
+#include <string>
+
+#include "ClientProxyMembershipID.hpp"
+
+namespace apache {
+namespace geode {
+namespace client {
+
+class ClientProxyMembershipIDFactory {
+ public:
+  ClientProxyMembershipIDFactory(std::string dsName);
+
+  std::unique_ptr<ClientProxyMembershipID> create(
+      const char* hostname, uint32_t hostAddr, uint32_t hostPort,
+      const char* durableClientId = nullptr,
+      const uint32_t durableClntTimeOut = 0);
+
+ private:
+  std::string dsName;
+  std::string randString;
+};
+
+}  // namespace client
+}  // namespace geode
+}  // namespace apache
+
+#endif  // GEODE_CLIENTPROXYMEMBERSHIPID_H_

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ConcurrentEntriesMap.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ConcurrentEntriesMap.cpp b/src/cppcache/src/ConcurrentEntriesMap.cpp
index c79d4c2..c8338be 100644
--- a/src/cppcache/src/ConcurrentEntriesMap.cpp
+++ b/src/cppcache/src/ConcurrentEntriesMap.cpp
@@ -24,19 +24,17 @@ using namespace apache::geode::client;
 
 bool EntriesMap::boolVal = false;
 
-ConcurrentEntriesMap::ConcurrentEntriesMap(EntryFactory* entryFactory,
-                                           bool concurrencyChecksEnabled,
-                                           RegionInternal* region,
-                                           uint8_t concurrency)
-    : EntriesMap(entryFactory),
+ConcurrentEntriesMap::ConcurrentEntriesMap(
+    ExpiryTaskManager* expiryTaskManager,
+    std::unique_ptr<EntryFactory> entryFactory, bool concurrencyChecksEnabled,
+    RegionInternal* region, uint8_t concurrency)
+    : EntriesMap(std::move(entryFactory)),
+      m_expiryTaskManager(expiryTaskManager),
       m_concurrency(0),
       m_segments((MapSegment*)0),
       m_size(0),
       m_region(region),
       m_numDestroyTrackers(0),
-      /* adongre
-       * CID 28929: Uninitialized pointer field (UNINIT_CTOR)
-       */
       m_concurrencyChecksEnabled(concurrencyChecksEnabled) {
   GF_DEV_ASSERT(entryFactory != nullptr);
 
@@ -52,8 +50,9 @@ void ConcurrentEntriesMap::open(uint32_t initialCapacity) {
   uint32_t segSize = 1 + (initialCapacity - 1) / m_concurrency;
   m_segments = new MapSegment[m_concurrency];
   for (int index = 0; index < m_concurrency; ++index) {
-    m_segments[index].open(m_region, this->getEntryFactory(), segSize,
-                           &m_numDestroyTrackers, m_concurrencyChecksEnabled);
+    m_segments[index].open(m_region, getEntryFactory(), m_expiryTaskManager,
+                           segSize, &m_numDestroyTrackers,
+                           m_concurrencyChecksEnabled);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ConcurrentEntriesMap.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ConcurrentEntriesMap.hpp b/src/cppcache/src/ConcurrentEntriesMap.hpp
index 94e6a34..0a67fbb 100644
--- a/src/cppcache/src/ConcurrentEntriesMap.hpp
+++ b/src/cppcache/src/ConcurrentEntriesMap.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_CONCURRENTENTRIESMAP_H_
-#define GEODE_CONCURRENTENTRIESMAP_H_
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -20,7 +15,12 @@
  * limitations under the License.
  */
 
+#pragma once
+
+#ifndef GEODE_CONCURRENTENTRIESMAP_H_
+#define GEODE_CONCURRENTENTRIESMAP_H_
 #include <atomic>
+
 #include <geode/geode_globals.hpp>
 #include "EntriesMap.hpp"
 #include "MapSegment.hpp"
@@ -38,6 +38,7 @@ class RegionInternal;
  */
 class CPPCACHE_EXPORT ConcurrentEntriesMap : public EntriesMap {
  protected:
+  ExpiryTaskManager* m_expiryTaskManager;
   uint8_t m_concurrency;
   MapSegment* m_segments;
   std::atomic<uint32_t> m_size;
@@ -70,7 +71,8 @@ class CPPCACHE_EXPORT ConcurrentEntriesMap : public EntriesMap {
   /**
    * @brief constructor, must call open before using map.
    */
-  ConcurrentEntriesMap(EntryFactory* entryFactory,
+  ConcurrentEntriesMap(ExpiryTaskManager* expiryTaskManager,
+                       std::unique_ptr<EntryFactory> entryFactory,
                        bool concurrencyChecksEnabled, RegionInternal* region,
                        uint8_t concurrency = 16);
 

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CppCacheLibrary.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CppCacheLibrary.cpp b/src/cppcache/src/CppCacheLibrary.cpp
index ea77dbb..c9c1fd9 100644
--- a/src/cppcache/src/CppCacheLibrary.cpp
+++ b/src/cppcache/src/CppCacheLibrary.cpp
@@ -33,7 +33,6 @@
 #include <geode/DataOutput.hpp>
 #include "TcrMessage.hpp"
 #include "Utils.hpp"
-#include "PdxTypeRegistry.hpp"
 
 #include <string>
 
@@ -57,12 +56,6 @@ CppCacheLibrary::CppCacheLibrary() {
   // Put initialization code for statics and other such things here.
   try {
     gf_log_libinit();
-    EntryFactory::init();
-    LRUEntryFactory::init();
-    ExpEntryFactory::init();
-    LRUExpEntryFactory::init();
-    CacheFactory::init();
-    SerializationRegistry::init();
     // PdxTypeRegistry::init();
     // log( "Finished initializing CppCacheLibrary." );
   } catch (apache::geode::client::Exception& ge) {
@@ -73,7 +66,6 @@ CppCacheLibrary::CppCacheLibrary() {
 
 CppCacheLibrary::~CppCacheLibrary() {
   // Put any global clean up code here.
-  CacheFactory::cleanup();
   //  PdxTypeRegistry::cleanup();
 
   ACE::fini();

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CqEventImpl.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqEventImpl.cpp b/src/cppcache/src/CqEventImpl.cpp
index 8d15bd0..050c9cd 100644
--- a/src/cppcache/src/CqEventImpl.cpp
+++ b/src/cppcache/src/CqEventImpl.cpp
@@ -68,7 +68,11 @@ CacheablePtr CqEventImpl::getNewValue() const {
     return m_newValue;
   } else {
     // Get full object for delta
-    TcrMessageRequestEventValue fullObjectMsg(m_eventId);
+    TcrMessageRequestEventValue fullObjectMsg(m_tcrdm->getConnectionManager()
+                                                  .getCacheImpl()
+                                                  ->getCache()
+                                                  ->createDataOutput(),
+                                              m_eventId);
     TcrMessageReply reply(true, nullptr);
     ThinClientPoolHADM* poolHADM = dynamic_cast<ThinClientPoolHADM*>(m_tcrdm);
     GfErrType err = GF_NOTCON;