From ebc9044c704cf2b9751c01cbda9aa52aff36e2b8 Mon Sep 17 00:00:00 2001 From: Teyras Date: Thu, 5 Apr 2018 11:37:33 +0200 Subject: [PATCH 1/2] Tweak clang-format settings and reformat some source files --- .clang-format | 4 ++-- src/handlers/broker_handler.cpp | 9 ++++----- src/helpers/curl.h | 2 +- src/helpers/logger.h | 2 +- src/helpers/string_to_hex.h | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.clang-format b/.clang-format index b969e86..8af8c71 100644 --- a/.clang-format +++ b/.clang-format @@ -9,8 +9,8 @@ AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: true AllowShortCaseLabelsOnASingleLine: true AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: true -AllowShortLoopsOnASingleLine: true +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: false AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: false diff --git a/src/handlers/broker_handler.cpp b/src/handlers/broker_handler.cpp index 451628f..d6b030f 100644 --- a/src/handlers/broker_handler.cpp +++ b/src/handlers/broker_handler.cpp @@ -23,8 +23,8 @@ broker_handler::broker_handler(std::shared_ptr config, process_client_eval(identity, message, respond); }); - client_commands_.register_command( - "get-runtime-stats", [this](const std::string &identity, const std::vector &message, response_cb respond) { + client_commands_.register_command("get-runtime-stats", + [this](const std::string &identity, const std::vector &message, response_cb respond) { process_client_get_runtime_stats(identity, message, respond); }); @@ -472,9 +472,8 @@ bool broker_handler::check_failure_count(worker::request_ptr request, { if (request->failure_count >= config_->get_max_request_failures()) { status_notifier.job_failed(request->data.get_job_id(), - "Job was reassigned too many (" + std::to_string(request->failure_count - 1) + ") times. Last" - " failure message was: " + - failure_msg); + "Job was reassigned too many (" + std::to_string(request->failure_count - 1) + + ") times. Last failure message was: " + failure_msg); notify_monitor(request, "FAILED", respond); return false; } diff --git a/src/helpers/curl.h b/src/helpers/curl.h index bd0fe9b..f97745b 100644 --- a/src/helpers/curl.h +++ b/src/helpers/curl.h @@ -94,7 +94,7 @@ namespace helpers /** Describes circumstances which lead to throwing this exception. */ std::string what_; }; -} +} // namespace helpers #endif // RECODEX_BROKER_HELPERS_CURL_H diff --git a/src/helpers/logger.h b/src/helpers/logger.h index f650741..c34d7cf 100644 --- a/src/helpers/logger.h +++ b/src/helpers/logger.h @@ -40,7 +40,7 @@ namespace helpers * @return difference */ int compare_log_levels(spdlog::level::level_enum first, spdlog::level::level_enum second); -} +} // namespace helpers #endif // RECODEX_BROKER_HELPERS_LOGGER_H diff --git a/src/helpers/string_to_hex.h b/src/helpers/string_to_hex.h index 09d62b1..8e29182 100644 --- a/src/helpers/string_to_hex.h +++ b/src/helpers/string_to_hex.h @@ -13,7 +13,7 @@ namespace helpers * @return textual description of hexadecimal characters from given string */ std::string string_to_hex(const std::string &string); -} +} // namespace helpers #endif // RECODEX_BROKER_STRING_TO_HEX_H From 5068291b1a479c9783ced01ba1c5b0f79591a913 Mon Sep 17 00:00:00 2001 From: Teyras Date: Thu, 5 Apr 2018 12:10:10 +0200 Subject: [PATCH 2/2] Better log messages during queueing --- src/handlers/broker_handler.cpp | 11 +++++++---- src/queuing/queue_manager_interface.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/handlers/broker_handler.cpp b/src/handlers/broker_handler.cpp index d6b030f..5c5cdba 100644 --- a/src/handlers/broker_handler.cpp +++ b/src/handlers/broker_handler.cpp @@ -279,8 +279,6 @@ void broker_handler::process_worker_done( if (next_request != nullptr) { send_request(worker, next_request, respond); - } else { - logger_->debug(" - worker {} is now free", worker->get_description()); } runtime_stats_[STATS_EVALUATED_JOBS] += 1; @@ -329,6 +327,10 @@ void broker_handler::process_worker_done( } else { logger_->warn("Received unexpected status code {} from worker {}", status, worker->get_description()); } + + if (queue_->get_current_request(worker) == nullptr) { + logger_->debug(" - worker {} is now free", worker->get_description()); + } } void broker_handler::process_worker_ping( @@ -447,13 +449,14 @@ bool broker_handler::reassign_request(worker::request_ptr request, handler_inter if (!result.enqueued) { notify_monitor(request, "FAILED", respond); + logger_->debug(" - failed to enqueue job {}", request->data.get_job_id()); return false; } if (result.assigned_to != nullptr) { send_request(result.assigned_to, request, respond); - logger_->debug( - " - job {} queued for worker {}", request->data.get_job_id(), result.assigned_to->get_description()); + } else { + logger_->debug(" - job {} is now waiting in the queue", request->data.get_job_id()); } return true; diff --git a/src/queuing/queue_manager_interface.h b/src/queuing/queue_manager_interface.h index 7d0f4f2..afa4ca8 100644 --- a/src/queuing/queue_manager_interface.h +++ b/src/queuing/queue_manager_interface.h @@ -17,7 +17,7 @@ struct enqueue_result { worker_ptr assigned_to; /** - * True if the request was successfully enqueued, false otherwise + * True if the request was successfully enqueued or assigned to a worker, false otherwise */ bool enqueued; };