master
h 48 lines 1.83 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #ifndef NETDATA_REGISTRY_MACHINE_H
4 #define NETDATA_REGISTRY_MACHINE_H 1
5
6 #include "registry_internals.h"
7
8 // ----------------------------------------------------------------------------
9 // MACHINE structures
10
11 // For each MACHINE-URL pair we keep this
12 struct registry_machine_url {
13 STRING *url; // de-duplicated URL
14
15 uint8_t flags;
16
17 uint32_t first_t; // the first time we saw this
18 uint32_t last_t; // the last time we saw this
19 uint32_t usages; // how many times this has been accessed
20
21 struct registry_machine_url *prev, *next;
22 };
23 typedef struct registry_machine_url REGISTRY_MACHINE_URL;
24
25 // A machine
26 struct registry_machine {
27 char guid[GUID_LEN + 1]; // the GUID
28
29 uint32_t links; // the number of REGISTRY_PERSON_URL linked to this machine
30
31 REGISTRY_MACHINE_URL *machine_urls; // MACHINE_URL *
32
33 uint32_t first_t; // the first time we saw this
34 uint32_t last_t; // the last time we saw this
35 uint32_t usages; // how many times this has been accessed
36 };
37 typedef struct registry_machine REGISTRY_MACHINE;
38
39 REGISTRY_MACHINE *registry_machine_find(const char *machine_guid);
40 REGISTRY_MACHINE_URL *registry_machine_url_allocate(REGISTRY_MACHINE *m, STRING *u, time_t when);
41 REGISTRY_MACHINE *registry_machine_allocate(const char *machine_guid, time_t when);
42 REGISTRY_MACHINE *registry_machine_find_or_create(const char *machine_guid, time_t when, bool is_dummy);
43 REGISTRY_MACHINE_URL *registry_machine_link_to_url(REGISTRY_MACHINE *m, STRING *url, time_t when);
44
45 REGISTRY_MACHINE_URL *registry_machine_url_find(REGISTRY_MACHINE *m, STRING *url);
46 void registry_machine_url_unlink_from_machine_and_free(REGISTRY_MACHINE *m, REGISTRY_MACHINE_URL *mu);
47
48 #endif //NETDATA_REGISTRY_MACHINE_H