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_r287296622
##########
File path: be/src/runtime/client_cache.cpp
##########
@@ -135,15 +135,26 @@ 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()));
- DCHECK(j != _client_cache.end());
- j->second.push_back(*client_key);
+ if (_max_cache_size >= 0 && get_cache_size() >= _max_cache_size) {
+ // cache is full, close it and remove it from _client_map
+ ClientMap::iterator client_map_entry = _client_map.find(*client_key);
+ DCHECK(client_map_entry != _client_map.end());
+ client_map_entry->second->close();
+ _client_map.erase(*client_key);
+
+ if (_metrics_enabled) {
+ _opened_clients->increment(-1);
+ }
Review comment:
you call this function two times.
----------------------------------------------------------------
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]