Support multiple domains in configuration

Change the structure of the configuration file (in a backwards
compatible manner) to allow specifying configurations for multiple
domains in a file.  (Listing multiple files in CYCLONEDDS_URI was
already supported.)  A configuration specifies an id, with a default of
any, configurations for an incompatible id are ignored.

If the application specifies an id other than DDS_DOMAIN_DEFAULT in the
call to create_participant, then only configuration specifications for
Domain elements with that id or with id "any" will be used.  If the
application does specify DDS_DOMAIN_DEFAULT, then the id will be taken
from the first Domain element that specifies an id.  If none do, the
domain id defaults to 0.  Each applicable domain specification is taken
as a separate source and may override settings made previously.

All settings moved from the top-level CycloneDDS element to the
CycloneDDS/Domain element.  The CycloneDDS/Domain/Id element moved to
become the "id" attribute of CycloneDDS/Domain.  The old locations still
work, with appropriate deprecation warnings.

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2019-08-09 17:12:52 +02:00 committed by eboasson
parent 70a342991f
commit 891fc2b12f
27 changed files with 1161 additions and 711 deletions

View file

@ -45,11 +45,32 @@ static dds_return_t dds_domain_init (dds_domain *domain, dds_domainid_t domain_i
char * uri = NULL;
uint32_t len;
domain->m_id = domain_id;
domain->gv.tstart = now ();
domain->m_refc = 1;
ddsrt_avl_init (&dds_topictree_def, &domain->m_topics);
domain->gv.tstart = now ();
/* | domain_id | domain id in config | result
+-----------+---------------------+----------
| DEFAULT | any (or absent) | 0
| DEFAULT | n | n
| n | any (or absent) | n
| n | m = n | n
| n | m /= n | n, entire config ignored
Config models:
1: <CycloneDDS>
<Domain id="X">...</Domain>
<Domain .../>
</CycloneDDS>
where ... is all that can today be set in children of CycloneDDS
with the exception of the id
2: <CycloneDDS>
<Domain><Id>X</Id></Domain>
...
</CycloneDDS>
legacy form, domain id must be the first element in the file with
a value (if nothing has been set previously, it a warning is good
enough) */
(void) ddsrt_getenv ("CYCLONEDDS_URI", &uri);
domain->cfgst = config_init (uri, &domain->gv.config, domain_id);
@ -60,30 +81,8 @@ static dds_return_t dds_domain_init (dds_domain *domain, dds_domainid_t domain_i
goto fail_config;
}
/* if a domain id was explicitly given, check & fix up the configuration */
if (domain_id != DDS_DOMAIN_DEFAULT)
{
if (domain_id > 230)
{
DDS_ILOG (DDS_LC_ERROR, domain_id, "requested domain id %"PRIu32" is out of range\n", domain_id);
ret = DDS_RETCODE_ERROR;
goto fail_config_domainid;
}
else if (domain->gv.config.domainId.isdefault)
{
domain->gv.config.domainId.value = domain_id;
}
else if (domain_id != domain->gv.config.domainId.value)
{
DDS_ILOG (DDS_LC_ERROR, domain_id, "requested domain id %"PRIu32" is inconsistent with configured value %"PRIu32"\n", domain_id, domain->gv.config.domainId.value);
ret = DDS_RETCODE_ERROR;
goto fail_config_domainid;
}
}
/* FIXME: The gv.config.domainId can change internally in DDSI. So, remember what the
* main configured domain id is. */
domain->m_id = domain->gv.config.domainId.value;
assert (domain_id == DDS_DOMAIN_DEFAULT || domain_id == domain->gv.config.domainId);
domain->m_id = domain->gv.config.domainId;
if (rtps_config_prep (&domain->gv, domain->cfgst) != 0)
{
@ -146,7 +145,7 @@ static dds_return_t dds_domain_init (dds_domain *domain, dds_domainid_t domain_i
if (rtps_start (&domain->gv) < 0)
{
DDS_LOG (DDS_LC_CONFIG, "Failed to start RTPS\n");
DDS_ILOG (DDS_LC_CONFIG, domain->m_id, "Failed to start RTPS\n");
ret = DDS_RETCODE_ERROR;
goto fail_rtps_start;
}
@ -169,7 +168,6 @@ fail_threadmon_new:
rtps_fini (&domain->gv);
fail_rtps_init:
fail_rtps_config:
fail_config_domainid:
config_fini (domain->cfgst);
fail_config:
return ret;

View file

@ -13,24 +13,23 @@
<CycloneDDS>
<!-- Simple config-file for testing whether a config-file can be picked up
correctly. -->
<Domain>
<Id>3</Id>
<Domain id="3">
<General>
<NetworkInterfaceAddress>127.0.0.1</NetworkInterfaceAddress>
<AllowMulticast>true</AllowMulticast>
<EnableMulticastLoopback>true</EnableMulticastLoopback>
</General>
<Compatibility>
<StandardsConformance>lax</StandardsConformance>
</Compatibility>
<Tracing>
<Verbosity>warning</Verbosity>
<OutputFile>&#118;&#x6F;rtexdds-<![CDATA[trace]]>.${NON_EXISTENT_ENV_VARIABLE:-l}${CYCLONEDDS_URI:+o}g </OutputFile>
</Tracing>
<Internal>
<MaxParticipants>${MAX_PARTICIPANTS}</MaxParticipants>
<HeartbeatInterval max="10 s"> 100 ms </HeartbeatInterval>
<RediscoveryBlacklistDuration></RediscoveryBlacklistDuration>
</Internal>
</Domain>
<General>
<NetworkInterfaceAddress>127.0.0.1</NetworkInterfaceAddress>
<AllowMulticast>true</AllowMulticast>
<EnableMulticastLoopback>true</EnableMulticastLoopback>
</General>
<Compatibility>
<StandardsConformance>lax</StandardsConformance>
</Compatibility>
<Tracing>
<Verbosity>warning</Verbosity>
<OutputFile>&#118;&#x6F;rtexdds-<![CDATA[trace]]>.${NON_EXISTENT_ENV_VARIABLE:-l}${CYCLONEDDS_URI:+o}g </OutputFile>
</Tracing>
<Internal>
<MaxParticipants>${MAX_PARTICIPANTS}</MaxParticipants>
<HeartbeatInterval max="10 s"> 100 ms </HeartbeatInterval>
<RediscoveryBlacklistDuration></RediscoveryBlacklistDuration>
</Internal>
</CycloneDDS>

View file

@ -102,7 +102,7 @@ CU_Test(ddsc_participant, create_multiple_domains)
/* Test for creating participant with valid configuration file */
CU_Test(ddsc_participant, create_with_conf_no_env) {
dds_entity_t participant, participant2, participant3;
dds_entity_t participant2, participant3;
dds_return_t status;
dds_domainid_t domain_id;
dds_domainid_t valid_domain=3;
@ -114,10 +114,6 @@ CU_Test(ddsc_participant, create_with_conf_no_env) {
ddsrt_getenv(DDS_PROJECT_NAME_NOSPACE_CAPS"_URI", &env_uri);
CU_ASSERT_PTR_NOT_EQUAL_FATAL(env_uri, NULL);
//invalid domain
participant = dds_create_participant (1, NULL, NULL);
CU_ASSERT_FATAL(participant < 0);
//valid specific domain value
participant2 = dds_create_participant (valid_domain, NULL, NULL);
CU_ASSERT_FATAL(participant2 > 0);