Skip to content

Commit

Permalink
fix info cmd bug
Browse files Browse the repository at this point in the history
  • Loading branch information
LLiuJJ committed Jul 3, 2023
1 parent 4032c3f commit 3090f56
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ PacketLength Client::_HandlePacket(const char *start, std::size_t bytes) {
return static_cast<PacketLength>(bytes);
}

Client::Client(std::string meta_addrs) : leader_addr_("") {
Client::Client(std::string meta_addrs)
: leader_addr_(""), meta_addrs_(meta_addrs) {
// init stub to meta server node
auto meta_node_addrs = StringUtil::Split(meta_addrs, ',');
for (auto meta_node_addr : meta_node_addrs) {
Expand Down
4 changes: 3 additions & 1 deletion src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ class Client : public StreamSocket {

eraftkv::ClusterConfigChangeResp cluster_conf_;

std::string meta_addrs_;

public:
Client(std::string kv_addrs);
Client(std::string meta_addrs);

std::string GetLeaderAddr(std::string partion_key);

Expand Down
7 changes: 4 additions & 3 deletions src/info_command_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@
*/

#include "command_handler.h"
#include "util.h"

EStatus InfoCommandHandler::Execute(const std::vector<std::string>& params,
Client* cli) {
ClientContext context;
eraftkv::ClusterConfigChangeReq req;
req.set_change_type(eraftkv::ChangeType::MetaMembersQuery);
eraftkv::ClusterConfigChangeResp resp;

auto status =
cli->stubs_.begin()->second->ClusterConfigChange(&context, req, &resp);
auto status = cli->stubs_[StringUtil::Split(cli->meta_addrs_, ',')[0]]
->ClusterConfigChange(&context, req, &resp);
std::string info_str;
for (int i = 0; i < resp.shard_group(0).servers_size(); i++) {
info_str += "meta server: \r\n";
info_str += "server_id: ";
info_str += std::to_string(resp.shard_group(0).servers(i).id());
info_str += ",server_address: ";
Expand Down

0 comments on commit 3090f56

Please sign in to comment.