Skip to content

Commit

Permalink
Merge pull request #3 from ReCodEx/logging-and-formatting
Browse files Browse the repository at this point in the history
Code formatting and log message tweaks
  • Loading branch information
janbuchar committed Apr 12, 2018
2 parents dcee3d1 + 5068291 commit 60d2a4a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 11 additions & 9 deletions src/handlers/broker_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ broker_handler::broker_handler(std::shared_ptr<const broker_config> config,
process_client_eval(identity, message, respond);
});

client_commands_.register_command(
"get-runtime-stats", [this](const std::string &identity, const std::vector<std::string> &message, response_cb respond) {
client_commands_.register_command("get-runtime-stats",
[this](const std::string &identity, const std::vector<std::string> &message, response_cb respond) {
process_client_get_runtime_stats(identity, message, respond);
});

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand All @@ -472,9 +475,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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/curl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/helpers/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/helpers/string_to_hex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/queuing/queue_manager_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 60d2a4a

Please sign in to comment.