Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kvs: Support FLUX_KVS_WATCH_WAITCREATE #1820

Merged
merged 5 commits into from Nov 9, 2018
Merged
Diff settings

Always

Just for now

cmd/flux-kvs: Add --waitcreate option to kvs

Support in get and getroot commands.
  • Loading branch information...
chu11 committed Nov 3, 2018
commit 64dedba61091d2771f8eed0efd32daae3e1b96b3
Copy path View file
@@ -68,7 +68,7 @@ Remove a kvs namespace.
*namespace-list*::
List all current namespaces and info on each namespace.

*get* [-j|-r|-t] [-a treeobj] [-l] [-w] [-c count] 'key' ['key...']::
*get* [-j|-r|-t] [-a treeobj] [-l] [-w] [-W] [-c count] 'key' ['key...']::
Retrieve the value stored under 'key'. If nothing has been stored under
'key', display an error message. If no options, value is displayed with
a newline appended (if value length is nonzero). If '-l', a 'key=' prefix is
@@ -77,7 +77,9 @@ If '-r', value is displayed without a newline. If '-t', the RFC 11 object
is displayed. '-a treeobj' causes the lookup to be relative to an RFC 11
snapshot reference. If '-w', after the initial value, display the
new value each time the key changes until interrupted, or if '-c count'
is specified, until 'count' values have been displayed.
is specified, until 'count' values have been displayed. If the
initial value does not yet exist, `-W` can be specified to wait for it
to be crated.

This comment has been minimized.

Copy link
@SteVwonder

SteVwonder Nov 9, 2018

Member

Sorry for not catching this earlier. (copy and pasted later on in the .adoc too)

crated -> created

This comment has been minimized.

Copy link
@chu11

chu11 Nov 9, 2018

Author Contributor

oops ... I'll stick that fix onto my next PR.


*put* [-j|-r|-t] [-n] [-A] 'key=value' ['key=value...']::
Store 'value' under 'key' and commit it. If it already has a value,
@@ -160,12 +162,14 @@ of synchronization between peers is: node A puts a value, commits it,
reads version, sends version to node B. Node B waits for version, gets
value.

*getroot* [-w] [-c count] [-s | -o | -b]::
*getroot* [-w] [-W] [-c count] [-s | -o | -b]::
Retrieve the current KVS root, displaying it as an RFC 11 dirref object.
If '-b' is specified, display it as a blobref. If '-o' is specified,
display the namespace owner. If '-s' is specified, display the root
sequence number. If '-w' is specified, display the current root,
then a new value each time it is updated, up to 'count', if specified.
If the namespace does not yet exist, `-W` can be specified to wait for
it to be crated.

*eventlog get* [-w] [-c count] [-u] 'key'::
Display the contents of an RFC 18 KVS eventlog referred to by 'key'.
Copy path View file
@@ -104,6 +104,9 @@ static struct optparse_option get_opts[] = {
{ .name = "watch", .key = 'w', .has_arg = 0,
.usage = "Monitor key changes",
},
{ .name = "waitcreate", .key = 'W', .has_arg = 0,
.usage = "Wait for creation to occur on watch",
},
{ .name = "count", .key = 'c', .has_arg = 1, .arginfo = "COUNT",
.usage = "Display at most COUNT changes",
},
@@ -210,6 +213,9 @@ static struct optparse_option getroot_opts[] = {
{ .name = "watch", .key = 'w', .has_arg = 0,
.usage = "Monitor root changes",
},
{ .name = "waitcreate", .key = 'W', .has_arg = 0,
.usage = "Wait for creation to occur on watch",
},
{ .name = "count", .key = 'c', .has_arg = 1, .arginfo = "COUNT",
.usage = "Display at most COUNT changes",
},
@@ -239,7 +245,7 @@ static struct optparse_subcommand subcommands[] = {
NULL
},
{ "get",
"[-j|-r|-t] [-a treeobj] [-l] [-w] [-c COUNT] key [key...]",
"[-j|-r|-t] [-a treeobj] [-l] [-w] [-W] [-c COUNT] key [key...]",
"Get value stored under key",
cmd_get,
0,
@@ -337,7 +343,7 @@ static struct optparse_subcommand subcommands[] = {
NULL
},
{ "getroot",
"[-w] [-c COUNT] [-s|-o|-b]",
"[-w] [-W] [-c COUNT] [-s|-o|-b]",
"Get KVS root treeobj",
cmd_getroot,
0,
@@ -677,8 +683,11 @@ void cmd_get_one (flux_t *h, const char *key, struct lookup_ctx *ctx)

if (optparse_hasopt (ctx->p, "treeobj"))
flags |= FLUX_KVS_TREEOBJ;
if (optparse_hasopt (ctx->p, "watch"))
if (optparse_hasopt (ctx->p, "watch")) {
flags |= FLUX_KVS_WATCH;
if (optparse_hasopt (ctx->p, "waitcreate"))
flags |= FLUX_KVS_WATCH_WAITCREATE;
}
if (optparse_hasopt (ctx->p, "at")) {
const char *reference = optparse_get_str (ctx->p, "at", "");
if (!(f = flux_kvs_lookupat (h, flags, key, reference)))
@@ -1754,8 +1763,11 @@ int cmd_getroot (optparse_t *p, int argc, char **argv)
optparse_print_usage (p);
exit (1);
}
if (optparse_hasopt (p, "watch"))
if (optparse_hasopt (p, "watch")) {
flags |= FLUX_KVS_WATCH;
if (optparse_hasopt (p, "waitcreate"))
flags |= FLUX_KVS_WATCH_WAITCREATE;
}
if (!(f = flux_kvs_getroot (h, NULL, flags)))
log_err_exit ("flux_kvs_getroot");
if (flux_future_then (f, -1., getroot_continuation, &ctx) < 0)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.