Skip to content

Commit

Permalink
Merge pull request OpenDDS#4545 from mitza-oci/participant-location-d…
Browse files Browse the repository at this point in the history
…uration

Added lease duration to ParticipantLocationBuiltinTopicData
  • Loading branch information
jrw972 authored Mar 26, 2024
2 parents 3c813b5 + 536ffb9 commit fafdb00
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 11 deletions.
2 changes: 2 additions & 0 deletions dds/DCPS/RTPS/DiscoveredEntities.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ struct DiscoveredParticipant {
location_data_.ice6_timestamp.nanosec = 0;
location_data_.relay6_timestamp.sec = 0;
location_data_.relay6_timestamp.nanosec = 0;
location_data_.lease_duration.sec = 0;
location_data_.lease_duration.nanosec = 0;

#ifdef OPENDDS_SECURITY
security_info_.participant_security_attributes = 0;
Expand Down
18 changes: 10 additions & 8 deletions dds/DCPS/RTPS/Spdp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,16 @@ void Spdp::process_location_updates_i(const DiscoveredParticipantIter& iter, con
ACE_DEBUG((LM_DEBUG, "(%P|%t) DEBUG: Spdp::process_location_updates_i: %@ %C has %B location update(s) force_publish=%d reason=%C\n", this, LogGuid(iter->first).c_str(), location_updates.size(), force_publish, reason));
}

const DCPS::TimeDuration leaseDuration = rtps_duration_to_time_duration(iter->second.pdata_.leaseDuration,
iter->second.pdata_.participantProxy.protocolVersion,
iter->second.pdata_.participantProxy.vendorId);

DCPS::ParticipantLocationBuiltinTopicData& location_data = iter->second.location_data_;
location_data.lease_duration = leaseDuration.to_dds_duration();

bool published = false;
for (DiscoveredParticipant::LocationUpdateList::const_iterator pos = location_updates.begin(),
limit = location_updates.end(); iter != participants_.end() && pos != limit; ++pos) {
DCPS::ParticipantLocationBuiltinTopicData& location_data = iter->second.location_data_;
limit = location_updates.end(); pos != limit; ++pos) {

OPENDDS_STRING addr = "";
const DCPS::ParticipantLocation old_mask = location_data.location;
Expand Down Expand Up @@ -572,12 +578,8 @@ void Spdp::process_location_updates_i(const DiscoveredParticipantIter& iter, con
break;
}

const DDS::Time_t expr =
(
pos->timestamp_ - rtps_duration_to_time_duration(iter->second.pdata_.leaseDuration,
iter->second.pdata_.participantProxy.protocolVersion,
iter->second.pdata_.participantProxy.vendorId)
).to_dds_time();
const DDS::Time_t expr = (pos->timestamp_ - leaseDuration).to_dds_time();

if ((location_data.location & DCPS::LOCATION_LOCAL) && DCPS::operator<(location_data.local_timestamp, expr)) {
location_data.location &= ~(DCPS::LOCATION_LOCAL);
location_data.change_mask |= DCPS::LOCATION_LOCAL;
Expand Down
1 change: 1 addition & 0 deletions dds/OpenddsDcpsExt.idl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module OpenDDS
DDS::Time_t ice6_timestamp;
string relay6_addr;
DDS::Time_t relay6_timestamp;
DDS::Duration_t lease_duration;
};

const string RTPS_RELAY_STUN_PROTOCOL = "RtpsRelay:STUN";
Expand Down
2 changes: 2 additions & 0 deletions docs/devguide/built_in_topics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ The topic type ParticipantLocationBuiltinTopicData is defined in :ghfile:`dds/Op

* ``local6_addr``, ``local6_timestamp``, ``ice6_addr``, ``ice6_timestamp``, ``relay6_addr``, and ``relay6_timestamp`` -- Are the IPV6 equivalents.

* ``lease_duration`` -- The remote participant's lease duration (see Lease Duration in :ref:`run_time_configuration--rtps-disc-config-options`)

.. _built_in_topics--openddsconnectionrecord-topic:

OpenDDSConnectionRecord Topic
Expand Down
8 changes: 8 additions & 0 deletions docs/news.d/participant-location-duration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. news-prs: 4545
.. news-start-section: Additions
- The data type for the OpenDDS-specific Built-in ParticipantLocation Topic now includes the lease duration.

- See :ref:`built_in_topics--openddsparticipantlocation-topic` for details.

.. news-end-section
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public synchronized void on_data_available(DDS.DataReader reader) {
}

ParticipantLocationBuiltinTopicDataHolder participant = new ParticipantLocationBuiltinTopicDataHolder(
new ParticipantLocationBuiltinTopicData(new byte[16], 0, 0, "", new DDS.Time_t(), "", new DDS.Time_t(), "",
new DDS.Time_t(), "", new DDS.Time_t(), "", new DDS.Time_t(), "", new DDS.Time_t()));
new ParticipantLocationBuiltinTopicData(new byte[16], 0, 0, "", new DDS.Time_t(), "", new DDS.Time_t(), "",
new DDS.Time_t(), "", new DDS.Time_t(), "", new DDS.Time_t(), "", new DDS.Time_t(), new DDS.Duration_t()));
SampleInfoHolder si = new SampleInfoHolder(
new SampleInfo(0, 0, 0, new DDS.Time_t(), 0, 0, 0, 0, 0, 0, 0, false, 0));

Expand Down Expand Up @@ -93,6 +93,7 @@ public synchronized void on_data_available(DDS.DataReader reader) {
System.out.println(" : " + participant.value.ice_timestamp.sec);
System.out.println(" relay: " + participant.value.relay_addr);
System.out.println(" : " + participant.value.relay_timestamp.sec);
System.out.println(" lease: " + participant.value.lease_duration.sec);

// update locations if SampleInfo is valid
if (si.value.valid_data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ void ParticipantLocationListenerImpl::on_data_available(DDS::DataReader_ptr read
<< " ice6: " << participant.ice6_addr << std::endl
<< " : " << participant.ice6_timestamp.sec << std::endl
<< "relay6: " << participant.relay6_addr << std::endl
<< " : " << participant.relay6_timestamp.sec << std::endl;
<< " : " << participant.relay6_timestamp.sec << std::endl
<< " lease: " << OpenDDS::DCPS::TimeDuration(participant.lease_duration).str(9) << std::endl;

// update locations if SampleInfo is valid.
if (si.valid_data == 1)
Expand Down
2 changes: 2 additions & 0 deletions tests/unit-tests/dds/DCPS/RTPS/DiscoveredEntities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ TEST(dds_DCPS_RTPS_DiscoveredEntities, DiscoveredParticipant_ctor)
EXPECT_EQ(uut.location_data_.ice6_timestamp.nanosec, 0u);
EXPECT_EQ(uut.location_data_.relay6_timestamp.sec, 0);
EXPECT_EQ(uut.location_data_.relay6_timestamp.nanosec, 0u);
EXPECT_EQ(uut.location_data_.lease_duration.sec, 0);
EXPECT_EQ(uut.location_data_.lease_duration.nanosec, 0u);

#ifdef OPENDDS_SECURITY
EXPECT_EQ(uut.have_spdp_info_, false);
Expand Down

0 comments on commit fafdb00

Please sign in to comment.