Skip to content

Commit

Permalink
Refactor IStatusQueryable and make monitor service interfaces private (
Browse files Browse the repository at this point in the history
…#4651) (#4687)

* Refactor IStatusQueryable and make monitor service interfaces private (#4651)

* Refs #20739: Make monitor service interfaces private (except IProxyQueryable)

Signed-off-by: Mario Dominguez <[email protected]>

* Refs #20739: Replace tabs with spaces in monitorservice_types.idl

Signed-off-by: Mario Dominguez <[email protected]>

* Refs #20739: Refactor include and src files

Signed-off-by: Mario Dominguez <[email protected]>

* Refs #20739: Refactor tests

Signed-off-by: Mario Dominguez <[email protected]>

* Refs #20739: Apply suggestion regarding asserts

Signed-off-by: Mario Dominguez <[email protected]>

* Refs 20739: Rev 2 changes

Signed-off-by: Mario Dominguez <[email protected]>

* Refs 20739: Linter

Signed-off-by: Mario Dominguez <[email protected]>

* Refs 20739: Rev 3 changes

Signed-off-by: Mario Dominguez <[email protected]>

* Refs #20739: Remove status assert

Signed-off-by: Mario Dominguez <[email protected]>

* Refs #20739: Comment typo

Signed-off-by: Mario Dominguez <[email protected]>

---------

Signed-off-by: Mario Dominguez <[email protected]>
(cherry picked from commit fb841b9)

# Conflicts:
#	include/fastdds/rtps/reader/RTPSReader.h
#	include/fastdds/rtps/writer/RTPSWriter.h

* Fix conflicts based on original PR

Signed-off-by: JesusPoderoso <[email protected]>

---------

Signed-off-by: JesusPoderoso <[email protected]>
Co-authored-by: Mario Domínguez López <[email protected]>
Co-authored-by: JesusPoderoso <[email protected]>
  • Loading branch information
3 people authored May 24, 2024
1 parent db64268 commit 4ca144e
Show file tree
Hide file tree
Showing 30 changed files with 313 additions and 336 deletions.
9 changes: 8 additions & 1 deletion include/fastdds/rtps/builtin/discovery/participant/PDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <fastdds/rtps/participant/ParticipantDiscoveryInfo.h>
#include <fastdds/rtps/reader/ReaderDiscoveryInfo.h>
#include <fastdds/rtps/writer/WriterDiscoveryInfo.h>
#include <fastdds/statistics/rtps/monitor_service/interfaces/IProxyObserver.hpp>
#include <fastdds/statistics/rtps/monitor_service/interfaces/IProxyQueryable.hpp>
#include <fastrtps/qos/QosPolicies.h>
#include <fastrtps/utils/collections/ResourceLimitedVector.hpp>
Expand All @@ -42,6 +41,14 @@
namespace eprosima {

namespace fastdds {
namespace statistics {
namespace rtps {

struct IProxyObserver;

} // namespace rtps
} // namespace statistics

namespace rtps {

class PDPServerListener;
Expand Down
9 changes: 2 additions & 7 deletions include/fastdds/rtps/reader/RTPSReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,11 @@
#include <fastdds/rtps/common/Time_t.h>
#include <fastdds/rtps/history/ReaderHistory.h>
#include <fastdds/rtps/interfaces/IReaderDataFilter.hpp>
#include <fastdds/statistics/rtps/monitor_service/connections_fwd.hpp>
#include <fastdds/statistics/rtps/StatisticsCommon.hpp>
#include <fastrtps/qos/LivelinessChangedStatus.h>
#include <fastrtps/utils/TimedConditionVariable.hpp>

#include <fastdds/statistics/rtps/StatisticsCommon.hpp>

#ifdef FASTDDS_STATISTICS
#include <fastdds/statistics/rtps/monitor_service/interfaces/IConnectionsQueryable.hpp>
#include <fastdds/statistics/rtps/monitor_service/interfaces/IConnectionsObserver.hpp>
#endif // ifdef FASTDDS_STATISTICS

namespace eprosima {
namespace fastrtps {
namespace rtps {
Expand Down
11 changes: 4 additions & 7 deletions include/fastdds/rtps/writer/RTPSWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,13 @@
#include <fastdds/rtps/Endpoint.h>
#include <fastdds/rtps/interfaces/IReaderDataFilter.hpp>
#include <fastdds/rtps/messages/RTPSMessageGroup.h>
#include "DeliveryRetCode.hpp"
#include "LocatorSelectorSender.hpp"
#include <fastdds/statistics/rtps/monitor_service/connections_fwd.hpp>
#include <fastdds/statistics/rtps/StatisticsCommon.hpp>
#include <fastrtps/qos/LivelinessLostStatus.h>

#include <fastdds/statistics/rtps/StatisticsCommon.hpp>

#ifdef FASTDDS_STATISTICS
#include <fastdds/statistics/rtps/monitor_service/interfaces/IConnectionsQueryable.hpp>
#include <fastdds/statistics/rtps/monitor_service/interfaces/IConnectionsObserver.hpp>
#endif // ifdef FASTDDS_STATISTICS
#include "DeliveryRetCode.hpp"
#include "LocatorSelectorSender.hpp"

namespace eprosima {

Expand Down
186 changes: 93 additions & 93 deletions include/fastdds/statistics/monitorservice_types.idl
Original file line number Diff line number Diff line change
Expand Up @@ -22,99 +22,99 @@ module eprosima {
module fastdds {
module statistics {

enum ConnectionMode
{
DATA_SHARING,
INTRAPROCESS,
TRANSPORT
};

struct Connection
{
ConnectionMode mode;
detail::GUID_s guid;
sequence<detail::Locator_s> announced_locators;
sequence<detail::Locator_s> used_locators;
};

struct QosPolicyCount_s
{
unsigned long policy_id;
unsigned long count;
};

struct BaseStatus_s
{
unsigned long total_count;
};

typedef sequence<QosPolicyCount_s> QosPolicyCountSeq_s;

struct IncompatibleQoSStatus_s
{
unsigned long total_count;
unsigned long last_policy_id;
QosPolicyCountSeq_s policies;
};

struct LivelinessChangedStatus_s
{
unsigned long alive_count;
unsigned long not_alive_count;
octet last_publication_handle[16];
};

struct DeadlineMissedStatus_s
{
unsigned long total_count;
octet last_instance_handle[16];
};

typedef BaseStatus_s LivelinessLostStatus_s;
typedef BaseStatus_s InconsistentTopicStatus_s;
typedef BaseStatus_s SampleLostStatus_s;

enum StatusKind
{
PROXY,
CONNECTION_LIST,
INCOMPATIBLE_QOS,
INCONSISTENT_TOPIC,
LIVELINESS_LOST,
LIVELINESS_CHANGED,
DEADLINE_MISSED,
SAMPLE_LOST,
STATUSES_SIZE
};

union MonitorServiceData switch(StatusKind)
{
case PROXY:
sequence<octet> entity_proxy;
case CONNECTION_LIST:
sequence<Connection> connection_list;
case INCOMPATIBLE_QOS:
IncompatibleQoSStatus_s incompatible_qos_status;
case INCONSISTENT_TOPIC:
InconsistentTopicStatus_s inconsistent_topic_status;
case LIVELINESS_LOST:
LivelinessLostStatus_s liveliness_lost_status;
case LIVELINESS_CHANGED:
LivelinessChangedStatus_s liveliness_changed_status;
case DEADLINE_MISSED:
DeadlineMissedStatus_s deadline_missed_status;
case SAMPLE_LOST:
SampleLostStatus_s sample_lost_status;
case STATUSES_SIZE:
octet statuses_size;
};

struct MonitorServiceStatusData
{
@Key detail::GUID_s local_entity;
@Key StatusKind status_kind;
MonitorServiceData value;
};
enum ConnectionMode
{
DATA_SHARING,
INTRAPROCESS,
TRANSPORT
};

struct Connection
{
ConnectionMode mode;
detail::GUID_s guid;
sequence<detail::Locator_s> announced_locators;
sequence<detail::Locator_s> used_locators;
};

struct QosPolicyCount_s
{
unsigned long policy_id;
unsigned long count;
};

struct BaseStatus_s
{
unsigned long total_count;
};

typedef sequence<QosPolicyCount_s> QosPolicyCountSeq_s;

struct IncompatibleQoSStatus_s
{
unsigned long total_count;
unsigned long last_policy_id;
QosPolicyCountSeq_s policies;
};

struct LivelinessChangedStatus_s
{
unsigned long alive_count;
unsigned long not_alive_count;
octet last_publication_handle[16];
};

struct DeadlineMissedStatus_s
{
unsigned long total_count;
octet last_instance_handle[16];
};

typedef BaseStatus_s LivelinessLostStatus_s;
typedef BaseStatus_s InconsistentTopicStatus_s;
typedef BaseStatus_s SampleLostStatus_s;

enum StatusKind
{
PROXY,
CONNECTION_LIST,
INCOMPATIBLE_QOS,
INCONSISTENT_TOPIC,
LIVELINESS_LOST,
LIVELINESS_CHANGED,
DEADLINE_MISSED,
SAMPLE_LOST,
STATUSES_SIZE
};

union MonitorServiceData switch(StatusKind)
{
case PROXY:
sequence<octet> entity_proxy;
case CONNECTION_LIST:
sequence<Connection> connection_list;
case INCOMPATIBLE_QOS:
IncompatibleQoSStatus_s incompatible_qos_status;
case INCONSISTENT_TOPIC:
InconsistentTopicStatus_s inconsistent_topic_status;
case LIVELINESS_LOST:
LivelinessLostStatus_s liveliness_lost_status;
case LIVELINESS_CHANGED:
LivelinessChangedStatus_s liveliness_changed_status;
case DEADLINE_MISSED:
DeadlineMissedStatus_s deadline_missed_status;
case SAMPLE_LOST:
SampleLostStatus_s sample_lost_status;
case STATUSES_SIZE:
octet statuses_size;
};

struct MonitorServiceStatusData
{
@Key detail::GUID_s local_entity;
@Key StatusKind status_kind;
MonitorServiceData value;
};

}; // namespace statisitcs
}; // namespace fastdds
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @file connections_fwd.hpp
*
*/

#ifndef _FASTDDS_STATISTICS_MONITOR_SERVICE_CONNECTION_FWD_HPP_
#define _FASTDDS_STATISTICS_MONITOR_SERVICE_CONNECTION_FWD_HPP_

namespace eprosima {
namespace fastdds {
namespace statistics {

class Connection;

namespace rtps {

using ConnectionList = std::vector<eprosima::fastdds::statistics::Connection>;

} // rtps
} // statistics
} // fastdds
} // eprosima

#endif // _FASTDDS_STATISTICS_MONITOR_SERVICE_CONNECTION_FWD_HPP_
31 changes: 24 additions & 7 deletions src/cpp/fastdds/publisher/PublisherImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,7 @@ PublisherListener* PublisherImpl::get_listener_for(

#ifdef FASTDDS_STATISTICS
bool PublisherImpl::get_monitoring_status(
const uint32_t& status_id,
statistics::rtps::DDSEntityStatus*& status,
statistics::MonitorServiceData& status,
const fastrtps::rtps::GUID_t& entity_guid)
{
bool ret = false;
Expand All @@ -662,11 +661,21 @@ bool PublisherImpl::get_monitoring_status(
{
if (writer->guid() == entity_guid)
{
switch (status_id)
switch (status._d())
{
case statistics::INCOMPATIBLE_QOS:
{
writer->get_offered_incompatible_qos_status(*static_cast<OfferedIncompatibleQosStatus*>(status));
OfferedIncompatibleQosStatus incompatible_qos_status;
writer->get_offered_incompatible_qos_status(incompatible_qos_status);
status.incompatible_qos_status().total_count(incompatible_qos_status.total_count);
status.incompatible_qos_status().last_policy_id(incompatible_qos_status.last_policy_id);
for (auto& qos : incompatible_qos_status.policies)
{
statistics::QosPolicyCount_s count;
count.count(qos.count);
count.policy_id(qos.policy_id);
status.incompatible_qos_status().policies().push_back(count);
}
ret = true;
break;
}
Expand All @@ -679,19 +688,27 @@ bool PublisherImpl::get_monitoring_status(
}*/
case statistics::LIVELINESS_LOST:
{
writer->get_liveliness_lost_status(*static_cast<LivelinessLostStatus*>(status));
LivelinessLostStatus liveliness_lost_status;
writer->get_liveliness_lost_status(liveliness_lost_status);
status.liveliness_lost_status().total_count(liveliness_lost_status.total_count);
ret = true;
break;
}
case statistics::DEADLINE_MISSED:
{
writer->get_offered_deadline_missed_status(*static_cast<DeadlineMissedStatus*>(status));
DeadlineMissedStatus deadline_missed_status;
writer->get_offered_deadline_missed_status(deadline_missed_status);
status.deadline_missed_status().total_count(deadline_missed_status.total_count);
std::memcpy(
status.deadline_missed_status().last_instance_handle().data(),
deadline_missed_status.last_instance_handle.value,
16);
ret = true;
break;
}
default:
{
EPROSIMA_LOG_ERROR(PUBLISHER, "Queried status not available for this entity " << status_id);
EPROSIMA_LOG_ERROR(PUBLISHER, "Queried status not available for this entity " << status._d());
break;
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/cpp/fastdds/publisher/PublisherImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <map>

#ifdef FASTDDS_STATISTICS
#include <fastdds/statistics/rtps/monitor_service/interfaces/IStatusQueryable.hpp>
#include <statistics/rtps/monitor-service/interfaces/IStatusQueryable.hpp>
#endif // ifdef FASTDDS_STATISTICS

using eprosima::fastrtps::types::ReturnCode_t;
Expand Down Expand Up @@ -206,8 +206,7 @@ class PublisherImpl

#ifdef FASTDDS_STATISTICS
bool get_monitoring_status(
const uint32_t& status_id,
statistics::rtps::DDSEntityStatus*& status,
statistics::MonitorServiceData& status,
const fastrtps::rtps::GUID_t& entity_guid);
#endif //FASTDDS_STATISTICS

Expand Down
Loading

0 comments on commit 4ca144e

Please sign in to comment.