zyearn commented on a change in pull request #592: lb configurable &&
consistency hash lb refactor
URL: https://github.com/apache/incubator-brpc/pull/592#discussion_r273454920
##########
File path: src/brpc/policy/consistent_hashing_load_balancer.h
##########
@@ -56,14 +54,28 @@ class ConsistentHashingLoadBalancer : public LoadBalancer {
return hash < code;
}
};
+ explicit ConsistentHashingLoadBalancer(ConsistentHashingLoadBalancerType
type);
+ bool AddServer(const ServerId& server);
+ bool RemoveServer(const ServerId& server);
+ size_t AddServersInBatch(const std::vector<ServerId> &servers);
+ size_t RemoveServersInBatch(const std::vector<ServerId> &servers);
+ LoadBalancer *New(const butil::StringPiece& params) const;
+ void Destroy();
+ int SelectServer(const SelectIn &in, SelectOut *out);
+ void Describe(std::ostream &os, const DescribeOptions& options);
+
+private:
+ bool SetParameters(const butil::StringPiece& params);
+ void GetLoads(std::map<butil::EndPoint, double> *load_map);
static size_t AddBatch(std::vector<Node> &bg, const std::vector<Node> &fg,
const std::vector<Node> &servers, bool *executed);
static size_t RemoveBatch(std::vector<Node> &bg, const std::vector<Node>
&fg,
const std::vector<ServerId> &servers, bool
*executed);
static size_t Remove(std::vector<Node> &bg, const std::vector<Node> &fg,
const ServerId& server, bool *executed);
- HashFunc _hash;
+ const ReplicaPolicy* _replicas_policy;
size_t _num_replicas;
+ ConsistentHashingLoadBalancerType _type;
Review comment:
_replicas_policy和_type是一一对应的,也就是说没必要存_replicas_policy了,在初始化时候,保证_type对应的数组项存在,之后直接用_type读数组就好了吧
----------------------------------------------------------------
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]