Skip to content

Commit

Permalink
plugin: use job_aux_get() to fetch default bank
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cmoussa1 committed Jul 30, 2021
1 parent 3ed16ce commit 60a801b
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/plugins/mf_priority.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ std::map<int, std::string> 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;
Expand All @@ -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<char *> (bank));
fshare_factor = inner_it->second;

priority = (fshare_weight * fshare_factor) + (urgency - 16);

Expand Down Expand Up @@ -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 };

Expand Down

0 comments on commit 60a801b

Please sign in to comment.