Adar Dembo has posted comments on this change. ( http://gerrit.cloudera.org:8080/12619 )
Change subject: [master] cache locations assigned to clients ...................................................................... Patch Set 1: (2 comments) http://gerrit.cloudera.org:8080/#/c/12619/1/src/kudu/master/location_cache.h File src/kudu/master/location_cache.h: http://gerrit.cloudera.org:8080/#/c/12619/1/src/kudu/master/location_cache.h@32 PS1, Line 32: We don't care much : // of the semantic behind the key, it's just simple key-value store. I think a clearer way to express this is to say that the key is treated as an opaque sequence of bytes by the location cache. http://gerrit.cloudera.org:8080/#/c/12619/1/src/kudu/master/master_service.cc File src/kudu/master/master_service.cc: http://gerrit.cloudera.org:8080/#/c/12619/1/src/kudu/master/master_service.cc@571 PS1, Line 571: // Assign a location to the client if needed. : if (!FLAGS_location_mapping_cmd.empty() && : PREDICT_TRUE(FLAGS_master_client_location_assignment_enabled)) { : const auto& location_key = rpc->remote_address().host(); : auto* location_cache = server_->location_cache(); : string location; : if (location_cache->Get(location_key, &location)) { : resp->set_client_location(location); : } else { : Status s = GetLocationFromLocationMappingCmd(FLAGS_location_mapping_cmd, : rpc->remote_address().host(), : &location); : if (s.ok()) { : location_cache->PutIfNotPresent(location_key, location); : resp->set_client_location(location); : } else { : LOG(WARNING) << Substitute("unable to assign location to client $0@$1: $2", : rpc->remote_user().ToString(), : rpc->remote_address().ToString(), : s.ToString()); : } : } : } Consider moving part (or all) of this into the LocationCache, if only for better separation of concerns. Put another way, a cleaner LocationCache API might be just this one function: // Gets the cached location for key 'key'. // // If no cached location is found, will run the location mapping command // provided at cache initialization time to determine the location, caching // the result for the lifetime of the cache. // // Returns an error if there was an issue running the command. Status GetLocation(const std::string& key, std::string* location); -- To view, visit http://gerrit.cloudera.org:8080/12619 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: kudu Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I12c8952c43a8ad352acd46c8006824b2ad9d1204 Gerrit-Change-Number: 12619 Gerrit-PatchSet: 1 Gerrit-Owner: Alexey Serbin <[email protected]> Gerrit-Reviewer: Adar Dembo <[email protected]> Gerrit-Reviewer: Alexey Serbin <[email protected]> Gerrit-Reviewer: Andrew Wong <[email protected]> Gerrit-Reviewer: Kudu Jenkins (120) Gerrit-Reviewer: Will Berkeley <[email protected]> Gerrit-Comment-Date: Wed, 27 Feb 2019 05:25:20 +0000 Gerrit-HasComments: Yes
