Skip to content

Commit

Permalink
fixup! resource
Browse files Browse the repository at this point in the history
  • Loading branch information
milroy committed Apr 29, 2024
1 parent 9497cdd commit b30f493
Showing 1 changed file with 38 additions and 35 deletions.
73 changes: 38 additions & 35 deletions resource/modules/resource_match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2209,8 +2209,6 @@ static void stat_request_cb (flux_t *h, flux_msg_handler_t *w,
std::shared_ptr<resource_ctx_t> ctx = getctx ((flux_t *)arg);
int saved_errno;
json_t *o = nullptr;
json_t *match_succeeded = nullptr;
json_t *match_failed = nullptr;
double mean = 0.0f;
double min = 0.0f;
double variance = 0.0f;
Expand All @@ -2235,8 +2233,7 @@ static void stat_request_cb (flux_t *h, flux_msg_handler_t *w,
variance_failed = ctx->perf.M2_failed
/ (double)ctx->perf.njobs_reset_failed;
}
if ( !(o = json_object ()) || !(match_succeeded = json_object ())
|| !(match_failed = json_object ())) {
if ( !(o = json_object ())) {
errno = ENOMEM;
goto error;
}
Expand All @@ -2250,37 +2247,43 @@ static void stat_request_cb (flux_t *h, flux_msg_handler_t *w,
time_since_reset_s = std::chrono::duration_cast<std::chrono::seconds> (
now - ctx->perf.time_since_reset).count ();

if (!(match_succeeded = json_pack ("{s:I s:I s:f s:f s:f s:f}",
"njobs", ctx->perf.njobs,
"njobs-reset", ctx->perf.njobs_reset,
"min-match", min,
"max-match", ctx->perf.max,
"avg-match", mean,
"match-variance", variance))) {
errno = ENOMEM;
goto error;
}
if (!(match_failed = json_pack ("{s:I s:I s:f s:f s:f s:f}",
"njobs-failed", ctx->perf.njobs_failed,
"njobs-reset-failed", ctx->perf.njobs_reset_failed,
"min-match-failed", min_failed,
"max-match-failed", ctx->perf.max_failed,
"avg-match-failed", mean_failed,
"match-variance-failed", variance_failed))) {
errno = ENOMEM;
goto error;
}

if (flux_respond_pack (h, msg, "{s:I s:I s:o s:f s:I s:I s:{s:o s:o}}",
"V", num_vertices (ctx->db->resource_graph),
"E", num_edges (ctx->db->resource_graph),
"by_rank", o,
"load-time", ctx->perf.load,
"graph-uptime", graph_uptime_s,
"time-since-reset", time_since_reset_s,
"match",
"succeeded", match_succeeded,
"failed", match_failed) < 0) {
if (flux_respond_pack (h, msg, "{s:I s:I s:o s:f s:I s:I"
"s:{"
"s:{"
"s:I s:I s:{"
"s:f s:f s:f s:f"
"}"
"}"
"s:{"
"s:I s:I s:{"
"s:f s:f s:f s:f"
"}"
"}"
"}"
"}",
"V", num_vertices (ctx->db->resource_graph),
"E", num_edges (ctx->db->resource_graph),
"by_rank", o,
"load-time", ctx->perf.load,
"graph-uptime", graph_uptime_s,
"time-since-reset", time_since_reset_s,
"match",
"succeeded",
"njobs", ctx->perf.njobs,
"njobs-reset", ctx->perf.njobs_reset,
"stats",
"min", min,
"max", ctx->perf.max,
"avg", mean,
"variance", variance,
"failed",
"njobs", ctx->perf.njobs_failed,
"njobs-reset", ctx->perf.njobs_reset_failed,
"stats",
"min", min_failed,
"max", ctx->perf.max_failed,
"avg", mean_failed,
"variance", variance_failed) < 0) {
flux_log_error (h, "%s: flux_respond_pack", __FUNCTION__);
}

Expand Down

0 comments on commit b30f493

Please sign in to comment.