Notification iterator: transform precondition checks to BT_ASSERT_PRE()
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 2 Mar 2018 00:08:30 +0000 (19:08 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 2 May 2019 03:41:50 +0000 (23:41 -0400)
commitf42867e2d049c1e7cad50cd097290a3adef8d54c
tree92c8c01f53a16a2a6b9ad9a3898d3183ff441694
parentf6ccaed94e575af57fe6bf38154771bee4871a2a
Notification iterator: transform precondition checks to BT_ASSERT_PRE()

Use BT_ASSERT_PRE() to assert that notification iterator preconditions
are satisfied instead of unconditional run-time checks.

A notification iterator now expects, for a given stream, that a
BT_NOTIFICATION_TYPE_STREAM_BEGIN notification is received as the first
notification, and a BT_NOTIFICATION_TYPE_PACKET_END notification as the
last one. It also expects that, for a given sequence of
BT_NOTIFICATION_TYPE_EVENT notifications which belong to the same
packet, a BT_NOTIFICATION_TYPE_PACKET_BEGIN notification is received
before and a BT_NOTIFICATION_TYPE_PACKET_END notification after.

A notification iterator does not automatically generate
BT_NOTIFICATION_TYPE_STREAM_BEGIN, BT_NOTIFICATION_TYPE_STREAM_END,
BT_NOTIFICATION_TYPE_PACKET_BEGIN, and BT_NOTIFICATION_TYPE_PACKET_END
notifications anymore. In developer mode, the iterator validates that
those notifications were emitted in the correct order and that no
notification is missing for the stream. This is made possible by a
notification sequence number. The first time a notification is received
by an iterator, the iterator sets its sequence number to the expected
one (previous sequence number for this stream plus one). Other iterators
validate that, for a given stream, the received notification's sequence
number is expected.

Because BT_NOTIFICATION_TYPE_STREAM_BEGIN,
BT_NOTIFICATION_TYPE_STREAM_END, BT_NOTIFICATION_TYPE_PACKET_BEGIN, and
BT_NOTIFICATION_TYPE_PACKET_END notifications are expected to be
manually emitted now, the concept of notification subscription is
removed. Each notification iterator user receives all the emitted
notifications, and either forwards the whole notification sequence (for
a given stream) as is or use them to create its own stream and
notifications.

Thanks to the notification sequence number, the stream's current
component port hash table is removed. A component can send notifications
from the same stream to two different ports now, but both streams of
notifications must be complete.

A notification iterator also checks that, when requested to be ended,
its stream is finished (BT_NOTIFICATION_TYPE_STREAM_END received). This
confirms that the iterator's user (consumer) received all the
notifications for a given stream and that nothing is discarded.

`plugins/ctf/common/notif-iter/notif-iter.c` is modified so that it
emits the required BT_NOTIFICATION_TYPE_STREAM_BEGIN notification as its
first one and BT_NOTIFICATION_TYPE_STREAM_END as its last one (when the
medium returns "end of stream"). In order to support multiple stream
files which contain packets of the same logical stream (LTTng's trace
file rotation), `plugins/ctf/fs-src/fs.c` is changed to ignore
"intermediate" BT_NOTIFICATION_TYPE_STREAM_BEGIN and
BT_NOTIFICATION_TYPE_STREAM_END notifications when it resets its CTF
notification iterator (`notif-iter`) between stream files.

Python bindings, some plugins, and some tests are not updated and could
not work as of this patch because further changes in the same patch set
will significantly change them anyway. The changes also do not deal with
BT_NOTIFICATION_TYPE_DISCARDED_EVENTS and
BT_NOTIFICATION_TYPE_DISCARDED_PACKETS notification types as I plan to
remove those types and make this information part of the
BT_NOTIFICATION_TYPE_PACKET_BEGIN type.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
27 files changed:
include/babeltrace/ctf-ir/stream-internal.h
include/babeltrace/graph/component-class-sink-colander-internal.h
include/babeltrace/graph/notification-internal.h
include/babeltrace/graph/notification-iterator-internal.h
include/babeltrace/graph/notification.h
include/babeltrace/graph/output-port-notification-iterator.h
include/babeltrace/graph/private-connection.h
lib/ctf-ir/stream.c
lib/graph/component-class-sink-colander.c
lib/graph/connection.c
lib/graph/iterator.c
lib/graph/notification/inactivity.c
lib/graph/notification/notification.c
plugins/ctf/common/notif-iter/notif-iter.c
plugins/ctf/common/notif-iter/notif-iter.h
plugins/ctf/fs-sink/writer.c
plugins/ctf/fs-src/fs.c
plugins/ctf/fs-src/fs.h
plugins/lttng-utils/plugin.c
plugins/text/pretty/pretty.c
plugins/utils/counter/counter.c
plugins/utils/dummy/dummy.c
plugins/utils/muxer/muxer.c
plugins/utils/trimmer/iterator.c
tests/lib/test_bt_notification_heap.c
tests/lib/test_bt_notification_iterator.c
tests/plugins/test-utils-muxer.c
This page took 0.02782 seconds and 4 git commands to generate.