Skip to content

Commit

Permalink
broker/state_machine: rename quorum-monitor to quorum-get
Browse files Browse the repository at this point in the history
Problem: now that the quorum-monitor RPC does not support
streaming, the name doesn't fit.

Rename 'quorum-monitor' to 'quorum-get'.

Update tests.
  • Loading branch information
garlick committed Sep 15, 2020
1 parent 1feea3c commit 1ab95c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
21 changes: 9 additions & 12 deletions src/broker/state_machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,10 +688,10 @@ static flux_watcher_t *quorum_create_batch_timer (struct state_machine *s)
s);
}

static void quorum_monitor_cb (flux_t *h,
flux_msg_handler_t *mh,
const flux_msg_t *msg,
void *arg)
static void quorum_get_cb (flux_t *h,
flux_msg_handler_t *mh,
const flux_msg_t *msg,
void *arg)
{
struct state_machine *s = arg;
const char *errstr = NULL;
Expand All @@ -700,7 +700,7 @@ static void quorum_monitor_cb (flux_t *h,
if (flux_request_decode (msg, NULL, NULL) < 0)
goto error;
if (s->ctx->rank != 0) {
errstr = "quorum-monitor RPC is only available on rank 0";
errstr = "quorum-get RPC is only available on rank 0";
errno = EPROTO;
goto error;
}
Expand All @@ -713,7 +713,7 @@ static void quorum_monitor_cb (flux_t *h,
return;
error:
if (flux_respond_error (h, msg, errno, errstr) < 0)
flux_log_error (h, "error responding to quorum-monitor request");
flux_log_error (h, "error responding to quorum-get request");
free (tmp);
}

Expand Down Expand Up @@ -851,10 +851,8 @@ static bool msglist_drop_sender (zlist_t *l, const char *sender)
return false;
}

/* If a disconnect is received for streaming monitor or quorum-monitor
* requests, drop the request. Example use cases:
* - monitor module unloads while still watching quorum-monitor
* - tests (potentially)
/* If a disconnect is received for streaming monitor request,
* drop the request.
*/
static void disconnect_cb (flux_t *h,
flux_msg_handler_t *mh,
Expand All @@ -881,8 +879,7 @@ static void disconnect_cb (flux_t *h,
static const struct flux_msg_handler_spec htab[] = {
{ FLUX_MSGTYPE_REQUEST, "state-machine.monitor", monitor_cb, 0 },
{ FLUX_MSGTYPE_REQUEST, "state-machine.quorum", quorum_cb, 0 },
{ FLUX_MSGTYPE_REQUEST, "state-machine.quorum-monitor",
quorum_monitor_cb, 0 },
{ FLUX_MSGTYPE_REQUEST, "state-machine.quorum-get", quorum_get_cb, 0 },
{ FLUX_MSGTYPE_REQUEST, "state-machine.disconnect", disconnect_cb, 0 },
FLUX_MSGHANDLER_TABLE_END,
};
Expand Down
10 changes: 5 additions & 5 deletions t/t0025-broker-state-machine.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ARGS="-o,-Sbroker.rc1_path=,-Sbroker.rc3_path="

test_expect_success 'create qget.sh script to query quorum' '
cat >qget.sh <<-EOT &&
$RPC state-machine.quorum-monitor | jq -r .idset
$RPC state-machine.quorum-get | jq -r .idset
EOT
chmod +x qget.sh
'
Expand Down Expand Up @@ -88,16 +88,16 @@ test_expect_success HAVE_JQ 'instance functions with late-joiner' '
test_cmp late.exp late.out
'

test_expect_success HAVE_JQ 'quorum-monitor singleton RPC works' '
test_expect_success HAVE_JQ 'quorum-get RPC works' '
flux start ${ARGS} \
$RPC state-machine.quorum-monitor \
$RPC state-machine.quorum-get \
</dev/null >qm0.out &&
jq -cea .idset qm0.out
'

test_expect_success 'quorum-monitor RPC fails on rank > 0' '
test_expect_success 'quorum-get RPC fails on rank > 0' '
test_must_fail flux start -s2 ${ARGS} \
flux exec -r1 $RPC state-machine.quorum-monitor \
flux exec -r1 $RPC state-machine.quorum-get \
</dev/null 2>qm1.err &&
grep "only available on rank 0" qm1.err
'
Expand Down

0 comments on commit 1ab95c0

Please sign in to comment.