Commit | Line | Data |
---|---|---|
db66e574 JD |
1 | /* |
2 | * Copyright (C) 2017 - Julien Desfossez <jdesfossez@efficios.com> | |
d68c9a04 | 3 | * Copyright (C) 2018 - Jérémie Galarneau <jeremie.galarneau@efficios.com> |
db66e574 JD |
4 | * |
5 | * This library is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License, version 2.1 only, | |
7 | * as published by the Free Software Foundation. | |
8 | * | |
9 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | |
12 | * for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU Lesser General Public License | |
15 | * along with this library; if not, write to the Free Software Foundation, | |
16 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | */ | |
18 | ||
19 | #ifndef LTTNG_ROTATION_H | |
20 | #define LTTNG_ROTATION_H | |
21 | ||
22 | #include <stdint.h> | |
23 | ||
24 | #ifdef __cplusplus | |
25 | extern "C" { | |
26 | #endif | |
27 | ||
28 | /* | |
d68c9a04 | 29 | * Return codes for lttng_rotation_handle_get_state() |
db66e574 | 30 | */ |
d68c9a04 | 31 | enum lttng_rotation_state { |
db66e574 | 32 | /* |
d68c9a04 | 33 | * Rotation is ongoing, but has not been completed yet. |
db66e574 | 34 | */ |
d68c9a04 | 35 | LTTNG_ROTATION_STATE_ONGOING = 0, |
db66e574 | 36 | /* |
d68c9a04 JD |
37 | * Rotation has been completed and the resulting chunk |
38 | * can now safely be read. | |
db66e574 | 39 | */ |
d68c9a04 | 40 | LTTNG_ROTATION_STATE_COMPLETED = 1, |
db66e574 | 41 | /* |
d68c9a04 JD |
42 | * The rotation has expired. |
43 | * | |
44 | * The information associated with a given rotation is eventually | |
45 | * purged by the session daemon. In such a case, the attributes of | |
46 | * the rotation, such as its path, may no longer be available. | |
47 | * | |
48 | * Note that this state does not guarantee the the rotation was | |
49 | * completed successfully. | |
db66e574 | 50 | */ |
d68c9a04 | 51 | LTTNG_ROTATION_STATE_EXPIRED = 2, |
db66e574 | 52 | /* |
d68c9a04 | 53 | * The rotation could not be completed due to an error. |
db66e574 | 54 | */ |
d68c9a04 JD |
55 | LTTNG_ROTATION_STATE_ERROR = 3, |
56 | }; | |
57 | ||
58 | enum lttng_rotation_status { | |
59 | LTTNG_ROTATION_STATUS_OK = 0, | |
60 | /* Information not available. */ | |
61 | LTTNG_ROTATION_STATUS_UNAVAILABLE = 1, | |
62 | /* Generic error. */ | |
63 | LTTNG_ROTATION_STATUS_ERROR = -1, | |
64 | /* Invalid parameters provided. */ | |
65 | LTTNG_ROTATION_STATUS_INVALID = -2, | |
db66e574 JD |
66 | }; |
67 | ||
d68c9a04 JD |
68 | /* |
69 | * Input parameter to the lttng_rotate_session command. | |
70 | * | |
71 | * An immediate rotation is performed as soon as possible by the tracers. | |
72 | * | |
73 | * The lttng_rotation_immediate_attr object is opaque to the user. Use the | |
74 | * helper functions below to access it. | |
75 | */ | |
76 | struct lttng_rotation_immediate_attr; | |
77 | ||
78 | /* | |
79 | * Handle used to represent a specific rotation. | |
80 | * | |
81 | * This object is opaque to the user. Use the helper functions below to access | |
82 | * it. | |
83 | */ | |
84 | struct lttng_rotation_handle; | |
85 | ||
86 | /* | |
87 | * Return a newly allocated immediate session rotation descriptor object or NULL | |
88 | * on error. | |
89 | */ | |
90 | extern struct lttng_rotation_immediate_attr * | |
91 | lttng_rotation_immediate_attr_create(void); | |
92 | ||
93 | /* | |
94 | * Destroy a given immediate session rotation descriptor object. | |
95 | */ | |
96 | extern void lttng_rotation_immediate_attr_destroy( | |
97 | struct lttng_rotation_immediate_attr *attr); | |
98 | ||
99 | /* | |
100 | * Set the name of the session to rotate immediately. | |
101 | * | |
102 | * The session_name parameter is copied to the immediate session rotation | |
103 | * attributes. | |
104 | */ | |
105 | extern enum lttng_rotation_status lttng_rotation_immediate_attr_set_session_name( | |
106 | struct lttng_rotation_immediate_attr *attr, | |
107 | const char *session_name); | |
108 | ||
109 | /* | |
110 | * Get the current state of the rotation referenced by the handle. | |
111 | * | |
112 | * This will issue a request to the session daemon on every call. Hence, | |
113 | * the result of this call may change over time. | |
114 | */ | |
115 | extern enum lttng_rotation_status lttng_rotation_handle_get_state( | |
116 | struct lttng_rotation_handle *rotation_handle, | |
117 | enum lttng_rotation_state *rotation_state); | |
118 | ||
119 | /* | |
120 | * Get the location of the rotation's resulting archive. | |
121 | * | |
122 | * The rotation must be completed in order for this call to succeed. | |
123 | * The path returned is owned by the rotation handle. | |
124 | * | |
125 | * Note that path will not be set in case of error, or if the session | |
126 | * rotation has expired. | |
127 | * | |
128 | * FIXME: Return an lttng_location object instead of a path. | |
129 | */ | |
130 | extern enum lttng_rotation_status lttng_rotation_handle_get_completed_archive_location( | |
131 | struct lttng_rotation_handle *rotation_handle, | |
132 | const char **path); | |
133 | ||
134 | /* | |
135 | * Destroy an lttng_rotate_session handle. | |
136 | */ | |
137 | extern void lttng_rotation_handle_destroy( | |
138 | struct lttng_rotation_handle *rotation_handle); | |
139 | ||
140 | /* | |
141 | * Rotate the output folder of the session | |
142 | * | |
143 | * On success, handle is allocated and can be used to monitor the progress | |
144 | * of the rotation with lttng_rotation_get_state(). The handle must be freed | |
145 | * by the caller with lttng_rotation_handle_destroy(). | |
146 | * | |
147 | * Return 0 if the rotate action was successfully launched or a negative | |
148 | * LTTng error code on error. | |
149 | */ | |
150 | extern int lttng_rotate_session(struct lttng_rotation_immediate_attr *attr, | |
151 | struct lttng_rotation_handle **rotation_handle); | |
152 | ||
db66e574 JD |
153 | #ifdef __cplusplus |
154 | } | |
155 | #endif | |
156 | ||
157 | #endif /* LTTNG_ROTATION_H */ |