Store loom name in metadata instead of path
This commit is contained in:
parent
3751f3ac64
commit
4ec966cb67
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC)
|
||||
/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC)
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#include "loom.h"
|
||||
@ -8,15 +8,13 @@
|
||||
#include "cpu.h"
|
||||
#include "path.h"
|
||||
#include "proc.h"
|
||||
#include "stream.h"
|
||||
#include "uthash.h"
|
||||
|
||||
static const char *loom_prefix = "loom.";
|
||||
|
||||
static void
|
||||
set_hostname(char host[PATH_MAX], const char name[PATH_MAX])
|
||||
{
|
||||
/* Skip prefix */
|
||||
const char *start = name + strlen(loom_prefix);
|
||||
const char *start = name;
|
||||
|
||||
/* Copy until dot or end */
|
||||
int i;
|
||||
@ -30,10 +28,19 @@ set_hostname(char host[PATH_MAX], const char name[PATH_MAX])
|
||||
host[i] = '\0';
|
||||
}
|
||||
|
||||
int
|
||||
loom_matches(const char *path)
|
||||
const char *
|
||||
loom_name(struct stream *s)
|
||||
{
|
||||
return path_has_prefix(path, loom_prefix);
|
||||
JSON_Object *meta = stream_metadata(s);
|
||||
const char *loom = json_object_dotget_string(meta, "ovni.loom");
|
||||
|
||||
if (loom == NULL) {
|
||||
err("cannot get attribute ovni.loom for stream: %s",
|
||||
s->relpath);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return loom;
|
||||
}
|
||||
|
||||
int
|
||||
@ -41,11 +48,6 @@ loom_init_begin(struct loom *loom, const char *name)
|
||||
{
|
||||
memset(loom, 0, sizeof(struct loom));
|
||||
|
||||
if (!path_has_prefix(name, loom_prefix)) {
|
||||
err("loom name must start with '%s': %s", loom_prefix, name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strchr(name, '/') != NULL) {
|
||||
err("loom name cannot contain '/': %s", name);
|
||||
return -1;
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "cpu.h"
|
||||
#include "extend.h"
|
||||
struct proc;
|
||||
struct stream;
|
||||
|
||||
struct loom {
|
||||
int64_t gindex;
|
||||
@ -50,7 +51,7 @@ struct loom {
|
||||
struct extend ext;
|
||||
};
|
||||
|
||||
USE_RET int loom_matches(const char *relpath);
|
||||
USE_RET const char *loom_name(struct stream *s);
|
||||
USE_RET int loom_init_begin(struct loom *loom, const char *name);
|
||||
USE_RET int loom_init_end(struct loom *loom);
|
||||
USE_RET int loom_add_cpu(struct loom *loom, struct cpu *cpu);
|
||||
|
@ -194,9 +194,13 @@ stream_data_get(struct stream *stream)
|
||||
return stream->data;
|
||||
}
|
||||
|
||||
/* Is never NULL */
|
||||
JSON_Object *
|
||||
stream_metadata(struct stream *stream)
|
||||
{
|
||||
if (stream->meta == NULL)
|
||||
die("stream metadata is NULL: %s", stream->relpath);
|
||||
|
||||
return stream->meta;
|
||||
}
|
||||
|
||||
|
@ -131,16 +131,11 @@ find_loom(struct system *sys, const char *id)
|
||||
}
|
||||
|
||||
static struct loom *
|
||||
create_loom(struct system *sys, const char *relpath)
|
||||
create_loom(struct system *sys, struct stream *s)
|
||||
{
|
||||
char name[PATH_MAX];
|
||||
if (snprintf(name, PATH_MAX, "%s", relpath) >= PATH_MAX) {
|
||||
err("path too long: %s", relpath);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strtok(name, "/") == NULL) {
|
||||
err("cannot find first '/': %s", relpath);
|
||||
const char *name = loom_name(s);
|
||||
if (name == NULL) {
|
||||
err("loom_name failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -268,7 +263,7 @@ create_system(struct system *sys, struct trace *trace)
|
||||
continue;
|
||||
}
|
||||
|
||||
struct loom *loom = create_loom(sys, s->relpath);
|
||||
struct loom *loom = create_loom(sys, s);
|
||||
if (loom == NULL) {
|
||||
err("create_loom failed");
|
||||
return -1;
|
||||
|
@ -556,6 +556,9 @@ thread_metadata_populate(void)
|
||||
|
||||
if (json_object_dotset_number(meta, "ovni.pid", (double) rproc.pid) != 0)
|
||||
die("json_object_dotset_number failed");
|
||||
|
||||
if (json_object_dotset_string(meta, "ovni.loom", rproc.loom) != 0)
|
||||
die("json_object_dotset_string failed");
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user