b6be533997c471ba83dbfd87502286cdbd99ed95
[lttng-tools.git] / src / common / consumer / consumer-stream.h
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 LTTNG_CONSUMER_STREAM_H
19 #define LTTNG_CONSUMER_STREAM_H
20
21 #include "consumer.h"
22
23 /*
24 * Create a consumer stream.
25 *
26 * The channel lock MUST be acquired.
27 */
28 struct lttng_consumer_stream *consumer_stream_create(
29 struct lttng_consumer_channel *channel,
30 uint64_t channel_key,
31 uint64_t stream_key,
32 const char *channel_name,
33 uint64_t relayd_id,
34 uint64_t session_id,
35 struct lttng_trace_chunk *trace_chunk,
36 int cpu,
37 int *alloc_ret,
38 enum consumer_channel_type type,
39 unsigned int monitor);
40
41 /*
42 * Close stream's file descriptors and, if needed, close stream also on the
43 * relayd side.
44 *
45 * The stream lock MUST be acquired.
46 * The consumer data lock MUST be acquired.
47 */
48 void consumer_stream_close(struct lttng_consumer_stream *stream);
49
50 /*
51 * Close stream on the relayd side. This call can destroy a relayd if the
52 * conditions are met.
53 *
54 * A RCU read side lock MUST be acquired if the relayd object was looked up in
55 * a hash table before calling this.
56 */
57 void consumer_stream_relayd_close(struct lttng_consumer_stream *stream,
58 struct consumer_relayd_sock_pair *relayd);
59
60 /*
61 * Delete the stream from all possible hash tables.
62 *
63 * The consumer data lock MUST be acquired.
64 */
65 void consumer_stream_delete(struct lttng_consumer_stream *stream,
66 struct lttng_ht *ht);
67
68 /*
69 * Free the given stream within a RCU call.
70 */
71 void consumer_stream_free(struct lttng_consumer_stream *stream);
72
73 /*
74 * Destroy a stream completely. This will delete, close and free the stream.
75 * Once return, the stream is NO longer usable. Its channel may get destroyed
76 * if conditions are met.
77 *
78 * This MUST be called WITHOUT the consumer data and stream lock acquired.
79 */
80 void consumer_stream_destroy(struct lttng_consumer_stream *stream,
81 struct lttng_ht *ht);
82
83 /*
84 * Destroy the stream's buffers on the tracer side. This is also called in a
85 * stream destroy.
86 */
87 void consumer_stream_destroy_buffers(struct lttng_consumer_stream *stream);
88
89 /*
90 * Write index of a specific stream either on the relayd or local disk.
91 */
92 int consumer_stream_write_index(struct lttng_consumer_stream *stream,
93 struct ctf_packet_index *index);
94
95 int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx,
96 uint64_t session_id);
97
98 /*
99 * Create the output files of a local stream.
100 *
101 * This must be called with the channel's and the stream's lock held.
102 */
103 int consumer_stream_create_output_files(struct lttng_consumer_stream *stream,
104 bool create_index);
105
106 /*
107 * Rotate the output files of a local stream. This will change the
108 * active output files of both the binary and index in accordance
109 * with the stream's configuration (stream file count).
110 *
111 * This must be called with the channel's and the stream's lock held.
112 */
113 int consumer_stream_rotate_output_files(struct lttng_consumer_stream *stream);
114
115 /*
116 * Indicates whether or not a stream is logically deleted. A deleted stream
117 * should no longer be used; its existence is only garanteed by the RCU lock
118 * held by the caller.
119 *
120 * This function must be called with the RCU read side lock held.
121 */
122 bool consumer_stream_is_deleted(struct lttng_consumer_stream *stream);
123
124 #endif /* LTTNG_CONSUMER_STREAM_H */
This page took 0.031074 seconds and 3 git commands to generate.