Skip to content

Commit

Permalink
Merge pull request OpenDDS#4475 from jrw972/load-transport-configuration
Browse files Browse the repository at this point in the history
`load_transport_configuration` uses `ACE_Configuration_Heap`
  • Loading branch information
jrw972 authored Feb 19, 2024
2 parents b1c5340 + 0b8d2a7 commit 9495d63
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 289 deletions.
3 changes: 1 addition & 2 deletions dds/DCPS/RTPS/Sedp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,7 @@ Sedp::init(const GUID_t& guid,
domainStr;
transport_cfg_ = TheTransportRegistry->create_config(config_name.c_str());
transport_cfg_->instances_.push_back(transport_inst_);
transport_cfg_->passive_connect_duration_ =
static_cast<unsigned long>(disco.config()->sedp_passive_connect_duration().value().get_msec());
transport_cfg_->passive_connect_duration_ = disco.config()->sedp_passive_connect_duration();

// Use a static cast to avoid dependency on the RtpsUdp library
DCPS::RtpsUdpInst_rch rtps_inst =
Expand Down
2 changes: 1 addition & 1 deletion dds/DCPS/Service_Participant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ Service_Participant::load_configuration(
-1);
}

status = TransportRegistry::instance()->load_transport_configuration(ACE_TEXT_ALWAYS_CHAR(filename), config);
status = TransportRegistry::instance()->load_transport_configuration(ACE_TEXT_ALWAYS_CHAR(filename));
const String global_transport_config = config_store_->get(OPENDDS_COMMON_DCPS_GLOBAL_TRANSPORT_CONFIG,
OPENDDS_COMMON_DCPS_GLOBAL_TRANSPORT_CONFIG_default);
if (!global_transport_config.empty()) {
Expand Down
7 changes: 3 additions & 4 deletions dds/DCPS/transport/framework/TransportClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,16 @@ TransportClient::enable_transport_using_config(bool reliable, bool durable,
swap_bytes_ = tc->swap_bytes_;
reliable_ = reliable;
durable_ = durable;
unsigned long duration = tc->passive_connect_duration_;
if (duration == 0) {
duration = TransportConfig::DEFAULT_PASSIVE_CONNECT_DURATION;
passive_connect_duration_ = tc->passive_connect_duration_;
if (passive_connect_duration_ == 0) {
passive_connect_duration_ = TimeDuration::from_msec(TransportConfig::DEFAULT_PASSIVE_CONNECT_DURATION);
if (DCPS_debug_level) {
ACE_DEBUG((LM_WARNING,
ACE_TEXT("(%P|%t) TransportClient::enable_transport_using_config ")
ACE_TEXT("passive_connect_duration_ configured as 0, changing to ")
ACE_TEXT("default value\n")));
}
}
passive_connect_duration_ = TimeDuration::from_msec(duration);

populate_connection_info(dpi);

Expand Down
47 changes: 45 additions & 2 deletions dds/DCPS/transport/framework/TransportConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,57 @@ const unsigned long TransportConfig::DEFAULT_PASSIVE_CONNECT_DURATION;
#endif

TransportConfig::TransportConfig(const OPENDDS_STRING& name)
: swap_bytes_(false)
, passive_connect_duration_(DEFAULT_PASSIVE_CONNECT_DURATION)
: swap_bytes_(*this, &TransportConfig::swap_bytes, &TransportConfig::swap_bytes)
, passive_connect_duration_(*this, &TransportConfig::passive_connect_duration, &TransportConfig::passive_connect_duration)
, transports_(*this, &TransportConfig::transports, &TransportConfig::transports)
, name_(name)
, config_prefix_(ConfigPair::canonicalize("OPENDDS_CONFIG_" + name_))
{}

TransportConfig::~TransportConfig()
{}

void
TransportConfig::swap_bytes(bool flag)
{
TheServiceParticipant->config_store()->set_boolean(config_key("SWAP_BYTES").c_str(), flag);
}

bool
TransportConfig::swap_bytes() const
{
return TheServiceParticipant->config_store()->get_boolean(config_key("SWAP_BYTES").c_str(), false);
}

void
TransportConfig::passive_connect_duration(const TimeDuration& pcd)
{
TheServiceParticipant->config_store()->set(config_key("PASSIVE_CONNECT_DURATION").c_str(),
pcd,
ConfigStoreImpl::Format_IntegerMilliseconds);

}

TimeDuration
TransportConfig::passive_connect_duration() const
{
return TheServiceParticipant->config_store()->get(config_key("PASSIVE_CONNECT_DURATION").c_str(),
TimeDuration::from_msec(DEFAULT_PASSIVE_CONNECT_DURATION),
ConfigStoreImpl::Format_IntegerMilliseconds);
}

void
TransportConfig::transports(const ConfigStoreImpl::StringList& t)
{
TheServiceParticipant->config_store()->set(config_key("TRANSPORTS").c_str(), t);
}

ConfigStoreImpl::StringList
TransportConfig::transports() const
{
return TheServiceParticipant->config_store()->get(config_key("TRANSPORTS").c_str(), ConfigStoreImpl::StringList());
}

void
TransportConfig::sorted_insert(const TransportInst_rch& inst)
{
Expand Down
24 changes: 19 additions & 5 deletions dds/DCPS/transport/framework/TransportConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,30 @@ class OpenDDS_Dcps_Export TransportConfig : public virtual RcObject {

static const unsigned long DEFAULT_PASSIVE_CONNECT_DURATION = 60000;

OPENDDS_STRING name() const { return name_; }
const String& name() const { return name_; }
const String& config_prefix() const { return config_prefix_; }
String config_key(const String& key) const
{
return ConfigPair::canonicalize(config_prefix_ + "_" + key);
}

typedef OPENDDS_VECTOR(TransportInst_rch) InstancesType;
InstancesType instances_;

bool swap_bytes_;
ConfigValue<TransportConfig, bool> swap_bytes_;
void swap_bytes(bool flag);
bool swap_bytes() const;

/// The time period in milliseconds for the acceptor side
/// of a connection to wait for the connection.
/// The default is 60 seconds
unsigned long passive_connect_duration_;
ConfigValueRef<TransportConfig, TimeDuration> passive_connect_duration_;
void passive_connect_duration(const TimeDuration& pcd);
TimeDuration passive_connect_duration() const;

ConfigValueRef<TransportConfig, ConfigStoreImpl::StringList> transports_;
void transports(const ConfigStoreImpl::StringList& t);
ConfigStoreImpl::StringList transports() const;

/// Insert the TransportInst in sorted order (by name) in the instances_ list.
/// Use when the names of the TransportInst objects are specifically assigned
Expand All @@ -56,10 +69,11 @@ class OpenDDS_Dcps_Export TransportConfig : public virtual RcObject {
friend class TransportRegistry;
template <typename T, typename U>
friend RcHandle<T> OpenDDS::DCPS::make_rch(U const&);
explicit TransportConfig(const OPENDDS_STRING& name);
explicit TransportConfig(const String& name);
~TransportConfig();

const OPENDDS_STRING name_;
const String name_;
const String config_prefix_;
};

}
Expand Down
Loading

0 comments on commit 9495d63

Please sign in to comment.