Skip to content

Commit

Permalink
Update easy client-server environment mechanism (#1325)
Browse files Browse the repository at this point in the history
* Update easy client-server environment mechanism (#1251)

* Updating variables values

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Ongoing changes...

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Added server creation tool.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Rename the tool binary and generate symlink on install

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Windows: install only symlinks if elevation granted.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Correct a help flag misspelt

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Solving linux jenkins issues (whitespaces on installation path)

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Solving mac jenkins issues. Handling old cmake versions.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Mac workaround didn't play well. Second attempt.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Mac workaround didn't play well. Third attempt.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Addressing reviewer comments.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Applied uncrustified requirements.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Applied uncrustified requirements.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Applied uncrustified requirements.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Applied uncrustified requirements.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Avoid warning when symlink already exists

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Update config file to export the tool target. This way other projects like discovery-server can use this target to locate the binaries.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* DDS Domain updated to handle environmental variables

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Solving uncrustify issues

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Solving uncrustify issues

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Support symlink geneartion on old cmake versions

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Solving unix issues if sh is the default shell.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* solving windows issues. Unmatching quotes

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Workaround lack of privileges on Windows to create symlinks by creating a .bat script in that case.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Solved bash issue on linux

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Solved installer generation issues. Update .bat to be independent of the current working dir.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Solved trim error on participant drop

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Meeting uncrustify requirements.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Meeting uncrustify requirements.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Solved MinSizeRel and RelWithDebInfo install config issues on Windows

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Solved EDP trimming issue on participant drop

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Solved uncrustify issues.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Solved EDP sync issue on trimming.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
# Conflicts:
#	test/blackbox/BlackboxTestsDiscovery.cpp

* Uncrustify

Co-authored-by: MiguelBarro <45819833+MiguelBarro@users.noreply.github.com>
  • Loading branch information
Luis Gasco and MiguelBarro authored Sep 3, 2020
1 parent 80cd860 commit 42c360b
Show file tree
Hide file tree
Showing 21 changed files with 4,446 additions and 531 deletions.
37 changes: 37 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,15 @@ if(EPROSIMA_BUILD)
set(SHM_TRANSPORT_DEFAULT ON)
endif()

###############################################################################
# Tools default setup
###############################################################################
option(COMPILE_TOOLS "Build tools" ON)

if(EPROSIMA_BUILD AND IS_TOP_LEVEL)
set(COMPILE_TOOLS ON)
endif()

###############################################################################
# Compile library.
###############################################################################
Expand All @@ -290,6 +299,14 @@ if(COMPILE_EXAMPLES)
add_subdirectory(examples)
endif()

###############################################################################
# Tools
###############################################################################

if(COMPILE_TOOLS)
add_subdirectory(tools)
endif()

###############################################################################
# Documentation
###############################################################################
Expand Down Expand Up @@ -408,6 +425,7 @@ set(CPACK_COMPONENTS_ALL headers licenses)
option(INSTALL_EXAMPLES "Install example" OFF)
if(EPROSIMA_INSTALLER)
set(INSTALL_EXAMPLES ON)
set(INSTALL_TOOLS ON)
endif()

if(INSTALL_EXAMPLES)
Expand All @@ -424,6 +442,25 @@ if(INSTALL_EXAMPLES)
set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} examples)
endif()

option(INSTALL_TOOLS "Install tools" OFF)
if(EPROSIMA_INSTALLER)
set(INSTALL_TOOLS ON)
endif()

if(INSTALL_TOOLS)
# Install tools
install(DIRECTORY ${PROJECT_SOURCE_DIR}/tools
DESTINATION tools/
COMPONENT tools
PATTERN "tools/CMakeLists.txt" EXCLUDE
)

set(CPACK_COMPONENT_TOOLS_DISPLAY_NAME "Tools")
set(CPACK_COMPONENT_TOOLS_DESCRIPTION "eProsima ${PROJECT_NAME_LARGE} tools")

set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} tools)
endif()

if(BUILD_DOCUMENTATION)

# Instalation of doxygen files
Expand Down
1 change: 1 addition & 0 deletions cmake/packaging/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ find_package(TinyXML2 QUIET)
@FASTRTPS_PACKAGE_OPT_DEPS@

include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake)
@INCLUDE_FASTDS_TARGETS@
6 changes: 4 additions & 2 deletions include/fastdds/rtps/RTPSDomain.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,14 @@ class RTPSDomain
/**
* Creates a RTPSParticipant as default server or client if ROS_MASTER_URI environment variable is set.
* @param domain_id DDS domain associated
* @param enabled True if the RTPSParticipant should be enabled on creation. False if it will be enabled later with RTPSParticipant::enable()
* @param attrs RTPSParticipant Attributes.
* @param listen Pointer to the ParticipantListener.
* @return Pointer to the RTPSParticipant.
*/
static RTPSParticipant* clientServerEnvironmentCreationOverride(
uint32_t domain_id,
bool enabled,
const RTPSParticipantAttributes& attrs,
RTPSParticipantListener* listen /*= nullptr*/);

Expand Down Expand Up @@ -195,8 +197,8 @@ class RTPSDomain
static std::set<uint32_t> m_RTPSParticipantIDs;
};

}
} /* namespace */
} // namespace rtps
} /* namespace fastrtps */
} /* namespace eprosima */

#endif /* _FASTDDS_RTPS_DOMAIN_H_*/
111 changes: 76 additions & 35 deletions include/fastdds/rtps/attributes/ServerAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,55 +28,96 @@


namespace eprosima {
namespace fastrtps{
namespace fastrtps {
namespace rtps {

class ParticipantProxyData;
class ParticipantProxyData;

/**
* Class RemoteServerAttributes, to define the attributes of the Discovery Server Protocol.
* @ingroup RTPS_ATTRIBUTES_MODULE
*/
/**
* Class RemoteServerAttributes, to define the attributes of the Discovery Server Protocol.
* @ingroup RTPS_ATTRIBUTES_MODULE
*/

class RemoteServerAttributes
{
public:

class RemoteServerAttributes
RTPS_DllAPI inline bool operator ==(
const RemoteServerAttributes& r) const
{
public:
RTPS_DllAPI inline bool operator==(const RemoteServerAttributes& r) const
{ return guidPrefix == r.guidPrefix; }
return guidPrefix == r.guidPrefix
&& metatrafficUnicastLocatorList == r.metatrafficUnicastLocatorList
&& metatrafficMulticastLocatorList == r.metatrafficMulticastLocatorList;
// && proxy == r.proxy;
}

RTPS_DllAPI void clear()
{
guidPrefix = GuidPrefix_t::unknown();
metatrafficUnicastLocatorList.clear();
metatrafficMulticastLocatorList.clear();
proxy = nullptr;
}

RTPS_DllAPI GUID_t GetParticipant() const;

RTPS_DllAPI GUID_t GetParticipant() const;
RTPS_DllAPI GUID_t GetPDPReader() const;
RTPS_DllAPI GUID_t GetPDPWriter() const;

RTPS_DllAPI GUID_t GetPDPReader() const;
RTPS_DllAPI GUID_t GetPDPWriter() const;
RTPS_DllAPI GUID_t GetEDPPublicationsReader() const;
RTPS_DllAPI GUID_t GetEDPSubscriptionsWriter() const;

RTPS_DllAPI GUID_t GetEDPPublicationsReader() const;
RTPS_DllAPI GUID_t GetEDPSubscriptionsWriter() const;
RTPS_DllAPI GUID_t GetEDPPublicationsWriter() const;
RTPS_DllAPI GUID_t GetEDPSubscriptionsReader() const;

RTPS_DllAPI GUID_t GetEDPPublicationsWriter() const;
RTPS_DllAPI GUID_t GetEDPSubscriptionsReader() const;
RTPS_DllAPI inline bool ReadguidPrefix(
const char* pfx)
{
return bool(std::istringstream(pfx) >> guidPrefix);
}

//!Metatraffic Unicast Locator List
LocatorList_t metatrafficUnicastLocatorList;
//!Metatraffic Multicast Locator List.
LocatorList_t metatrafficMulticastLocatorList;

RTPS_DllAPI inline bool ReadguidPrefix(const char * pfx)
{
return bool(std::istringstream(pfx) >> guidPrefix);
}
//!Guid prefix
GuidPrefix_t guidPrefix;

//!Metatraffic Unicast Locator List
LocatorList_t metatrafficUnicastLocatorList;
//!Metatraffic Multicast Locator List.
LocatorList_t metatrafficMulticastLocatorList;
// Live participant proxy reference
const ParticipantProxyData* proxy{};
};

//!Guid prefix
GuidPrefix_t guidPrefix;
typedef std::list<RemoteServerAttributes> RemoteServerList_t;

// Live participant proxy reference
const ParticipantProxyData * proxy{};
};
// port use if the ros environment variable doesn't specified one
constexpr uint16_t DEFAULT_ROS2_SERVER_PORT = 11811;
// default server base guidPrefix
const char* const DEFAULT_ROS2_SERVER_GUIDPREFIX = "44.49.53.43.53.45.52.56.45.52.5F.30";

typedef std::list<RemoteServerAttributes> RemoteServerList_t;
/**
* Retrieves a ; separated list of locators from an environment variable and
* populates a RemoteServerList_t mapping list position to default guid.
* @param list servers listening locator list provided.
* @param attributes referenct to a RemoteServerList_t to populate.
* @return true if parsing succeeds
*/
RTPS_DllAPI bool load_environment_server_info(
std::string list,
RemoteServerList_t& attributes);
/**
* returns the guidPrefix associated to the default server id given
* @param id of the default server whose guidPrefix we want to retrieve
* @param guid reference to the guidPrefix to modify
* @return true if the server guid can be delivered
*/
RTPS_DllAPI bool get_server_client_default_guidPrefix(
int id,
GuidPrefix_t& guid);

}
} /* namespace rtps */
} /* namespace eprosima */
} // namespace rtps
} // namespace fastrtps
} // namespace eprosima

#endif
#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
#endif /* _FASTDDS_SERVERATTRIBUTES_H_ */
46 changes: 23 additions & 23 deletions include/fastdds/rtps/builtin/discovery/endpoint/EDPServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ class EDPServer : public EDPSimple
}

/**
* This method generates the corresponding change in the subscription writer and send it to all known remote endpoints.
* @param reader Pointer to the Reader object.
* @param rdata Pointer to the ReaderProxyData object.
* @return true if correct.
*/
* This method generates the corresponding change in the subscription writer and send it to all known remote endpoints.
* @param reader Pointer to the Reader object.
* @param rdata Pointer to the ReaderProxyData object.
* @return true if correct.
*/
bool processLocalReaderProxyData(
RTPSReader* reader,
ReaderProxyData* rdata) override;
Expand All @@ -97,14 +97,14 @@ class EDPServer : public EDPSimple
* @return True if correct.
*/
bool removeLocalReader(
RTPSReader*R) override;
RTPSReader* R) override;
/**
* This methods generates the change disposing of the local Writer and calls the unpairing and removal methods of the base class.
* @param W Pointer to the RTPSWriter object.
* @return True if correct.
*/
bool removeLocalWriter(
RTPSWriter*W) override;
RTPSWriter* W) override;

/**
* Some History data is flag for defer removal till every client
Expand All @@ -120,13 +120,13 @@ class EDPServer : public EDPSimple
bool trimPUBWriterHistory()
{
return trimWriterHistory<ProxyHashTable<WriterProxyData>*>(_PUBdemises,
*publications_writer_.first, *publications_writer_.second, &ParticipantProxyData::m_writers);
*publications_writer_.first, *publications_writer_.second, &ParticipantProxyData::m_writers);
}

bool trimSUBWriterHistory()
{
return trimWriterHistory<ProxyHashTable<ReaderProxyData>*>(_SUBdemises,
*subscriptions_writer_.first, *subscriptions_writer_.second, &ParticipantProxyData::m_readers);
*subscriptions_writer_.first, *subscriptions_writer_.second, &ParticipantProxyData::m_readers);
}

//! returns true if loading info from persistency database
Expand All @@ -135,12 +135,21 @@ class EDPServer : public EDPSimple
//! Process the info recorded in the persistence database
void processPersistentData();

protected:
/**
* Trigger the participant CacheChange_t removal system
* @return True if successfully modified WriterHistory
*/
void removePublisherFromHistory(
const InstanceHandle_t&);
void removeSubscriberFromHistory(
const InstanceHandle_t&);

protected:

/**
* Add participant CacheChange_ts from reader to writer
* @return True if successfully modified WriterHistory
*/
* Add participant CacheChange_ts from reader to writer
* @return True if successfully modified WriterHistory
*/
bool addPublisherFromHistory(
CacheChange_t& c)
{
Expand All @@ -153,15 +162,6 @@ class EDPServer : public EDPSimple
return addEndpointFromHistory(*subscriptions_writer_.first, *subscriptions_writer_.second, c);
}

/**
* Trigger the participant CacheChange_t removal system
* @return True if successfully modified WriterHistory
*/
void removePublisherFromHistory(
const InstanceHandle_t&);
void removeSubscriberFromHistory(
const InstanceHandle_t&);

private:

/**
Expand Down Expand Up @@ -193,5 +193,5 @@ class EDPServer : public EDPSimple
} /* namespace fastrtps */
} /* namespace eprosima */

#endif
#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
#endif /* _FASTDDS_RTPS_EDPSERVER_H_ */
4 changes: 4 additions & 0 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,10 @@ elseif(NOT EPROSIMA_INSTALLER)
set(FASTRTPS_PACKAGE_OPT_BIN_DIR_CONDITION "if(0)")
endif()

if(COMPILE_TOOLS)
set(INCLUDE_FASTDS_TARGETS "include(\${CMAKE_CURRENT_LIST_DIR}/fast-discovery-server-targets.cmake)")
endif()

# Add fastrtps dependencies in its CMake config file.
if(LINK_SSL AND NOT EPROSIMA_INSTALLER_MINION)
set(FASTRTPS_PACKAGE_OPT_DEPS "find_package(OpenSSL REQUIRED)")
Expand Down
Loading

0 comments on commit 42c360b

Please sign in to comment.