imay commented on a change in pull request #1202: Add max cache size to 
ClientCache in BE
URL: https://github.com/apache/incubator-doris/pull/1202#discussion_r287359123
 
 

 ##########
 File path: be/src/runtime/client_cache.cpp
 ##########
 @@ -135,15 +135,23 @@ Status ClientCacheHelper::create_client(
 void ClientCacheHelper::release_client(void** client_key) {
     DCHECK(*client_key != NULL) << "Trying to release NULL client";
     boost::lock_guard<boost::mutex> lock(_lock);
-    ClientMap::iterator i = _client_map.find(*client_key);
-    DCHECK(i != _client_map.end());
-    ThriftClientImpl* info = i->second;
-    //VLOG_RPC << "releasing client for "
-    //         << info->ipaddress() << ":" << info->port();
-    ClientCacheMap::iterator j =
-        _client_cache.find(make_network_address(info->ipaddress(), 
info->port()));
+    ClientMap::iterator client_map_entry = _client_map.find(*client_key);
+    DCHECK(client_map_entry != _client_map.end());
+    ThriftClientImpl* info = client_map_entry->second;
+    ClientCacheMap::iterator j = 
_client_cache.find(make_network_address(info->ipaddress(), info->port()));
     DCHECK(j != _client_cache.end());
-    j->second.push_back(*client_key);
+    
+    if (_max_cache_size_per_host >=0 && j->second.size() >= 
_max_cache_size_per_host) {
+        // cache of this host is full, close this client connection and remove 
if from _client_map
+        client_map_entry->second->close();
 
 Review comment:
   ```suggestion
           info->close();
           delete info;
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to