Add metadata version support
This commit is contained in:
parent
6fd2b51621
commit
6180235b50
14
ovni.c
14
ovni.c
@ -167,6 +167,19 @@ proc_set_app(int appid)
|
||||
die("json_object_set_number for app_id failed\n");
|
||||
}
|
||||
|
||||
static void
|
||||
proc_set_version(void)
|
||||
{
|
||||
JSON_Object *meta = json_value_get_object(rproc.meta);
|
||||
|
||||
if(meta == NULL)
|
||||
die("json_value_get_object failed\n");
|
||||
|
||||
if(json_object_set_number(meta, "version", OVNI_METADATA_VERSION) != 0)
|
||||
die("json_object_set_number for app_id failed\n");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ovni_proc_set_rank(int rank, int nranks)
|
||||
{
|
||||
@ -246,6 +259,7 @@ ovni_proc_init(int app, const char *loom, int pid)
|
||||
|
||||
rproc.ready = 1;
|
||||
|
||||
proc_set_version();
|
||||
proc_set_app(app);
|
||||
}
|
||||
|
||||
|
2
ovni.h
2
ovni.h
@ -40,6 +40,8 @@ extern "C" {
|
||||
/* Hardcode the JSON_Value to avoid a dependency with janson */
|
||||
typedef struct json_value_t JSON_Value;
|
||||
|
||||
#define OVNI_METADATA_VERSION 1
|
||||
|
||||
#define OVNI_TRACEDIR "ovni"
|
||||
#define OVNI_MAX_HOSTNAME 512
|
||||
|
||||
|
25
trace.c
25
trace.c
@ -124,6 +124,29 @@ load_proc_metadata(struct ovni_eproc *proc, int *rank_enabled)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
check_metadata_version(struct ovni_eproc *proc)
|
||||
{
|
||||
JSON_Object *meta = json_value_get_object(proc->meta);
|
||||
if(meta == NULL)
|
||||
die("check_metadata_version: json_value_get_object() failed\n");
|
||||
|
||||
JSON_Value *version_val = json_object_get_value(meta, "version");
|
||||
if(version_val == NULL)
|
||||
{
|
||||
die("process %d is missing attribute \"version\" in metadata\n",
|
||||
proc->pid);
|
||||
}
|
||||
|
||||
int version = (int) json_number(version_val);
|
||||
|
||||
if(version != OVNI_METADATA_VERSION)
|
||||
{
|
||||
die("pid %d: metadata version mismatch %d (expected %d)\n",
|
||||
proc->pid, version,
|
||||
OVNI_METADATA_VERSION);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
load_proc(struct ovni_eproc *proc, struct ovni_loom *loom, int index, int pid, char *procdir)
|
||||
@ -156,6 +179,8 @@ load_proc(struct ovni_eproc *proc, struct ovni_loom *loom, int index, int pid, c
|
||||
return -1;
|
||||
}
|
||||
|
||||
check_metadata_version(proc);
|
||||
|
||||
/* The appid is populated from the metadata */
|
||||
load_proc_metadata(proc, &loom->rank_enabled);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user