1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

path: add UUID

This commit is contained in:
Steffen Vogel 2020-08-17 17:01:36 +02:00
parent 487d90fc10
commit c191b15809
2 changed files with 26 additions and 7 deletions

View file

@ -31,6 +31,7 @@
#include <bitset>
#include <uuid/uuid.h>
#include <pthread.h>
#include <jansson.h>
@ -59,6 +60,8 @@ struct vpath {
enum PathMode mode; /**< Determines when this path is triggered. */
uuid_t uuid;
struct {
int nfds;
struct pollfd *pfds;
@ -79,10 +82,10 @@ struct vpath {
double rate; /**< A timeout for */
int enabled; /**< Is this path enabled. */
int poll; /**< Weather or not to use poll(2). */
int reverse; /**< This path as a matching reverse path. */
int reverse; /**< This path has a matching reverse path. */
int builtin; /**< This path should use built-in hooks by default. */
int original_sequence_no; /**< Use original source sequence number when multiplexing */
unsigned queuelen; /**< The queue length for each path_destination::queue */
int original_sequence_no; /**< Use original source sequence number when multiplexing */
unsigned queuelen; /**< The queue length for each path_destination::queue */
char *_name; /**< Singleton: A string which is used to print this path to screen. */
@ -92,7 +95,7 @@ struct vpath {
villas::Logger logger;
std::bitset<MAX_SAMPLE_LENGTH> mask; /**< A mask of path_sources which are enabled for poll(). */
std::bitset<MAX_SAMPLE_LENGTH> received; /**< A mask of path_sources for which we already received samples. */
std::bitset<MAX_SAMPLE_LENGTH> received; /**< A mask of path_sources for which we already received samples. */
};
/** Initialize internal data structures. */

View file

@ -27,6 +27,7 @@
#include <unistd.h>
#include <poll.h>
#include <openssl/md5.h>
#include <villas/node/config.h>
#include <villas/utils.hpp>
@ -323,12 +324,12 @@ int path_parse(struct vpath *p, json_t *cfg, struct vlist *nodes)
json_t *json_hooks = nullptr;
json_t *json_mask = nullptr;
const char *mode = nullptr;
const char *mode = nullptr, *uuid = nullptr;
struct vlist destinations;
vlist_init(&destinations);
ret = json_unpack_ex(cfg, &err, 0, "{ s: o, s?: o, s?: o, s?: b, s?: b, s?: b, s?: i, s?: s, s?: b, s?: F, s?: o, s?: b}",
ret = json_unpack_ex(cfg, &err, 0, "{ s: o, s?: o, s?: o, s?: b, s?: b, s?: b, s?: i, s?: s, s?: b, s?: F, s?: o, s?: b, s?: s}",
"in", &json_in,
"out", &json_out,
"hooks", &json_hooks,
@ -340,7 +341,8 @@ int path_parse(struct vpath *p, json_t *cfg, struct vlist *nodes)
"poll", &p->poll,
"rate", &p->rate,
"mask", &json_mask,
"original_sequence_no", &p->original_sequence_no
"original_sequence_no", &p->original_sequence_no,
"uuid", &uuid
);
if (ret)
jerror(&err, "Failed to parse path configuration");
@ -364,6 +366,20 @@ int path_parse(struct vpath *p, json_t *cfg, struct vlist *nodes)
}
}
if (uuid) {
ret = uuid_parse(uuid, p->uuid);
if (ret)
throw ConfigError(cfg, "node-config-path-uuid", "Failed to parse UUID: {}", uuid);
}
else {
/* Generate UUID from hashed config */
char *json_str = json_dumps(cfg, JSON_COMPACT | JSON_SORT_KEYS);
MD5((unsigned char*) json_str, strlen(json_str), (unsigned char*) &p->uuid);
free(json_str);
}
/* Output node(s) */
if (json_out) {
ret = node_list_parse(&destinations, json_out, nodes);