diff --git a/resource/modules/feasibility.cpp b/resource/modules/feasibility.cpp index eefd2d24e..48a283ba6 100644 --- a/resource/modules/feasibility.cpp +++ b/resource/modules/feasibility.cpp @@ -17,9 +17,9 @@ MOD_NAME ("sched-fluxion-feasibility"); //////////////////////////////////////////////////////////////////////////////// static void feasibility_request_cb (flux_t *h, - flux_msg_handler_t *w, - const flux_msg_t *msg, - void *arg); + flux_msg_handler_t *w, + const flux_msg_t *msg, + void *arg); static const struct flux_msg_handler_spec htab[] = {{FLUX_MSGTYPE_REQUEST, "feasibility.check", feasibility_request_cb, 0}, @@ -102,11 +102,7 @@ static int process_config_file (std::shared_ptr &ctx) int rc = 0; json_t *conf = nullptr; - if ((rc = flux_conf_unpack (flux_get_conf (ctx->h), - nullptr, - "{ s?:o }", - mod_name, - &conf)) + if ((rc = flux_conf_unpack (flux_get_conf (ctx->h), nullptr, "{ s?:o }", mod_name, &conf)) < 0) { flux_log_error (ctx->h, "%s: flux_conf_unpack", __FUNCTION__); return rc; @@ -153,7 +149,7 @@ static std::shared_ptr init_module (flux_t *h, int argc, char ** std::shared_ptr ctx = nullptr; flux_future_t *f = nullptr; uint32_t rank = 1; - + if (!(ctx = getctx (h))) { flux_log (h, LOG_ERR, "%s: can't allocate the context", __FUNCTION__); return nullptr; @@ -188,7 +184,7 @@ static std::shared_ptr init_module (flux_t *h, int argc, char ** goto error; } return ctx; - + error: return nullptr; } @@ -198,9 +194,9 @@ static std::shared_ptr init_module (flux_t *h, int argc, char ** //////////////////////////////////////////////////////////////////////////////// static void feasibility_request_cb (flux_t *h, - flux_msg_handler_t *w, - const flux_msg_t *msg, - void *arg) + flux_msg_handler_t *w, + const flux_msg_t *msg, + void *arg) { int64_t at = 0; int64_t now = 0; @@ -275,7 +271,7 @@ static int init_resource_graph (std::shared_ptr &ctx) if (!(ctx->writers = match_writers_factory_t::create (format))) return -1; - //TODO remove? + // TODO remove? if (ctx->opts.get_opt ().is_prune_filters_set () && ctx->matcher->set_pruning_types_w_spec (ctx->matcher->dom_subsystem (), ctx->opts.get_opt ().get_prune_filters ()) @@ -294,11 +290,11 @@ static int init_resource_graph (std::shared_ptr &ctx) return -1; } - //TODO remove? - // Perform the initial status marking only when "up" rankset is available - // Rankless reader cases (required for testing e.g., GRUG) must not - // execute the following branch. - // Use ctx->update_f != nullptr to differentiate + // TODO remove? + // Perform the initial status marking only when "up" rankset is available + // Rankless reader cases (required for testing e.g., GRUG) must not + // execute the following branch. + // Use ctx->update_f != nullptr to differentiate if (ctx->update_f) { if (mark (ctx, "all", resource_pool_t::status_t::DOWN) < 0) { flux_log (ctx->h, LOG_ERR, "%s: mark (down)", __FUNCTION__); @@ -332,7 +328,7 @@ extern "C" int mod_main (flux_t *h, int argc, char **argv) flux_log (h, LOG_ERR, "%s: can't initialize feasibility module", __FUNCTION__); goto done; } - + // Because mod_main is always active, the following is safe. flux_aux_set (h, mod_name, &ctx, NULL); flux_log (h, LOG_DEBUG, "%s: feasibility module starting", __FUNCTION__); diff --git a/resource/modules/resource.cpp b/resource/modules/resource.cpp index c677dfe31..682d9b196 100644 --- a/resource/modules/resource.cpp +++ b/resource/modules/resource.cpp @@ -171,11 +171,7 @@ static int process_config_file (std::shared_ptr &ctx) int rc = 0; json_t *conf = nullptr; - if ((rc = flux_conf_unpack (flux_get_conf (ctx->h), - nullptr, - "{ s?:o }", - mod_name, - &conf)) + if ((rc = flux_conf_unpack (flux_get_conf (ctx->h), nullptr, "{ s?:o }", mod_name, &conf)) < 0) { flux_log_error (ctx->h, "%s: flux_conf_unpack", __FUNCTION__); return rc; @@ -1027,12 +1023,12 @@ static void notify_request_cb (flux_t *h, flux_msg_handler_t *w, const flux_msg_ // This is guaranteed by the order of mod_main: // init_resource_graph runs before flux_reactor_run. if (flux_respond_pack (ctx->h, - msg, - "{s:O s:f}", - "resources", - ctx->m_acquired_resources.get (), - "expiration", - ctx->m_acquired_resources_expiration) + msg, + "{s:O s:f}", + "resources", + ctx->m_acquired_resources.get (), + "expiration", + ctx->m_acquired_resources_expiration) < 0) { flux_log_error (ctx->h, "%s: flux_respond_pack", __FUNCTION__); } @@ -1040,7 +1036,7 @@ static void notify_request_cb (flux_t *h, flux_msg_handler_t *w, const flux_msg_ // Add msg as a subscriber to resource UP/DOWN updates m->set_msg (msg); auto ret = ctx->notify_msgs.insert ( - std::pair> (route, m)); + std::pair> (route, m)); if (!ret.second) { errno = EEXIST; flux_log_error (h, "%s: insert", __FUNCTION__); @@ -1352,7 +1348,6 @@ static int init_resource_graph (std::shared_ptr &ctx) return 0; } - //////////////////////////////////////////////////////////////////////////////// // Module Main //////////////////////////////////////////////////////////////////////////////// diff --git a/resource/modules/resource_match.cpp b/resource/modules/resource_match.cpp index 05e1ee3c3..9bd6b5936 100644 --- a/resource/modules/resource_match.cpp +++ b/resource/modules/resource_match.cpp @@ -222,11 +222,13 @@ static void update_resource (flux_future_t *f, void *arg) &down, "expiration", &expiration) - < 0) { + < 0) { flux_log_error (ctx->h, - ctx->m_acquire_resources_from_core \ - ? "%s: exiting due to resource.acquire failure" \ - : "%s: exiting due to sched-fluxion-resource.notify failure", + ctx->m_acquire_resources_from_core ? "%s: exiting due to resource.acquire " + "failure" + : "%s: exiting due to " + "sched-fluxion-resource.notify " + "failure", __FUNCTION__); flux_reactor_stop (flux_get_reactor (ctx->h)); /* Cancels notify msgs */ goto done; @@ -266,7 +268,8 @@ static void update_resource (flux_future_t *f, void *arg) ctx->set_update_rc (rc); } -static void update_resource_no_up_down (flux_future_t *f, void *arg) { +static void update_resource_no_up_down (flux_future_t *f, void *arg) +{ int rc = -1; std::shared_ptr &ctx = *(static_cast *> (arg)); @@ -287,17 +290,15 @@ static int populate_resource_db_acquire (std::shared_ptr &ctx) json_t *o = NULL; // If this module is not getting resources from core, use - // sched-fluxion-resource.notify instead of resource.acquire to avoid + // sched-fluxion-resource.notify instead of resource.acquire to avoid // using more than one resource.acquire RPC, which is not allowed - if (!(ctx->update_f = - flux_rpc (ctx->h, - ctx->m_acquire_resources_from_core \ - ? "resource.acquire" \ - : "sched-fluxion-resource.notify", - NULL, - FLUX_NODEID_ANY, - FLUX_RPC_STREAMING))) - { + if (!(ctx->update_f = flux_rpc (ctx->h, + ctx->m_acquire_resources_from_core ? "resource.acquire" + : "sched-fluxion-resource." + "notify", + NULL, + FLUX_NODEID_ANY, + FLUX_RPC_STREAMING))) { flux_log_error (ctx->h, "%s: flux_rpc", __FUNCTION__); goto done; } @@ -311,24 +312,20 @@ static int populate_resource_db_acquire (std::shared_ptr &ctx) // Only add full update_resource callback if the module needs UP/DOWN updates // Otherwise, add update_resource_no_up_down callback to get error updates if (ctx->m_get_up_down_updates) { - if (rc = flux_future_then (ctx->update_f, - -1.0, - update_resource, - static_cast (&ctx)) - < 0) { + if (rc = flux_future_then (ctx->update_f, -1.0, update_resource, static_cast (&ctx)) + < 0) { flux_log_error (ctx->h, "%s: flux_future_then", __FUNCTION__); goto done; } } else { if (rc = flux_future_then (ctx->update_f, - -1.0, - update_resource_no_up_down, + -1.0, + update_resource_no_up_down, static_cast (&ctx)) - < 0) { + < 0) { flux_log_error (ctx->h, "%s: flux_future_then", __FUNCTION__); goto done; } - } done: @@ -360,9 +357,10 @@ int populate_resource_db (std::shared_ptr &ctx) } flux_log (ctx->h, LOG_DEBUG, - ctx->m_acquire_resources_from_core \ - ? "%s: loaded resources from core's resource.acquire" \ - : "%s: loaded resources from sched-fluxion-resource.notify", + ctx->m_acquire_resources_from_core ? "%s: loaded resources from core's " + "resource.acquire" + : "%s: loaded resources from " + "sched-fluxion-resource.notify", __FUNCTION__); } @@ -1077,18 +1075,16 @@ static int mark_now (std::shared_ptr &ctx, return rc; } -int mark (std::shared_ptr &ctx, - const char *ids, - resource_pool_t::status_t status) +int mark (std::shared_ptr &ctx, const char *ids, resource_pool_t::status_t status) { return (ctx->traverser->is_initialized ()) ? mark_now (ctx, ids, status) : mark_lazy (ctx, ids, status); } int update_resource_db (std::shared_ptr &ctx, - json_t *resources, - const char *up, - const char *down) + json_t *resources, + const char *up, + const char *down) { int rc = 0; // TODO Will need to get duration update and set graph metadata when @@ -1393,14 +1389,14 @@ static int run (std::shared_ptr &ctx, } int run_match (std::shared_ptr &ctx, - int64_t jobid, - const char *cmd, - const std::string &jstr, - int64_t *now, - int64_t *at, - double *overhead, - std::stringstream &o, - flux_error_t *errp) + int64_t jobid, + const char *cmd, + const std::string &jstr, + int64_t *now, + int64_t *at, + double *overhead, + std::stringstream &o, + flux_error_t *errp) { int rc = 0; std::chrono::time_point start; @@ -1451,11 +1447,11 @@ int run_match (std::shared_ptr &ctx, } int run_update (std::shared_ptr &ctx, - int64_t jobid, - const char *R, - int64_t &at, - double &overhead, - std::stringstream &o) + int64_t jobid, + const char *R, + int64_t &at, + double &overhead, + std::stringstream &o) { int rc = 0; uint64_t duration = 0; @@ -1493,10 +1489,10 @@ int run_update (std::shared_ptr &ctx, } int run_remove (std::shared_ptr &ctx, - int64_t jobid, - const char *R, - bool part_cancel, - bool &full_removal) + int64_t jobid, + const char *R, + bool part_cancel, + bool &full_removal) { int rc = -1; dfu_traverser_t &tr = *(ctx->traverser); @@ -1547,9 +1543,9 @@ int run_remove (std::shared_ptr &ctx, } int run_find (std::shared_ptr &ctx, - const std::string &criteria, - const std::string &format_str, - json_t **R) + const std::string &criteria, + const std::string &format_str, + json_t **R) { int rc = -1; json_t *o = nullptr; diff --git a/resource/modules/resource_match.hpp b/resource/modules/resource_match.hpp index a415ae608..40ccb2af6 100644 --- a/resource/modules/resource_match.hpp +++ b/resource/modules/resource_match.hpp @@ -40,7 +40,6 @@ extern "C" { using namespace Flux::resource_model; using namespace Flux::opts_manager; - //////////////////////////////////////////////////////////////////////////////// // Resource Matching Service Module Context //////////////////////////////////////////////////////////////////////////////// @@ -134,32 +133,32 @@ inline bool is_existent_jobid (const std::shared_ptr &ctx, uint6 int Rlite_equal (const std::shared_ptr &ctx, const char *R1, const char *R2); int run_match (std::shared_ptr &ctx, - int64_t jobid, - const char *cmd, - const std::string &jstr, - int64_t *now, - int64_t *at, - double *overhead, - std::stringstream &o, - flux_error_t *errp); + int64_t jobid, + const char *cmd, + const std::string &jstr, + int64_t *now, + int64_t *at, + double *overhead, + std::stringstream &o, + flux_error_t *errp); int run_update (std::shared_ptr &ctx, - int64_t jobid, - const char *R, - int64_t &at, - double &overhead, - std::stringstream &o); + int64_t jobid, + const char *R, + int64_t &at, + double &overhead, + std::stringstream &o); int run_remove (std::shared_ptr &ctx, - int64_t jobid, - const char *R, - bool part_cancel, - bool &full_removal); + int64_t jobid, + const char *R, + bool part_cancel, + bool &full_removal); int run_find (std::shared_ptr &ctx, - const std::string &criteria, - const std::string &format_str, - json_t **R); + const std::string &criteria, + const std::string &format_str, + json_t **R); //////////////////////////////////////////////////////////////////////////////// // Resource Graph and Traverser Initialization @@ -167,14 +166,12 @@ int run_find (std::shared_ptr &ctx, int populate_resource_db (std::shared_ptr &ctx); -int mark (std::shared_ptr &ctx, - const char *ids, - resource_pool_t::status_t status); +int mark (std::shared_ptr &ctx, const char *ids, resource_pool_t::status_t status); int update_resource_db (std::shared_ptr &ctx, - json_t *resources, - const char *up, - const char *down); + json_t *resources, + const char *up, + const char *down); int select_subsystems (std::shared_ptr &ctx); diff --git a/resource/modules/resource_match_opts.cpp b/resource/modules/resource_match_opts.cpp index f73ef185f..9e6179ae8 100644 --- a/resource/modules/resource_match_opts.cpp +++ b/resource/modules/resource_match_opts.cpp @@ -258,9 +258,10 @@ resource_opts_t::resource_opts_t () resource_opts_t ::resource_opts_key_t ::MATCH_FORMAT))); inserted &= ret.second; ret = m_tab.insert ( - std::pair ("subsystems", - static_cast ( - resource_opts_t ::resource_opts_key_t ::MATCH_SUBSYSTEMS))); + std::pair ("subsystems", + static_cast ( + resource_opts_t ::resource_opts_key_t ::MATCH_SUBSYSTEMS))); inserted &= ret.second; ret = m_tab.insert ( std::pair ("reserve-vtx-vec",