[GitHub] [incubator-brpc] yanglimingcn commented on issue #692: Add Mysql Protocol, only support text protocol now, not support trans…

2019-04-04 Thread GitBox
yanglimingcn commented on issue #692: Add Mysql Protocol, only support text 
protocol now, not support trans…
URL: https://github.com/apache/incubator-brpc/pull/692#issuecomment-480142246
 
 
   
多次的交互如果对用户屏蔽,就需要像权限校验那样,在parseResponse的地方做多次的处理,我觉得这样可行。这样用户操作应该挺简洁的。而且single估计也可以了呢。
   但是prepared 
statement这种有点区别,prepare目的是想让用户执行一次prepare,生成一个stmt,然后后边用户一直用这个stmt操作,这个stmt对应到数据库里面一个已经解析过的语句,这样能避免数据库每次都解析这个语句,所以这种肯定得要多次交互使用的。但是prepare可以做到不关联某个连接,如果应用stmt的某次操作底层连接变了,我可以底层再发一次prepare。stmt要记录一下它用过的连接,如果后边执行操作选择的连接以前用过就不用发prepare,如果没用过就发prepare。所以这块儿的修改是得在发送命令前有一个位置对选择的连接做比较。
   


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] cdjingit commented on a change in pull request #592: lb configurable && consistency hash lb refactor

2019-04-04 Thread GitBox
cdjingit commented on a change in pull request #592: lb configurable && 
consistency hash lb refactor
URL: https://github.com/apache/incubator-brpc/pull/592#discussion_r272431987
 
 

 ##
 File path: src/brpc/policy/consistent_hashing_load_balancer.cpp
 ##
 @@ -29,16 +31,111 @@ namespace policy {
 DEFINE_int32(chash_num_replicas, 100, 
  "default number of replicas per server in chash");
 
-ConsistentHashingLoadBalancer::ConsistentHashingLoadBalancer(HashFunc hash) 
-: _hash(hash)
-, _num_replicas(FLAGS_chash_num_replicas) {
+class ReplicaPolicy {
+public:
+ReplicaPolicy() : _hash_func(nullptr) {}
+ReplicaPolicy(HashFunc hash) : _hash_func(hash) {}
+virtual ~ReplicaPolicy() = default;
+
+virtual bool Build(ServerId server, 
+   size_t num_replicas,
+   std::vector* 
replicas) const = 0;
+
+protected:
+HashFunc _hash_func;
+};
+
+class DefaultReplicaPolicy : public ReplicaPolicy {
+public:
+DefaultReplicaPolicy(HashFunc hash) : ReplicaPolicy(hash) {}
+
+virtual bool Build(ServerId server,
+   size_t num_replicas,
+   std::vector* 
replicas) const;
+};
+
+bool DefaultReplicaPolicy::Build(ServerId server,
+ size_t num_replicas,
+ 
std::vector* replicas) const {
+SocketUniquePtr ptr;
+if (Socket::AddressFailedAsWell(server.id, ) == -1) {
+return false;
+}
+replicas->clear();
+for (size_t i = 0; i < num_replicas; ++i) {
+char host[32];
+int len = snprintf(host, sizeof(host), "%s-%lu",
+   endpoint2str(ptr->remote_side()).c_str(), i);
+ConsistentHashingLoadBalancer::Node node;
+node.hash = _hash_func(host, len);
+node.server_sock = server;
+node.server_addr = ptr->remote_side();
+replicas->push_back(node);
+}
+return true;
+}
+
+class KetamaReplicaPolicy : public ReplicaPolicy {
+public:
+virtual bool Build(ServerId server,
+   size_t num_replicas,
+   std::vector* 
replicas) const;
+};
+
+bool KetamaReplicaPolicy::Build(ServerId server,
+size_t num_replicas,
+
std::vector* replicas) const {
+SocketUniquePtr ptr;
+if (Socket::AddressFailedAsWell(server.id, ) == -1) {
+return false;
+}
+replicas->clear();
+const size_t points_per_hash = 4;
+CHECK(num_replicas % points_per_hash == 0)
+<< "Ketam hash replicas number(" << num_replicas << ") should be n*4";
+for (size_t i = 0; i < num_replicas / points_per_hash; ++i) {
+char host[32];
+int len = snprintf(host, sizeof(host), "%s-%lu",
+   endpoint2str(ptr->remote_side()).c_str(), i);
+unsigned char digest[16];
+MD5HashSignature(host, len, digest);
+for (size_t j = 0; j < points_per_hash; ++j) {
+ConsistentHashingLoadBalancer::Node node;
+node.server_sock = server;
+node.server_addr = ptr->remote_side();
+node.hash = ((uint32_t) (digest[3 + j * 4] & 0xFF) << 24)
+  | ((uint32_t) (digest[2 + j * 4] & 0xFF) << 16)
+  | ((uint32_t) (digest[1 + j * 4] & 0xFF) << 8)
+  | (digest[0 + j * 4] & 0xFF);
+replicas->push_back(node);
+}
+}
+return true;
 }
 
-ConsistentHashingLoadBalancer::ConsistentHashingLoadBalancer(
-HashFunc hash,
-size_t num_replicas) 
-: _hash(hash)
-, _num_replicas(num_replicas) {
+namespace {
+
+const std::map g_replica_policy_map = {
 
 Review comment:
   once为什么还需要数组呢?


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] cdjingit commented on a change in pull request #592: lb configurable && consistency hash lb refactor

2019-04-04 Thread GitBox
cdjingit commented on a change in pull request #592: lb configurable && 
consistency hash lb refactor
URL: https://github.com/apache/incubator-brpc/pull/592#discussion_r272430577
 
 

 ##
 File path: src/brpc/load_balancer.h
 ##
 @@ -102,8 +104,21 @@ class LoadBalancer : public NonConstDescribable, public 
Destroyable {
 // Caller is responsible for Destroy() the instance after usage.
 virtual LoadBalancer* New() const = 0;
 
+// Config user passed parameters to lb after constrction which 
+// make lb function more flexible.
+virtual bool SetParameters(const butil::StringPiece& params) { return 
true; }
 
 Review comment:
   参数解析是在每个类自己决定的,所以直接传了字符串


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] cdjingit commented on a change in pull request #592: lb configurable && consistency hash lb refactor

2019-04-04 Thread GitBox
cdjingit commented on a change in pull request #592: lb configurable && 
consistency hash lb refactor
URL: https://github.com/apache/incubator-brpc/pull/592#discussion_r272430603
 
 

 ##
 File path: src/brpc/load_balancer.h
 ##
 @@ -102,8 +104,21 @@ class LoadBalancer : public NonConstDescribable, public 
Destroyable {
 // Caller is responsible for Destroy() the instance after usage.
 virtual LoadBalancer* New() const = 0;
 
+// Config user passed parameters to lb after constrction which 
+// make lb function more flexible.
+virtual bool SetParameters(const butil::StringPiece& params) { return 
true; }
+
 protected:
 virtual ~LoadBalancer() { }
+static bool SplitParameters(const butil::StringPiece& params, 
 
 Review comment:
   好的


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] jamesge edited a comment on issue #692: Add Mysql Protocol, only support text protocol now, not support trans…

2019-04-04 Thread GitBox
jamesge edited a comment on issue #692: Add Mysql Protocol, only support text 
protocol now, not support trans…
URL: https://github.com/apache/incubator-brpc/pull/692#issuecomment-480129822
 
 
   > @jamesge 最近在考虑prepared statement 和 
transaction的实现问题。这两个功能的特点是,需要在一个连接上面进行多次回话,在多次回话过程中连接需要独占。
   > 调用接口的伪代码:
   > // begin transaction
   > brpc::MysqlRequest txReq;
   > brpc::MysqlResponse txRsp;
   > brpc::Controller txCntl;
   > txCntl.txState = BEGIN_TX;
   > txReq.BeginTx();
   > channel.CallMethod(NULL, , , , NULL);
   > 
   > const brpc::MysqlReply::Tx& tx = txRsp.reply(0).tx();
   > 
   > //txRsp keep a connection
   > // begin crud operation
   > brpc::MysqlRequest crudReq1;
   > brpc::MysqlResponse curdRsp1;
   > brpc::Controller crudCntl1;
   > crudCntl1.tx = tx;
   > txReq1.Query("sql statement1");
   > channel.CallMethod(NULL, , , , NULL);
   > 
   > brpc::MysqlRequest crudReq2;
   > brpc::MysqlResponse curdRsp2;
   > brpc::Controller crudCntl2;
   > crudCntl2.tx = tx;
   > txReq1.Query("sql statement2");
   > channel.CallMethod(NULL, , , , NULL);
   > // end crud operation
   > 
   > // commit transaction
   > // after that release the connect to pool
   > brpc::MysqlRequest commitReq;
   > brpc::MysqlResponse commitRsp;
   > brpc::Controller commitCntl;
   > commitCntl.tx = tx;
   > commitCntl.txState = END_TX;
   > commitReq.Commit();
   > channel.CallMethod(NULL, , , , NULL);
   > 
   > 需要对代码修改的地方有
   > 
1、在开始事务的controller里面设置一个标识,这样在它的OnComplete调用的时候,不释放连接到pool里面,返回的接口里面包含事务的信息。
   > 
2、后续的crud的controller里面设置事务的信息,在IssueRPC的时候,lb和选择连接的地方,可以根据是否设置事务做分支处理,主要是在选择连接的地方。
   > 3、在结束事务的controller里面设置一个标识,这样它在OnComplete的时候会释放连接。
   > 
   > prepared statement和这个类似。
   > 
   > 事务和prepared 
statement的处理流程在所有关系型数据库都类似,也可以抽象出来一些公共的内容。我参考了golang的database/sql库
   > 
   > 以上请戈君评审一下,看有什么建议。
   
   
实现上需要多次交互,并不意味着用户一定要感知到多次交互,本质上一个tx对用户也是一件事(要么成功要么失败),一个tx里的所有请求能否让用户一次性输入?即用户调用request中的BeginTx/Query/EndTx等接口可以编排一次tx,然后再CallMethod。另外这部分功能就别添加在这个pr中了,可以另启新的。


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] jamesge commented on issue #692: Add Mysql Protocol, only support text protocol now, not support trans…

2019-04-04 Thread GitBox
jamesge commented on issue #692: Add Mysql Protocol, only support text protocol 
now, not support trans…
URL: https://github.com/apache/incubator-brpc/pull/692#issuecomment-480129822
 
 
   > @jamesge 最近在考虑prepared statement 和 
transaction的实现问题。这两个功能的特点是,需要在一个连接上面进行多次回话,在多次回话过程中连接需要独占。
   > 调用接口的伪代码:
   > // begin transaction
   > brpc::MysqlRequest txReq;
   > brpc::MysqlResponse txRsp;
   > brpc::Controller txCntl;
   > txCntl.txState = BEGIN_TX;
   > txReq.BeginTx();
   > channel.CallMethod(NULL, , , , NULL);
   > 
   > const brpc::MysqlReply::Tx& tx = txRsp.reply(0).tx();
   > 
   > //txRsp keep a connection
   > // begin crud operation
   > brpc::MysqlRequest crudReq1;
   > brpc::MysqlResponse curdRsp1;
   > brpc::Controller crudCntl1;
   > crudCntl1.tx = tx;
   > txReq1.Query("sql statement1");
   > channel.CallMethod(NULL, , , , NULL);
   > 
   > brpc::MysqlRequest crudReq2;
   > brpc::MysqlResponse curdRsp2;
   > brpc::Controller crudCntl2;
   > crudCntl2.tx = tx;
   > txReq1.Query("sql statement2");
   > channel.CallMethod(NULL, , , , NULL);
   > // end crud operation
   > 
   > // commit transaction
   > // after that release the connect to pool
   > brpc::MysqlRequest commitReq;
   > brpc::MysqlResponse commitRsp;
   > brpc::Controller commitCntl;
   > commitCntl.tx = tx;
   > commitCntl.txState = END_TX;
   > commitReq.Commit();
   > channel.CallMethod(NULL, , , , NULL);
   > 
   > 需要对代码修改的地方有
   > 
1、在开始事务的controller里面设置一个标识,这样在它的OnComplete调用的时候,不释放连接到pool里面,返回的接口里面包含事务的信息。
   > 
2、后续的crud的controller里面设置事务的信息,在IssueRPC的时候,lb和选择连接的地方,可以根据是否设置事务做分支处理,主要是在选择连接的地方。
   > 3、在结束事务的controller里面设置一个标识,这样它在OnComplete的时候会释放连接。
   > 
   > prepared statement和这个类似。
   > 
   > 事务和prepared 
statement的处理流程在所有关系型数据库都类似,也可以抽象出来一些公共的内容。我参考了golang的database/sql库
   > 
   > 以上请戈君评审一下,看有什么建议。
   
   
实现上需要多次交互,并不意味着用户一定要感知到多次交互,本质上一个tx对用户也是一件事(要么成功要么失败),一个tx里的所有请求能否让用户一次性输入?即用户调用request中的BeginTx/Query/EndTx等接口可以编排一次tx,然后再CallMethod。


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] jamesge commented on a change in pull request #592: lb configurable && consistency hash lb refactor

2019-04-04 Thread GitBox
jamesge commented on a change in pull request #592: lb configurable && 
consistency hash lb refactor
URL: https://github.com/apache/incubator-brpc/pull/592#discussion_r272426700
 
 

 ##
 File path: src/brpc/load_balancer.h
 ##
 @@ -102,8 +104,21 @@ class LoadBalancer : public NonConstDescribable, public 
Destroyable {
 // Caller is responsible for Destroy() the instance after usage.
 virtual LoadBalancer* New() const = 0;
 
+// Config user passed parameters to lb after constrction which 
+// make lb function more flexible.
+virtual bool SetParameters(const butil::StringPiece& params) { return 
true; }
 
 Review comment:
   为什么不把params放New的参数上?从通用的角度看,有些对象创建时就知道params可能会效率更高。


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] jamesge commented on a change in pull request #592: lb configurable && consistency hash lb refactor

2019-04-04 Thread GitBox
jamesge commented on a change in pull request #592: lb configurable && 
consistency hash lb refactor
URL: https://github.com/apache/incubator-brpc/pull/592#discussion_r272427635
 
 

 ##
 File path: src/brpc/policy/consistent_hashing_load_balancer.cpp
 ##
 @@ -29,16 +31,111 @@ namespace policy {
 DEFINE_int32(chash_num_replicas, 100, 
  "default number of replicas per server in chash");
 
-ConsistentHashingLoadBalancer::ConsistentHashingLoadBalancer(HashFunc hash) 
-: _hash(hash)
-, _num_replicas(FLAGS_chash_num_replicas) {
+class ReplicaPolicy {
+public:
+ReplicaPolicy() : _hash_func(nullptr) {}
+ReplicaPolicy(HashFunc hash) : _hash_func(hash) {}
+virtual ~ReplicaPolicy() = default;
+
+virtual bool Build(ServerId server, 
+   size_t num_replicas,
+   std::vector* 
replicas) const = 0;
+
+protected:
+HashFunc _hash_func;
+};
+
+class DefaultReplicaPolicy : public ReplicaPolicy {
+public:
+DefaultReplicaPolicy(HashFunc hash) : ReplicaPolicy(hash) {}
+
+virtual bool Build(ServerId server,
+   size_t num_replicas,
+   std::vector* 
replicas) const;
+};
+
+bool DefaultReplicaPolicy::Build(ServerId server,
+ size_t num_replicas,
+ 
std::vector* replicas) const {
+SocketUniquePtr ptr;
+if (Socket::AddressFailedAsWell(server.id, ) == -1) {
+return false;
+}
+replicas->clear();
+for (size_t i = 0; i < num_replicas; ++i) {
+char host[32];
+int len = snprintf(host, sizeof(host), "%s-%lu",
+   endpoint2str(ptr->remote_side()).c_str(), i);
+ConsistentHashingLoadBalancer::Node node;
+node.hash = _hash_func(host, len);
+node.server_sock = server;
+node.server_addr = ptr->remote_side();
+replicas->push_back(node);
+}
+return true;
+}
+
+class KetamaReplicaPolicy : public ReplicaPolicy {
+public:
+virtual bool Build(ServerId server,
+   size_t num_replicas,
+   std::vector* 
replicas) const;
+};
+
+bool KetamaReplicaPolicy::Build(ServerId server,
+size_t num_replicas,
+
std::vector* replicas) const {
+SocketUniquePtr ptr;
+if (Socket::AddressFailedAsWell(server.id, ) == -1) {
+return false;
+}
+replicas->clear();
+const size_t points_per_hash = 4;
+CHECK(num_replicas % points_per_hash == 0)
+<< "Ketam hash replicas number(" << num_replicas << ") should be n*4";
+for (size_t i = 0; i < num_replicas / points_per_hash; ++i) {
+char host[32];
+int len = snprintf(host, sizeof(host), "%s-%lu",
+   endpoint2str(ptr->remote_side()).c_str(), i);
+unsigned char digest[16];
+MD5HashSignature(host, len, digest);
+for (size_t j = 0; j < points_per_hash; ++j) {
+ConsistentHashingLoadBalancer::Node node;
+node.server_sock = server;
+node.server_addr = ptr->remote_side();
+node.hash = ((uint32_t) (digest[3 + j * 4] & 0xFF) << 24)
+  | ((uint32_t) (digest[2 + j * 4] & 0xFF) << 16)
+  | ((uint32_t) (digest[1 + j * 4] & 0xFF) << 8)
+  | (digest[0 + j * 4] & 0xFF);
+replicas->push_back(node);
+}
+}
+return true;
 }
 
-ConsistentHashingLoadBalancer::ConsistentHashingLoadBalancer(
-HashFunc hash,
-size_t num_replicas) 
-: _hash(hash)
-, _num_replicas(num_replicas) {
+namespace {
+
+const std::map g_replica_policy_map = {
 
 Review comment:
   如果有一个线程在main函数之后还发了个rpc(不少见),这里可能就挂了把。建议搞成once初始化+数组(而不是map)的形式


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] yanglimingcn commented on issue #692: Add Mysql Protocol, only support text protocol now, not support trans…

2019-04-04 Thread GitBox
yanglimingcn commented on issue #692: Add Mysql Protocol, only support text 
protocol now, not support trans…
URL: https://github.com/apache/incubator-brpc/pull/692#issuecomment-480111084
 
 
   @jamesge 最近在考虑prepared statement 和 
transaction的实现问题。这两个功能的特点是,需要在一个连接上面进行多次回话,在多次回话过程中连接需要独占。
   调用接口的伪代码:
   // begin transaction
   brpc::MysqlRequest txReq;
   brpc::MysqlResponse txRsp;
   brpc::Controller txCntl;
   txCntl.txState = BEGIN_TX;
   txReq.BeginTx();
   channel.CallMethod(NULL, , , , NULL);
   
   const brpc::MysqlReply::Tx& tx = txRsp.reply(0).tx();
   
   //txRsp keep a connection
   // begin crud operation
   brpc::MysqlRequest crudReq1;
   brpc::MysqlResponse curdRsp1;
   brpc::Controller crudCntl1;
   crudCntl1.tx = tx;
   txReq1.Query("sql statement1");
   channel.CallMethod(NULL, , , , NULL);
   
   brpc::MysqlRequest crudReq2;
   brpc::MysqlResponse curdRsp2;
   brpc::Controller crudCntl2;
   crudCntl2.tx = tx;
   txReq1.Query("sql statement2");
   channel.CallMethod(NULL, , , , NULL);
   // end crud operation
   
   // commit transaction
   // after that release the connect to pool
   brpc::MysqlRequest commitReq;
   brpc::MysqlResponse commitRsp;
   brpc::Controller commitCntl;
   commitCntl.tx = tx;
   commitCntl.txState = END_TX;
   commitReq.Commit();
   channel.CallMethod(NULL, , , , NULL);
   
   需要对代码修改的地方有
   1、在开始事务的controller里面设置一个标识,这样在它的OnComplete调用的时候,不释放连接到pool里面,返回的接口里面包含事务的信息。
   
2、后续的crud的controller里面设置事务的信息,在IssueRPC的时候,lb和选择连接的地方,可以根据是否设置事务做分支处理,主要是在选择连接的地方。
   3、在结束事务的controller里面设置一个标识,这样它在OnComplete的时候会释放连接。
   
   prepared statement和这个类似。
   
   事务和prepared 
statement的处理流程在所有关系型数据库都类似,也可以抽象出来一些公共的内容。我参考了golang的database/sql库
   
   以上请戈君评审一下,看有什么建议。


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] yjhjstz commented on issue #715: http2 / grpc问题

2019-04-04 Thread GitBox
yjhjstz commented on issue #715: http2 / grpc问题
URL: https://github.com/apache/incubator-brpc/issues/715#issuecomment-480106186
 
 
   有更优雅的方式吗?


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] jamesge commented on a change in pull request #592: lb configurable && consistency hash lb refactor

2019-04-04 Thread GitBox
jamesge commented on a change in pull request #592: lb configurable && 
consistency hash lb refactor
URL: https://github.com/apache/incubator-brpc/pull/592#discussion_r272216066
 
 

 ##
 File path: src/brpc/policy/consistent_hashing_load_balancer.cpp
 ##
 @@ -29,16 +31,111 @@ namespace policy {
 DEFINE_int32(chash_num_replicas, 100, 
  "default number of replicas per server in chash");
 
-ConsistentHashingLoadBalancer::ConsistentHashingLoadBalancer(HashFunc hash) 
-: _hash(hash)
-, _num_replicas(FLAGS_chash_num_replicas) {
+class ReplicaPolicy {
+public:
+ReplicaPolicy() : _hash_func(nullptr) {}
+ReplicaPolicy(HashFunc hash) : _hash_func(hash) {}
+virtual ~ReplicaPolicy() = default;
+
+virtual bool Build(ServerId server, 
+   size_t num_replicas,
+   std::vector* 
replicas) const = 0;
+
+protected:
+HashFunc _hash_func;
 
 Review comment:
   这东西和基类有关系么?


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] cdjingit commented on issue #465: Brpc couchbase

2019-04-04 Thread GitBox
cdjingit commented on issue #465: Brpc couchbase
URL: https://github.com/apache/incubator-brpc/pull/465#issuecomment-479864006
 
 
   这个已经开发完成了


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] Xavier1994 closed issue #704: [grpc-java-client] grpc java client call brpc server get INTERNAL: HTTP/2 error code: FLOW_CONTROL_ERROR

2019-04-04 Thread GitBox
Xavier1994 closed issue #704: [grpc-java-client] grpc java client call brpc 
server get INTERNAL: HTTP/2 error code: FLOW_CONTROL_ERROR 
URL: https://github.com/apache/incubator-brpc/issues/704
 
 
   


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org