Skip to content

Commit

Permalink
Send ack messages on freeze and unfreeze, add is-frozen to runtime st…
Browse files Browse the repository at this point in the history
…atistics response
  • Loading branch information
Neloop committed Feb 4, 2019
1 parent cbe7faf commit d7a9f28
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/handlers/broker_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,11 @@ void broker_handler::process_client_get_runtime_stats(
response.data.push_back(std::to_string(pair.second));
}

// additional statistics
response.data.push_back("is-frozen");
response.data.push_back(std::to_string(is_frozen_));

logger_->debug("Client requested runtime statistics");
respond(response);
}

Expand All @@ -518,11 +523,17 @@ void broker_handler::process_client_freeze(
{
is_frozen_ = true;
logger_->info("The broker was frozen and will not accept any requests until it is restarted or unfrozen");

// let client know that freeze was successful
respond(message_container(broker_connect::KEY_CLIENTS, identity, {"ack"}));
}

void broker_handler::process_client_unfreeze(
const std::string &identity, const std::vector<std::string> &message, const handler_interface::response_cb &respond)
{
is_frozen_ = false;
logger_->info("The broker was unfrozen and will now accept requests again");

// let client know that unfreeze was successful
respond(message_container(broker_connect::KEY_CLIENTS, identity, {"ack"}));
}
4 changes: 3 additions & 1 deletion tests/broker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ TEST(broker, freeze)

// The broker is frozen
handler.on_request(message_container(broker_connect::KEY_CLIENTS, client_id, {"freeze"}), respond);
ASSERT_EQ(0u, messages.size());
ASSERT_EQ(1u, messages.size());

messages.clear();

// The client requests another evaluation
handler.on_request(
Expand Down

0 comments on commit d7a9f28

Please sign in to comment.