PDPClient.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @file PDPClient.h
  16. *
  17. */
  18. #ifndef _FASTDDS_RTPS_PDPCLIENT_H_
  19. #define _FASTDDS_RTPS_PDPCLIENT_H_
  20. #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
  21. #include <fastdds/rtps/builtin/discovery/participant/PDP.h>
  22. #include <fastdds/rtps/messages/RTPSMessageGroup.h>
  23. #include <fastdds/rtps/builtin/discovery/participant/timedevent/DSClientEvent.h>
  24. namespace eprosima {
  25. namespace fastrtps{
  26. namespace rtps {
  27. class StatefulWriter;
  28. class StatefulReader;
  29. /**
  30. * Class PDPClient manages client side of the discovery server mechanism
  31. *@ingroup DISCOVERY_MODULE
  32. */
  33. class PDPClient : public PDP
  34. {
  35. friend class DSClientEvent;
  36. public:
  37. /**
  38. * Constructor
  39. * @param builtin Pointer to the BuiltinProcols object.
  40. * @param allocation Participant allocation parameters.
  41. */
  42. PDPClient(
  43. BuiltinProtocols* builtin,
  44. const RTPSParticipantAllocationAttributes& allocation);
  45. ~PDPClient();
  46. void initializeParticipantProxyData(ParticipantProxyData* participant_data) override;
  47. /**
  48. * Initialize the PDP.
  49. * @param part Pointer to the RTPSParticipant.
  50. * @return True on success
  51. */
  52. bool init(RTPSParticipantImpl* part) override;
  53. /**
  54. * Creates an initializes a new participant proxy from a DATA(p) raw info
  55. * @param p from DATA msg deserialization
  56. * @param writer_guid GUID of originating writer
  57. * @return new ParticipantProxyData * or nullptr on failure
  58. */
  59. ParticipantProxyData* createParticipantProxyData(
  60. const ParticipantProxyData& p,
  61. const GUID_t& writer_guid) override;
  62. /**
  63. * Create the SPDP Writer and Reader
  64. * @return True if correct.
  65. */
  66. bool createPDPEndpoints() override;
  67. /**
  68. * Check if all servers have acknowledge the client PDP data
  69. * This method must be called from a mutex protected context.
  70. * @return True if all can reach the client
  71. */
  72. bool all_servers_acknowledge_PDP();
  73. /**
  74. * Check if we have our PDP received data updated
  75. * This method must be called from a mutex protected context.
  76. * @return True if we known all the participants the servers are aware of
  77. */
  78. bool is_all_servers_PDPdata_updated();
  79. /**
  80. * Force the sending of our local PDP to all servers
  81. * @param new_change If true a new change (with new seqNum) is created and sent;
  82. * if false the last change is re-sent
  83. * @param dispose Sets change kind to NOT_ALIVE_DISPOSED_UNREGISTERED
  84. * @param wparams allows to identify the change
  85. */
  86. void announceParticipantState(
  87. bool new_change,
  88. bool dispose = false,
  89. WriteParams& wparams = WriteParams::WRITE_PARAM_DEFAULT) override;
  90. /**
  91. * These methods wouldn't be needed under perfect server operation
  92. * (no need of dynamic endpoint allocation) but must be implemented
  93. * to solve server shutdown situations.
  94. * @param pdata Pointer to the RTPSParticipantProxyData object.
  95. */
  96. void assignRemoteEndpoints(ParticipantProxyData* pdata) override;
  97. void removeRemoteEndpoints(ParticipantProxyData* pdata) override;
  98. void notifyAboveRemoteEndpoints(const ParticipantProxyData& pdata) override;
  99. /**
  100. * Matching server EDP endpoints
  101. * @return true if all servers have been discovered
  102. */
  103. bool match_servers_EDP_endpoints();
  104. private:
  105. /**
  106. * TimedEvent for server synchronization:
  107. * first stage: periodically resend the local RTPSParticipant information until
  108. * all servers have acknowledge reception
  109. * second stage: waiting PDP info is up to date before allowing EDP matching
  110. */
  111. DSClientEvent* mp_sync;
  112. //! flag to hightlight we need a server ping announcement
  113. bool _serverPing;
  114. };
  115. }
  116. } /* namespace rtps */
  117. } /* namespace eprosima */
  118. #endif
  119. #endif /* _FASTDDS_RTPS_PDPCLIENT_H_ */