Commit | Line | Data |
---|---|---|
0475c50c DG |
1 | /* |
2 | * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com> | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU General Public License, version 2 only, as | |
6 | * published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
11 | * more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License along with | |
14 | * this program; if not, write to the Free Software Foundation, Inc., 51 | |
15 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
16 | */ | |
17 | ||
18 | #ifndef _JUL_H | |
19 | #define _JUL_H | |
20 | ||
f20baf8e DG |
21 | #define _GNU_SOURCE |
22 | #include <inttypes.h> | |
23 | ||
0475c50c DG |
24 | #include <common/hashtable/hashtable.h> |
25 | #include <lttng/lttng.h> | |
26 | ||
f20baf8e DG |
27 | /* |
28 | * Hash table that contains the JUL app created upon registration indexed by | |
29 | * socket. | |
30 | */ | |
31 | struct lttng_ht *jul_apps_ht_by_sock; | |
32 | ||
33 | /* | |
34 | * Registration message payload from a JUL application. The PID is used to find | |
35 | * back the corresponding UST app object so both socket can be linked. | |
36 | */ | |
37 | struct jul_register_msg { | |
38 | uint32_t pid; | |
39 | }; | |
40 | ||
41 | /* | |
42 | * JUL application object created after a successful registration. This object | |
43 | * is kept inside an UST app. | |
44 | */ | |
45 | struct jul_app { | |
46 | /* | |
47 | * PID sent during registration of a JUL application. | |
48 | */ | |
49 | pid_t pid; | |
50 | ||
51 | /* | |
52 | * JUL TCP socket that was created upon registration. | |
53 | */ | |
54 | struct lttcomm_sock *sock; | |
55 | ||
56 | /* | |
57 | * Associated UST app. socket. To get a reference to the ust application | |
58 | * object corresponding to that socket, a lookup MUST be done each time | |
59 | * since there is important synchronization issue for the lockless hash | |
60 | * table shared accross multiple threads. | |
61 | */ | |
62 | int ust_app_sock; | |
63 | ||
64 | /* Initialized with the JUL sock value. */ | |
65 | struct lttng_ht_node_ulong node; | |
66 | }; | |
67 | ||
0475c50c DG |
68 | /* |
69 | * Java Util Logging event representation. | |
70 | */ | |
71 | struct jul_event { | |
72 | /* | |
73 | * Name of the event which is directly mapped to a Logger object name in | |
74 | * the JUL API. | |
75 | */ | |
76 | char name[LTTNG_SYMBOL_NAME_LEN]; | |
77 | ||
78 | /* | |
79 | * Tells if the event is enabled or not on the JUL Agent. | |
80 | */ | |
81 | unsigned int enabled:1; | |
82 | ||
83 | /* | |
84 | * Hash table nodes of the JUL domain. Indexed by name string. | |
85 | */ | |
86 | struct lttng_ht_node_str node; | |
87 | }; | |
88 | ||
89 | /* | |
90 | * Top level data structure in a UST session containing JUL event name created | |
91 | * for it. | |
92 | */ | |
93 | struct jul_domain { | |
3c6a091f DG |
94 | /* |
95 | * This indicates if that domain is being used meaning if at least one | |
96 | * event has been at some point in time added to it. This is used so when | |
97 | * listing domains for a session, we can tell or not if the JUL is actually | |
98 | * enabled. | |
99 | */ | |
100 | unsigned int being_used:1; | |
0475c50c DG |
101 | /* |
102 | * Contains JUL event indexed by name. | |
103 | */ | |
104 | struct lttng_ht *events; | |
105 | }; | |
106 | ||
f20baf8e DG |
107 | /* Initialize JUL domain subsystem. */ |
108 | int jul_init(void); | |
109 | ||
110 | /* Initialize an already allocated JUL domain. */ | |
0475c50c | 111 | int jul_init_domain(struct jul_domain *dom); |
f20baf8e DG |
112 | void jul_destroy_domain(struct jul_domain *dom); |
113 | ||
114 | /* JUL event API. */ | |
0475c50c DG |
115 | struct jul_event *jul_create_event(const char *name); |
116 | void jul_add_event(struct jul_event *event, struct jul_domain *dom); | |
117 | struct jul_event *jul_find_by_name(const char *name, struct jul_domain *dom); | |
118 | void jul_delete_event(struct jul_event *event, struct jul_domain *dom); | |
119 | void jul_destroy_event(struct jul_event *event); | |
f20baf8e DG |
120 | |
121 | /* JUL app API. */ | |
122 | struct jul_app *jul_create_app(pid_t pid, struct lttcomm_sock *sock); | |
123 | void jul_add_app(struct jul_app *app); | |
124 | void jul_delete_app(struct jul_app *app); | |
125 | struct jul_app *jul_find_app_by_sock(int sock); | |
126 | void jul_attach_app(struct jul_app *japp); | |
127 | void jul_detach_app(struct jul_app *app); | |
128 | void jul_destroy_app(struct jul_app *app); | |
129 | ||
130 | /* JUL action API */ | |
131 | int jul_enable_event(struct jul_event *event); | |
132 | int jul_disable_event(struct jul_event *event); | |
133 | void jul_update(struct jul_domain *domain, int sock); | |
3c6a091f | 134 | int jul_list_events(struct lttng_event **events); |
0475c50c DG |
135 | |
136 | #endif /* _JUL_H */ |