-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[19942] Make remove unused entities compatible with the discovery trigger #83
Open
Tempate
wants to merge
5
commits into
main
Choose a base branch
from
feature/dynamic_tracks_discovery_trigger
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
01b592e
Make remove unused entities compatible with the discovery trigger
Tempate ddae53b
Generate the routes outside of the DdsBridge
Tempate e77bab7
Uncrustify
Tempate e00db76
Apply suggestions
Tempate 0789d95
Apply suggestions
Tempate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,12 @@ | |
#include <ddspipe_core/communication/Bridge.hpp> | ||
#include <ddspipe_core/communication/dds/Track.hpp> | ||
#include <ddspipe_core/configuration/RoutesConfiguration.hpp> | ||
#include <ddspipe_core/types/dds/Endpoint.hpp> | ||
#include <ddspipe_core/types/topic/dds/DistributedTopic.hpp> | ||
#include <ddspipe_core/types/topic/filter/ManualTopic.hpp> | ||
#include <ddspipe_core/types/topic/filter/WildcardDdsFilterTopic.hpp> | ||
|
||
|
||
namespace eprosima { | ||
namespace ddspipe { | ||
namespace core { | ||
|
@@ -49,7 +51,10 @@ class DdsBridge : public Bridge | |
* @param participant_database: Collection of Participants to manage communication | ||
* @param payload_pool: Payload Pool that handles the reservation/release of payloads throughout the DDS Router | ||
* @param thread_pool: Shared pool of threads in charge of data transmission. | ||
* @param enable: Whether the Bridge should be initialized as enabled | ||
* @param routes_config: Configuration of the routes of the Bridge | ||
* @param remove_unused_entities: Whether the Bridge should remove unused entities | ||
* @param manual_topics: Topics that explicitally set a QoS attribute for this participant | ||
* @param endpoint_kind: Kind of the endpoint that discovered the topic | ||
* | ||
* @throw InitializationException in case \c IWriters or \c IReaders creation fails. | ||
*/ | ||
|
@@ -61,7 +66,8 @@ class DdsBridge : public Bridge | |
const std::shared_ptr<utils::SlotThreadPool>& thread_pool, | ||
const RoutesConfiguration& routes_config, | ||
const bool remove_unused_entities, | ||
const std::vector<core::types::ManualTopic>& manual_topics); | ||
const std::vector<core::types::ManualTopic>& manual_topics, | ||
const types::EndpointKind& endpoint_kind); | ||
juanlofer-eprosima marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
DDSPIPE_CORE_DllAPI | ||
~DdsBridge(); | ||
|
@@ -85,76 +91,120 @@ class DdsBridge : public Bridge | |
void disable() noexcept override; | ||
|
||
/** | ||
* Build the IReaders and IWriters inside the bridge for the new participant, | ||
* and add them to the Tracks. | ||
* Create a new endpoint in the bridge. | ||
* | ||
* Thread safe | ||
* It will call either \c create_writer_and_its_tracks_nts_ or \c create_reader_and_its_track_nts_ depending on the | ||
* \c discovered_endpoint_kind. | ||
* | ||
* @param participant_id: The id of the participant who is creating the writer. | ||
* @param participant_id: The id of the participant who is creating the endpoint. | ||
* @param discovered_endpoint_kind: The kind of endpoint that has been discovered. | ||
* | ||
* @throw InitializationException in case \c IWriters or \c IReaders creation fails. | ||
* Thread safe. | ||
*/ | ||
DDSPIPE_CORE_DllAPI | ||
void create_writer( | ||
const types::ParticipantId& participant_id); | ||
void create_endpoint( | ||
const types::ParticipantId& participant_id, | ||
const types::EndpointKind& discovered_endpoint_kind); | ||
|
||
/** | ||
* Remove the IWriter from all the Tracks in the bridge. | ||
* Remove the IReaders and Tracks that don't have any IWriters. | ||
* Remove an endpoint from the bridge. | ||
* | ||
* Thread safe | ||
* It will call either \c remove_writer_and_its_tracks_nts_ or \c remove_reader_and_its_track_nts_ depending on the | ||
* \c removed_endpoint_kind. | ||
* | ||
* @param participant_id: The id of the participant who is removing the writer. | ||
* @param participant_id: The id of the participant who is removing the endpoint. | ||
* @param removed_endpoint_kind: The kind of endpoint that has been removed. | ||
* | ||
* Thread safe. | ||
*/ | ||
DDSPIPE_CORE_DllAPI | ||
void remove_writer( | ||
const types::ParticipantId& participant_id) noexcept; | ||
void remove_endpoint( | ||
const types::ParticipantId& participant_id, | ||
const types::EndpointKind& removed_endpoint_kind); | ||
|
||
protected: | ||
|
||
/** | ||
* Create the readers, writers, and tracks that are required by the routes. | ||
* Create an IWriter for the new participant. | ||
* Create the IReaders in the IWriter's route. | ||
* Create the Tracks of the IReaders with the IWriter. | ||
* | ||
* Thread safe | ||
* @param participant_id: The id of the participant who is creating the writer. | ||
* | ||
* @throw InitializationException in case \c IWriters or \c IReaders creation fails. | ||
*/ | ||
DDSPIPE_CORE_DllAPI | ||
void create_all_tracks_(); | ||
void create_writer_and_its_tracks_nts_( | ||
const types::ParticipantId& participant_id); | ||
|
||
/** | ||
* Add each Participant's IWriters to its Track. | ||
* If the Participant's IReader doesn't exist, create it. | ||
* If the Participant's Track doesn't exist, create it. | ||
* Create an IReader for the new participant. | ||
* Create the IWriters in the IReader's route. | ||
* Create the Track with the IReader and IWriters. | ||
* | ||
* @param writers: The map of ids to writers that are required for the tracks. | ||
* @param participant_id: The id of the participant who is creating the reader. | ||
* | ||
* @throw InitializationException in case \c IReaders creation fails. | ||
* @throw InitializationException in case \c IWriters or \c IReaders creation fails. | ||
*/ | ||
DDSPIPE_CORE_DllAPI | ||
void add_writer_to_tracks_nts_( | ||
const types::ParticipantId& participant_id, | ||
std::shared_ptr<IWriter>& writer); | ||
void create_reader_and_its_track_nts_( | ||
const types::ParticipantId& participant_id); | ||
|
||
/** | ||
* Remove the IWriter from all the Tracks. | ||
* Remove the IReaders and Tracks without IWriters. | ||
* | ||
* @param participant_id: The id of the participant who is removing the writer. | ||
*/ | ||
void remove_writer_and_its_tracks_nts_( | ||
const types::ParticipantId& participant_id) noexcept; | ||
|
||
/** | ||
* Add each Participant's IWriters to its Track. | ||
* If the Participant's IReader doesn't exist, create it. | ||
* If the Participant's Track doesn't exist, create it. | ||
* Remove the IReader and its Track. | ||
* Remove the IWriters that no longer belong to a Track. | ||
* | ||
* @param writers: The map of ids to writers that are required for the tracks. | ||
* @param participant_id: The id of the participant who is removing the reader. | ||
*/ | ||
void remove_reader_and_its_track_nts_( | ||
const types::ParticipantId& participant_id) noexcept; | ||
|
||
/** | ||
* @brief Create a Track for an IReader and its IWriters. | ||
* | ||
* @throw InitializationException in case \c IReaders creation fails. | ||
* @param id: The id of the participant who is creating the track. | ||
* @param reader: The IReader of the track. | ||
* @param writers: The IWriters of the track. | ||
*/ | ||
DDSPIPE_CORE_DllAPI | ||
void add_writers_to_tracks_nts_( | ||
void create_track_nts_( | ||
const types::ParticipantId& id, | ||
const std::shared_ptr<IReader>& reader, | ||
std::map<types::ParticipantId, std::shared_ptr<IWriter>>& writers); | ||
|
||
/** | ||
* @brief Create an IWriter for a participant in the topic. | ||
* | ||
* A tailored Topic is created for the participant, depending on the QoS configured for it. | ||
* | ||
* @param participant_id: The id of the participant who is creating the writer. | ||
*/ | ||
std::shared_ptr<core::IWriter> create_writer_nts_( | ||
const types::ParticipantId& participant_id); | ||
|
||
/** | ||
* @brief Create an IReader for a participant in the topic. | ||
* | ||
* A tailored Topic is created for the participant, depending on the QoS configured for it. | ||
* | ||
* @param participant_id: The id of the participant who is creating the reader. | ||
*/ | ||
std::shared_ptr<core::IReader> create_reader_nts_( | ||
const types::ParticipantId& participant_id); | ||
|
||
/** | ||
* @brief Impose the Topic QoS that have been pre-configured for a participant. | ||
* | ||
* First, it imposes the Topic QoS configured at \c manual_topics and then the ones configured at \c participants. | ||
* | ||
* @param participant: The participant to impose the QoS on. | ||
*/ | ||
DDSPIPE_CORE_DllAPI | ||
utils::Heritable<types::DistributedTopic> create_topic_for_participant_nts_( | ||
const std::shared_ptr<IParticipant>& participant) noexcept; | ||
|
||
|
@@ -166,17 +216,18 @@ class DdsBridge : public Bridge | |
utils::Heritable<types::DistributedTopic> topic_; | ||
|
||
//! Routes associated to the Topic. | ||
RoutesConfiguration::RoutesMap routes_; | ||
RoutesConfiguration::RoutesMap writers_in_route_; | ||
RoutesConfiguration::RoutesMap readers_in_route_; | ||
|
||
//! Topics that explicitally set a QoS attribute for this participant. | ||
std::vector<types::ManualTopic> manual_topics_; | ||
|
||
/** | ||
* Inside \c Tracks | ||
* They are indexed by the Id of the participant that is source | ||
*/ | ||
//! The tracks of the bridge indexed by the participant_id of their reader. | ||
std::map<types::ParticipantId, std::unique_ptr<Track>> tracks_; | ||
|
||
//! The writers of the bridge index by their participant_id. | ||
std::map<types::ParticipantId, std::shared_ptr<IWriter>> writers_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Design comment: up to now bridges contain tracks, and tracks the only ones holding reference to endpoints. Analyze implications (such as object lifespan) and try to maintain this principle if makes sense. |
||
|
||
//! Mutex to prevent simultaneous calls to enable and/or disable | ||
std::mutex mutex_; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: I believe DdsBridge should be agnostic (or at least has been until now) to discovery events. So instead of passing the kind of the endpoint that discovered the topic or was discovered, I would pass the kind of the endpoint that should be created.