rotation-api: pass session name explicitly
[lttng-tools.git] / include / lttng / rotation.h
index 9b797ac11c2783256c420f1cd70b22da08c835bd..6091a7b988078039f73d641a6329cd6045f21701 100644 (file)
@@ -20,6 +20,7 @@
 #define LTTNG_ROTATION_H
 
 #include <stdint.h>
+#include <lttng/location.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -29,15 +30,19 @@ extern "C" {
  * Return codes for lttng_rotation_handle_get_state()
  */
 enum lttng_rotation_state {
+       /*
+        * Session has not been rotated.
+        */
+       LTTNG_ROTATION_STATE_NO_ROTATION = 0,
        /*
         * Rotation is ongoing, but has not been completed yet.
         */
-       LTTNG_ROTATION_STATE_ONGOING = 0,
+       LTTNG_ROTATION_STATE_ONGOING = 1,
        /*
         * Rotation has been completed and the resulting chunk
         * can now safely be read.
         */
-       LTTNG_ROTATION_STATE_COMPLETED = 1,
+       LTTNG_ROTATION_STATE_COMPLETED = 2,
        /*
         * The rotation has expired.
         *
@@ -48,11 +53,11 @@ enum lttng_rotation_state {
         * Note that this state does not guarantee the the rotation was
         * completed successfully.
         */
-       LTTNG_ROTATION_STATE_EXPIRED = 2,
+       LTTNG_ROTATION_STATE_EXPIRED = 3,
        /*
         * The rotation could not be completed due to an error.
         */
-       LTTNG_ROTATION_STATE_ERROR = 3,
+       LTTNG_ROTATION_STATE_ERROR = 4,
 };
 
 enum lttng_rotation_status {
@@ -83,25 +88,14 @@ struct lttng_rotation_schedule_attr;
 struct lttng_rotation_handle;
 
 /*
- * Return a newly allocated immediate session rotation descriptor object or NULL
- * on error.
- */
-extern struct lttng_rotation_immediate_attr *
-lttng_rotation_immediate_attr_create(void);
-
-/*
- * Return a newly allocated scheduled rotate session descriptor object or NULL
+ * Return a newly allocated session rotation schedule descriptor object or NULL
  * on error.
+ *
+ * The rotation schedule may be expressed as a size or as a time period.
  */
 extern struct lttng_rotation_schedule_attr *
 lttng_rotation_schedule_attr_create(void);
 
-/*
- * Destroy a given immediate session rotation descriptor object.
- */
-extern void lttng_rotation_immediate_attr_destroy(
-               struct lttng_rotation_immediate_attr *attr);
-
 /*
  * Destroy a given scheduled rotate session descriptor object.
  */
@@ -109,30 +103,16 @@ extern void lttng_rotation_schedule_attr_destroy(
                struct lttng_rotation_schedule_attr *attr);
 
 /*
- * Set the name of the session to rotate immediately.
- *
- * The session_name parameter is copied to the immediate session rotation
- * attributes.
- */
-extern enum lttng_rotation_status lttng_rotation_immediate_attr_set_session_name(
-               struct lttng_rotation_immediate_attr *attr,
-               const char *session_name);
-
-/*
- * Set the name of the session to rotate automatically.
- *
- * The session_name parameter is copied to the immediate session rotation
- * attributes.
+ * Set the timer to periodically rotate the session (in µs).
  */
-extern enum lttng_rotation_status lttng_rotation_schedule_attr_set_session_name(
-               struct lttng_rotation_schedule_attr *attr,
-               const char *session_name);
+extern enum lttng_rotation_status lttng_rotation_schedule_attr_set_timer_period(
+               struct lttng_rotation_schedule_attr *attr, uint64_t timer);
 
 /*
- * Set the timer to periodically rotate the session (µs, -1ULL to disable).
+ * Set the size to rotate the session (in bytes).
  */
-extern enum lttng_rotation_status lttng_rotation_schedule_attr_set_timer_period(
-               struct lttng_rotation_schedule_attr *attr, uint64_t timer);
+void lttng_rotation_schedule_attr_set_size(
+               struct lttng_rotation_schedule_attr *attr, uint64_t size);
 
 /*
  * lttng rotate session handle functions.
@@ -152,16 +132,14 @@ extern enum lttng_rotation_status lttng_rotation_handle_get_state(
  * Get the location of the rotation's resulting archive.
  *
  * The rotation must be completed in order for this call to succeed.
- * The path returned is owned by the rotation handle.
+ * The location returned remains owned by the rotation handle.
  *
- * Note that path will not be set in case of error, or if the session
- * rotation has expired.
- *
- * FIXME: Return an lttng_location object instead of a path.
+ * Note that location will not be set in case of error, or if the session
+ * rotation handle has expired.
  */
-extern enum lttng_rotation_status lttng_rotation_handle_get_completed_archive_location(
+extern enum lttng_rotation_status lttng_rotation_handle_get_archive_location(
                struct lttng_rotation_handle *rotation_handle,
-               const char **path);
+               const struct lttng_trace_archive_location **location);
 
 /*
  * Destroy an lttng_rotate_session handle.
@@ -170,24 +148,48 @@ extern void lttng_rotation_handle_destroy(
                struct lttng_rotation_handle *rotation_handle);
 
 /*
- * Rotate the output folder of the session
+ * Rotate the output folder of the session.
  *
  * On success, handle is allocated and can be used to monitor the progress
  * of the rotation with lttng_rotation_get_state(). The handle must be freed
  * by the caller with lttng_rotation_handle_destroy().
  *
+ * Passing NULL as the immediate rotation attribute results in the default
+ * options being used.
+ *
  * Return 0 if the rotate action was successfully launched or a negative
  * LTTng error code on error.
  */
-extern int lttng_rotate_session(struct lttng_rotation_immediate_attr *attr,
+extern int lttng_rotate_session(const char *session_name,
+               struct lttng_rotation_immediate_attr *attr,
                struct lttng_rotation_handle **rotation_handle);
 
 /*
- * Configure a session to rotate periodically or based on the size written.
+ * Configure a session to rotate according to a given schedule.
  */
-extern int lttng_rotation_set_schedule(
+extern int lttng_rotation_set_schedule(const char *session_name,
                struct lttng_rotation_schedule_attr *attr);
 
+/*
+ * Ask the sessiond for the value of the rotate timer (in micro-seconds) of the
+ * session.
+ *
+ * On success, return 0 and set the value or rotate_timer, on error return a
+ * negative value.
+ */
+extern int lttng_rotation_schedule_get_timer_period(const char *session_name,
+               uint64_t *rotate_timer);
+
+/*
+ * Ask the sessiond for the value of the rotate size (in micro-seconds) of the
+ * session.
+ *
+ * On success, return 0 and set the value or rotate_size, on error return
+ * a negative value.
+ */
+extern int lttng_rotation_schedule_get_size(const char *session_name,
+               uint64_t *rotate_size);
+
 #ifdef __cplusplus
 }
 #endif
This page took 0.026107 seconds and 5 git commands to generate.