geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbarr...@apache.org
Subject [12/23] geode-native git commit: GEODE-2741: Code cleanup to move to std::shared_ptr
Date Tue, 06 Jun 2017 17:56:38 GMT
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/ClientMetadataService.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientMetadataService.cpp b/src/cppcache/src/ClientMetadataService.cpp
index eaf93f4..aa7b01a 100644
--- a/src/cppcache/src/ClientMetadataService.cpp
+++ b/src/cppcache/src/ClientMetadataService.cpp
@@ -14,14 +14,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include "TcrMessage.hpp"
-#include "ClientMetadataService.hpp"
-#include "ThinClientPoolDM.hpp"
-#include <geode/FixedPartitionResolver.hpp>
+
+#include <unordered_set>
 #include <iterator>
 #include <cstdlib>
 #include <climits>
 
+#include <geode/FixedPartitionResolver.hpp>
+
+#include "TcrMessage.hpp"
+#include "ClientMetadataService.hpp"
+#include "ThinClientPoolDM.hpp"
+
 namespace apache {
 namespace geode {
 namespace client {
@@ -43,8 +47,8 @@ ClientMetadataService::~ClientMetadataService() {
 
 ClientMetadataService::ClientMetadataService(Pool* pool)
     /* adongre
-    * CID 28928: Uninitialized scalar field (UNINIT_CTOR)
-    */
+     * CID 28928: Uninitialized scalar field (UNINIT_CTOR)
+     */
     : m_run(false)
 
 {
@@ -64,12 +68,12 @@ int ClientMetadataService::svc() {
     while (true) {
       std::string* regionFullPath = m_regionQueue->get();
 
-      if (regionFullPath != NULL && regionFullPath->c_str() != NULL) {
+      if (regionFullPath != nullptr && regionFullPath->c_str() != nullptr) {
         while (true) {
           if (m_regionQueue->size() > 0) {
             std::string* nextRegionFullPath = m_regionQueue->get();
-            if (nextRegionFullPath != NULL &&
-                nextRegionFullPath->c_str() != NULL &&
+            if (nextRegionFullPath != nullptr &&
+                nextRegionFullPath->c_str() != nullptr &&
                 regionFullPath->compare(nextRegionFullPath->c_str()) == 0) {
               delete nextRegionFullPath;  // we are going for same
             } else {
@@ -83,14 +87,14 @@ int ClientMetadataService::svc() {
         }
       }
 
-      if (!cache->isCacheDestroyPending() && regionFullPath != NULL &&
-          regionFullPath->c_str() != NULL) {
+      if (!cache->isCacheDestroyPending() && regionFullPath != nullptr &&
+          regionFullPath->c_str() != nullptr) {
         getClientPRMetadata(regionFullPath->c_str());
         delete regionFullPath;
-        regionFullPath = NULL;
+        regionFullPath = nullptr;
       } else {
         delete regionFullPath;
-        regionFullPath = NULL;
+        regionFullPath = nullptr;
         break;
       }
     }
@@ -101,9 +105,9 @@ int ClientMetadataService::svc() {
 }
 
 void ClientMetadataService::getClientPRMetadata(const char* regionFullPath) {
-  if (regionFullPath == NULL) return;
+  if (regionFullPath == nullptr) return;
   ThinClientPoolDM* tcrdm = dynamic_cast<ThinClientPoolDM*>(m_pool);
-  if (tcrdm == NULL) {
+  if (tcrdm == nullptr) {
     throw IllegalArgumentException(
         "ClientMetaData: pool cast to ThinClientPoolDM failed");
   }
@@ -111,7 +115,7 @@ void ClientMetadataService::getClientPRMetadata(const char* regionFullPath) {
   // for a particular region use GetClientPartitionAttributesOp
   // TcrMessage to fetch the metadata and put it into map for later use.send
   // this message to server and get metadata from server.
-  TcrMessageReply reply(true, NULL);
+  TcrMessageReply reply(true, nullptr);
   std::string path(regionFullPath);
   ClientMetadataPtr cptr = nullptr;
   {
@@ -120,31 +124,23 @@ void ClientMetadataService::getClientPRMetadata(const char* regionFullPath) {
     if (itr != m_regionMetaDataMap.end()) {
       cptr = itr->second;
     }
-    // cptr = m_regionMetaDataMap[path];
   }
   ClientMetadataPtr newCptr = nullptr;
 
-  {
-    // ACE_Guard< ACE_Recursive_Thread_Mutex > guard( m_regionMetadataLock );
-
-    if (cptr == nullptr) {
-      TcrMessageGetClientPartitionAttributes request(regionFullPath);
-      GfErrType err = tcrdm->sendSyncRequest(request, reply);
-      if (err == GF_NOERR &&
-          reply.getMessageType() ==
-              TcrMessage::RESPONSE_CLIENT_PARTITION_ATTRIBUTES) {
-        cptr = std::make_shared<ClientMetadata>(reply.getNumBuckets(),
-                                                reply.getColocatedWith(), tcrdm,
-                                                reply.getFpaSet());
-        if (m_bucketWaitTimeout > 0 && reply.getNumBuckets() > 0) {
-          WriteGuard guard(m_PRbucketStatusLock);
-          m_bucketStatus[regionFullPath] = new PRbuckets(reply.getNumBuckets());
-        }
-        LOGDEBUG("ClientMetadata buckets %d ", reply.getNumBuckets());
-        if (cptr != nullptr) {
-          // m_regionMetaDataMap[regionFullPath] = cptr;
-        }
+  if (cptr == nullptr) {
+    TcrMessageGetClientPartitionAttributes request(regionFullPath);
+    GfErrType err = tcrdm->sendSyncRequest(request, reply);
+    if (err == GF_NOERR &&
+        reply.getMessageType() ==
+            TcrMessage::RESPONSE_CLIENT_PARTITION_ATTRIBUTES) {
+      cptr = std::make_shared<ClientMetadata>(reply.getNumBuckets(),
+                                              reply.getColocatedWith(), tcrdm,
+                                              reply.getFpaSet());
+      if (m_bucketWaitTimeout > 0 && reply.getNumBuckets() > 0) {
+        WriteGuard guard(m_PRbucketStatusLock);
+        m_bucketStatus[regionFullPath] = new PRbuckets(reply.getNumBuckets());
       }
+      LOGDEBUG("ClientMetadata buckets %d ", reply.getNumBuckets());
     }
   }
   if (cptr == nullptr) {
@@ -165,13 +161,9 @@ void ClientMetadataService::getClientPRMetadata(const char* regionFullPath) {
       LOGINFO("Updated client meta data");
     }
   } else {
-    {
-      // ACE_Guard< ACE_Recursive_Thread_Mutex > guard( m_regionMetadataLock );
-      // m_regionMetaDataMap[colocatedWith->asChar()] = cptr;
-    }
     newCptr = SendClientPRMetadata(colocatedWith->asChar(), cptr);
 
-    if (newCptr != nullptr) {
+    if (newCptr) {
       cptr->setPreviousone(nullptr);
       newCptr->setPreviousone(cptr);
       // now we will get new instance so assign it again
@@ -186,12 +178,12 @@ void ClientMetadataService::getClientPRMetadata(const char* regionFullPath) {
 ClientMetadataPtr ClientMetadataService::SendClientPRMetadata(
     const char* regionPath, ClientMetadataPtr cptr) {
   ThinClientPoolDM* tcrdm = dynamic_cast<ThinClientPoolDM*>(m_pool);
-  if (tcrdm == NULL) {
+  if (tcrdm == nullptr) {
     throw IllegalArgumentException(
         "ClientMetaData: pool cast to ThinClientPoolDM failed");
   }
   TcrMessageGetClientPrMetadata request(regionPath);
-  TcrMessageReply reply(true, NULL);
+  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",
           regionPath);
@@ -205,7 +197,7 @@ ClientMetadataPtr ClientMetadataService::SendClientPRMetadata(
       lregion->getRegionStats()->incMetaDataRefreshCount();
     }
     std::vector<BucketServerLocationsType>* metadata = reply.getMetadata();
-    if (metadata == NULL) return nullptr;
+    if (metadata == nullptr) return nullptr;
     if (metadata->empty()) {
       delete metadata;
       return nullptr;
@@ -238,18 +230,15 @@ void ClientMetadataService::getBucketServerLocation(
         m_regionMetaDataMap.size());
     std::string path(region->getFullPath());
     ClientMetadataPtr cptr = nullptr;
-    RegionMetadataMapType::iterator itr = m_regionMetaDataMap.find(path);
+    const auto& itr = m_regionMetaDataMap.find(path);
     if (itr != m_regionMetaDataMap.end()) {
       cptr = itr->second;
     }
-    // ClientMetadataPtr cptr = m_regionMetaDataMap[path];
-    if (cptr == nullptr) {
-      // serverLocation = BucketServerLocation();
+    if (!cptr) {
       return;
     }
     CacheableKeyPtr resolvekey;
-    const PartitionResolverPtr& resolver =
-        region->getAttributes()->getPartitionResolver();
+    const auto& resolver = region->getAttributes()->getPartitionResolver();
 
     EntryEvent event(region, key, value, nullptr, aCallbackArgument, false);
     int bucketId = 0;
@@ -266,7 +255,7 @@ void ClientMetadataService::getBucketServerLocation(
         dynamic_cast<FixedPartitionResolver*>(resolver.get()));
     if (fpResolver != nullptr) {
       const char* partition = fpResolver->getPartitionName(event);
-      if (partition == NULL) {
+      if (partition == nullptr) {
         throw IllegalStateException(
             "partition name returned by Partition resolver is null.");
       } else {
@@ -277,8 +266,8 @@ void ClientMetadataService::getBucketServerLocation(
       }
     } else {
       if (cptr->getTotalNumBuckets() > 0) {
-        bucketId = std::abs(resolvekey->hashcode() %
-                            cptr->getTotalNumBuckets());
+        bucketId =
+            std::abs(resolvekey->hashcode() % cptr->getTotalNumBuckets());
       }
     }
     cptr->getServerLocation(bucketId, isPrimary, serverLocation, version);
@@ -294,7 +283,7 @@ void ClientMetadataService::removeBucketServerLocation(
     ClientMetadataPtr cptr = (*regionMetadataIter).second;
     if (cptr != nullptr) {
       // Yogesh has commented out this as it was causing a SIGV
-      // cptr->removeBucketServerLocation(serverLocation);
+      // clientMetadata->removeBucketServerLocation(serverLocation);
     }
   }
 }
@@ -310,29 +299,6 @@ ClientMetadataPtr ClientMetadataService::getClientMetadata(
   return nullptr;
 }
 
-/*const  PartitionResolverPtr& ClientMetadataService::getResolver(const
-  RegionPtr& region, const CacheableKeyPtr& key,
-   const UserDataPtr& aCallbackArgument){
-     //const char * regionFullPath = region->getFullPath();
-     //if (regionFullPath != NULL) {
-       //const RegionAttributesPtr& rAttrsPtr = region->getAttributes();
-       return region->getAttributes()->getPartitionResolver();
-     //}
-  }*/
-
-/*BucketServerLocation
-ClientMetadataService::getServerLocation(ClientMetadataPtr cptr, int bucketId,
-bool tryPrimary)
-{
-LOGFINE("Inside getServerLocation");
-if (cptr == nullptr) {
-LOGDEBUG("MetaData does not exist");
-return BucketServerLocation();
-}
-LOGFINE("Ending getServerLocation");
-return cptr->getServerLocation(bucketId, tryPrimary);
-}*/
-
 void ClientMetadataService::populateDummyServers(const char* regionName,
                                                  ClientMetadataPtr cptr) {
   WriteGuard guard(m_regionMetadataLock);
@@ -342,7 +308,7 @@ void ClientMetadataService::populateDummyServers(const char* regionName,
 void ClientMetadataService::enqueueForMetadataRefresh(
     const char* regionFullPath, int8_t serverGroupFlag) {
   ThinClientPoolDM* tcrdm = dynamic_cast<ThinClientPoolDM*>(m_pool);
-  if (tcrdm == NULL) {
+  if (tcrdm == nullptr) {
     throw IllegalArgumentException(
         "ClientMetaData: pool cast to ThinClientPoolDM failed");
   }
@@ -380,41 +346,36 @@ void ClientMetadataService::enqueueForMetadataRefresh(
   }
 }
 
-HashMapT<BucketServerLocationPtr, VectorOfCacheableKeyPtr>*
-ClientMetadataService::getServerToFilterMap(const VectorOfCacheableKey* keys,
-                                            const RegionPtr& region,
-                                            bool isPrimary) {
-  // const char* regionFullPath = region->getFullPath();
-  ClientMetadataPtr cptr = nullptr;
-  {
-    ReadGuard guard(m_regionMetadataLock);
-    RegionMetadataMapType::iterator cptrIter =
-        m_regionMetaDataMap.find(region->getFullPath());
+ClientMetadataPtr ClientMetadataService::getClientMetadata(
+    const RegionPtr& region) {
+  ReadGuard guard(m_regionMetadataLock);
 
-    if (cptrIter != m_regionMetaDataMap.end()) {
-      cptr = cptrIter->second;
-    }
+  const auto& entry = m_regionMetaDataMap.find(region->getFullPath());
 
-    if (cptr == nullptr || keys == NULL) {
-      // enqueueForMetadataRefresh(region->getFullPath());
-      return NULL;
-      //		//serverLocation = BucketServerLocation();
-      //		return;
-    }
+  if (entry == m_regionMetaDataMap.end()) {
+    return nullptr;
+  }
+
+  return entry->second;
+}
+
+ClientMetadataService::ServerToFilterMapPtr
+ClientMetadataService::getServerToFilterMap(const VectorOfCacheableKey& keys,
+                                            const RegionPtr& region,
+                                            bool isPrimary) {
+  auto clientMetadata = getClientMetadata(region);
+  if (!clientMetadata) {
+    return nullptr;
   }
-  // int totalNumberOfBuckets = cptr->getTotalNumBuckets();
-  auto* result =
-      new HashMapT<BucketServerLocationPtr, VectorOfCacheableKeyPtr>();
-  auto keysWhichLeft = std::make_shared<VectorOfCacheableKey>();
 
+  auto serverToFilterMap = std::make_shared<ServerToFilterMap>();
+
+  VectorOfCacheableKey keysWhichLeft;
   std::map<int, BucketServerLocationPtr> buckets;
 
-  for (VectorOfCacheableKey::Iterator iter = keys->begin(); iter != keys->end();
-       iter++) {
-    CacheableKeyPtr key = *iter;
+  for (const auto& key : keys) {
     LOGDEBUG("cmds = %s", key->toString()->toString());
-    PartitionResolverPtr resolver =
-        region->getAttributes()->getPartitionResolver();
+    const auto resolver = region->getAttributes()->getPartitionResolver();
     CacheableKeyPtr resolveKey;
 
     if (resolver == nullptr) {
@@ -426,73 +387,65 @@ ClientMetadataService::getServerToFilterMap(const VectorOfCacheableKey* keys,
       resolveKey = resolver->getRoutingObject(event);
     }
 
-    int bucketId = std::abs(resolveKey->hashcode() %
-                            cptr->getTotalNumBuckets());
+    int bucketId =
+        std::abs(resolveKey->hashcode() % clientMetadata->getTotalNumBuckets());
     VectorOfCacheableKeyPtr keyList = nullptr;
-    std::map<int, BucketServerLocationPtr>::iterator bucketsIter =
-        buckets.find(bucketId);
 
+    const auto& bucketsIter = buckets.find(bucketId);
     if (bucketsIter == buckets.end()) {
       int8_t version = -1;
       // auto serverLocation = std::make_shared<BucketServerLocation>();
       BucketServerLocationPtr serverLocation = nullptr;
-      cptr->getServerLocation(bucketId, isPrimary, serverLocation, version);
-      if (serverLocation == nullptr) {  //:if server not returns all buckets,
-                                        // need to confiem with PR team about
-        // this why??
-        keysWhichLeft->push_back(key);
-        continue;
-      } else if (!serverLocation->isValid()) {
-        keysWhichLeft->push_back(key);
+      clientMetadata->getServerLocation(bucketId, isPrimary, serverLocation,
+                                        version);
+      if (!(serverLocation && serverLocation->isValid())) {
+        keysWhichLeft.push_back(key);
         continue;
       }
-      // if(serverLocation == nullptr)
-      // continue;// need to fix
+
       buckets[bucketId] = serverLocation;
-      HashMapT<BucketServerLocationPtr, VectorOfCacheableKeyPtr>::Iterator
-          itrRes = result->find(serverLocation);
-      // keyList = (*result)[serverLocation];
 
-      if (itrRes == result->end()) {
+      const auto& itrRes = serverToFilterMap->find(serverLocation);
+
+      if (itrRes == serverToFilterMap->end()) {
         keyList = std::make_shared<VectorOfCacheableKey>();
-        result->insert(serverLocation, keyList);
+        serverToFilterMap->emplace(serverLocation, keyList);
       } else {
-        keyList = itrRes.second();
+        keyList = itrRes->second;
       }
+
       LOGDEBUG("new keylist buckets =%d res = %d", buckets.size(),
-               result->size());
+               serverToFilterMap->size());
     } else {
-      keyList = (*result)[bucketsIter->second];
+      keyList = (*serverToFilterMap)[bucketsIter->second];
     }
 
     keyList->push_back(key);
   }
 
-  if (keysWhichLeft->size() > 0 &&
-      result->size() > 0) {  // add left keys in result
-    int keyLefts = keysWhichLeft->size();
-    int totalServers = result->size();
-    int perServer = keyLefts / totalServers + 1;
+  if (keysWhichLeft.size() > 0 &&
+      serverToFilterMap->size() > 0) {  // add left keys in result
+    auto keyLefts = keysWhichLeft.size();
+    auto totalServers = serverToFilterMap->size();
+    auto perServer = keyLefts / totalServers + 1;
 
     int keyIdx = 0;
-    for (HashMapT<BucketServerLocationPtr, VectorOfCacheableKeyPtr>::Iterator
-             locationIter = result->begin();
-         locationIter != result->end(); locationIter++) {
-      VectorOfCacheableKeyPtr keys = locationIter.second();
+    for (const auto& locationIter : *serverToFilterMap) {
+      const auto keys = locationIter.second;
       for (int i = 0; i < perServer; i++) {
         if (keyIdx < keyLefts) {
-          keys->push_back(keysWhichLeft->at(keyIdx++));
+          keys->push_back(keysWhichLeft.at(keyIdx++));
         } else {
           break;
         }
       }
       if (keyIdx >= keyLefts) break;  // done
     }
-  } else if (result->size() == 0) {  // not be able to map any key
-    return NULL;  // it will force all keys to send to one server
+  } else if (serverToFilterMap->size() == 0) {  // not be able to map any key
+    return nullptr;  // it will force all keys to send to one server
   }
 
-  return result;
+  return serverToFilterMap;
 }
 
 void ClientMetadataService::markPrimaryBucketForTimeout(
@@ -507,7 +460,7 @@ void ClientMetadataService::markPrimaryBucketForTimeout(
                           false /*look for secondary host*/, serverLocation,
                           version);
 
-  if (serverLocation != nullptr && serverLocation->isValid()) {
+  if (serverLocation && serverLocation->isValid()) {
     LOGDEBUG("Server host and port are %s:%d",
              serverLocation->getServerName().c_str(),
              serverLocation->getPort());
@@ -523,167 +476,143 @@ void ClientMetadataService::markPrimaryBucketForTimeout(
   }
 }
 
-HashMapT<CacheableInt32Ptr, CacheableHashSetPtr>*
-ClientMetadataService::groupByBucketOnClientSide(const RegionPtr& region,
-                                                 CacheableVectorPtr* keySet,
-                                                 ClientMetadataPtr& metadata) {
-  HashMapT<CacheableInt32Ptr, CacheableHashSetPtr>* bucketToKeysMap =
-      new HashMapT<CacheableInt32Ptr, CacheableHashSetPtr>();
-  for (CacheableVector::Iterator itr = (*keySet)->begin();
-       itr != (*keySet)->end(); ++itr) {
-    CacheableKeyPtr key = std::dynamic_pointer_cast<CacheableKey>(*itr);
-    PartitionResolverPtr resolver =
-        region->getAttributes()->getPartitionResolver();
+ClientMetadataService::BucketToKeysMapPtr
+ClientMetadataService::groupByBucketOnClientSide(
+    const RegionPtr& region, const CacheableVectorPtr& keySet,
+    const ClientMetadataPtr& metadata) {
+  auto bucketToKeysMap = std::make_shared<BucketToKeysMap>();
+  for (const auto& k : *keySet) {
+    const auto key = std::static_pointer_cast<CacheableKey>(k);
+    const auto resolver = region->getAttributes()->getPartitionResolver();
     CacheableKeyPtr resolvekey;
     EntryEvent event(region, key, nullptr, nullptr, nullptr, false);
     int bucketId = -1;
-    if (resolver == nullptr) {
-      resolvekey = key;
-    } else {
+    if (resolver) {
       resolvekey = resolver->getRoutingObject(event);
-      if (resolvekey == nullptr) {
+      if (!resolvekey) {
         throw IllegalStateException(
             "The RoutingObject returned by PartitionResolver is null.");
       }
+    } else {
+      resolvekey = key;
     }
-    FixedPartitionResolverPtr fpResolver(
-        dynamic_cast<FixedPartitionResolver*>(resolver.get()));
-    if (fpResolver != nullptr) {
-      const char* partition = fpResolver->getPartitionName(event);
-      if (partition == NULL) {
-        throw IllegalStateException(
-            "partition name returned by Partition resolver is null.");
-      } else {
+
+    if (const auto fpResolver =
+            std::dynamic_pointer_cast<FixedPartitionResolver>(resolver)) {
+      const auto partition = fpResolver->getPartitionName(event);
+      if (partition) {
         bucketId = metadata->assignFixedBucketId(partition, resolvekey);
         if (bucketId == -1) {
           this->enqueueForMetadataRefresh(region->getFullPath(), 0);
         }
+      } else {
+        throw IllegalStateException(
+            "partition name returned by Partition resolver is null.");
       }
     } else {
       if (metadata->getTotalNumBuckets() > 0) {
-        bucketId = std::abs(resolvekey->hashcode() %
-                            metadata->getTotalNumBuckets());
+        bucketId =
+            std::abs(resolvekey->hashcode() % metadata->getTotalNumBuckets());
       }
     }
-    HashMapT<CacheableInt32Ptr, CacheableHashSetPtr>::Iterator iter =
-        bucketToKeysMap->find(CacheableInt32::create(bucketId));
+
     CacheableHashSetPtr bucketKeys;
+
+    const auto& iter = bucketToKeysMap->find(bucketId);
     if (iter == bucketToKeysMap->end()) {
       bucketKeys = CacheableHashSet::create();
-      bucketToKeysMap->insert(CacheableInt32::create(bucketId), bucketKeys);
+      bucketToKeysMap->emplace(bucketId, bucketKeys);
     } else {
-      bucketKeys = iter.second();
+      bucketKeys = iter->second;
     }
+
     bucketKeys->insert(key);
   }
+
   return bucketToKeysMap;
 }
 
-HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>*
+ClientMetadataService::ServerToKeysMapPtr
 ClientMetadataService::getServerToFilterMapFESHOP(
-    CacheableVectorPtr* routingKeys, const RegionPtr& region, bool isPrimary) {
+    const CacheableVectorPtr& routingKeys, const RegionPtr& region,
+    bool isPrimary) {
   ClientMetadataPtr cptr = getClientMetadata(region->getFullPath());
 
-  if (cptr == nullptr /*|| cptr->adviseRandomServerLocation() == nullptr*/) {
+  if (!cptr) {
     enqueueForMetadataRefresh(region->getFullPath(), 0);
-    return NULL;
+    return nullptr;
   }
 
-  if (routingKeys == NULL) {
-    return NULL;
+  if (!routingKeys) {
+    return nullptr;
   }
 
-  HashMapT<CacheableInt32Ptr, CacheableHashSetPtr>* bucketToKeysMap =
+  const auto bucketToKeysMap =
       groupByBucketOnClientSide(region, routingKeys, cptr);
-  CacheableHashSetPtr bucketSet = CacheableHashSet::create();
-  for (HashMapT<CacheableInt32Ptr, CacheableHashSetPtr>::Iterator iter =
-           bucketToKeysMap->begin();
-       iter != bucketToKeysMap->end(); ++iter) {
-    bucketSet->insert(iter.first());
+  BucketSet bucketSet(bucketToKeysMap->size());
+  for (const auto& iter : *bucketToKeysMap) {
+    bucketSet.insert(iter.first);
   }
   LOGDEBUG(
       "ClientMetadataService::getServerToFilterMapFESHOP: bucketSet size = %d ",
-      bucketSet->size());
+      bucketSet.size());
 
-  HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>* serverToBuckets =
+  const auto serverToBuckets =
       groupByServerToBuckets(cptr, bucketSet, isPrimary);
 
-  if (serverToBuckets == NULL) {
-    delete bucketToKeysMap;
-    return NULL;
+  if (serverToBuckets == nullptr) {
+    return nullptr;
   }
 
-  HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>* serverToKeysMap =
-      new HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>();
+  auto serverToKeysMap = std::make_shared<ServerToKeysMap>();
 
-  for (HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>::Iterator itrRes =
-           serverToBuckets->begin();
-       itrRes != serverToBuckets->end(); ++itrRes) {
-    BucketServerLocationPtr serverLocation = itrRes.first();
-    CacheableHashSetPtr buckets = itrRes.second();
-    for (CacheableHashSet::Iterator bucket = buckets->begin();
-         bucket != buckets->end(); ++bucket) {
-      HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>::Iterator iter =
-          serverToKeysMap->find(serverLocation);
-      CacheableHashSetPtr keys;
+  for (const auto& serverToBucket : *serverToBuckets) {
+    const auto& serverLocation = serverToBucket.first;
+    const auto& buckets = serverToBucket.second;
+    for (const auto& bucket : *buckets) {
+      CacheableHashSetPtr serverToKeysEntry;
+      const auto& iter = serverToKeysMap->find(serverLocation);
       if (iter == serverToKeysMap->end()) {
-        keys = CacheableHashSet::create();
+        serverToKeysEntry = CacheableHashSet::create();
+        serverToKeysMap->emplace(serverLocation, serverToKeysEntry);
       } else {
-        keys = iter.second();
+        serverToKeysEntry = iter->second;
       }
-      HashMapT<CacheableInt32Ptr, CacheableHashSetPtr>::Iterator
-          bucketToKeysiter = bucketToKeysMap->find(
-              std::static_pointer_cast<CacheableInt32>(*bucket));
-      if (bucketToKeysiter != bucketToKeysMap->end()) {
-        CacheableHashSetPtr bkeys = bucketToKeysiter.second();
-        for (CacheableHashSet::Iterator itr = bkeys->begin();
-             itr != bkeys->end(); ++itr) {
-          keys->insert(*itr);
-        }
+
+      const auto& bucketToKeys = bucketToKeysMap->find(bucket);
+      if (bucketToKeys != bucketToKeysMap->end()) {
+        const auto& bucketKeys = bucketToKeys->second;
+        serverToKeysEntry->insert(bucketKeys->begin(), bucketKeys->end());
       }
-      serverToKeysMap->insert(serverLocation, keys);
     }
   }
-  delete bucketToKeysMap;
-  delete serverToBuckets;
   return serverToKeysMap;
 }
 
 BucketServerLocationPtr ClientMetadataService::findNextServer(
-    HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>* serverToBucketsMap,
-    CacheableHashSetPtr& currentBucketSet) {
-  BucketServerLocationPtr serverLocation;
-  int max = -1;
+    const ClientMetadataService::ServerToBucketsMap& serverToBucketsMap,
+    const ClientMetadataService::BucketSet& currentBucketSet) {
+  size_t max = 0;
   std::vector<BucketServerLocationPtr> nodesOfEqualSize;
-  for (HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>::Iterator itr =
-           serverToBucketsMap->begin();
-       itr != serverToBucketsMap->end(); ++itr) {
-    CacheableHashSetPtr buckets = CacheableHashSet::create();
-    CacheableHashSetPtr sBuckets = itr.second();
 
-    for (CacheableHashSet::Iterator sItr = sBuckets->begin();
-         sItr != sBuckets->end(); ++sItr) {
-      buckets->insert(*sItr);
-    }
+  for (const auto& serverToBucketEntry : serverToBucketsMap) {
+    const auto& serverLocation = serverToBucketEntry.first;
+    BucketSet buckets(*(serverToBucketEntry.second));
 
     LOGDEBUG(
         "ClientMetadataService::findNextServer currentBucketSet->size() = %d  "
         "bucketSet->size() = %d ",
-        currentBucketSet->size(), buckets->size());
+        currentBucketSet.size(), buckets.size());
 
-    for (CacheableHashSet::Iterator currentBucketSetIter =
-             currentBucketSet->begin();
-         currentBucketSetIter != currentBucketSet->end();
-         ++currentBucketSetIter) {
-      buckets->erase(*currentBucketSetIter);
+    for (const auto& currentBucketSetIter : currentBucketSet) {
+      buckets.erase(currentBucketSetIter);
       LOGDEBUG("ClientMetadataService::findNextServer bucketSet->size() = %d ",
-               buckets->size());
+               buckets.size());
     }
 
-    int size = buckets->size();
+    auto size = buckets.size();
     if (max < size) {
       max = size;
-      serverLocation = itr.first();
       nodesOfEqualSize.clear();
       nodesOfEqualSize.push_back(serverLocation);
     } else if (max == size) {
@@ -691,101 +620,58 @@ BucketServerLocationPtr ClientMetadataService::findNextServer(
     }
   }
 
-  size_t nodeSize = nodesOfEqualSize.size();
+  auto nodeSize = nodesOfEqualSize.size();
   if (nodeSize > 0) {
     RandGen randgen;
-    int random = randgen(nodeSize);
+    auto random = randgen(nodeSize);
     return nodesOfEqualSize.at(random);
   }
   return nullptr;
 }
 
-bool ClientMetadataService::AreBucketSetsEqual(
-    CacheableHashSetPtr& currentBucketSet, CacheableHashSetPtr& bucketSet) {
-  int32_t currentBucketSetSize = currentBucketSet->size();
-  int32_t bucketSetSetSize = bucketSet->size();
+ClientMetadataService::ServerToBucketsMapPtr ClientMetadataService::pruneNodes(
+    const ClientMetadataPtr& metadata, const BucketSet& buckets) {
+  BucketSet bucketSetWithoutServer;
+  ServerToBucketsMap serverToBucketsMap;
 
-  LOGDEBUG(
-      "ClientMetadataService::AreBucketSetsEqual currentBucketSetSize = %d "
-      "bucketSetSetSize = %d ",
-      currentBucketSetSize, bucketSetSetSize);
-
-  if (currentBucketSetSize != bucketSetSetSize) {
-    return false;
-  }
-
-  bool found = false;
-  for (CacheableHashSet::Iterator currentBucketSetIter =
-           currentBucketSet->begin();
-       currentBucketSetIter != currentBucketSet->end();
-       ++currentBucketSetIter) {
-    found = false;
-    for (CacheableHashSet::Iterator bucketSetIter = bucketSet->begin();
-         bucketSetIter != bucketSet->end(); ++bucketSetIter) {
-      if (*currentBucketSetIter == *bucketSetIter) {
-        found = true;
-        break;
-      }
-    }
-    if (!found) return false;
-  }
-  return true;
-}
+  auto prunedServerToBucketsMap = std::make_shared<ServerToBucketsMap>();
 
-HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>*
-ClientMetadataService::pruneNodes(ClientMetadataPtr& metadata,
-                                  CacheableHashSetPtr& buckets) {
-  CacheableHashSetPtr bucketSetWithoutServer = CacheableHashSet::create();
-  HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>* serverToBucketsMap =
-      new HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>();
-  HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>*
-      prunedServerToBucketsMap =
-          new HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>();
-
-  for (CacheableHashSet::Iterator bucketId = buckets->begin();
-       bucketId != buckets->end(); ++bucketId) {
-    CacheableInt32Ptr bID = std::static_pointer_cast<CacheableInt32>(*bucketId);
-    std::vector<BucketServerLocationPtr> locations =
-        metadata->adviseServerLocations(bID->value());
+  for (const auto& bucketId : buckets) {
+    const auto locations = metadata->adviseServerLocations(bucketId);
     if (locations.size() == 0) {
       LOGDEBUG(
           "ClientMetadataService::pruneNodes Since no server location "
           "available for bucketId = %d  putting it into "
           "bucketSetWithoutServer ",
-          bID->value());
-      bucketSetWithoutServer->insert(bID);
+          bucketId);
+      bucketSetWithoutServer.insert(bucketId);
       continue;
     }
 
-    for (std::vector<BucketServerLocationPtr>::iterator location =
-             locations.begin();
-         location != locations.end(); ++location) {
-      HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>::Iterator itrRes =
-          serverToBucketsMap->find(*location);
-      CacheableHashSetPtr bucketSet;
-      if (itrRes == serverToBucketsMap->end()) {
-        bucketSet = CacheableHashSet::create();
+    for (const auto& location : locations) {
+      BucketSetPtr bucketSet;
+
+      const auto& itrRes = serverToBucketsMap.find(location);
+      if (itrRes == serverToBucketsMap.end()) {
+        bucketSet = std::make_shared<BucketSet>();
+        serverToBucketsMap.emplace(location, bucketSet);
       } else {
-        bucketSet = itrRes.second();
+        bucketSet = itrRes->second;
       }
-      bucketSet->insert(bID);
-      serverToBucketsMap->insert(*location, bucketSet);
+
+      bucketSet->insert(bucketId);
     }
   }
 
-  HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>::Iterator itrRes =
-      serverToBucketsMap->begin();
-  CacheableHashSetPtr currentBucketSet = CacheableHashSet::create();
+  auto& itrRes = serverToBucketsMap.begin();
   BucketServerLocationPtr randomFirstServer;
-  if (serverToBucketsMap->empty()) {
+  if (serverToBucketsMap.empty()) {
     LOGDEBUG(
         "ClientMetadataService::pruneNodes serverToBucketsMap is empty so "
-        "returning NULL");
-    delete prunedServerToBucketsMap;
-    delete serverToBucketsMap;
-    return NULL;
+        "returning nullptr");
+    return nullptr;
   } else {
-    size_t size = serverToBucketsMap->size();
+    size_t size = serverToBucketsMap.size();
     LOGDEBUG(
         "ClientMetadataService::pruneNodes Total size of serverToBucketsMap = "
         "%d ",
@@ -793,22 +679,18 @@ ClientMetadataService::pruneNodes(ClientMetadataPtr& metadata,
     for (size_t idx = 0; idx < (rand() % size); idx++) {
       itrRes++;
     }
-    randomFirstServer = itrRes.first();
+    randomFirstServer = itrRes->first;
   }
-  HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>::Iterator itrRes1 =
-      serverToBucketsMap->find(randomFirstServer);
-  CacheableHashSetPtr bucketSet = itrRes1.second();
+  const auto& itrRes1 = serverToBucketsMap.find(randomFirstServer);
+  const auto bucketSet = itrRes1->second;
 
-  for (CacheableHashSet::Iterator bt = bucketSet->begin();
-       bt != bucketSet->end(); ++bt) {
-    currentBucketSet->insert(*bt);
-  }
-  prunedServerToBucketsMap->insert(randomFirstServer, bucketSet);
-  serverToBucketsMap->erase(randomFirstServer);
+  BucketSet currentBucketSet(*bucketSet);
+
+  prunedServerToBucketsMap->emplace(randomFirstServer, bucketSet);
+  serverToBucketsMap.erase(randomFirstServer);
 
-  while (!AreBucketSetsEqual(currentBucketSet, buckets)) {
-    BucketServerLocationPtr server =
-        findNextServer(serverToBucketsMap, currentBucketSet);
+  while (buckets != currentBucketSet) {
+    auto server = findNextServer(serverToBucketsMap, currentBucketSet);
     if (server == nullptr) {
       LOGDEBUG(
           "ClientMetadataService::pruneNodes findNextServer returned no "
@@ -816,20 +698,14 @@ ClientMetadataService::pruneNodes(ClientMetadataPtr& metadata,
       break;
     }
 
-    HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>::Iterator itrRes2 =
-        serverToBucketsMap->find(server);
-    CacheableHashSetPtr bucketSet2 = itrRes2.second();
-
+    const auto& bucketSet2 = serverToBucketsMap.find(server)->second;
     LOGDEBUG(
         "ClientMetadataService::pruneNodes currentBucketSet->size() = %d  "
         "bucketSet2->size() = %d ",
-        currentBucketSet->size(), bucketSet2->size());
+        currentBucketSet.size(), bucketSet2->size());
 
-    for (CacheableHashSet::Iterator currentBucketSetIter =
-             currentBucketSet->begin();
-         currentBucketSetIter != currentBucketSet->end();
-         ++currentBucketSetIter) {
-      bucketSet2->erase(*currentBucketSetIter);
+    for (const auto& currentBucketSetIter : currentBucketSet) {
+      bucketSet2->erase(currentBucketSetIter);
       LOGDEBUG("ClientMetadataService::pruneNodes bucketSet2->size() = %d ",
                bucketSet2->size());
     }
@@ -838,86 +714,76 @@ ClientMetadataService::pruneNodes(ClientMetadataPtr& metadata,
       LOGDEBUG(
           "ClientMetadataService::pruneNodes bucketSet2 is empty() so removing "
           "server from serverToBucketsMap");
-      serverToBucketsMap->erase(server);
+      serverToBucketsMap.erase(server);
       continue;
     }
 
-    for (CacheableHashSet::Iterator itr = bucketSet2->begin();
-         itr != bucketSet2->end(); ++itr) {
-      currentBucketSet->insert(*itr);
+    for (const auto& itr : *bucketSet2) {
+      currentBucketSet.insert(itr);
     }
 
-    prunedServerToBucketsMap->insert(server, bucketSet2);
-    serverToBucketsMap->erase(server);
+    prunedServerToBucketsMap->emplace(server, bucketSet2);
+    serverToBucketsMap.erase(server);
   }
 
-  HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>::Iterator itrRes2 =
-      prunedServerToBucketsMap->begin();
-  for (CacheableHashSet::Iterator itr = bucketSetWithoutServer->begin();
-       itr != bucketSetWithoutServer->end(); ++itr) {
-    CacheableInt32Ptr buckstId = std::static_pointer_cast<CacheableInt32>(*itr);
-    itrRes2.second()->insert(buckstId);
+  const auto& itrRes2 = prunedServerToBucketsMap->begin();
+  for (const auto& itr : bucketSetWithoutServer) {
+    itrRes2->second->insert(itr);
   }
 
-  delete serverToBucketsMap;
   return prunedServerToBucketsMap;
 }
 
-HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>*
+ClientMetadataService::ServerToBucketsMapPtr
 ClientMetadataService::groupByServerToAllBuckets(const RegionPtr& region,
                                                  bool optimizeForWrite) {
   ClientMetadataPtr cptr = getClientMetadata(region->getFullPath());
   if (cptr == nullptr) {
     enqueueForMetadataRefresh(region->getFullPath(), false);
-    return NULL;
+    return nullptr;
   }
   int totalBuckets = cptr->getTotalNumBuckets();
-  CacheableHashSetPtr bucketSet = CacheableHashSet::create();
+  BucketSet bucketSet(totalBuckets);
   for (int i = 0; i < totalBuckets; i++) {
-    bucketSet->insert(CacheableInt32::create(i));
+    bucketSet.insert(i);
   }
   return groupByServerToBuckets(cptr, bucketSet, optimizeForWrite);
 }
 
-HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>*
-ClientMetadataService::groupByServerToBuckets(ClientMetadataPtr& metadata,
-                                              CacheableHashSetPtr& bucketSet,
+ClientMetadataService::ServerToBucketsMapPtr
+ClientMetadataService::groupByServerToBuckets(const ClientMetadataPtr& metadata,
+                                              const BucketSet& bucketSet,
                                               bool optimizeForWrite) {
   if (optimizeForWrite) {
-    HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>* serverToBucketsMap =
-        new HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>();
-    CacheableHashSetPtr bucketsWithoutServer = CacheableHashSet::create();
-    for (CacheableHashSet::Iterator itr = bucketSet->begin();
-         itr != bucketSet->end(); ++itr) {
-      CacheableInt32Ptr bucketId =
-          std::static_pointer_cast<CacheableInt32>(*itr);
-      BucketServerLocationPtr serverLocation =
-          metadata->advisePrimaryServerLocation(bucketId->value());
+    auto serverToBucketsMap = std::make_shared<ServerToBucketsMap>();
+    BucketSet bucketsWithoutServer(bucketSet.size());
+    for (const auto& bucketId : bucketSet) {
+      const auto serverLocation =
+          metadata->advisePrimaryServerLocation(bucketId);
       if (serverLocation == nullptr) {
-        bucketsWithoutServer->insert(bucketId);
+        bucketsWithoutServer.insert(bucketId);
         continue;
       } else if (!serverLocation->isValid()) {
-        bucketsWithoutServer->insert(bucketId);
+        bucketsWithoutServer.insert(bucketId);
         continue;
       }
-      HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>::Iterator itrRes =
-          serverToBucketsMap->find(serverLocation);
-      CacheableHashSetPtr buckets;
+
+      BucketSetPtr buckets;
+      const auto& itrRes = serverToBucketsMap->find(serverLocation);
       if (itrRes == serverToBucketsMap->end()) {
-        buckets = CacheableHashSet::create();
-        serverToBucketsMap->insert(serverLocation, buckets);
+        buckets = std::make_shared<BucketSet>();
+        serverToBucketsMap->emplace(serverLocation, buckets);
       } else {
-        buckets = itrRes.second();
+        buckets = itrRes->second;
       }
+
       buckets->insert(bucketId);
     }
 
     if (!serverToBucketsMap->empty()) {
-      HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>::Iterator itrRes =
-          serverToBucketsMap->begin();
-      for (CacheableHashSet::Iterator itr = bucketsWithoutServer->begin();
-           itr != bucketsWithoutServer->end(); ++itr) {
-        itrRes.second()->insert(*itr);
+      const auto& itrRes = serverToBucketsMap->begin();
+      for (const auto& itr : bucketsWithoutServer) {
+        itrRes->second->insert(itr);
         LOGDEBUG(
             "ClientMetadataService::groupByServerToBuckets inserting "
             "bucketsWithoutServer");
@@ -940,12 +806,12 @@ void ClientMetadataService::markPrimaryBucketForTimeoutButLookSecondaryBucket(
   std::map<std::string, PRbuckets*>::iterator bs =
       m_bucketStatus.find(region->getFullPath());
 
-  PRbuckets* prBuckets = NULL;
+  PRbuckets* prBuckets = nullptr;
   if (bs != m_bucketStatus.end()) {
     prBuckets = bs->second;
   }
 
-  if (prBuckets == NULL) return;
+  if (prBuckets == nullptr) return;
 
   getBucketServerLocation(region, key, value, aCallbackArgument, true,
                           serverLocation, version);

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/ClientMetadataService.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientMetadataService.hpp b/src/cppcache/src/ClientMetadataService.hpp
index c39a69a..f9d2da2 100644
--- a/src/cppcache/src/ClientMetadataService.hpp
+++ b/src/cppcache/src/ClientMetadataService.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_CLIENTMETADATASERVICE_H_
-#define GEODE_CLIENTMETADATASERVICE_H_
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -20,17 +15,27 @@
  * limitations under the License.
  */
 
+#pragma once
+
+#ifndef GEODE_CLIENTMETADATASERVICE_H_
+#define GEODE_CLIENTMETADATASERVICE_H_
+
+#include <unordered_map>
+#include <memory>
+#include <string>
+
 #include <ace/Task.h>
-#include "ClientMetadata.hpp"
-#include "ServerLocation.hpp"
-#include "BucketServerLocation.hpp"
-#include <geode/HashMapT.hpp>
+
+#include <geode/utils.hpp>
 #include <geode/SharedPtr.hpp>
 #include <geode/CacheableKey.hpp>
 #include <geode/Cacheable.hpp>
 #include <geode/Region.hpp>
+
+#include "ClientMetadata.hpp"
+#include "ServerLocation.hpp"
+#include "BucketServerLocation.hpp"
 #include "Queue.hpp"
-#include <string>
 #include "DistributedSystemImpl.hpp"
 #include "NonCopyable.hpp"
 
@@ -138,9 +143,14 @@ class ClientMetadataService : public ACE_Task_Base,
   void enqueueForMetadataRefresh(const char* regionFullPath,
                                  int8_t serverGroupFlag);
 
-  HashMapT<BucketServerLocationPtr, VectorOfCacheableKeyPtr>*
-  getServerToFilterMap(const VectorOfCacheableKey* keys,
-                       const RegionPtr& region, bool isPrimary);
+  typedef std::unordered_map<BucketServerLocationPtr, VectorOfCacheableKeyPtr,
+                             dereference_hash<BucketServerLocationPtr>,
+                             dereference_equal_to<BucketServerLocationPtr>>
+      ServerToFilterMap;
+  typedef std::shared_ptr<ServerToFilterMap> ServerToFilterMapPtr;
+  ServerToFilterMapPtr getServerToFilterMap(const VectorOfCacheableKey& keys,
+                                            const RegionPtr& region,
+                                            bool isPrimary);
 
   void markPrimaryBucketForTimeout(
       const RegionPtr& region, const CacheableKeyPtr& key,
@@ -154,31 +164,45 @@ class ClientMetadataService : public ACE_Task_Base,
 
   bool isBucketMarkedForTimeout(const char* regionFullPath, int32_t bucketid);
 
-  bool AreBucketSetsEqual(CacheableHashSetPtr& currentBucketSet,
-                          CacheableHashSetPtr& bucketSet);
+  typedef std::unordered_set<int32_t> BucketSet;
+  typedef std::shared_ptr<BucketSet> BucketSetPtr;
+  typedef std::unordered_map<BucketServerLocationPtr, BucketSetPtr,
+                             dereference_hash<BucketServerLocationPtr>,
+                             dereference_equal_to<BucketServerLocationPtr>>
+      ServerToBucketsMap;
+  typedef std::shared_ptr<ServerToBucketsMap> ServerToBucketsMapPtr;
+  // bool AreBucketSetsEqual(const BucketSet& currentBucketSet,
+  //                        const BucketSet& bucketSet);
 
   BucketServerLocationPtr findNextServer(
-      HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>*
-          serverToBucketsMap,
-      CacheableHashSetPtr& currentBucketSet);
-
-  HashMapT<CacheableInt32Ptr, CacheableHashSetPtr>* groupByBucketOnClientSide(
-      const RegionPtr& region, CacheableVectorPtr* keySet,
-      ClientMetadataPtr& metadata);
-
-  HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>*
-  getServerToFilterMapFESHOP(CacheableVectorPtr* keySet,
-                             const RegionPtr& region, bool isPrimary);
-
-  HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>*
-  groupByServerToAllBuckets(const RegionPtr& region, bool optimizeForWrite);
-
-  HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>*
-  groupByServerToBuckets(ClientMetadataPtr& metadata,
-                         CacheableHashSetPtr& bucketSet, bool optimizeForWrite);
-
-  HashMapT<BucketServerLocationPtr, CacheableHashSetPtr>* pruneNodes(
-      ClientMetadataPtr& metadata, CacheableHashSetPtr& totalBuckets);
+      const ServerToBucketsMap& serverToBucketsMap,
+      const BucketSet& currentBucketSet);
+
+  typedef std::unordered_map<int32_t, CacheableHashSetPtr> BucketToKeysMap;
+  typedef std::shared_ptr<BucketToKeysMap> BucketToKeysMapPtr;
+  BucketToKeysMapPtr groupByBucketOnClientSide(
+      const RegionPtr& region, const CacheableVectorPtr& keySet,
+      const ClientMetadataPtr& metadata);
+
+  typedef std::unordered_map<BucketServerLocationPtr, CacheableHashSetPtr,
+                             dereference_hash<BucketServerLocationPtr>,
+                             dereference_equal_to<BucketServerLocationPtr>>
+      ServerToKeysMap;
+  typedef std::shared_ptr<ServerToKeysMap> ServerToKeysMapPtr;
+  ServerToKeysMapPtr getServerToFilterMapFESHOP(
+      const CacheableVectorPtr& keySet, const RegionPtr& region,
+      bool isPrimary);
+
+  ClientMetadataService::ServerToBucketsMapPtr groupByServerToAllBuckets(
+      const RegionPtr& region, bool optimizeForWrite);
+
+  ClientMetadataService::ServerToBucketsMapPtr groupByServerToBuckets(
+      const ClientMetadataPtr& metadata, const BucketSet& bucketSet,
+      bool optimizeForWrite);
+
+  ClientMetadataService::ServerToBucketsMapPtr
+  ClientMetadataService::pruneNodes(const ClientMetadataPtr& metadata,
+                                    const BucketSet& buckets);
 
  private:
   // const PartitionResolverPtr& getResolver(const RegionPtr& region, const
@@ -191,6 +215,8 @@ class ClientMetadataService : public ACE_Task_Base,
   ClientMetadataPtr SendClientPRMetadata(const char* regionPath,
                                          ClientMetadataPtr cptr);
 
+  ClientMetadataPtr getClientMetadata(const RegionPtr& region);
+
  private:
   // ACE_Recursive_Thread_Mutex m_regionMetadataLock;
   ACE_RW_Thread_Mutex m_regionMetadataLock;

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/ClientProxyMembershipID.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientProxyMembershipID.cpp b/src/cppcache/src/ClientProxyMembershipID.cpp
index 07e6a9b..2b438dc 100644
--- a/src/cppcache/src/ClientProxyMembershipID.cpp
+++ b/src/cppcache/src/ClientProxyMembershipID.cpp
@@ -105,7 +105,7 @@ ClientProxyMembershipID::ClientProxyMembershipID(const char *durableClientId,
                                                  const uint32_t
 durableClntTimeOut)
 {
-  if( durableClientId != NULL && durableClntTimeOut != 0 ) {
+  if( durableClientId != nullptr && durableClntTimeOut != 0 ) {
     DataOutput  m_memID;
     m_memID.write((int8_t)GeodeTypeIds::CacheableASCIIString);
     m_memID.writeASCII(durableClientId);
@@ -119,7 +119,7 @@ durableClntTimeOut)
 */
 ClientProxyMembershipID::ClientProxyMembershipID()
     : m_hostPort(0),
-      m_hostAddr(NULL)
+      m_hostAddr(nullptr)
       /* adongre  - Coverity II
        * CID 29278: Uninitialized scalar field (UNINIT_CTOR)
        */
@@ -158,7 +158,7 @@ void ClientProxyMembershipID::initObjectVars(
     int8_t vmkind, int8_t splitBrainFlag, const char* dsname,
     const char* uniqueTag, uint32_t vmViewId) {
   DataOutput m_memID;
-  if (dsname == NULL) {
+  if (dsname == nullptr) {
     m_dsname = std::string("");
   } else {
     m_dsname = std::string(dsname);
@@ -167,7 +167,7 @@ void ClientProxyMembershipID::initObjectVars(
   m_hostAddr = hostAddr;
   m_hostAddrLen = hostAddrLen;
   m_hostAddrLocalMem = hostAddrLocalMem;
-  if (uniqueTag == NULL) {
+  if (uniqueTag == nullptr) {
     m_uniqueTag = std::string("");
   } else {
     m_uniqueTag = std::string(uniqueTag);
@@ -199,7 +199,7 @@ void ClientProxyMembershipID::initObjectVars(
   m_memID.write(static_cast<int8_t>(GeodeTypeIds::CacheableASCIIString));
   m_memID.writeASCII(uniqueTag);
 
-  if (durableClientId != NULL && durableClntTimeOut != 0) {
+  if (durableClientId != nullptr && durableClntTimeOut != 0) {
     m_memID.write(static_cast<int8_t>(GeodeTypeIds::CacheableASCIIString));
     m_memID.writeASCII(durableClientId);
     CacheableInt32Ptr int32ptr = CacheableInt32::create(durableClntTimeOut);
@@ -389,7 +389,7 @@ Serializable* ClientProxyMembershipID::fromData(DataInput& input) {
     vmViewId = atoi(uniqueTag.get()->asChar());
     initObjectVars(hostname->asChar(), hostAddr, len, true, hostPort,
                    durableClientId->asChar(), durableClntTimeOut, dcport, vPID,
-                   vmKind, splitbrain, dsName->asChar(), NULL, vmViewId);
+                   vmKind, splitbrain, dsName->asChar(), nullptr, vmViewId);
   } else {
     // initialize the object
     initObjectVars(hostname->asChar(), hostAddr, len, true, hostPort,
@@ -439,7 +439,7 @@ Serializable* ClientProxyMembershipID::readEssentialData(DataInput& input) {
   if (vmKind != ClientProxyMembershipID::LONER_DM_TYPE) {
     // initialize the object with the values read and some dummy values
     initObjectVars("", hostAddr, len, true, hostPort, "", 0, DCPORT, 0, vmKind,
-                   0, dsName->asChar(), NULL, vmViewId);
+                   0, dsName->asChar(), nullptr, vmViewId);
   } else {
     // initialize the object with the values read and some dummy values
     initObjectVars("", hostAddr, len, true, hostPort, "", 0, DCPORT, 0, vmKind,
@@ -478,7 +478,7 @@ int16_t ClientProxyMembershipID::compareTo(
   uint8_t* myAddr = getHostAddr();
   uint8_t* otherAddr = otherMember.getHostAddr();
   // Discard null cases
-  if (myAddr == NULL && otherAddr == NULL) {
+  if (myAddr == nullptr && otherAddr == nullptr) {
     if (myPort < otherPort) {
       return -1;
     } else if (myPort > otherPort) {
@@ -486,9 +486,9 @@ int16_t ClientProxyMembershipID::compareTo(
     } else {
       return 0;
     }
-  } else if (myAddr == NULL) {
+  } else if (myAddr == nullptr) {
     return -1;
-  } else if (otherAddr == NULL) {
+  } else if (otherAddr == nullptr) {
     return 1;
   }
   for (uint32_t i = 0; i < getHostAddrLen(); i++) {

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/ClientProxyMembershipID.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientProxyMembershipID.hpp b/src/cppcache/src/ClientProxyMembershipID.hpp
index 347cc52..a61e86e 100644
--- a/src/cppcache/src/ClientProxyMembershipID.hpp
+++ b/src/cppcache/src/ClientProxyMembershipID.hpp
@@ -38,7 +38,8 @@ class ClientProxyMembershipID : public DSMemberForVersionStamp {
   const char* getDSMemberId(uint32_t& mesgLength) const;
   const char* getDSMemberIdForCS43(uint32_t& mesgLength) const;
   ClientProxyMembershipID(const char* hostname, uint32_t hostAddr,
-                          uint32_t hostPort, const char* durableClientId = NULL,
+                          uint32_t hostPort,
+                          const char* durableClientId = nullptr,
                           const uint32_t durableClntTimeOut = 0);
 
   // This constructor is only for testing and should not be used for any
@@ -46,8 +47,8 @@ class ClientProxyMembershipID : public DSMemberForVersionStamp {
   ClientProxyMembershipID(uint8_t* hostAddr, uint32_t hostAddrLen,
                           uint32_t hostPort, const char* dsname,
                           const char* uniqueTag, uint32_t vmViewId);
-  // ClientProxyMembershipID(const char *durableClientId = NULL, const uint32_t
-  // durableClntTimeOut = 0);
+  // ClientProxyMembershipID(const char *durableClientId = nullptr, const
+  // uint32_t durableClntTimeOut = 0);
   ClientProxyMembershipID();
   ~ClientProxyMembershipID();
   void getClientProxyMembershipID();

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/ClientReplacementRequest.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientReplacementRequest.cpp b/src/cppcache/src/ClientReplacementRequest.cpp
index 304f872..08e4358 100644
--- a/src/cppcache/src/ClientReplacementRequest.cpp
+++ b/src/cppcache/src/ClientReplacementRequest.cpp
@@ -25,8 +25,8 @@ void ClientReplacementRequest::toData(DataOutput& output) const {
   this->m_serverLocation.toData(output);
 }
 Serializable* ClientReplacementRequest::fromData(DataInput& input) {
-  return NULL;  // not needed as of now and my guess is  it will never be
-                // needed.
+  return nullptr;  // not needed as of now and my guess is  it will never be
+                   // needed.
 }
 int8_t ClientReplacementRequest::typeId() const {
   return static_cast<int8_t>(GeodeTypeIdsImpl::ClientReplacementRequest);

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/ConcurrentEntriesMap.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ConcurrentEntriesMap.cpp b/src/cppcache/src/ConcurrentEntriesMap.cpp
index b2fd1fc..ea21d14 100644
--- a/src/cppcache/src/ConcurrentEntriesMap.cpp
+++ b/src/cppcache/src/ConcurrentEntriesMap.cpp
@@ -39,7 +39,7 @@ ConcurrentEntriesMap::ConcurrentEntriesMap(EntryFactory* entryFactory,
        * CID 28929: Uninitialized pointer field (UNINIT_CTOR)
        */
       m_concurrencyChecksEnabled(concurrencyChecksEnabled) {
-  GF_DEV_ASSERT(entryFactory != NULL);
+  GF_DEV_ASSERT(entryFactory != nullptr);
 
   uint8_t maxConcurrency = TableOfPrimes::getMaxPrimeForConcurrency();
   if (concurrency > maxConcurrency) {

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/ConcurrentEntriesMap.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ConcurrentEntriesMap.hpp b/src/cppcache/src/ConcurrentEntriesMap.hpp
index 136d425..5494f8b 100644
--- a/src/cppcache/src/ConcurrentEntriesMap.hpp
+++ b/src/cppcache/src/ConcurrentEntriesMap.hpp
@@ -70,8 +70,7 @@ class CPPCACHE_EXPORT ConcurrentEntriesMap : public EntriesMap {
    * @brief constructor, must call open before using map.
    */
   ConcurrentEntriesMap(EntryFactory* entryFactory,
-                       bool concurrencyChecksEnabled,
-                       RegionInternal* region,
+                       bool concurrencyChecksEnabled, RegionInternal* region,
                        uint8_t concurrency = 16);
 
   /**
@@ -90,7 +89,7 @@ class CPPCACHE_EXPORT ConcurrentEntriesMap : public EntriesMap {
                         CacheablePtr& oldValue, int updateCount,
                         int destroyTracker, VersionTagPtr versionTag,
                         bool& isUpdate = EntriesMap::boolVal,
-                        DataInput* delta = NULL);
+                        DataInput* delta = nullptr);
   virtual GfErrType invalidate(const CacheableKeyPtr& key, MapEntryImplPtr& me,
                                CacheablePtr& oldValue,
                                VersionTagPtr versionTag);

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/CppCacheLibrary.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CppCacheLibrary.cpp b/src/cppcache/src/CppCacheLibrary.cpp
index 50cd260..ea77dbb 100644
--- a/src/cppcache/src/CppCacheLibrary.cpp
+++ b/src/cppcache/src/CppCacheLibrary.cpp
@@ -38,7 +38,9 @@
 #include <string>
 
 // called during DLL initialization
-void initLibDllEntry(void) { apache::geode::client::CppCacheLibrary::initLib(); }
+void initLibDllEntry(void) {
+  apache::geode::client::CppCacheLibrary::initLib();
+}
 
 extern "C" {
 void DllMainGetPath(char* result, int maxLen);
@@ -48,7 +50,7 @@ namespace apache {
 namespace geode {
 namespace client {
 
-  void gf_log_libinit();
+void gf_log_libinit();
 
 CppCacheLibrary::CppCacheLibrary() {
   // TODO: This should catch any exceptions, log it, and bail out..
@@ -102,7 +104,7 @@ void CppCacheLibrary::closeLib(void) {
 std::string CppCacheLibrary::getProductLibDir(const char* addon) {
   std::string proddir = CppCacheLibrary::getProductDir();
   proddir += "/lib/";
-  if (addon != NULL) {
+  if (addon != nullptr) {
     proddir += addon;
   }
   return proddir;
@@ -123,9 +125,9 @@ std::string CppCacheLibrary::getProductLibDir() {
   cppName += ".dll";
   pos = path.find(cppName);
   if (std::string::npos == pos) {
-	  std::string dotNetName = PRODUCT_DLL_NAME;
-	  dotNetName += ".dll";
-	  pos = path.find(dotNetName);
+    std::string dotNetName = PRODUCT_DLL_NAME;
+    dotNetName += ".dll";
+    pos = path.find(dotNetName);
   }
 #else
   std::string cppName = "lib";
@@ -133,7 +135,7 @@ std::string CppCacheLibrary::getProductLibDir() {
   pos = path.find(cppName);
 #endif
   if (0 < pos) {
-	  return path.substr(0, --pos);
+    return path.substr(0, --pos);
   }
   return std::string();
 }
@@ -167,7 +169,7 @@ std::string CppCacheLibrary::getProductDir() {
   }
   libdirname = slashtmp;
   delete[] slashtmp;
-  slashtmp = NULL;
+  slashtmp = nullptr;
 
   // check if it is "hidden/lib/debug" and work back from build area.
   size_t hiddenidx = libdirname.find("hidden");
@@ -192,7 +194,6 @@ std::string CppCacheLibrary::getProductDir() {
   } else {
     return libdirname;
   }
-
 }
 
 }  // namespace client

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/CqEventImpl.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqEventImpl.cpp b/src/cppcache/src/CqEventImpl.cpp
index 4485cb9..8d15bd0 100644
--- a/src/cppcache/src/CqEventImpl.cpp
+++ b/src/cppcache/src/CqEventImpl.cpp
@@ -69,7 +69,7 @@ CacheablePtr CqEventImpl::getNewValue() const {
   } else {
     // Get full object for delta
     TcrMessageRequestEventValue fullObjectMsg(m_eventId);
-    TcrMessageReply reply(true, NULL);
+    TcrMessageReply reply(true, nullptr);
     ThinClientPoolHADM* poolHADM = dynamic_cast<ThinClientPoolHADM*>(m_tcrdm);
     GfErrType err = GF_NOTCON;
     if (poolHADM) {

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/CqQueryVsdStats.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqQueryVsdStats.cpp b/src/cppcache/src/CqQueryVsdStats.cpp
index 258d6d2..c666720 100644
--- a/src/cppcache/src/CqQueryVsdStats.cpp
+++ b/src/cppcache/src/CqQueryVsdStats.cpp
@@ -36,15 +36,15 @@ using namespace apache::geode::statistics;
 
 ////////////////////////////////////////////////////////////////////////////////
 
-CqQueryStatType* CqQueryStatType::single = NULL;
+CqQueryStatType* CqQueryStatType::single = nullptr;
 SpinLock CqQueryStatType::m_singletonLock;
 SpinLock CqQueryStatType::m_statTypeLock;
 
 void CqQueryStatType::clean() {
   SpinLockGuard guard(m_singletonLock);
-  if (single != NULL) {
+  if (single != nullptr) {
     delete single;
-    single = NULL;
+    single = nullptr;
   }
 }
 
@@ -56,7 +56,7 @@ StatisticsType* CqQueryStatType::getStatType() {
 
   StatisticsType* statsType = factory->findType("CqQueryStatistics");
 
-  if (statsType == NULL) {
+  if (statsType == nullptr) {
     m_stats[0] = factory->createIntCounter(
         "inserts", "The total number of inserts this cq qurey", "entries",
         largerIsBetter);
@@ -83,7 +83,7 @@ StatisticsType* CqQueryStatType::getStatType() {
 
 CqQueryStatType* CqQueryStatType::getInstance() {
   SpinLockGuard guard(m_singletonLock);
-  if (single == NULL) {
+  if (single == nullptr) {
     single = new CqQueryStatType();
   }
   return single;
@@ -112,7 +112,7 @@ CqQueryVsdStats::CqQueryVsdStats(const char* cqqueryName) {
 
   StatisticsType* statsType = regStatType->getStatType();
 
-  GF_D_ASSERT(statsType != NULL);
+  GF_D_ASSERT(statsType != nullptr);
 
   StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
 
@@ -131,10 +131,10 @@ CqQueryVsdStats::CqQueryVsdStats(const char* cqqueryName) {
 }
 
 CqQueryVsdStats::~CqQueryVsdStats() {
-  if (m_cqQueryVsdStats != NULL) {
-    // Don't Delete, Already closed, Just set NULL
+  if (m_cqQueryVsdStats != nullptr) {
+    // Don't Delete, Already closed, Just set nullptr
     // delete m_CqQueryVsdStats;
-    m_cqQueryVsdStats = NULL;
+    m_cqQueryVsdStats = nullptr;
   }
 }
 }  // namespace client

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/CqService.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqService.cpp b/src/cppcache/src/CqService.cpp
index d634e47..d2d5e7f 100644
--- a/src/cppcache/src/CqService.cpp
+++ b/src/cppcache/src/CqService.cpp
@@ -35,7 +35,7 @@ CqService::CqService(ThinClientBaseDM* tccdm)
   LOGDEBUG("CqService Started");
 }
 CqService::~CqService() {
-  if (m_cqQueryMap != NULL) delete m_cqQueryMap;
+  if (m_cqQueryMap != nullptr) delete m_cqQueryMap;
   LOGDEBUG("CqService Destroyed");
 }
 
@@ -91,7 +91,7 @@ CqQueryPtr CqService::newCq(const std::string& cqName,
 
   // Check if the subscription is enabled on the pool
   auto pool = dynamic_cast<ThinClientPoolDM*>(m_tccdm);
-  if (pool != NULL && !pool->getSubscriptionEnabled()) {
+  if (pool != nullptr && !pool->getSubscriptionEnabled()) {
     LOGERROR(
         "Cannot create CQ because subscription is not enabled on the pool.");
     throw IllegalStateException(
@@ -117,7 +117,7 @@ CqQueryPtr CqService::newCq(const std::string& cqName,
   }
 
   UserAttributesPtr ua = nullptr;
-  if (m_tccdm != NULL && m_tccdm->isMultiUserMode()) {
+  if (m_tccdm != nullptr && m_tccdm->isMultiUserMode()) {
     ua =
         TSSUserAttributesWrapper::s_geodeTSSUserAttributes->getUserAttributes();
   }
@@ -263,8 +263,8 @@ void CqService::executeCqs(query_container_type& cqs, bool afterFailover) {
                        " Error : " + qe.getMessage())
                           .c_str());
       } catch (CqClosedException& cce) {
-        LOGFINE(("Failed to execute the CQ, CqName : " + cqName + " Error : " +
-                 cce.getMessage())
+        LOGFINE(("Failed to execute the CQ, CqName : " + cqName +
+                 " Error : " + cce.getMessage())
                     .c_str());
       }
     }
@@ -296,12 +296,12 @@ void CqService::stopCqs(query_container_type& cqs) {
         cqName = cq->getName();
         cq->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());
       }
     }
@@ -325,12 +325,12 @@ void CqService::closeCqs(query_container_type& cqs) {
           cqi->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());
       }
     }
@@ -488,16 +488,16 @@ void CqService::invokeCqConnectedListeners(const std::string& poolName,
     std::string cqName = vec.at(i)->getName();
     auto cQuery = getCq(cqName);
     auto cQueryImpl = std::dynamic_pointer_cast<CqQueryImpl>(cQuery);
-    if (cQueryImpl == NULL || !cQueryImpl->isRunning()) {
+    if (cQueryImpl == nullptr || !cQueryImpl->isRunning()) {
       LOGFINE("Unable to invoke CqStatusListener, %s, CqName: %s",
-              (cQueryImpl == NULL) ? "CQ not found" : "CQ is Not running",
+              (cQueryImpl == nullptr) ? "CQ not found" : "CQ is Not running",
               cqName.c_str());
       continue;
     }
 
     // Check cq pool to determine if the pool matches, if not continue.
     auto* poolDM = dynamic_cast<ThinClientPoolDM*>(cQueryImpl->getDM());
-    if (poolDM != NULL) {
+    if (poolDM != nullptr) {
       std::string pName = poolDM->getName();
       if (pName.compare(poolName) != 0) {
         continue;
@@ -564,11 +564,11 @@ CqOperation::CqOperationType CqService::getOperation(int eventType) {
 }
 
 /**
-  * Gets all the durable CQs registered by this client.
-  *
-  * @return List of names of registered durable CQs, empty list if no durable
+ * Gets all the durable CQs registered by this client.
+ *
+ * @return List of names of registered durable CQs, empty list if no durable
  * cqs.
-  */
+ */
 CacheableArrayListPtr CqService::getAllDurableCqsFromServer() {
   TcrMessageGetDurableCqs msg(m_tccdm);
   TcrMessageReply reply(true, m_tccdm);

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/CqServiceVsdStats.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqServiceVsdStats.cpp b/src/cppcache/src/CqServiceVsdStats.cpp
index af154d6..fd6e1d5 100644
--- a/src/cppcache/src/CqServiceVsdStats.cpp
+++ b/src/cppcache/src/CqServiceVsdStats.cpp
@@ -36,15 +36,15 @@ using namespace apache::geode::statistics;
 
 ////////////////////////////////////////////////////////////////////////////////
 
-CqServiceStatType* CqServiceStatType::single = NULL;
+CqServiceStatType* CqServiceStatType::single = nullptr;
 SpinLock CqServiceStatType::m_singletonLock;
 SpinLock CqServiceStatType::m_statTypeLock;
 
 void CqServiceStatType::clean() {
   SpinLockGuard guard(m_singletonLock);
-  if (single != NULL) {
+  if (single != nullptr) {
     delete single;
-    single = NULL;
+    single = nullptr;
   }
 }
 
@@ -56,7 +56,7 @@ StatisticsType* CqServiceStatType::getStatType() {
 
   StatisticsType* statsType = factory->findType("CqServiceStatistics");
 
-  if (statsType == NULL) {
+  if (statsType == nullptr) {
     m_stats[0] = factory->createIntCounter(
         "CqsActive", "The total number of CqsActive this cq qurey", "entries",
         largerIsBetter);
@@ -89,7 +89,7 @@ StatisticsType* CqServiceStatType::getStatType() {
 
 CqServiceStatType* CqServiceStatType::getInstance() {
   SpinLockGuard guard(m_singletonLock);
-  if (single == NULL) {
+  if (single == nullptr) {
     single = new CqServiceStatType();
   }
   return single;
@@ -119,7 +119,7 @@ CqServiceVsdStats::CqServiceVsdStats(const char* cqServiceName) {
 
   StatisticsType* statsType = regStatType->getStatType();
 
-  GF_D_ASSERT(statsType != NULL);
+  GF_D_ASSERT(statsType != nullptr);
 
   StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
 
@@ -139,10 +139,10 @@ CqServiceVsdStats::CqServiceVsdStats(const char* cqServiceName) {
 }
 
 CqServiceVsdStats::~CqServiceVsdStats() {
-  if (m_cqServiceVsdStats != NULL) {
-    // Don't Delete, Already closed, Just set NULL
+  if (m_cqServiceVsdStats != nullptr) {
+    // Don't Delete, Already closed, Just set nullptr
     // delete m_CqServiceVsdStats;
-    m_cqServiceVsdStats = NULL;
+    m_cqServiceVsdStats = nullptr;
   }
 }
 }  // namespace client

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/DataOutput.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/DataOutput.cpp b/src/cppcache/src/DataOutput.cpp
index a9feab0..f718d12 100644
--- a/src/cppcache/src/DataOutput.cpp
+++ b/src/cppcache/src/DataOutput.cpp
@@ -39,7 +39,7 @@ class BufferDesc {
 
   BufferDesc(uint8_t* buf, uint32_t size) : m_buf(buf), m_size(size) {}
 
-  BufferDesc() : m_buf(NULL), m_size(0) {}
+  BufferDesc() : m_buf(nullptr), m_size(0) {}
 
   ~BufferDesc() {}
 
@@ -105,7 +105,8 @@ TSSDataOutput::~TSSDataOutput() {
 
 ACE_TSS<TSSDataOutput> TSSDataOutput::s_tssDataOutput;
 
-DataOutput::DataOutput() : m_poolName(NULL), m_size(0), m_haveBigBuffer(false) {
+DataOutput::DataOutput()
+    : m_poolName(nullptr), m_size(0), m_haveBigBuffer(false) {
   m_buf = m_bytes = DataOutput::checkoutBuffer(&m_size);
 }
 

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/DiffieHellman.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/DiffieHellman.cpp b/src/cppcache/src/DiffieHellman.cpp
index a5b14d4..6f07d71 100644
--- a/src/cppcache/src/DiffieHellman.cpp
+++ b/src/cppcache/src/DiffieHellman.cpp
@@ -29,7 +29,7 @@ bool DiffieHellman::m_inited = false;
 ACE_Recursive_Thread_Mutex DiffieHellman::s_mutex;
 
 #define INIT_DH_FUNC_PTR(OrigName) \
-  DiffieHellman::OrigName##_Type DiffieHellman::OrigName##_Ptr = NULL;
+  DiffieHellman::OrigName##_Type DiffieHellman::OrigName##_Ptr = nullptr;
 
 INIT_DH_FUNC_PTR(gf_initDhKeys)
 INIT_DH_FUNC_PTR(gf_clearDhKeys)
@@ -42,7 +42,7 @@ INIT_DH_FUNC_PTR(gf_verifyDH)
 
 void* DiffieHellman::getOpenSSLFuncPtr(const char* function_name) {
   void* func = m_dll.symbol(function_name);
-  if (func == NULL) {
+  if (func == nullptr) {
     char msg[1000];
     ACE_OS::snprintf(msg, 1000, "cannot find function %s in library %s",
                      function_name, "cryptoImpl");
@@ -83,7 +83,7 @@ void DiffieHellman::initOpenSSLFuncPtrs() {
 
 void DiffieHellman::initDhKeys(const PropertiesPtr& props) {
   ACE_Guard<ACE_Recursive_Thread_Mutex> guard(DiffieHellman::s_mutex);
-  m_dhCtx = NULL;
+  m_dhCtx = nullptr;
 
   CacheableStringPtr dhAlgo = props->find(SecurityClientDhAlgo);
   CacheableStringPtr ksPath = props->find(SecurityClientKsPath);
@@ -95,7 +95,7 @@ void DiffieHellman::initDhKeys(const PropertiesPtr& props) {
   }
 
   int error = gf_initDhKeys_Ptr(&m_dhCtx, dhAlgo->asChar(),
-                                ksPath != nullptr ? ksPath->asChar() : NULL);
+                                ksPath != nullptr ? ksPath->asChar() : nullptr);
 
   if (error == DH_ERR_UNSUPPORTED_ALGO) {  // Unsupported Algorithm
     char msg[64] = {'\0'};
@@ -107,7 +107,7 @@ void DiffieHellman::initDhKeys(const PropertiesPtr& props) {
     ACE_OS::snprintf(msg, 64, "Illegal key size for algorithm %s.",
                      dhAlgo->asChar());
     throw IllegalArgumentException(msg);
-  } else if (m_dhCtx == NULL) {
+  } else if (m_dhCtx == nullptr) {
     throw IllegalStateException(
         "Could not initialize the Diffie-Hellman helper");
   }
@@ -115,18 +115,18 @@ void DiffieHellman::initDhKeys(const PropertiesPtr& props) {
 
 void DiffieHellman::clearDhKeys(void) {
   // Sanity check for accidental calls
-  if (gf_clearDhKeys_Ptr == NULL) {
+  if (gf_clearDhKeys_Ptr == nullptr) {
     return;
   }
 
   gf_clearDhKeys_Ptr(m_dhCtx);
 
-  m_dhCtx = NULL;
+  m_dhCtx = nullptr;
 
   /*
   //reset all pointers
 #define CLEAR_DH_FUNC_PTR(OrigName) \
-  OrigName##_Ptr = NULL;
+  OrigName##_Ptr = nullptr;
 
   CLEAR_DH_FUNC_PTR(gf_initDhKeys)
   CLEAR_DH_FUNC_PTR(gf_clearDhKeys)

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/DiskPolicyType.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/DiskPolicyType.cpp b/src/cppcache/src/DiskPolicyType.cpp
index ab8d650..a71ee1f 100644
--- a/src/cppcache/src/DiskPolicyType.cpp
+++ b/src/cppcache/src/DiskPolicyType.cpp
@@ -20,7 +20,7 @@
 
 using namespace apache::geode::client;
 
-const char* DiskPolicyType::names[] = {"none", "overflows", "persist", NULL};
+const char* DiskPolicyType::names[] = {"none", "overflows", "persist", nullptr};
 
 const char* DiskPolicyType::fromOrdinal(const uint8_t ordinal) {
   if (ordinal > DiskPolicyType::PERSIST) return names[DiskPolicyType::NONE];
@@ -29,7 +29,7 @@ const char* DiskPolicyType::fromOrdinal(const uint8_t ordinal) {
 
 DiskPolicyType::PolicyType DiskPolicyType::fromName(const char* name) {
   uint32_t i = 0;
-  while ((names[i] != NULL) ||
+  while ((names[i] != nullptr) ||
          (i <= static_cast<uint32_t>(DiskPolicyType::PERSIST))) {
     if (name && names[i] && ACE_OS::strcasecmp(names[i], name) == 0) {
       return static_cast<DiskPolicyType::PolicyType>(i);

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/DistributedSystem.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/DistributedSystem.cpp b/src/cppcache/src/DistributedSystem.cpp
index ac7038a..04a5dd1 100644
--- a/src/cppcache/src/DistributedSystem.cpp
+++ b/src/cppcache/src/DistributedSystem.cpp
@@ -44,17 +44,17 @@
 using namespace apache::geode::client;
 using namespace apache::geode::statistics;
 
-DistributedSystemPtr* DistributedSystem::m_instance_ptr = NULL;
+DistributedSystemPtr* DistributedSystem::m_instance_ptr = nullptr;
 bool DistributedSystem::m_connected = false;
-DistributedSystemImpl* DistributedSystem::m_impl = NULL;
+DistributedSystemImpl* DistributedSystem::m_impl = nullptr;
 
 ACE_Recursive_Thread_Mutex* g_disconnectLock = new ACE_Recursive_Thread_Mutex();
 
 namespace {
 
-StatisticsManager* g_statMngr = NULL;
+StatisticsManager* g_statMngr = nullptr;
 
-SystemProperties* g_sysProps = NULL;
+SystemProperties* g_sysProps = nullptr;
 }  // namespace
 
 namespace apache {
@@ -62,18 +62,18 @@ namespace geode {
 namespace client {
 void setLFH() {
 #ifdef _WIN32
-  static HINSTANCE kernelMod = NULL;
-  if (kernelMod == NULL) {
+  static HINSTANCE kernelMod = nullptr;
+  if (kernelMod == nullptr) {
     kernelMod = GetModuleHandle("kernel32");
-    if (kernelMod != NULL) {
+    if (kernelMod != nullptr) {
       typedef BOOL(WINAPI * PHSI)(
           HANDLE HeapHandle, HEAP_INFORMATION_CLASS HeapInformationClass,
           PVOID HeapInformation, SIZE_T HeapInformationLength);
       typedef HANDLE(WINAPI * PGPH)();
-      PHSI pHSI = NULL;
-      PGPH pGPH = NULL;
+      PHSI pHSI = nullptr;
+      PGPH pGPH = nullptr;
       if ((pHSI = (PHSI)GetProcAddress(kernelMod, "HeapSetInformation")) !=
-          NULL) {
+          nullptr) {
         // The LFH API is available
         /* Only set LFH for process heap; causes problems in C++ framework if
         set for all heaps
@@ -92,7 +92,7 @@ void setLFH() {
         HANDLE hProcessHeapHandle;
         ULONG heapFragValue = 2;
         if ((pGPH = (PGPH)GetProcAddress(kernelMod, "GetProcessHeap")) !=
-            NULL) {
+            nullptr) {
           hProcessHeapHandle = pGPH();
           LOGCONFIG(
               "Setting Microsoft Windows' low-fragmentation heap for use as "
@@ -109,9 +109,9 @@ void setLFH() {
 }  // namespace geode
 }  // namespace apache
 
-DistributedSystem::DistributedSystem(const char* name) : m_name(NULL) {
+DistributedSystem::DistributedSystem(const char* name) : m_name(nullptr) {
   LOGDEBUG("DistributedSystem::DistributedSystem");
-  if (name != NULL) {
+  if (name != nullptr) {
     size_t len = strlen(name) + 1;
     m_name = new char[len];
     ACE_OS::strncpy(m_name, name, len);
@@ -133,20 +133,20 @@ DistributedSystemPtr DistributedSystem::connect(
   }
 
   // make sure statics are initialized.
-  if (m_instance_ptr == NULL) {
+  if (m_instance_ptr == nullptr) {
     m_instance_ptr = new DistributedSystemPtr();
   }
-  if (g_sysProps == NULL) {
-    g_sysProps = new SystemProperties(configPtr, NULL);
+  if (g_sysProps == nullptr) {
+    g_sysProps = new SystemProperties(configPtr, nullptr);
   }
   Exception::setStackTraces(g_sysProps->debugStackTraceEnabled());
 
-  if (name == NULL) {
+  if (name == nullptr) {
     delete g_sysProps;
-    g_sysProps = NULL;
+    g_sysProps = nullptr;
     throw IllegalArgumentException(
         "DistributedSystem::connect: "
-        "name cannot be NULL");
+        "name cannot be nullptr");
   }
   if (name[0] == '\0') {
     name = "NativeDS";
@@ -155,7 +155,7 @@ DistributedSystemPtr DistributedSystem::connect(
   // Fix for Ticket#866 on NC OR SR#13306117704
   // Set client name via native client API
   const char* propName = g_sysProps->name();
-  if (propName != NULL && strlen(propName) > 0) {
+  if (propName != nullptr && strlen(propName) > 0) {
     name = propName;
   }
 
@@ -169,7 +169,7 @@ DistributedSystemPtr DistributedSystem::connect(
   }
 
   const char* logFilename = g_sysProps->logFilename();
-  if (logFilename != NULL) {
+  if (logFilename != nullptr) {
     try {
       Log::close();
       Log::init(g_sysProps->logLevel(), logFilename,
@@ -180,7 +180,7 @@ DistributedSystemPtr DistributedSystem::connect(
       TcrMessage::cleanup();
       CppCacheLibrary::closeLib();
       delete g_sysProps;
-      g_sysProps = NULL;
+      g_sysProps = nullptr;
       *m_instance_ptr = nullptr;
       // delete g_disconnectLock;
       throw;
@@ -221,7 +221,7 @@ DistributedSystemPtr DistributedSystem::connect(
 #ifndef _WIN32
   const char* ld_libpath = ACE_OS::getenv("LD_LIBRARY_PATH");
   LOGCONFIG("Current library path: %s",
-            ld_libpath == NULL ? "NULL" : ld_libpath);
+            ld_libpath == nullptr ? "nullptr" : ld_libpath);
 #else
   if (Utils::s_setNewAndDelete) {
     LOGCONFIG("Operators new and delete have been set.");
@@ -242,7 +242,7 @@ DistributedSystemPtr DistributedSystem::connect(
         g_sysProps->statsFileSizeLimit(), g_sysProps->statsDiskSpaceLimit());
   } catch (const NullPointerException&) {
     // close all open handles, delete whatever was newed.
-    g_statMngr = NULL;
+    g_statMngr = nullptr;
     //:Merge issue
     /*if (strlen(g_sysProps->securityClientDhAlgo())>0) {
       DiffieHellman::clearDhKeys();
@@ -251,12 +251,12 @@ DistributedSystemPtr DistributedSystem::connect(
     TcrMessage::cleanup();
     CppCacheLibrary::closeLib();
     delete g_sysProps;
-    g_sysProps = NULL;
+    g_sysProps = nullptr;
     *m_instance_ptr = nullptr;
     // delete g_disconnectLock;
     throw;
   }
-  GF_D_ASSERT(g_statMngr != NULL);
+  GF_D_ASSERT(g_statMngr != nullptr);
 
   CacheImpl::expiryTaskManager = new ExpiryTaskManager();
   CacheImpl::expiryTaskManager->begin();
@@ -315,14 +315,14 @@ void DistributedSystem::disconnect() {
     LOGWARN("Exception while closing: %s: %s", e.getName(), e.getMessage());
   }
 
-  if (CacheImpl::expiryTaskManager != NULL) {
+  if (CacheImpl::expiryTaskManager != nullptr) {
     CacheImpl::expiryTaskManager->stopExpiryTaskManager();
   }
 
   if (m_impl) {
     m_impl->disconnect();
     delete m_impl;
-    m_impl = NULL;
+    m_impl = nullptr;
   }
 
   LOGFINEST("Deleted DistributedSystemImpl");
@@ -338,13 +338,13 @@ void DistributedSystem::disconnect() {
 
   GF_D_ASSERT(!!g_sysProps);
   delete g_sysProps;
-  g_sysProps = NULL;
+  g_sysProps = nullptr;
 
   LOGFINEST("Deleted SystemProperties");
 
-  if (CacheImpl::expiryTaskManager != NULL) {
+  if (CacheImpl::expiryTaskManager != nullptr) {
     delete CacheImpl::expiryTaskManager;
-    CacheImpl::expiryTaskManager = NULL;
+    CacheImpl::expiryTaskManager = nullptr;
   }
 
   LOGFINEST("Deleted ExpiryTaskManager");
@@ -355,7 +355,7 @@ void DistributedSystem::disconnect() {
 
   GF_D_ASSERT(!!g_statMngr);
   g_statMngr->clean();
-  g_statMngr = NULL;
+  g_statMngr = nullptr;
 
   LOGFINEST("Cleaned StatisticsManager");
 
@@ -392,7 +392,7 @@ bool DistributedSystem::isConnected() {
 
 DistributedSystemPtr DistributedSystem::getInstance() {
   CppCacheLibrary::initLib();
-  if (m_instance_ptr == NULL) {
+  if (m_instance_ptr == nullptr) {
     return nullptr;
   }
   return *m_instance_ptr;

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/DistributedSystemImpl.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/DistributedSystemImpl.cpp b/src/cppcache/src/DistributedSystemImpl.cpp
index c59b771..6b5b08d 100644
--- a/src/cppcache/src/DistributedSystemImpl.cpp
+++ b/src/cppcache/src/DistributedSystemImpl.cpp
@@ -69,7 +69,7 @@ int DistributedSystemImpl::currentInstances() {
   ACE_Guard<ACE_Recursive_Thread_Mutex> disconnectGuard(*g_disconnectLock);
 
   if (DistributedSystem::getInstance() != nullptr &&
-      DistributedSystem::getInstance()->getSystemProperties() != NULL &&
+      DistributedSystem::getInstance()->getSystemProperties() != nullptr &&
       !DistributedSystem::getInstance()
            ->getSystemProperties()
            ->isAppDomainEnabled()) {
@@ -82,7 +82,7 @@ int DistributedSystemImpl::currentInstances() {
 void DistributedSystemImpl::connectInstance() {
   ACE_Guard<ACE_Recursive_Thread_Mutex> disconnectGuard(*g_disconnectLock);
 
-  if (DistributedSystem::getInstance()->getSystemProperties() != NULL &&
+  if (DistributedSystem::getInstance()->getSystemProperties() != nullptr &&
       DistributedSystem::getInstance()
           ->getSystemProperties()
           ->isAppDomainEnabled()) {
@@ -93,7 +93,7 @@ void DistributedSystemImpl::connectInstance() {
 void DistributedSystemImpl::disconnectInstance() {
   ACE_Guard<ACE_Recursive_Thread_Mutex> disconnectGuard(*g_disconnectLock);
 
-  if (DistributedSystem::getInstance()->getSystemProperties() != NULL &&
+  if (DistributedSystem::getInstance()->getSystemProperties() != nullptr &&
       DistributedSystem::getInstance()
           ->getSystemProperties()
           ->isAppDomainEnabled()) {

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/EntriesMap.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/EntriesMap.hpp b/src/cppcache/src/EntriesMap.hpp
index 08a08ca..a6cea61 100644
--- a/src/cppcache/src/EntriesMap.hpp
+++ b/src/cppcache/src/EntriesMap.hpp
@@ -59,7 +59,7 @@ class CPPCACHE_EXPORT EntriesMap {
                         CacheablePtr& oldValue, int updateCount,
                         int destroyTracker, VersionTagPtr versionTag,
                         bool& isUpdate = EntriesMap::boolVal,
-                        DataInput* delta = NULL) = 0;
+                        DataInput* delta = nullptr) = 0;
   virtual GfErrType invalidate(const CacheableKeyPtr& key, MapEntryImplPtr& me,
                                CacheablePtr& oldValue,
                                VersionTagPtr versionTag) = 0;
@@ -75,7 +75,7 @@ class CPPCACHE_EXPORT EntriesMap {
                    MapEntryImplPtr& me) = 0;
 
   /**
-   * @brief get MapEntry for key; returns NULL if absent
+   * @brief get MapEntry for key; returns nullptr if absent
    */
   virtual void getEntry(const CacheableKeyPtr& key, MapEntryImplPtr& result,
                         CacheablePtr& value) const = 0;
@@ -84,7 +84,7 @@ class CPPCACHE_EXPORT EntriesMap {
 
   /**
    * @brief remove the entry for key from the map;
-   *   returns false and NULL MapEntry if absent
+   *   returns false and nullptr MapEntry if absent
    */
   virtual GfErrType remove(const CacheableKeyPtr& key, CacheablePtr& result,
                            MapEntryImplPtr& me, int updateCount,

http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/src/EntriesMapFactory.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/EntriesMapFactory.cpp b/src/cppcache/src/EntriesMapFactory.cpp
index 343007d..99213dd 100644
--- a/src/cppcache/src/EntriesMapFactory.cpp
+++ b/src/cppcache/src/EntriesMapFactory.cpp
@@ -34,7 +34,7 @@ using namespace apache::geode::client;
  */
 EntriesMap* EntriesMapFactory::createMap(RegionInternal* region,
                                          const RegionAttributesPtr& attrs) {
-  EntriesMap* result = NULL;
+  EntriesMap* result = nullptr;
   uint32_t initialCapacity = attrs->getInitialCapacity();
   uint8_t concurrency = attrs->getConcurrencyLevel();
   /** @TODO will need a statistics entry factory... */
@@ -56,7 +56,7 @@ EntriesMap* EntriesMapFactory::createMap(RegionInternal* region,
       lruEvictionAction = LRUAction::LOCAL_DESTROY;
       if (prop && prop->heapLRULimitEnabled()) heapLRUEnabled = true;
     } else {
-      return NULL;
+      return nullptr;
     }
     if (ttl != 0 || idle != 0) {
       EntryFactory* entryFactory = LRUExpEntryFactory::singleton;


Mime
View raw message