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

libkvs: cleanup, deprecate old functions, update users #1233

Merged
merged 39 commits into from
Oct 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2a473c9
libkvs/dir: drop _struct suffix per RFC 7
garlick Oct 3, 2017
97163c5
libkvs/dir: add flux_ prefix to kvsdir_t
garlick Oct 3, 2017
5d00af2
libkvs/dir: add flux_ prefix to kvsitr_t
garlick Oct 3, 2017
a6ff79f
libkvs/dir: add flux_ prefix to all functions
garlick Oct 3, 2017
0acbac2
libkvs/dir: skip re-encode in flux_kvsdir_tostring()
garlick Oct 16, 2017
0f2e38a
libkvs/dir: add missing const
garlick Oct 16, 2017
e33cd6a
libkvs/dir: add flux_kvsdir_copy()
garlick Oct 9, 2017
eb832d9
libkvs: add flux_ prefix to all kvs functions
garlick Oct 3, 2017
690a1e8
libkvs/lookup: add flux_kvs_lookup_get_dir()
garlick Oct 9, 2017
d09234a
libkvs/lookup: add missing free()
garlick Oct 16, 2017
a94e0d5
cmd/flux-hwloc: modernize KVS API usage
garlick Oct 3, 2017
bbc01d3
t/kvs/asyncfence: drop no-op KVS fence test
garlick Oct 4, 2017
7ea51fa
t/kvs/watch: modernize KVS API usage
garlick Oct 4, 2017
42e52a8
t/kvs/commitmerge: modernize KVS API usage
garlick Oct 4, 2017
0f8bd26
t/kvs/dtree: modernize KVS API usage
garlick Oct 4, 2017
0a898c7
libjsc: modernize KVS API usage
garlick Oct 4, 2017
83a8505
modules/wreck/job: modernize KVS API usage
garlick Oct 4, 2017
d1dcef8
modules/wreck/wrexecd: drop no-aggregate-task-exit
garlick Oct 17, 2017
fef0392
modules/wreck/wrexecd: update KVS API usage
garlick Oct 9, 2017
81e771b
modules/resource-hwloc: modernize KVS API usage
garlick Oct 5, 2017
abbfd2c
bindings/lua: use flux_kvs_lookup()
garlick Oct 10, 2017
291b888
t/kvs/torture: modernize KVS API usage
garlick Oct 5, 2017
f512c07
modules/aggregator: modernize KVS API usage
garlick Oct 5, 2017
914ab8b
libkz: modernize KVS API usage
garlick Oct 5, 2017
eb6d7d7
t/kvs/basic: modernize KVS API usage
garlick Oct 10, 2017
d1ec8b5
t/kvs/getas: modernize KVS API usage
garlick Oct 10, 2017
be3fa50
cmd/flux-kvs: modernize kvs API usage
garlick Oct 10, 2017
7a2a21e
libkvs/txn: expose flux_kvs_txn_vpack()
garlick Oct 3, 2017
84085b2
libkvs/classic: add flux_kvsdir_pack()
garlick Oct 5, 2017
eea640a
libkvs/classic: drop flux_kvs_put_<type> functions
garlick Oct 5, 2017
e475343
libkvs/classic: drop flux_kvsdir_put_<type> funcs
garlick Oct 5, 2017
a377466
libkvs/classic: add missing const
garlick Oct 10, 2017
7eb5542
libkvs/classic: use lookup_get_dir internally
garlick Oct 10, 2017
9465b92
libkvs/classic: add some inline documentation
garlick Oct 10, 2017
3a3a1d8
libkvs/classic: deprecate all functions
garlick Oct 11, 2017
4a24b8c
libkvs/dir: add some inline documentation
garlick Oct 10, 2017
9e23b76
libkvs/watch: add inline documentation
garlick Oct 10, 2017
04bd4e0
doc/flux_kvs_lookup(3): add flux_kvs_lookup_get_dir
garlick Oct 10, 2017
8101399
doc/flux_kvs_txn_create(3): add flux_kvs_txn_vpack
garlick Oct 10, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions doc/man1/flux-submit.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,6 @@ via commas. Currently available options include:
debugger. This option is provided for use with parallel
debuggers such as TotalView.

'no-aggregate-task-exit'::
Do not use aggregator for task exit messages. This option
will result in each task's exit status being committed
separately into the kvs.

'no-pmi-server'::
Do not start simple pmi server. This option can be used to
not launch the pmi server if a non-MPI job is being run.
Expand Down
5 changes: 0 additions & 5 deletions doc/man1/flux-wreckrun.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,6 @@ via commas. Currently available options include:
debugger. This option is provided for use with parallel
debuggers such as TotalView.

'no-aggregate-task-exit'::
Do not use aggregator for task exit messages. This option
will result in each task's exit status being committed
separately into the kvs.

'no-pmi-server'::
Do not start simple pmi server. This option can be used to
not launch the pmi server if a non-MPI job is being run.
Expand Down
4 changes: 4 additions & 0 deletions doc/man3/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,12 @@ MAN3_FILES_SECONDARY = \
flux_kvs_lookup_get.3 \
flux_kvs_lookup_get_unpack.3 \
flux_kvs_lookup_get_raw.3 \
flux_kvs_lookup_get_dir.3 \
flux_kvs_fence.3 \
flux_kvs_txn_destroy.3 \
flux_kvs_txn_put.3 \
flux_kvs_txn_pack.3 \
flux_kvs_txn_vpack.3 \
flux_kvs_txn_mkdir.3 \
flux_kvs_txn_unlink.3 \
flux_kvs_txn_symlink.3 \
Expand Down Expand Up @@ -236,10 +238,12 @@ flux_kvs_lookupat.3: flux_kvs_lookup.3
flux_kvs_lookup_get.3: flux_kvs_lookup.3
flux_kvs_lookup_get_unpack.3: flux_kvs_lookup.3
flux_kvs_lookup_get_raw.3: flux_kvs_lookup.3
flux_kvs_lookup_get_dir.3: flux_kvs_lookup.3
flux_kvs_fence.3: flux_kvs_commit.3
flux_kvs_txn_destroy.3: flux_kvs_txn_create.3
flux_kvs_txn_put.3: flux_kvs_txn_create.3
flux_kvs_txn_pack.3: flux_kvs_txn_create.3
flux_kvs_txn_vpack.3: flux_kvs_txn_create.3
flux_kvs_txn_mkdir.3: flux_kvs_txn_create.3
flux_kvs_txn_unlink.3: flux_kvs_txn_create.3
flux_kvs_txn_symlink.3: flux_kvs_txn_create.3
Expand Down
7 changes: 6 additions & 1 deletion doc/man3/flux_kvs_lookup.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ flux_kvs_lookup(3)

NAME
----
flux_kvs_lookup, flux_kvs_lookupat, flux_kvs_lookup_get, flux_kvs_lookup_get_unpack, flux_kvs_lookup_get_raw - look up KVS key
flux_kvs_lookup, flux_kvs_lookupat, flux_kvs_lookup_get, flux_kvs_lookup_get_unpack, flux_kvs_lookup_get_raw, flux_kvs_lookup_get_dir - look up KVS key


SYNOPSIS
Expand All @@ -23,6 +23,8 @@ SYNOPSIS

int flux_kvs_lookup_get_raw (flux_future_t *f, const void **data, int *len);

int flux_kvs_lookup_get_dir (flux_future_t *f, const flux_kvsdir_t **dir);


DESCRIPTION
-----------
Expand Down Expand Up @@ -53,6 +55,9 @@ the returned JSON is parsed according to variable arguments in Jansson
`flux_kvs_lookup_get_raw()` is identical to `flux_kvs_lookup_get()` except
the raw value is returned without decoding.

`flux_kvs_lookup_get_dir()` is identical to `flux_kvs_lookup_get()` except
a directory object is returned.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you are considering removal of the kvsdir abstraction, but in the context of the addition of flux_kvs_lookup_get_dir it might be useful to consider addition of a refcount to kvsdir objects. This would avoid the necessary copies in the common case where we want the kvsdir to persist, but we're done with the future.

Copy link
Member Author

@garlick garlick Oct 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have flux_kvsdir_incref() but since the object returned from the lookup is const (indicating that it still belongs to the future), it seems a bit wrong to allow its reference count to be modified? This is why I added flux_kvsdir_copy(), but I intended that to be short lived until the various places where flux_kvsdir_t was used for purposes other than "list of names in directory" were converted to something else TBD.

As we just discussed offline, possibly we need to come up with a new object that serves as a handle to the KVS, and contains things like a "current working directory", a snapshot reference, or a namespace handle, as well as the broker handle, and then all KVS functions would take one of those instead of the broker handle... I'll open an issue on that idea.

These functions may be used asynchronously.
See `flux_future_then(3)` for details.

Expand Down
8 changes: 6 additions & 2 deletions doc/man3/flux_kvs_txn_create.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ flux_kvs_txn_create(3)

NAME
----
flux_kvs_txn_create, flux_kvs_txn_destroy, flux_kvs_txn_put, flux_kvs_txn_pack, flux_kvs_txn_mkdir, flux_kvs_txn_unlink, flux_kvs_txn_symlink, flux_kvs_txn_put_raw - operate on a KVS transaction object
flux_kvs_txn_create, flux_kvs_txn_destroy, flux_kvs_txn_put, flux_kvs_txn_pack, flux_kvs_txn_vpack, flux_kvs_txn_mkdir, flux_kvs_txn_unlink, flux_kvs_txn_symlink, flux_kvs_txn_put_raw - operate on a KVS transaction object


SYNOPSIS
Expand All @@ -22,6 +22,9 @@ SYNOPSIS
int flux_kvs_txn_pack (flux_kvs_txn_t *txn, int flags,
const char *key, const char *fmt, ...);

int flux_kvs_txn_vpack (flux_kvs_txn_t *txn, int flags,
const char *key, const char *fmt, va_list ap);

int flux_kvs_txn_mkdir (flux_kvs_txn_t *txn, int flags,
const char *key);

Expand Down Expand Up @@ -59,7 +62,8 @@ equivalent to calling `flux_kvs_txn_unlink()` on _key_.

`flux_kvs_txn_pack()` is identical to `flux_kvs_txn_put()`, except
`json_pack()` style arguments (see below) are used to construct the
value.
value. `flux_kvs_txn_vpack()` is a variant that accepts a _va_list_
argument.

`flux_kvs_txn_mkdir()` sets _key_ to an empty directory.

Expand Down
2 changes: 2 additions & 0 deletions doc/test/spell.en.pws
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,5 @@ symlink
nprocs
procs
txn
kvsdir
vpack
92 changes: 60 additions & 32 deletions src/bindings/lua/flux-lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,11 @@ static int l_flux_new (lua_State *L)
static int l_flux_kvsdir_new (lua_State *L)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit seems to do more than just update to use flux_kvs_lookup_get_dir. Perhaps commit message should just be enhanced.

Copy link
Member

@chu11 chu11 Oct 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah, this specific line is not relevant, just didn't know how to comment on a commit message.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that was pretty vague. Changed to

bindings/lua: use flux_kvs_lookup()

Replace use of soon to be deprecated flux_kvs_get()
and flux_kvs_get_dir() with modern flux_kvs_lookup()
equivalents.

{
const char *path = ".";
kvsdir_t *dir;
const flux_kvsdir_t *dir;
flux_kvsdir_t *cpy;
flux_t *f = lua_get_flux (L, 1);
flux_future_t *fut = NULL;
int rc;

if (lua_isstring (L, 2)) {
/*
Expand All @@ -265,10 +268,16 @@ static int l_flux_kvsdir_new (lua_State *L)
return (2);
path = lua_tostring (L, 2);
}

if (kvs_get_dir (f, &dir, "%s", path) < 0)
return lua_pusherror (L, (char *)flux_strerror (errno));
return lua_push_kvsdir (L, dir);
if (!(fut = flux_kvs_lookup (f, FLUX_KVS_READDIR, path))
|| flux_kvs_lookup_get_dir (fut, &dir) < 0
|| !(cpy = flux_kvsdir_copy (dir))) {
rc = lua_pusherror (L, (char *)flux_strerror (errno));
goto done;
}
rc = lua_push_kvsdir (L, cpy);
done:
flux_future_destroy (fut);
return rc;
}

static int l_flux_kvs_symlink (lua_State *L)
Expand All @@ -284,7 +293,7 @@ static int l_flux_kvs_symlink (lua_State *L)
if (!(target = lua_tostring (L, 3)))
return lua_pusherror (L, "target expected in arg #3");

if (kvs_symlink (f, key, target) < 0)
if (flux_kvs_symlink (f, key, target) < 0)
return lua_pusherror (L, (char *)flux_strerror (errno));
lua_pushboolean (L, true);
return (1);
Expand All @@ -299,7 +308,7 @@ static int l_flux_kvs_unlink (lua_State *L)
if (!(key = lua_tostring (L, 2)))
return lua_pusherror (L, "key expected in arg #2");

if (kvs_unlink (f, key) < 0)
if (flux_kvs_unlink (f, key) < 0)
return lua_pusherror (L, (char *)flux_strerror (errno));
lua_pushboolean (L, true);
return (1);
Expand All @@ -309,8 +318,9 @@ static int l_flux_kvs_type (lua_State *L)
{
flux_t *f;
const char *key;
char *val;
kvsdir_t *d;
const flux_kvsdir_t *dir;
const char *json_str;
flux_kvsdir_t *cpy;
flux_future_t *future;
const char *target;

Expand All @@ -327,29 +337,36 @@ static int l_flux_kvs_type (lua_State *L)
return (2);
}
flux_future_destroy (future);
if (kvs_get_dir (f, &d, "%s", key) == 0) {
if ((future = flux_kvs_lookup (f, FLUX_KVS_READDIR, key))
&& flux_kvs_lookup_get_dir (future, &dir) == 0
&& (cpy = flux_kvsdir_copy (dir))) {
lua_pushstring (L, "dir");
lua_push_kvsdir (L, d);
lua_push_kvsdir (L, cpy);
flux_future_destroy (future);
return (2);
}
if (kvs_get (f, key, &val) == 0) {
flux_future_destroy (future);
if ((future = flux_kvs_lookup (f, 0, key))
&& flux_kvs_lookup_get (future, &json_str) == 0) {
json_object *o;
lua_pushstring (L, "file");
if (val && (o = json_tokener_parse (val))) {
if (json_str && (o = json_tokener_parse (json_str))) {
json_object_to_lua (L, o);
json_object_put (o);
}
else
lua_pushnil (L);
flux_future_destroy (future);
return (2);
}
flux_future_destroy (future);
return lua_pusherror (L, "key does not exist");
}

int l_flux_kvs_commit (lua_State *L)
{
flux_t *f = lua_get_flux (L, 1);
if (kvs_commit (f, 0) < 0)
if (flux_kvs_commit_anon (f, 0) < 0)
return lua_pusherror (L, (char *)flux_strerror (errno));
lua_pushboolean (L, true);
return (1);
Expand All @@ -364,16 +381,16 @@ int l_flux_kvs_put (lua_State *L)
return lua_pusherror (L, "key required");

if (lua_isnil (L, 3))
rc = kvs_put (f, key, NULL);
rc = flux_kvs_put (f, key, NULL);
else {
json_object *o;
if (lua_value_to_json (L, 3, &o) < 0)
return lua_pusherror (L, "Unable to convert to json");
rc = kvs_put (f, key, json_object_to_json_string (o));
rc = flux_kvs_put (f, key, json_object_to_json_string (o));
json_object_put (o);
}
if (rc < 0)
return lua_pusherror (L, "kvs_put (%s): %s",
return lua_pusherror (L, "flux_kvs_put (%s): %s",
key, (char *)flux_strerror (errno));

lua_pushboolean (L, true);
Expand All @@ -382,24 +399,34 @@ int l_flux_kvs_put (lua_State *L)

int l_flux_kvs_get (lua_State *L)
{
char *json_str;
json_object *o;
flux_future_t *fut = NULL;
const char *json_str;
json_object *o = NULL;
flux_t *f = lua_get_flux (L, 1);
const char *key = lua_tostring (L, 2);
int rc;

if (key == NULL)
return lua_pusherror (L, "key required");
if (kvs_get (f, key, &json_str) < 0)
return lua_pusherror (L, "kvs_get: %s", (char *)flux_strerror (errno));
if (key == NULL) {
rc = lua_pusherror (L, "key required");
goto done;
}
if (!(fut = flux_kvs_lookup (f, 0, key))
|| flux_kvs_lookup_get (fut, &json_str) < 0) {
rc = lua_pusherror (L, "flux_kvs_lookup: %s",
(char *)flux_strerror (errno));
goto done;
}
if (!(o = json_tokener_parse (json_str))
|| (json_object_to_lua (L, o) < 0)) {
free (json_str);
return lua_pusherror (L, "json_tokener_parse: %s",
rc = lua_pusherror (L, "json_tokener_parse: %s",
(char *)flux_strerror (errno));
goto done;
}
free (json_str);
rc = 1;
done:
json_object_put (o);
return (1);
flux_future_destroy (fut);
return (rc);
}

static int l_flux_barrier (lua_State *L)
Expand Down Expand Up @@ -1058,7 +1085,7 @@ static int l_msghandler_newindex (lua_State *L)
return (0);
}

static int kvswatch_cb_common (const char *key, kvsdir_t *dir,
static int kvswatch_cb_common (const char *key, flux_kvsdir_t *dir,
json_object *val, void *arg, int errnum)
{
int rc;
Expand Down Expand Up @@ -1102,7 +1129,8 @@ static int kvswatch_cb_common (const char *key, kvsdir_t *dir,
return rc;
}

static int l_kvsdir_watcher (const char *key, kvsdir_t *dir, void *arg, int errnum)
static int l_kvsdir_watcher (const char *key, flux_kvsdir_t *dir,
void *arg, int errnum)
{
return kvswatch_cb_common (key, dir, NULL, arg, errnum);
}
Expand All @@ -1123,7 +1151,7 @@ static int l_kvswatcher_remove (lua_State *L)
struct l_flux_ref *kw = luaL_checkudata (L, 1, "FLUX.kvswatcher");
l_flux_ref_gettable (kw, "kvswatcher");
lua_getfield (L, -1, "key");
if (kvs_unwatch (kw->flux, lua_tostring (L, -1)) < 0)
if (flux_kvs_unwatch (kw->flux, lua_tostring (L, -1)) < 0)
return (lua_pusherror (L, "kvs_unwatch: %s",
(char *)flux_strerror (errno)));
/*
Expand Down Expand Up @@ -1159,9 +1187,9 @@ static int l_kvswatcher_add (lua_State *L)
kw = l_flux_ref_create (L, f, 2, "kvswatcher");
lua_getfield (L, 2, "isdir");
if (lua_toboolean (L, -1))
rc = kvs_watch_dir (f, l_kvsdir_watcher, (void *) kw, "%s", key);
rc = flux_kvs_watch_dir (f, l_kvsdir_watcher, (void *) kw, "%s", key);
else
rc = kvs_watch (f, key, l_kvswatcher, (void *) kw);
rc = flux_kvs_watch (f, key, l_kvswatcher, (void *) kw);
if (rc < 0) {
l_flux_ref_destroy (kw, "kvswatcher");
return lua_pusherror (L, (char *)flux_strerror (errno));
Expand Down
Loading