Skip to content

Commit

Permalink
gms: Add is_shutdown helper for endpoint_state class
Browse files Browse the repository at this point in the history
It will be used by streaming manager to check if a node is in shutdown
status.
  • Loading branch information
asias committed Jul 19, 2017
1 parent aa87429 commit ed7e697
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions gms/endpoint_state.hh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#include "gms/heart_beat_state.hh"
#include "gms/application_state.hh"
#include "gms/versioned_value.hh"
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <experimental/optional>
#include <chrono>

Expand Down Expand Up @@ -148,6 +150,20 @@ public:
_is_alive = false;
}

bool is_shutdown() {
auto app_state = get_application_state(application_state::STATUS);
if (!app_state) {
return false;
}
auto value = app_state->value;
std::vector<sstring> pieces;
boost::split(pieces, value, boost::is_any_of(","));
if (pieces.empty()) {
return false;
}
return pieces[0] == sstring(versioned_value::SHUTDOWN);
}

friend std::ostream& operator<<(std::ostream& os, const endpoint_state& x);
};

Expand Down

0 comments on commit ed7e697

Please sign in to comment.