| 1 | /* |
| 2 | * Copyright (C) 2013 David Goulet <dgoulet@efficios.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0-only |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef SNAPSHOT_H |
| 9 | #define SNAPSHOT_H |
| 10 | |
| 11 | #include <limits.h> |
| 12 | #include <stdint.h> |
| 13 | |
| 14 | #include <common/common.h> |
| 15 | #include <common/hashtable/hashtable.h> |
| 16 | #include <common/uri.h> |
| 17 | |
| 18 | #include "consumer.h" |
| 19 | |
| 20 | struct consumer_output; |
| 21 | struct ltt_session; |
| 22 | |
| 23 | struct snapshot_output { |
| 24 | uint32_t id; |
| 25 | uint64_t max_size; |
| 26 | /* Number of snapshot taken with that output. */ |
| 27 | uint64_t nb_snapshot; |
| 28 | char name[NAME_MAX]; |
| 29 | struct consumer_output *consumer; |
| 30 | int kernel_sockets_copied; |
| 31 | int ust_sockets_copied; |
| 32 | /* |
| 33 | * Contains the string with "<date>-<time>" for when the snapshot command |
| 34 | * is triggered. This is to make sure every streams will use the same time |
| 35 | * for the directory output. |
| 36 | */ |
| 37 | char datetime[16]; |
| 38 | |
| 39 | /* Indexed by ID. */ |
| 40 | struct lttng_ht_node_ulong node; |
| 41 | }; |
| 42 | |
| 43 | struct snapshot { |
| 44 | unsigned long next_output_id; |
| 45 | size_t nb_output; |
| 46 | /* |
| 47 | * Number of snapshot taken for that object. This value is used with a |
| 48 | * temporary output of a snapshot record. |
| 49 | */ |
| 50 | uint64_t nb_snapshot; |
| 51 | struct lttng_ht *output_ht; |
| 52 | }; |
| 53 | |
| 54 | /* Snapshot object. */ |
| 55 | struct snapshot *snapshot_alloc(void); |
| 56 | void snapshot_destroy(struct snapshot *obj); |
| 57 | int snapshot_init(struct snapshot *obj); |
| 58 | void snapshot_delete_output(struct snapshot *snapshot, |
| 59 | struct snapshot_output *output); |
| 60 | void snapshot_add_output(struct snapshot *snapshot, |
| 61 | struct snapshot_output *output); |
| 62 | |
| 63 | /* Snapshot output object. */ |
| 64 | struct snapshot_output *snapshot_output_alloc(void); |
| 65 | void snapshot_output_destroy(struct snapshot_output *obj); |
| 66 | int snapshot_output_init(const struct ltt_session *session, |
| 67 | uint64_t max_size, const char *name, |
| 68 | const char *ctrl_url, const char *data_url, |
| 69 | struct consumer_output *consumer, struct snapshot_output *output, |
| 70 | struct snapshot *snapshot); |
| 71 | int snapshot_output_init_with_uri(const struct ltt_session *session, |
| 72 | uint64_t max_size, const char *name, |
| 73 | struct lttng_uri *uris, size_t nb_uri, |
| 74 | struct consumer_output *consumer, struct snapshot_output *output, |
| 75 | struct snapshot *snapshot); |
| 76 | struct snapshot_output *snapshot_find_output_by_id(uint32_t id, |
| 77 | struct snapshot *snapshot); |
| 78 | struct snapshot_output *snapshot_find_output_by_name(const char *name, |
| 79 | struct snapshot *snapshot); |
| 80 | |
| 81 | #endif /* SNAPSHOT_H */ |