Skip to content

Commit

Permalink
Merge pull request #21 from neuront/master
Browse files Browse the repository at this point in the history
cluster status info
  • Loading branch information
zheplusplus committed Nov 19, 2015
2 parents acec8bb + 34f889c commit 4a39864
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "utils/typetraits.hpp"

#define VERSION "0.7.4-2015-10-22"
#define VERSION "0.7.5-2015-11-12"

namespace cerb {

Expand Down
11 changes: 11 additions & 0 deletions core/globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ thread_local cerb::msize_t cerb_global::allocated_buffer(0);

static std::mutex remote_addrs_mutex;
static std::set<util::Address> remote_addrs;
static bool cluster_ok = false;

void cerb_global::set_remotes(std::set<util::Address> remotes)
{
Expand All @@ -32,3 +33,13 @@ bool cerb_global::cluster_req_full_cov()
{
return ::req_full_cov;
}

void cerb_global::set_cluster_ok(bool ok)
{
::cluster_ok = ok;
}

bool cerb_global::cluster_ok()
{
return ::cluster_ok;
}
3 changes: 3 additions & 0 deletions core/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ namespace cerb_global {
void set_cluster_req_full_cov(bool c);
bool cluster_req_full_cov();

void set_cluster_ok(bool ok);
bool cluster_ok();

}

#endif /* __CERBERUS_GLOBALS_HPP__ */
2 changes: 2 additions & 0 deletions core/proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ void Proxy::_set_slot_map(std::vector<RedisNode> const& map,
_server_map.replace_map(map, this);
_slot_map_expired = false;
cerb_global::set_remotes(std::move(remotes));
cerb_global::set_cluster_ok(true);
LOG(INFO) << "Slot map updated";
LOG(DEBUG) << "Retry MOVED or ASK: " << this->_retrying_commands.size();
if (this->_retrying_commands.empty()) {
Expand Down Expand Up @@ -178,6 +179,7 @@ void Proxy::_update_slot_map_failed()
}

this->_move_closed_slot_updaters();
cerb_global::set_cluster_ok(false);
LOG(DEBUG) << "Failed to retrieve slot map, discard all commands.";
_server_map.clear();
std::vector<util::sref<DataCommand>> cmds(std::move(this->_retrying_commands));
Expand Down
7 changes: 3 additions & 4 deletions core/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ void Server::on_events(int events)
try {
this->_recv_from();
} catch (BadRedisMessage& e) {
LOG(FATAL) << "Receive bad message from server " << this->str()
LOG(ERROR) << "Receive bad message from server " << this->str()
<< " because: " << e.what()
<< " dump buffer (before close): "
<< this->_buffer.to_string();
exit(1);
return this->close_conn();
}
}
this->_push_to_buffer_set();
Expand Down Expand Up @@ -70,8 +70,7 @@ void Server::_recv_from()
LOG(ERROR) << "::: " << rsp->get_buffer().to_string();
}
LOG(ERROR) << "Rest buffer: " << this->_buffer.to_string();
LOG(FATAL) << "Exit";
exit(1);
return this->close_conn();
}
LOG(DEBUG) << "+responses size: " << responses.size();
LOG(DEBUG) << "+rest buffer: " << this->_buffer.size();
Expand Down
1 change: 1 addition & 0 deletions core/stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ std::string cerb::stats_all()
return util::join("", {
"version:" VERSION
"\nthreads:", util::str(msize_t(cerb_global::all_threads.size())),
"\ncluster_ok:", cerb_global::cluster_ok() ? "1" : "0",
"\nread_slave:", ::read_slave ? "1" : "0",
"\nclients_count:", util::join(",", clients_counts),
"\nlong_connections_count:", util::join(",", long_conns_counts),
Expand Down

0 comments on commit 4a39864

Please sign in to comment.