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