Skip to content
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

Support for partitions on DataWriterQoS and DataReaderQoS [12709] (backport #2274) #2294

Merged
merged 2 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/cpp/fastdds/publisher/DataWriterImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,15 @@ ReturnCode_t DataWriterImpl::enable()
property.value(topic_->get_name().c_str());
w_att.endpoint.properties.properties().push_back(std::move(property));

if (publisher_->get_qos().partition().names().size() > 0)
std::string* endpoint_partitions = PropertyPolicyHelper::find_property(qos_.properties(), "partitions");

if (endpoint_partitions)
{
property.name("partitions");
property.value(*endpoint_partitions);
w_att.endpoint.properties.properties().push_back(std::move(property));
}
else if (publisher_->get_qos().partition().names().size() > 0)
{
property.name("partitions");
std::string partitions;
Expand Down Expand Up @@ -336,6 +344,17 @@ ReturnCode_t DataWriterImpl::enable()
{
wqos.data_sharing.off();
}
if (endpoint_partitions)
{
std::istringstream partition_string(*endpoint_partitions);
std::string partition_name;
wqos.m_partition.clear();

while (std::getline(partition_string, partition_name, ';'))
{
wqos.m_partition.push_back(partition_name.c_str());
}
}
publisher_->rtps_participant()->registerWriter(writer_, get_topic_attributes(qos_, *topic_, type_), wqos);

return ReturnCode_t::RETCODE_OK;
Expand Down
19 changes: 19 additions & 0 deletions src/cpp/fastdds/publisher/PublisherImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <fastdds/dds/domain/DomainParticipantListener.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp>

#include <fastdds/rtps/common/Property.h>
#include <fastdds/rtps/participant/RTPSParticipant.h>
#include <fastdds/dds/log/Log.hpp>

Expand All @@ -45,6 +46,7 @@ namespace dds {
using fastrtps::xmlparser::XMLProfileManager;
using fastrtps::xmlparser::XMLP_ret;
using fastrtps::rtps::InstanceHandle_t;
using fastrtps::rtps::Property;
using fastrtps::Duration_t;
using fastrtps::PublisherAttributes;

Expand Down Expand Up @@ -79,6 +81,23 @@ static void set_qos_from_attributes(
qos.history() = attr.topic.historyQos;
qos.resource_limits() = attr.topic.resourceLimitsQos;
qos.data_sharing() = attr.qos.data_sharing;

if (attr.qos.m_partition.size() > 0 )
{
Property property;
property.name("partitions");
std::string partitions;
bool is_first_partition = true;

for (auto partition : attr.qos.m_partition.names())
{
partitions += (is_first_partition ? "" : ";") + partition;
is_first_partition = false;
}

property.value(std::move(partitions));
qos.properties().properties().push_back(std::move(property));
}
}

PublisherImpl::PublisherImpl(
Expand Down
22 changes: 21 additions & 1 deletion src/cpp/fastdds/subscriber/DataReaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,16 @@ ReturnCode_t DataReaderImpl::enable()
property.name("topic_name");
property.value(topic_->get_name().c_str());
att.endpoint.properties.properties().push_back(std::move(property));
if (subscriber_->get_qos().partition().names().size() > 0)

std::string* endpoint_partitions = PropertyPolicyHelper::find_property(qos_.properties(), "partitions");

if (endpoint_partitions)
{
property.name("partitions");
property.value(*endpoint_partitions);
att.endpoint.properties.properties().push_back(std::move(property));
}
else if (subscriber_->get_qos().partition().names().size() > 0)
{
property.name("partitions");
std::string partitions;
Expand Down Expand Up @@ -249,6 +258,17 @@ ReturnCode_t DataReaderImpl::enable()
{
rqos.data_sharing.off();
}
if (endpoint_partitions)
{
std::istringstream partition_string(*endpoint_partitions);
std::string partition_name;
rqos.m_partition.clear();

while (std::getline(partition_string, partition_name, ';'))
{
rqos.m_partition.push_back(partition_name.c_str());
}
}
subscriber_->rtps_participant()->registerReader(reader_, topic_attributes(), rqos);

return ReturnCode_t::RETCODE_OK;
Expand Down
19 changes: 19 additions & 0 deletions src/cpp/fastdds/subscriber/SubscriberImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <fastdds/dds/subscriber/DataReader.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp>

#include <fastdds/rtps/common/Property.h>
#include <fastdds/rtps/participant/RTPSParticipant.h>
#include <fastdds/dds/log/Log.hpp>

Expand All @@ -44,6 +45,7 @@ namespace dds {
using fastrtps::xmlparser::XMLProfileManager;
using fastrtps::xmlparser::XMLP_ret;
using fastrtps::rtps::InstanceHandle_t;
using fastrtps::rtps::Property;
using fastrtps::Duration_t;
using fastrtps::SubscriberAttributes;

Expand Down Expand Up @@ -78,6 +80,23 @@ static void set_qos_from_attributes(
qos.history() = attr.topic.historyQos;
qos.resource_limits() = attr.topic.resourceLimitsQos;
qos.data_sharing() = attr.qos.data_sharing;

if (attr.qos.m_partition.size() > 0 )
{
Property property;
property.name("partitions");
std::string partitions;
bool is_first_partition = true;

for (auto partition : attr.qos.m_partition.names())
{
partitions += (is_first_partition ? "" : ";") + partition;
is_first_partition = false;
}

property.value(std::move(partitions));
qos.properties().properties().push_back(std::move(property));
}
}

SubscriberImpl::SubscriberImpl(
Expand Down
2 changes: 2 additions & 0 deletions test/blackbox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND)
${CMAKE_CURRENT_BINARY_DIR}/StatisticsDomainParticipant.xml)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/utils/check_guid.py
${CMAKE_CURRENT_BINARY_DIR}/check_guid.py)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/partitions.xml
${CMAKE_CURRENT_BINARY_DIR}/partitions.xml)

if(FASTRTPS_API_TESTS)
set(BLACKBOXTESTS_FASTRTPS_SOURCE
Expand Down
Loading