diff --git a/include/DSManager.h b/include/DSManager.h
index 9aca96db..e395763a 100644
--- a/include/DSManager.h
+++ b/include/DSManager.h
@@ -163,6 +163,8 @@ class DiscoveryServerManager
tinyxml2::XMLElement* snapshot);
void loadEnvironmentChange(
tinyxml2::XMLElement* snapshot);
+ void loadAPIChange(
+ tinyxml2::XMLElement* change);
void MapServerInfo(
tinyxml2::XMLElement* server);
diff --git a/include/IDs.h b/include/IDs.h
index 92886b08..be911f02 100644
--- a/include/IDs.h
+++ b/include/IDs.h
@@ -49,6 +49,11 @@ static const std::string s_sChange("change");
static const std::string s_sVariable("variable");
static const std::string s_sKey("key");
static const std::string s_sValue("value");
+static const std::string s_sAPIChange("serverchange");
+static const std::string s_sPrefix("prefix");
+static const std::string s_sRemoteServer("RemoteServer");
+static const std::string s_sAddress("address");
+static const std::string s_sPort("port");
// specific Snapshot schema string literals
static const std::string s_sDS_Snapshots("DS_Snapshots");
diff --git a/include/LJ.h b/include/LJ.h
index 05fcf286..8709eae2 100644
--- a/include/LJ.h
+++ b/include/LJ.h
@@ -553,6 +553,41 @@ class DelayedEnvironmentModification
DiscoveryServerManager& ) override;
};
+class DelayedServerListChange
+ : public LateJoinerData // Delayed Server List Change via API
+{
+ std::string prefix;
+ RemoteServerAttributes attributes;
+
+public:
+
+ DelayedServerListChange(
+ const std::chrono::steady_clock::time_point tp,
+ std::string client_prefix,
+ RemoteServerAttributes attr)
+ : LateJoinerData(tp)
+ , prefix(client_prefix)
+ , attributes(attr)
+ {
+ }
+
+ ~DelayedServerListChange() override
+ {
+ }
+
+ DelayedServerListChange() = delete;
+ DelayedServerListChange(
+ const DelayedServerListChange&) = default;
+ DelayedServerListChange(
+ DelayedServerListChange&&) = default;
+ DelayedServerListChange& operator =(
+ const DelayedServerListChange&) = default;
+ DelayedServerListChange& operator =(
+ DelayedServerListChange&&) = default;
+
+ void operator ()(
+ DiscoveryServerManager& ) override;
+};
} // fastrtps
} // discovery_server
diff --git a/resources/xsd/discovery-server.xsd b/resources/xsd/discovery-server.xsd
index e60dee76..7a3b9619 100644
--- a/resources/xsd/discovery-server.xsd
+++ b/resources/xsd/discovery-server.xsd
@@ -1028,6 +1028,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1069,6 +1083,13 @@
+
+
+
+
+
+
+
diff --git a/src/DSManager.cpp b/src/DSManager.cpp
index 6581af7d..44eb2401 100644
--- a/src/DSManager.cpp
+++ b/src/DSManager.cpp
@@ -219,6 +219,16 @@ DiscoveryServerManager::DiscoveryServerManager(
change = change->NextSiblingElement(s_sChange.c_str());
}
}
+ tinyxml2::XMLElement* serverchange = child->FirstChildElement(s_sAPIChange.c_str());
+ if (serverchange)
+ {
+ tinyxml2::XMLElement* change = serverchange->FirstChildElement(s_sChange.c_str());
+ while (change != nullptr)
+ {
+ loadAPIChange(change);
+ change = change->NextSiblingElement(s_sChange.c_str());
+ }
+ }
}
}
@@ -1740,6 +1750,55 @@ void DiscoveryServerManager::loadEnvironmentChange(
events.push_back(new DelayedEnvironmentModification(time, key, value));
}
+void DiscoveryServerManager::loadAPIChange(
+ tinyxml2::XMLElement* change)
+{
+ std::lock_guard lock(management_mutex);
+
+ // snapshots are created for debugging purposes
+ // time is mandatory
+ const char* time_str = change->Attribute(s_sTime.c_str());
+
+ if (time_str == nullptr)
+ {
+ LOG_ERROR(s_sTime << " is a mandatory attribute of " << s_sChange << " tag");
+ return;
+ }
+
+ const char* client_prefix = change->Attribute(s_sPrefix.c_str());
+ if (client_prefix == nullptr)
+ {
+ LOG_ERROR(s_sPrefix << " is a mandatory attribute of " << s_sChange << " tag");
+ return;
+ }
+
+ std::chrono::steady_clock::time_point time(getTime());
+ {
+ int aux;
+ std::istringstream(time_str) >> aux;
+ time += std::chrono::seconds(aux);
+ }
+
+ RemoteServerAttributes remote_server_att;
+
+ tinyxml2::XMLElement* remote_server = change->FirstChildElement(s_sRemoteServer.c_str());
+ while (remote_server != nullptr)
+ {
+ std::string address(remote_server->Attribute(s_sAddress.c_str()));
+ uint32_t port(remote_server->IntAttribute(s_sPort.c_str()));
+
+ remote_server_att.ReadguidPrefix(remote_server->Attribute(s_sPrefix.c_str()));
+ Locator locator;
+ IPLocator::setIPv4(locator, address);
+ locator.port = port;
+ remote_server_att.metatrafficUnicastLocatorList.push_back(locator);
+ remote_server = remote_server->NextSiblingElement(s_sRemoteServer.c_str());
+ }
+
+ // Add the event
+ events.push_back(new DelayedServerListChange(time, client_prefix, remote_server_att));
+}
+
void DiscoveryServerManager::MapServerInfo(
tinyxml2::XMLElement* server)
{
diff --git a/src/LJ.cpp b/src/LJ.cpp
index 68c1310b..25a98d75 100644
--- a/src/LJ.cpp
+++ b/src/LJ.cpp
@@ -15,6 +15,7 @@
#include "LJ.h"
#include
+#include
#include "log/DSLog.h"
#include "DSManager.h"
@@ -173,3 +174,23 @@ void DelayedEnvironmentModification::operator ()(
return;
}
}
+
+void DelayedServerListChange::operator ()(
+ DiscoveryServerManager& man) /*override*/
+{
+ GuidPrefix_t participant_prefix;
+ std::istringstream(prefix) >> participant_prefix;
+ GUID_t participant_guid (participant_prefix, ENTITYID_RTPSParticipant);
+ DomainParticipant* participant = man.getParticipant(participant_guid);
+
+ if (nullptr != participant)
+ {
+ DomainParticipantQos qos = participant->get_qos();
+ qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(attributes);
+ participant->set_qos(qos);
+ }
+ else
+ {
+ LOG_ERROR("Tried to modify Discovery Servers list of undiscovered participant: " << participant_guid);
+ }
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 0fbdeb6b..80e039b0 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -119,8 +119,8 @@ if(fastrtps_VERSION VERSION_GREATER_EQUAL "2.4.0")
list(APPEND TEST_LIST
test_36_dns_environment_variable_setup
test_37_dns_fast_discovery_server_tool
-
test_50_environment_modification
+ test_51_discovery_server_list_api
)
endif()
diff --git a/test/configuration/test_cases/test_51_discovery_server_list_api.xml b/test/configuration/test_cases/test_51_discovery_server_list_api.xml
new file mode 100644
index 00000000..2f9304e7
--- /dev/null
+++ b/test/configuration/test_cases/test_51_discovery_server_list_api.xml
@@ -0,0 +1,211 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ test_51_discovery_server_list_api_initial
+ test_51_discovery_server_list_api_add_server2
+ test_51_discovery_server_list_api_add_server1
+ test_51_discovery_server_list_api_final
+
+
+
+ ;;localhost:65000
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 63.6c.69.65.6e.74.31.5f.73.31.5f.5f
+
+
+ CLIENT
+
+
+
+
+
+ 127.0.0.1
+ 38811
+
+
+
+
+
+
+ 0
+
+
+ 250000000
+
+ DURATION_INFINITY
+ DURATION_INFINITY
+
+
+
+
+
+
+
+ 63.6c.69.65.6e.74.32.5f.73.31.5f.5f
+
+
+
+
+
+ 63.6c.69.65.6e.74.31.5f.73.32.5f.5f
+
+
+ CLIENT
+
+
+
+
+
+ 127.0.0.1
+ 38812
+
+
+
+
+
+
+ 0
+
+
+ 250000000
+
+ DURATION_INFINITY
+ DURATION_INFINITY
+
+
+
+
+
+
+
+ 44.53.00.5f.45.50.52.4f.53.49.4d.41
+
+
+ SERVER
+
+ 0
+
+ DURATION_INFINITY
+ DURATION_INFINITY
+
+
+
+
+ 127.0.0.1
+ 38811
+
+
+
+
+
+
+
+
+
+ 44.53.01.5f.45.50.52.4f.53.49.4d.41
+
+
+ SERVER
+
+ 0
+ 20000000
+
+
+ 0
+
+ DURATION_INFINITY
+ DURATION_INFINITY
+
+
+
+
+ 127.0.0.1
+ 38812
+
+
+
+
+
+
+
+
+ topic_1
+ sample_type_1
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/configuration/test_solutions/test_51_discovery_server_list_api.snapshot b/test/configuration/test_solutions/test_51_discovery_server_list_api.snapshot
new file mode 100644
index 00000000..f82ad2a9
--- /dev/null
+++ b/test/configuration/test_solutions/test_51_discovery_server_list_api.snapshot
@@ -0,0 +1,128 @@
+
+
+
+ test_51_discovery_server_list_api_initial
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ test_51_discovery_server_list_api_add_server2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ test_51_discovery_server_list_api_add_server1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ test_51_discovery_server_list_api_final
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/configuration/tests_params.json b/test/configuration/tests_params.json
index 9f7ba3b8..282fd0cf 100644
--- a/test/configuration/tests_params.json
+++ b/test/configuration/tests_params.json
@@ -2229,8 +2229,52 @@
}
}
},
+ "test_51_discovery_server_list_api":
+ {
+ "description": [
+ "Test to check the consequences of modifying the Discovery Server list of several participants ",
+ "using Qos modification API"
+ ],
-
+ "processes":
+ {
+ "main":
+ {
+ "environment_variables":
+ [
+ {
+ "name":"FASTDDS_ENVIRONMENT_FILE",
+ "value": "/environment.json"
+ }
+ ],
+ "xml_config_file": "/test_cases/test_51_discovery_server_list_api.xml",
+ "validation":
+ {
+ "count_lines_validation":
+ {
+ "file_path": "/test_solutions/test_51_discovery_server_list_api.snapshot"
+ },
+ "exit_code_validation":
+ {
+ "expected_exit_code": 0
+ },
+ "stderr_validation":
+ {
+ "err_expected_lines": 0
+ },
+ "generate_validation":
+ {
+ "disposals": false,
+ "server_endpoints": true
+ },
+ "ground_truth_validation":
+ {
+ "file_path": "/test_solutions/test_51_discovery_server_list_api.snapshot"
+ }
+ }
+ }
+ }
+ },
"test_99_tcp":
{
"processes":