Skip to content

Commit

Permalink
Merge pull request flux-framework#78 from flux-framework/feature/meta…
Browse files Browse the repository at this point in the history
…data_lookup

Check local cache before doing kvs lookup.
  • Loading branch information
JaeseungYeom authored Jan 26, 2024
2 parents 0f9baaf + fda9ed8 commit 998d318
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/dyad/core/dyad_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,41 @@ dyad_rc_t dyad_get_metadata (dyad_ctx_t* ctx,
DYAD_C_FUNCTION_UPDATE_STR ("fname", fname);
DYAD_C_FUNCTION_UPDATE_INT ("should_wait", should_wait);
dyad_rc_t rc = DYAD_RC_OK;
// check if file exist locally, if so skip kvs
int fd = open (fname, O_RDONLY);
if (fd != -1) {
close (fd);
if (mdata == NULL) {
DYAD_LOG_ERROR (ctx,
"Metadata double pointer is NULL. Cannot correctly create metadata "
"object");
rc = DYAD_RC_NOTFOUND;
goto get_metadata_done;
}
if (*mdata != NULL) {
DYAD_LOG_INFO (ctx, "Metadata object is already allocated. Skipping allocation");
} else {
*mdata = (dyad_metadata_t*)malloc (sizeof (struct dyad_metadata));
if (*mdata == NULL) {
DYAD_LOG_ERROR (ctx, "Cannot allocate memory for metadata object");
rc = DYAD_RC_SYSFAIL;
goto get_metadata_done;
}
}
size_t fname_len = strlen (fname);
(*mdata)->fpath = (char*)malloc (fname_len + 1);
if ((*mdata)->fpath == NULL) {
DYAD_LOG_ERROR (ctx, "Cannot allocate memory for fpath in metadata object");
rc = DYAD_RC_SYSFAIL;
goto get_metadata_done;
}
memset ((*mdata)->fpath, '\0', fname_len + 1);
strncpy ((*mdata)->fpath, fname, fname_len);
(*mdata)->owner_rank = ctx->rank;
rc = DYAD_RC_OK;
goto get_metadata_done;
}

const size_t topic_len = PATH_MAX;
char topic[PATH_MAX + 1] = {'\0'};
char upath[PATH_MAX] = {'\0'};
Expand Down

0 comments on commit 998d318

Please sign in to comment.