Fix: handle the registration done command for JUL
[lttng-tools.git] / src / bin / lttng-sessiond / jul.h
CommitLineData
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
96090c92
MD
18#ifndef LTTNG_SESSIOND_JUL_H
19#define LTTNG_SESSIOND_JUL_H
0475c50c 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 */
31struct 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 */
37struct jul_register_msg {
38 uint32_t pid;
39};
40
41/*
6657149e
MD
42 * JUL application object created after a successful registration. This
43 * object is linked to its associated UST app by their PID through hash
44 * table lookups.
f20baf8e
DG
45 */
46struct jul_app {
47 /*
48 * PID sent during registration of a JUL application.
49 */
50 pid_t pid;
51
52 /*
53 * JUL TCP socket that was created upon registration.
54 */
55 struct lttcomm_sock *sock;
56
f20baf8e
DG
57 /* Initialized with the JUL sock value. */
58 struct lttng_ht_node_ulong node;
59};
60
0475c50c
DG
61/*
62 * Java Util Logging event representation.
63 */
64struct jul_event {
65 /*
66 * Name of the event which is directly mapped to a Logger object name in
67 * the JUL API.
68 */
69 char name[LTTNG_SYMBOL_NAME_LEN];
b2064f54
DG
70 enum lttng_loglevel_jul loglevel;
71 enum lttng_loglevel_type loglevel_type;
0475c50c
DG
72
73 /*
74 * Tells if the event is enabled or not on the JUL Agent.
75 */
76 unsigned int enabled:1;
77
78 /*
79 * Hash table nodes of the JUL domain. Indexed by name string.
80 */
81 struct lttng_ht_node_str node;
82};
83
84/*
85 * Top level data structure in a UST session containing JUL event name created
86 * for it.
87 */
88struct jul_domain {
3c6a091f
DG
89 /*
90 * This indicates if that domain is being used meaning if at least one
91 * event has been at some point in time added to it. This is used so when
92 * listing domains for a session, we can tell or not if the JUL is actually
93 * enabled.
94 */
95 unsigned int being_used:1;
0475c50c
DG
96 /*
97 * Contains JUL event indexed by name.
98 */
99 struct lttng_ht *events;
100};
101
f20baf8e
DG
102/* Initialize JUL domain subsystem. */
103int jul_init(void);
104
105/* Initialize an already allocated JUL domain. */
0475c50c 106int jul_init_domain(struct jul_domain *dom);
f20baf8e
DG
107void jul_destroy_domain(struct jul_domain *dom);
108
109/* JUL event API. */
0475c50c
DG
110struct jul_event *jul_create_event(const char *name);
111void jul_add_event(struct jul_event *event, struct jul_domain *dom);
112struct jul_event *jul_find_by_name(const char *name, struct jul_domain *dom);
113void jul_delete_event(struct jul_event *event, struct jul_domain *dom);
114void jul_destroy_event(struct jul_event *event);
f20baf8e
DG
115
116/* JUL app API. */
117struct jul_app *jul_create_app(pid_t pid, struct lttcomm_sock *sock);
118void jul_add_app(struct jul_app *app);
119void jul_delete_app(struct jul_app *app);
120struct jul_app *jul_find_app_by_sock(int sock);
f20baf8e 121void jul_destroy_app(struct jul_app *app);
1b500e7a 122int jul_send_registration_done(struct jul_app *app);
f20baf8e
DG
123
124/* JUL action API */
125int jul_enable_event(struct jul_event *event);
126int jul_disable_event(struct jul_event *event);
127void jul_update(struct jul_domain *domain, int sock);
3c6a091f 128int jul_list_events(struct lttng_event **events);
0475c50c 129
96090c92 130#endif /* LTTNG_SESSIOND_JUL_H */
This page took 0.028576 seconds and 4 git commands to generate.