From 60a801b8f380b2f00a3966b65a753a320e9ccbb1 Mon Sep 17 00:00:00 2001 From: Christopher Moussa Date: Fri, 30 Jul 2021 08:24:29 -0700 Subject: [PATCH] plugin: use job_aux_get() to fetch default bank Now that the plugin has a map that stores a user's default bank, remove the "default" key-value pair from the "users" map. In priority_cb (), use flux_jobtap_job_aux_get to retrieve the bank value that was set in validate_cb () instead of doing another map lookup inside the function. --- src/plugins/mf_priority.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/plugins/mf_priority.cpp b/src/plugins/mf_priority.cpp index 75781abd1..f7536dca2 100644 --- a/src/plugins/mf_priority.cpp +++ b/src/plugins/mf_priority.cpp @@ -47,7 +47,7 @@ std::map users_def_bank; int64_t priority_calculation (flux_plugin_t *p, flux_plugin_arg_t *args, int userid, - char *bank, + void *bank, int urgency) { double fshare_factor = 0.0, priority = 0.0; @@ -64,19 +64,15 @@ int64_t priority_calculation (flux_plugin_t *p, if (urgency == FLUX_JOB_URGENCY_EXPEDITE) return FLUX_JOB_PRIORITY_MAX; + bank = flux_jobtap_job_aux_get (p, + FLUX_JOBTAP_CURRENT_JOB, + "mf_priority:bank"); + // search element in map of maps by key it = users.find (userid); - // search for correct fshare value using passed-in bank; otherwise, use - // a default bank - if (bank != NULL) { - inner_it = it->second.find (bank); - fshare_factor = inner_it->second; - } - else { - inner_it = it->second.find ("default"); - fshare_factor = inner_it->second; - } + inner_it = it->second.find (static_cast (bank)); + fshare_factor = inner_it->second; priority = (fshare_weight * fshare_factor) + (urgency - 16); @@ -114,9 +110,6 @@ static void rec_update_cb (flux_t *h, if (flux_respond (h, msg, NULL) < 0) flux_log_error (h, "flux_respond"); - if (strcmp (bank, default_bank) == 0) - users[std::atoi (uid)]["default"] = std::stod (fshare); - users[std::atoi (uid)][bank] = std::stod (fshare); users_mj[std::atoi (uid)][bank] = { std::atoi (max_jobs), 0 };