Skip to content
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
12 changes: 5 additions & 7 deletions examples/HelloWorldExampleDS/HelloWorldPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ bool HelloWorldPublisher::init(
m_hello.index(0);
m_hello.message("HelloWorld");

RemoteServerAttributes ratt;

ratt.ReadguidPrefix("44.49.53.43.53.45.52.56.45.52.5F.31");
LocatorList_t remote_server;

DomainParticipantQos participant_qos = PARTICIPANT_QOS_DEFAULT;

Expand All @@ -70,8 +68,8 @@ bool HelloWorldPublisher::init(
IPLocator::setPhysicalPort(server_address, default_port);
IPLocator::setLogicalPort(server_address, 65215);

ratt.metatrafficUnicastLocatorList.push_back(server_address);
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(ratt);
remote_server.push_back(server_address);
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server);
participant_qos.transport().use_builtin_transports = false;
std::shared_ptr<TCPv4TransportDescriptor> descriptor = std::make_shared<TCPv4TransportDescriptor>();

Expand All @@ -90,8 +88,8 @@ bool HelloWorldPublisher::init(
IPLocator::setIPv4(server_address, 127, 0, 0, 1);
}

ratt.metatrafficUnicastLocatorList.push_back(server_address);
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(ratt);
remote_server.push_back(server_address);
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server);
}

participant_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::CLIENT;
Expand Down
11 changes: 5 additions & 6 deletions examples/HelloWorldExampleDS/HelloWorldSubscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ bool HelloWorldSubscriber::init(
Locator server_address)
{

RemoteServerAttributes ratt;
ratt.ReadguidPrefix("44.49.53.43.53.45.52.56.45.52.5F.31");
LocatorList_t remote_server;

DomainParticipantQos participant_qos = PARTICIPANT_QOS_DEFAULT;

Expand All @@ -66,8 +65,8 @@ bool HelloWorldSubscriber::init(
IPLocator::setPhysicalPort(server_address, default_port);
IPLocator::setLogicalPort(server_address, 65215);

ratt.metatrafficUnicastLocatorList.push_back(server_address);
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(ratt);
remote_server.push_back(server_address);
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server);
participant_qos.transport().use_builtin_transports = false;
std::shared_ptr<TCPv4TransportDescriptor> descriptor = std::make_shared<TCPv4TransportDescriptor>();

Expand All @@ -86,8 +85,8 @@ bool HelloWorldSubscriber::init(
IPLocator::setIPv4(server_address, 127, 0, 0, 1);
}

ratt.metatrafficUnicastLocatorList.push_back(server_address);
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(ratt);
remote_server.push_back(server_address);
participant_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server);
}

participant_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::CLIENT;
Expand Down
14 changes: 13 additions & 1 deletion include/DiscoveryItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ struct ParticipantDiscoveryDatabase : public DiscoveryItem, public std::set<Part
typedef std::set<ParticipantDiscoveryItem>::size_type size_type;
typedef ParticipantDiscoveryDatabase::iterator iterator;

std::string participant_name_;

// we need a special iterator that ignores zombie members
struct smart_iterator
: std::iterator<
Expand Down Expand Up @@ -365,8 +367,10 @@ struct ParticipantDiscoveryDatabase : public DiscoveryItem, public std::set<Part
};

ParticipantDiscoveryDatabase(
const GUID_t& id )
const GUID_t& id,
const std::string& name = std::string())
: DiscoveryItem(id)
, participant_name_(name)
{
}

Expand Down Expand Up @@ -481,6 +485,10 @@ struct Snapshot : public std::set<ParticipantDiscoveryDatabase>
const ParticipantDiscoveryDatabase* operator [](
const GUID_t&) const;

ParticipantDiscoveryDatabase& access_snapshot(
const GUID_t& ptid,
const std::string& name);

void to_xml(
tinyxml2::XMLElement* pRoot,
tinyxml2::XMLDocument& xmlDoc) const;
Expand Down Expand Up @@ -508,6 +516,7 @@ class DiscoveryItemDatabase
class T>
bool AddEndPoint(T & (ParticipantDiscoveryItem::* m)() const,
const GUID_t& spokesman,
const std::string& srcName,
const GUID_t& ptid,
const GUID_t& sid,
const std::string& _typename,
Expand Down Expand Up @@ -542,6 +551,7 @@ class DiscoveryItemDatabase
//! Adds a new participant, returns false if allocation fails
bool AddParticipant(
const GUID_t& spokesman,
const std::string& srcName,
const GUID_t& ptid,
const std::string& name = std::string(),
const std::chrono::steady_clock::time_point& discovered_timestamp = std::chrono::steady_clock::now(),
Expand All @@ -559,6 +569,7 @@ class DiscoveryItemDatabase
//! Adds a new Subscriber, returns false if allocation fails
bool AddDataReader(
const GUID_t& spokesman,
const std::string& srcName,
const GUID_t& ptid,
const GUID_t& sid,
const std::string& _typename,
Expand All @@ -573,6 +584,7 @@ class DiscoveryItemDatabase
//! Adds a new Publisher, returns false if allocation fails
bool AddDataWriter(
const GUID_t& spokesman,
const std::string& srcName,
const GUID_t& ptid,
const GUID_t& pid,
const std::string& _typename,
Expand Down
2 changes: 0 additions & 2 deletions include/IDs.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ static const std::string s_sSimples("simples");
static const std::string s_sSimple("simple");
static const std::string s_sPersist("persist");
static const std::string s_sLP("ListeningPorts");
static const std::string s_sSL("ServersList");
static const std::string s_sRServer("RServer");
static const std::string s_sTime("time");
static const std::string s_sSomeone("someone");
static const std::string s_sShowLiveliness("show_liveliness");
Expand Down
16 changes: 6 additions & 10 deletions resources/xml/test_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@
<builtin>
<discoveryProtocol>CLIENT</discoveryProtocol>
<discoveryServersList>
<RemoteServer prefix="4D.49.47.55.45.4c.5f.42.41.52.52.4f">
<metatrafficUnicastLocatorList>
<locator>
<udpv4>
<address>127.0.0.1</address>
<port>65215</port>
</udpv4>
</locator>
</metatrafficUnicastLocatorList>
</RemoteServer>
<locator>
<udpv4>
<address>127.0.0.1</address>
<port>65215</port>
</udpv4>
</locator>
</discoveryServersList>
</builtin>
</rtps>
Expand Down
16 changes: 6 additions & 10 deletions resources/xml/test_schema2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,12 @@
<builtin>
<discoveryProtocol>CLIENT</discoveryProtocol>
<discoveryServersList>
<RemoteServer prefix="4D.49.47.55.45.4c.5f.42.41.52.52.4f">
<metatrafficUnicastLocatorList>
<locator>
<udpv4>
<address>127.0.0.1</address>
<port>65215</port>
</udpv4>
</locator>
</metatrafficUnicastLocatorList>
</RemoteServer>
<locator>
<udpv4>
<address>127.0.0.1</address>
<port>65215</port>
</udpv4>
</locator>
</discoveryServersList>
</builtin>
</rtps>
Expand Down
20 changes: 1 addition & 19 deletions resources/xsd/discovery-server.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,6 @@
<xs:attribute name="prefix" type="guid" use="required"/>
</xs:complexType>

<xs:complexType name="DiscoveryServerList">
<xs:sequence>
<xs:element name="RemoteServer" type="RemoteServerAttributes" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="initialAnnouncementsType">
<xs:all minOccurs="0">
<xs:element name="count" type="uint32Type" minOccurs="0"/>
Expand All @@ -372,7 +366,7 @@
<xs:element name="initialAnnouncements" type="initialAnnouncementsType" minOccurs="0"/>
<xs:element name="simpleEDP" type="simpleEDPType" minOccurs="0"/>
<xs:element name="clientAnnouncementPeriod" type="durationType" minOccurs="0"/>
<xs:element name="discoveryServersList" type="DiscoveryServerList" minOccurs="0"/>
<xs:element name="discoveryServersList" type="locatorListType" minOccurs="0"/>
<xs:element name="staticEndpointXMLFilename" type="stringType" minOccurs="0"/>
</xs:all>
</xs:complexType>
Expand Down Expand Up @@ -915,7 +909,6 @@
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="ServersList" type="ServersListType" minOccurs="0" maxOccurs="1" />
<!-- not mandatory may be present in the profile -->
<xs:choice minOccurs="0">
<!-- publisher and subscriber must be contiguous but in any order -->
Expand All @@ -942,19 +935,8 @@
<!-- removal time in seconds from startup-->
</xs:complexType>

<xs:complexType name="ServersListType">
<xs:sequence>
<xs:element name="RServer" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="prefix" type="guid" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="clientType">
<xs:sequence >
<xs:element name="ServersList" type="ServersListType" minOccurs="0" maxOccurs="1" />
<xs:choice minOccurs="0">
<!-- publisher and subscriber must be contiguous but in any order -->
<xs:sequence>
Expand Down
40 changes: 35 additions & 5 deletions src/DiscoveryItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,15 @@ std::vector<const ParticipantDiscoveryItem*> DiscoveryItemDatabase::FindParticip

bool DiscoveryItemDatabase::AddParticipant(
const GUID_t& spokesman,
const std::string& srcName,
const GUID_t& ptid,
const std::string& name,
const std::chrono::steady_clock::time_point& discovered_timestamp,
bool server /* = false*/)
{
std::lock_guard<std::mutex> lock(database_mutex);

ParticipantDiscoveryDatabase& _database = image[spokesman];
ParticipantDiscoveryDatabase& _database = image.access_snapshot(spokesman, srcName);
ParticipantDiscoveryDatabase::iterator it = std::lower_bound(_database.begin(), _database.end(), ptid);

if (it == _database.end() || *it != ptid)
Expand Down Expand Up @@ -455,6 +456,7 @@ template<class T>
bool DiscoveryItemDatabase::AddEndPoint(
T& (ParticipantDiscoveryItem::* m)() const,
const GUID_t& spokesman,
const std::string& srcName,
const GUID_t& ptid,
const GUID_t& id,
const std::string& _typename,
Expand All @@ -463,7 +465,7 @@ bool DiscoveryItemDatabase::AddEndPoint(
{
std::lock_guard<std::mutex> lock(database_mutex);

ParticipantDiscoveryDatabase& _database = image[spokesman];
ParticipantDiscoveryDatabase& _database = image.access_snapshot(spokesman, srcName);
ParticipantDiscoveryDatabase::iterator it = std::lower_bound(_database.begin(), _database.end(), ptid);

if (it == _database.end() || ptid == spokesman )
Expand Down Expand Up @@ -534,13 +536,14 @@ bool DiscoveryItemDatabase::RemoveEndPoint(

bool DiscoveryItemDatabase::AddDataReader(
const GUID_t& spokesman,
const std::string& srcName,
const GUID_t& ptid,
const GUID_t& sid,
const std::string& _typename,
const std::string& topicname,
const std::chrono::steady_clock::time_point& discovered_timestamp)
{
return AddEndPoint(&ParticipantDiscoveryItem::getDataReaders, spokesman, ptid, sid, _typename, topicname,
return AddEndPoint(&ParticipantDiscoveryItem::getDataReaders, spokesman, srcName, ptid, sid, _typename, topicname,
discovered_timestamp);
}

Expand All @@ -554,13 +557,14 @@ bool DiscoveryItemDatabase::RemoveDataReader(

bool DiscoveryItemDatabase::AddDataWriter(
const GUID_t& spokesman,
const std::string& srcName,
const GUID_t& ptid,
const GUID_t& pid,
const std::string& _typename,
const std::string& topicname,
const std::chrono::steady_clock::time_point& discovered_timestamp)
{
return AddEndPoint(&ParticipantDiscoveryItem::getDataWriters, spokesman, ptid, pid, _typename, topicname,
return AddEndPoint(&ParticipantDiscoveryItem::getDataWriters, spokesman, srcName, ptid, pid, _typename, topicname,
discovered_timestamp);
}

Expand Down Expand Up @@ -806,6 +810,26 @@ bool eprosima::discovery_server::operator ==(
return false;
}

ParticipantDiscoveryDatabase& Snapshot::access_snapshot (
const GUID_t& id,
const std::string& name)
{
auto it = std::lower_bound(begin(), end(), id);
const ParticipantDiscoveryDatabase* p = nullptr;

if (it == end() || *it != id)
{
// not there, emplace
p = &(*emplace(id, name).first);
}
else
{
p = &*it;
}

return const_cast<ParticipantDiscoveryDatabase&>(*p);
}

ParticipantDiscoveryDatabase& Snapshot::operator [](
const GUID_t& id)
{
Expand All @@ -815,7 +839,8 @@ ParticipantDiscoveryDatabase& Snapshot::operator [](
if (it == end() || *it != id)
{
// not there, emplace
p = &(*emplace(id).first);
// should never be called from this operator
p = &(*emplace(id, "").first);
}
else
{
Expand Down Expand Up @@ -877,6 +902,11 @@ void Snapshot::to_xml(
sstream << discovery_database.endpoint_guid.entityId;
pPtdb->SetAttribute(s_sGUID_entity.c_str(), sstream.str().c_str());
}
{
std::stringstream sstream;
sstream << discovery_database.participant_name_;
pPtdb->SetAttribute(s_sName.c_str(), sstream.str().c_str());
}

for (const ParticipantDiscoveryItem& discovery_item : discovery_database)
{
Expand Down
Loading