Skip to content

Commit 1b33309

Browse files
authored
Feature: RPC enhanced discovery (#5899)
* Refs #23361: Add related_entity_key to *BuiltinTopicData Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: Add unittest to BuiltinSerializationTests Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: Add serialization impl for related_entity_key Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: Add empty API for set_related_entity_key() Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: Add unittests for set_related_entity_key() Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: Add implementation for set_related_entity_key() Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: Add RPC Enhanced discovery BB tests Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: Add RPC Enhanced discovery implementation Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: CMakeLists.txt Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: Apply set_related_entity() Miguel's review Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: Apply Request Replier Miguel's review Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: Linter Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: Comment errata Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: Fix compilation without STATISTICS Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: versions.md Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: Apply second review Signed-off-by: Mario Dominguez <[email protected]> * Refs #23361: Improve discovery status in BB RPC Api classes as a consequence of Replier/Requester discovery listeners Signed-off-by: Mario Dominguez <[email protected]> --------- Signed-off-by: Mario Dominguez <[email protected]>
1 parent bf55d52 commit 1b33309

32 files changed

+1012
-125
lines changed

include/fastdds/dds/publisher/DataWriter.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct GUID_t;
4444

4545
namespace dds {
4646

47+
class DataReader;
4748
class PublisherListener;
4849
class PublisherImpl;
4950
class Publisher;
@@ -613,6 +614,24 @@ class DataWriter : public DomainEntity
613614
FASTDDS_EXPORTED_API ReturnCode_t set_sample_prefilter(
614615
std::shared_ptr<IContentFilter> prefilter);
615616

617+
/**
618+
* This operation sets the key of the DataReader that is related to this DataWriter.
619+
* This is used to establish a relationship between a DataReader and a DataWriter
620+
* in the context of RPC over DDS.
621+
*
622+
* @warning This operation is only valid if the entity is not enabled.
623+
*
624+
* @param [in] related_reader Pointer to the DataReader to set as related.
625+
*
626+
* @return RETCODE_OK if the key is set successfully.
627+
* @return RETCODE_ILLEGAL_OPERATION if this entity is enabled.
628+
* @return RETCODE_PRECONDITION_NOT_MET if the entity does not belong to the same participant.
629+
* @return RETCODE_BAD_PARAMETER if the provided GUID is unknown
630+
* or the pointer is not valid.
631+
*/
632+
FASTDDS_EXPORTED_API ReturnCode_t set_related_datareader(
633+
const DataReader* related_reader);
634+
616635
protected:
617636

618637
DataWriterImpl* impl_;

include/fastdds/dds/subscriber/DataReader.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class SubscriberImpl;
6565
class DataReaderImpl;
6666
class DataReaderListener;
6767
class DataReaderQos;
68+
class DataWriter;
6869
class TopicDescription;
6970
struct LivelinessChangedStatus;
7071

@@ -1088,6 +1089,24 @@ class DataReader : public DomainEntity
10881089
FASTDDS_EXPORTED_API ReturnCode_t get_subscription_builtin_topic_data(
10891090
SubscriptionBuiltinTopicData& subscription_data) const;
10901091

1092+
/**
1093+
* This operation sets the key of the DataWriter that is related to this DataReader.
1094+
* This is used to establish a relationship between a DataReader and a DataWriter
1095+
* in the context of RPC over DDS.
1096+
*
1097+
* @warning This operation is only valid if the entity is not enabled.
1098+
*
1099+
* @param [in] related_writer Pointer to the DataWriter to set as related.
1100+
*
1101+
* @return RETCODE_OK if the key is set successfully.
1102+
* @return RETCODE_ILLEGAL_OPERATION if this entity is enabled.
1103+
* @return RETCODE_PRECONDITION_NOT_MET if the entity does not belong to the same participant.
1104+
* @return RETCODE_BAD_PARAMETER if the provided GUID is unknown
1105+
* or the pointer is not valid.
1106+
*/
1107+
FASTDDS_EXPORTED_API ReturnCode_t set_related_datawriter(
1108+
const DataWriter* related_writer);
1109+
10911110
protected:
10921111

10931112
DataReaderImpl* impl_;

include/fastdds/rtps/builtin/data/PublicationBuiltinTopicData.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ struct PublicationBuiltinTopicData
125125
/// Data representation
126126
dds::DataRepresentationQosPolicy representation;
127127

128+
// RPC over DDS V1.0
129+
130+
// Related DataReader Key
131+
GUID_t related_datareader_key;
132+
128133
// eProsima extensions
129134

130135
/// Disable positive acks, implemented in the library.

include/fastdds/rtps/builtin/data/SubscriptionBuiltinTopicData.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ struct SubscriptionBuiltinTopicData
125125
/// Type consistency enforcement Qos, NOT implemented in the library.
126126
dds::TypeConsistencyEnforcementQosPolicy type_consistency;
127127

128+
// RPC over DDS V1.0
129+
130+
// Related DataWriter Key
131+
GUID_t related_datawriter_key;
132+
128133
// eProsima Extensions
129134

130135
/// Content filter configuration

src/cpp/fastdds/domain/DomainParticipantImpl.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,12 @@ rpc::Service* DomainParticipantImpl::create_service(
20362036
// that it will use for DDS endpoints creation, if it is necessary
20372037
if (!services_publisher_.second)
20382038
{
2039-
Publisher* pub = create_publisher(PUBLISHER_QOS_DEFAULT);
2039+
// Disable automatic enabling of created entities
2040+
// This is necessary to previously set the related_entity_key
2041+
PublisherQos pub_qos = PUBLISHER_QOS_DEFAULT;
2042+
pub_qos.entity_factory().autoenable_created_entities = false;
2043+
2044+
Publisher* pub = create_publisher(pub_qos);
20402045
if (!pub)
20412046
{
20422047
EPROSIMA_LOG_ERROR(PARTICIPANT, "Error creating Services publisher.");
@@ -2047,7 +2052,12 @@ rpc::Service* DomainParticipantImpl::create_service(
20472052

20482053
if (!services_subscriber_.second)
20492054
{
2050-
Subscriber* sub = create_subscriber(SUBSCRIBER_QOS_DEFAULT);
2055+
// Disable automatic enabling of created entities
2056+
// This is necessary to previously set the related_entity_key
2057+
SubscriberQos sub_qos = SUBSCRIBER_QOS_DEFAULT;
2058+
sub_qos.entity_factory().autoenable_created_entities = false;
2059+
2060+
Subscriber* sub = create_subscriber(sub_qos);
20512061
if (!sub)
20522062
{
20532063
EPROSIMA_LOG_ERROR(PARTICIPANT, "Error creating Services subscriber.");

src/cpp/fastdds/publisher/DataWriter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,12 @@ ReturnCode_t DataWriter::set_sample_prefilter(
311311
return impl_->set_sample_prefilter(prefilter);
312312
}
313313

314+
ReturnCode_t DataWriter::set_related_datareader(
315+
const DataReader* related_reader)
316+
{
317+
return impl_->set_related_datareader(related_reader);
318+
}
319+
314320
} // namespace dds
315321
} // namespace fastdds
316322
} // namespace eprosima

src/cpp/fastdds/publisher/DataWriterImpl.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <fastdds/dds/core/ReturnCode.hpp>
2929
#include <fastdds/dds/domain/DomainParticipant.hpp>
3030
#include <fastdds/dds/log/Log.hpp>
31+
#include <fastdds/dds/subscriber/DataReader.hpp>
3132
#include <fastdds/dds/publisher/DataWriter.hpp>
3233
#include <fastdds/dds/publisher/Publisher.hpp>
3334
#include <fastdds/dds/publisher/PublisherListener.hpp>
@@ -1517,6 +1518,34 @@ ReturnCode_t DataWriterImpl::set_sample_prefilter(
15171518
return RETCODE_OK;
15181519
}
15191520

1521+
ReturnCode_t DataWriterImpl::set_related_datareader(
1522+
const DataReader* related_reader)
1523+
{
1524+
ReturnCode_t ret = RETCODE_ILLEGAL_OPERATION;
1525+
1526+
if (nullptr == writer_)
1527+
{
1528+
if (nullptr != related_reader &&
1529+
related_reader->guid() != c_Guid_Unknown)
1530+
{
1531+
if (related_reader->guid().guidPrefix == guid_.guidPrefix)
1532+
{
1533+
related_datareader_key_ = related_reader->guid();
1534+
ret = RETCODE_OK;
1535+
}
1536+
else
1537+
{
1538+
ret = RETCODE_PRECONDITION_NOT_MET;
1539+
}
1540+
}
1541+
else
1542+
{
1543+
ret = RETCODE_BAD_PARAMETER;
1544+
}
1545+
}
1546+
return ret;
1547+
}
1548+
15201549
bool DataWriterImpl::deadline_timer_reschedule()
15211550
{
15221551
assert(qos_.deadline().period != dds::c_TimeInfinite);
@@ -1730,6 +1759,9 @@ ReturnCode_t DataWriterImpl::get_publication_builtin_topic_data(
17301759
publisher_->get_participant_impl()->fill_type_information(type_, publication_data.type_information);
17311760
publication_data.representation = qos_.representation();
17321761

1762+
// RPC over DDS
1763+
publication_data.related_datareader_key = related_datareader_key_;
1764+
17331765
// eProsima extensions
17341766

17351767
publication_data.disable_positive_acks = qos_.reliable_writer_qos().disable_positive_acks;

src/cpp/fastdds/publisher/DataWriterImpl.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,24 @@ class DataWriterImpl : protected rtps::IReaderDataFilter
432432
ReturnCode_t set_sample_prefilter(
433433
std::shared_ptr<IContentFilter> prefilter);
434434

435+
/**
436+
* This operation sets the key of the DataReader that is related to this DataWriter.
437+
* This is used to establish a relationship between a DataReader and a DataWriter
438+
* in the context of RPC over DDS.
439+
*
440+
* @warning This operation is only valid if the entity is not enabled.
441+
*
442+
* @param [in] related_reader Pointer to the DataReader to set as related.
443+
*
444+
* @return RETCODE_OK if the key is set successfully.
445+
* @return RETCODE_ILLEGAL_OPERATION if this entity is enabled.
446+
* @return RETCODE_PRECONDITION_NOT_MET if the entity does not belong to the same participant.
447+
* @return RETCODE_BAD_PARAMETER if the provided GUID is unknown
448+
* or the pointer is not valid.
449+
*/
450+
ReturnCode_t set_related_datareader(
451+
const DataReader* related_reader);
452+
435453
protected:
436454

437455
using IChangePool = eprosima::fastdds::rtps::IChangePool;
@@ -555,6 +573,9 @@ class DataWriterImpl : protected rtps::IReaderDataFilter
555573
mutable std::mutex filters_mtx_;
556574
std::shared_ptr<IContentFilter> sample_prefilter_;
557575

576+
//RPC over DDS
577+
rtps::GUID_t related_datareader_key_{rtps::c_Guid_Unknown};
578+
558579
ReturnCode_t check_write_preconditions(
559580
const void* const data,
560581
const InstanceHandle_t& handle,

0 commit comments

Comments
 (0)