-
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #83 +/- ##
==========================================
+ Coverage 34.10% 34.12% +0.01%
==========================================
Files 154 155 +1
Lines 7861 7881 +20
Branches 3515 3518 +3
==========================================
+ Hits 2681 2689 +8
- Misses 3267 3287 +20
+ Partials 1913 1905 -8 ☔ View full report in Codecov by Sentry. |
ddspipe_core/include/ddspipe_core/configuration/RoutesConfiguration.hpp
Outdated
Show resolved
Hide resolved
fd5c1bb
to
4428faa
Compare
4428faa
to
6abb4d6
Compare
ddspipe_core/include/ddspipe_core/communication/dds/DdsBridge.hpp
Outdated
Show resolved
Hide resolved
{ | ||
writer_it.second->disable(); | ||
} | ||
// Don't disable writers, as they may be used by other tracks |
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.
Although I agree this might make more sense, note that I believe this would imply a delayed abortion when stopping the pipe or blocking a topic (would keep looping through writers map until done). Also, I don't like the fact that this would make enable-disable asymmetrical.
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.
Not disabling the writers wasn't an aesthetic choice. If you disable the writers there are many scenarios that don't work or segfault with discovery-trigger
and remove-unused-entities
. If you propose another solution I may consider it.
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.
My comment was wrong, not disabling writers has no effect in how soon Track::transmit_ is aborted. After thinking about it, I prefer to leave it as it is: having "atomic" write operations for every taken data.
However, I still don't like the asymmetry. I propose:
- Leave it as it is but with a nice comment for future developers to consider.
- Do not enable writers in tracks' enable, create them always enabled and never disable, or handle enable/disable somewhere else (in DdsBridge for example, as long as we decide to keep the
writers_
attribute).
6abb4d6
to
1cf2453
Compare
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 comment
The 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.
} | ||
} | ||
else if (configuration_.remove_unused_entities && topic->topic_discoverer() != DEFAULT_PARTICIPANT_ID) | ||
{ | ||
// The bridge already exists. Create a writer in the participant who discovered it. | ||
it_bridge->second->create_writer(topic->topic_discoverer()); | ||
it_bridge->second->create_endpoint(topic->topic_discoverer(), endpoint_kind); |
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.
Design comment: call to endpoint creation method is done both from pipe and bridge. Analyze if it would be possible to further isolate their functionality so it's only done from one of them.
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.
Related: scope of remove_unused_endpoint
(used both in pipe and bridge).
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.
Piggyback: please add a comment explaining that comparison with DEFAULT_PARTICIPANT_ID
is used to determine whether topics are builtin.
{ | ||
writer_it.second->disable(); | ||
} | ||
// Don't disable writers, as they may be used by other tracks |
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.
My comment was wrong, not disabling writers has no effect in how soon Track::transmit_ is aborted. After thinking about it, I prefer to leave it as it is: having "atomic" write operations for every taken data.
However, I still don't like the asymmetry. I propose:
- Leave it as it is but with a nice comment for future developers to consider.
- Do not enable writers in tracks' enable, create them always enabled and never disable, or handle enable/disable somewhere else (in DdsBridge for example, as long as we decide to keep the
writers_
attribute).
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.
Piggyback request:
Please add to the participant's discovery traces the participant id (missing in endpoint removed/ignored/changed qos cases), I believe this is quite helpful for debugging.
* @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 |
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.
@@ -527,7 +531,8 @@ void DdsPipe::create_new_service_nts_( | |||
} | |||
|
|||
void DdsPipe::activate_topic_nts_( | |||
const utils::Heritable<DistributedTopic>& topic) noexcept | |||
const utils::Heritable<DistributedTopic>& topic, | |||
const EndpointKind& endpoint_kind /*= EndpointKind::reader*/) noexcept |
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.
Be careful with the following case: an endpoint is discovered while its topic is blocked, then it is only added to current_topics_
hence losing the kind information. So if the topic is then allowed, a bridge is wrongly created with the default kind value.
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.
Related scenario: subsequent relevant discovered endpoints would not be taken into account, but only the first one (used in DdsBridge constructor).
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.
Potential solution: create an EndpointsManager that would keep track of all created endpoints, and also the ones that should be created once enabled (so DdsBridges will always be created even if the topic is disabled). This new object would then contain all references of entities, so the creation of a track would require passing a reference to this object as well as a map of ids.
// Add the writer to the tracks it has routes for. | ||
add_writer_to_tracks_nts_(participant_id, writer); | ||
// Create the track | ||
create_track_nts_(participant_id, reader, writers_); |
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.
Shouldn't you be passing only the IWriters in the route?
assert(participant_id != DEFAULT_PARTICIPANT_ID); | ||
|
||
// Create the writer | ||
auto writer = create_writer_nts_(participant_id); |
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.
Another corner case: shouldn't we avoid creating writers if not present in any route?
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.
Related: should we also avoid creating a reader if there is a "blockage" route? I'd say yes.
Signed-off-by: tempate <danieldiaz@eprosima.com>
Signed-off-by: tempate <danieldiaz@eprosima.com>
Signed-off-by: tempate <danieldiaz@eprosima.com>
Signed-off-by: tempate <danieldiaz@eprosima.com>
Signed-off-by: tempate <danieldiaz@eprosima.com>
1cf2453
to
0789d95
Compare
RoutesConfiguration::RoutesMap RoutesConfiguration::routes_of_readers( | ||
const std::map<types::ParticipantId, bool>& participant_ids) const noexcept | ||
{ | ||
static RoutesConfiguration::RoutesMap readers_routes; |
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.
Remove static.
No description provided.