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-watch: only fetch new data for appends #6444

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 3 additions & 4 deletions doc/man3/flux_kvs_lookup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,9 @@ FLUX_KVS_WATCH_UNIQ
FLUX_KVS_WATCH_APPEND
Specified along with FLUX_KVS_WATCH, this flag will alter watch
behavior to only respond when :var:`key` is mentioned verbatim in a
committed transaction and the key has been appended to. The response
will only contain the additional appended data. Note that only data
length is considered for appends and no guarantee is made that prior
data hasn't been overwritten.
committed transaction and the key has been appended to. The
response will only contain the additional appended data. If the
value is overwritten, the lookup fails with EINVAL.

FLUX_KVS_WATCH_FULL
Specified along with FLUX_KVS_WATCH, this flag will alter watch
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/job/eventlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,15 @@ static void wait_event_continuation (flux_future_t *f, void *arg)
if (!ctx->quiet) {
if (eventlog_entry_dumpf (ctx->evf, stdout, &error, o) < 0)
log_err ("failed to print eventlog entry: %s", error.text);
fflush (stdout);
}
if (flux_job_event_watch_cancel (f) < 0)
log_err_exit ("flux_job_event_watch_cancel");
} else if (ctx->verbose) {
if (!ctx->got_event) {
if (eventlog_entry_dumpf (ctx->evf, stdout, &error, o) < 0)
log_err ("failed to print eventlog entry: %s", error.text);
fflush (stdout);
}
}

Expand Down
40 changes: 40 additions & 0 deletions src/common/libkvs/test/treeobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,45 @@ void test_corner_cases (void)
json_decref (symlink);
}

void test_type_name (void)
{
json_t *val, *valref, *dir, *dirref, *symlink, *notatreeobj;
const char *s;

val = treeobj_create_val ("a", 1);
valref = treeobj_create_valref (NULL);
dir = treeobj_create_dir ();
dirref = treeobj_create_dirref (NULL);
symlink = treeobj_create_symlink (NULL, "some-string");
notatreeobj = json_object ();
if (!val || !valref || !dir || !dirref || !symlink || !notatreeobj)
BAIL_OUT ("can't continue without test value");

s = treeobj_type_name (val);
ok (streq (s, "val"), "treeobj_type_name returns val correctly");
s = treeobj_type_name (valref);
ok (streq (s, "valref"), "treeobj_type_name returns valref correctly");
s = treeobj_type_name (dir);
ok (streq (s, "dir"), "treeobj_type_name returns dir correctly");
s = treeobj_type_name (dirref);
ok (streq (s, "dirref"), "treeobj_type_name returns dirref correctly");
s = treeobj_type_name (symlink);
ok (streq (s, "symlink"), "treeobj_type_name returns symlink correctly");
s = treeobj_type_name (notatreeobj);
ok (streq (s, "unknown"),
"treeobj_type_name returns unknown for non-treeobj");
s = treeobj_type_name (NULL);
ok (streq (s, "unknown"),
"treeobj_type_name returns unknown on invalid input");

json_decref (val);
json_decref (valref);
json_decref (dir);
json_decref (dirref);
json_decref (symlink);
json_decref (notatreeobj);
}

int main(int argc, char** argv)
{
plan (NO_PLAN);
Expand All @@ -820,6 +859,7 @@ int main(int argc, char** argv)
test_deep_copy ();
test_symlink ();
test_corner_cases ();
test_type_name ();

test_codec ();

Expand Down
15 changes: 15 additions & 0 deletions src/common/libkvs/treeobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,21 @@ char *treeobj_encode (const json_t *obj)
return json_dumps (obj, JSON_COMPACT|JSON_SORT_KEYS);
}

const char *treeobj_type_name (const json_t *obj)
{
if (treeobj_is_symlink (obj))
return "symlink";
else if (treeobj_is_val (obj))
return "val";
else if (treeobj_is_valref (obj))
return "valref";
else if (treeobj_is_dir (obj))
return "dir";
else if (treeobj_is_dirref (obj))
return "dirref";
return "unknown";
}

/*
* vi:tabstop=4 shiftwidth=4 expandtab
*/
6 changes: 6 additions & 0 deletions src/common/libkvs/treeobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ json_t *treeobj_decode (const char *buf);
json_t *treeobj_decodeb (const char *buf, size_t buflen);
char *treeobj_encode (const json_t *obj);

/* Get treeobj type name
* Returns "symlink", "val", "valref", "dir", "dirref" or NULL if
* invalid treeobj.
*/
const char *treeobj_type_name (const json_t *obj);

#endif /* !_FLUX_KVS_TREEOBJ_H */

/*
Expand Down
Loading
Loading