diff --git a/src/modules/kvs/commit.c b/src/modules/kvs/commit.c index 187a43fe89c7..3658a7d32179 100644 --- a/src/modules/kvs/commit.c +++ b/src/modules/kvs/commit.c @@ -1033,6 +1033,16 @@ void commit_mgr_clear_noop_stores (commit_mgr_t *cm) cm->noop_stores = 0; } +int commit_mgr_fences_count (commit_mgr_t *cm) +{ + return zhash_size (cm->fences); +} + +int commit_mgr_ready_commit_count (commit_mgr_t *cm) +{ + return zlist_size (cm->ready); +} + /* Merge ready commits that are mergeable, where merging consists of * popping the "donor" commit off the ready list, and appending its * ops to the top commit. The top commit can be appended to if it diff --git a/src/modules/kvs/commit.h b/src/modules/kvs/commit.h index 87942e30a2ad..84dc28ca32f0 100644 --- a/src/modules/kvs/commit.h +++ b/src/modules/kvs/commit.h @@ -139,6 +139,12 @@ void commit_mgr_remove_fence (commit_mgr_t *cm, const char *name); int commit_mgr_get_noop_stores (commit_mgr_t *cm); void commit_mgr_clear_noop_stores (commit_mgr_t *cm); +/* Get count of fences stored */ +int commit_mgr_fences_count (commit_mgr_t *cm); + +/* return count of ready commits */ +int commit_mgr_ready_commit_count (commit_mgr_t *cm); + /* In internally stored ready commits (moved to ready status via * commit_mgr_process_fence_request()), merge them if they are capable * of being merged. diff --git a/src/modules/kvs/kvs.c b/src/modules/kvs/kvs.c index b6d0a63e9ef0..d38436854bf7 100644 --- a/src/modules/kvs/kvs.c +++ b/src/modules/kvs/kvs.c @@ -1907,11 +1907,15 @@ static void stats_get_cb (flux_t *h, flux_msg_handler_t *mh, while (root) { json_t *s; - if (!(s = json_pack ("{ s:i s:i s:i }", + if (!(s = json_pack ("{ s:i s:i s:i s:i s:i }", "#watchers", wait_queue_length (root->watchlist), "#no-op stores", commit_mgr_get_noop_stores (root->cm), + "#fences", + commit_mgr_fences_count (root->cm), + "#readycommits", + commit_mgr_ready_commit_count (root->cm), "store revision", root->seq))) { errno = ENOMEM; goto done; @@ -1925,8 +1929,11 @@ static void stats_get_cb (flux_t *h, flux_msg_handler_t *mh, else { json_t *s; - if (!(s = json_pack ("{ s:i s:i }", + if (!(s = json_pack ("{ s:i s:i s:i s:i s:i }", "#watchers", 0, + "#no-op stores", 0, + "#fences", 0, + "#readycommits", 0, "store revision", 0))) { errno = ENOMEM; goto done; diff --git a/src/modules/kvs/test/commit.c b/src/modules/kvs/test/commit.c index ccb8be13818d..5f312b065fd7 100644 --- a/src/modules/kvs/test/commit.c +++ b/src/modules/kvs/test/commit.c @@ -157,6 +157,9 @@ void commit_mgr_basic_tests (void) commit_mgr_clear_noop_stores (cm); + ok (commit_mgr_fences_count (cm) == 0, + "commit_mgr_fences_count returns 0 when no fences submitted"); + ok ((f = fence_create ("fence1", 1, 0)) != NULL, "fence_create works"); @@ -175,9 +178,15 @@ void commit_mgr_basic_tests (void) ok (commit_mgr_lookup_fence (cm, "invalid") == NULL, "commit_mgr_lookup_fence can't find invalid fence"); + ok (commit_mgr_fences_count (cm) == 1, + "commit_mgr_fences_count returns 1 when fence submitted"); + ok (commit_mgr_process_fence_request (cm, f) == 0, "commit_mgr_process_fence_request works"); + ok (commit_mgr_ready_commit_count (cm) == 0, + "commit_mgr_ready_commit_count is 0"); + ok (commit_mgr_commits_ready (cm) == false, "commit_mgr_commits_ready says no fences are ready"); @@ -195,6 +204,9 @@ void commit_mgr_basic_tests (void) ok (commit_mgr_process_fence_request (cm, f) == 0, "commit_mgr_process_fence_request works"); + ok (commit_mgr_ready_commit_count (cm) == 1, + "commit_mgr_ready_commit_count is 1"); + ok (commit_mgr_commits_ready (cm) == true, "commit_mgr_commits_ready says a fence is ready");