Skip to content

Commit

Permalink
Refs #20738. Refactor monitor service
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
  • Loading branch information
richiware committed Apr 3, 2024
1 parent eb38f4c commit 3891c3f
Show file tree
Hide file tree
Showing 32 changed files with 338 additions and 328 deletions.
9 changes: 5 additions & 4 deletions include/fastdds/rtps/reader/RTPSReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
#include <fastdds/rtps/Endpoint.h>
#include <fastdds/rtps/history/ReaderHistory.h>
#include <fastdds/rtps/interfaces/IReaderDataFilter.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 <fastdds/statistics/rtps/StatisticsCommon.hpp>
#include <fastdds/utils/TimedConditionVariable.hpp>

#ifdef FASTDDS_STATISTICS
#include <statistics/rtps/monitor-service/interfaces/IConnectionsQueryable.hpp>
#include <statistics/rtps/monitor-service/interfaces/IConnectionsObserver.hpp>
#endif // ifdef FASTDDS_STATISTICS

namespace eprosima {
namespace fastrtps {
namespace rtps {
Expand Down
5 changes: 1 addition & 4 deletions include/fastdds/rtps/writer/RTPSWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@
#include <fastdds/rtps/messages/RTPSMessageGroup.h>
#include <fastdds/rtps/writer/DeliveryRetCode.hpp>
#include <fastdds/rtps/writer/LocatorSelectorSender.hpp>
#ifdef FASTDDS_STATISTICS
#include <fastdds/statistics/rtps/monitor_service/interfaces/IConnectionsObserver.hpp>
#include <fastdds/statistics/rtps/monitor_service/interfaces/IConnectionsQueryable.hpp>
#endif // ifdef FASTDDS_STATISTICS
#include <fastdds/statistics/rtps/monitor_service/connections_fwd.hpp>
#include <fastdds/statistics/rtps/StatisticsCommon.hpp>

namespace eprosima {
Expand Down
191 changes: 95 additions & 96 deletions include/fastdds/statistics/monitorservice_types.idl
Original file line number Diff line number Diff line change
Expand Up @@ -22,103 +22,102 @@ 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;

module StatusKind
{
typedef unsigned long StatusKind;

const StatusKind PROXY = 0;
const StatusKind CONNECTION_LIST = 1;
const StatusKind INCOMPATIBLE_QOS = 2;
const StatusKind INCONSISTENT_TOPIC = 3;
const StatusKind LIVELINESS_LOST = 4;
const StatusKind LIVELINESS_CHANGED = 5;
const StatusKind DEADLINE_MISSED = 6;
const StatusKind SAMPLE_LOST = 7;
const StatusKind STATUSES_SIZE = 8;
}; // module StatusKind

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

struct MonitorServiceStatusData
{
@Key detail::GUID_s local_entity;
@Key StatusKind::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;

module StatusKind
{
typedef unsigned long StatusKind;

const StatusKind PROXY = 0;
const StatusKind CONNECTION_LIST = 1;
const StatusKind INCOMPATIBLE_QOS = 2;
const StatusKind INCONSISTENT_TOPIC = 3;
const StatusKind LIVELINESS_LOST = 4;
const StatusKind LIVELINESS_CHANGED = 5;
const StatusKind DEADLINE_MISSED = 6;
const StatusKind SAMPLE_LOST = 7;
const StatusKind STATUSES_SIZE = 8;
}; // module StatusKind

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

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

}; // namespace statisitcs
}; // namespace fastdds
}; // namespace eprosima

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 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 connection_fwd.hpp
*
*/

#ifndef _FASTDDS_STATISTICS_MONITOR_SERVICE_CONNECTION_FWD_HPP_
#define _FASTDDS_STATISTICS_MONITOR_SERVICE_CONNECTION_FWD_HPP_

#ifdef FASTDDS_STATISTICS

namespace eprosima {
namespace fastdds {
namespace statistics {

class Connection;

namespace rtps {

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

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

#endif // ifdef FASTDDS_STATISTICS

#endif // _FASTDDS_STATISTICS_MONITOR_SERVICE_CONNECTION_FWD_HPP_
34 changes: 17 additions & 17 deletions include/fastdds/statistics/types.idl
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,23 @@ struct PhysicalData

module EventKind
{
const unsigned long HISTORY2HISTORY_LATENCY = 1;
const unsigned long NETWORK_LATENCY = 2;
const unsigned long PUBLICATION_THROUGHPUT = 4;
const unsigned long SUBSCRIPTION_THROUGHPUT = 8;
const unsigned long RTPS_SENT = 16;
const unsigned long RTPS_LOST = 32;
const unsigned long RESENT_DATAS = 64;
const unsigned long HEARTBEAT_COUNT = 128;
const unsigned long ACKNACK_COUNT = 256;
const unsigned long NACKFRAG_COUNT = 512;
const unsigned long GAP_COUNT = 1024;
const unsigned long DATA_COUNT = 2048;
const unsigned long PDP_PACKETS = 4096;
const unsigned long EDP_PACKETS = 8192;
const unsigned long DISCOVERED_ENTITY = 16384;
const unsigned long SAMPLE_DATAS = 32768;
const unsigned long PHYSICAL_DATA = 65536;
const unsigned long HISTORY2HISTORY_LATENCY = 0x1;
const unsigned long NETWORK_LATENCY = 0x2;
const unsigned long PUBLICATION_THROUGHPUT = 0x4;
const unsigned long SUBSCRIPTION_THROUGHPUT = 0x8;
const unsigned long RTPS_SENT = 0x10;
const unsigned long RTPS_LOST = 0x20;
const unsigned long RESENT_DATAS = 0x40;
const unsigned long HEARTBEAT_COUNT = 0x80;
const unsigned long ACKNACK_COUNT = 0x100;
const unsigned long NACKFRAG_COUNT = 0x200;
const unsigned long GAP_COUNT = 0x400;
const unsigned long DATA_COUNT = 0x800;
const unsigned long PDP_PACKETS = 0x1000;
const unsigned long EDP_PACKETS = 0x2000;
const unsigned long DISCOVERED_ENTITY = 0x4000;
const unsigned long SAMPLE_DATAS = 0x8000;
const unsigned long PHYSICAL_DATA = 0x10000;
};

union Data switch(unsigned long)
Expand Down
31 changes: 24 additions & 7 deletions src/cpp/fastdds/publisher/PublisherImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,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 @@ -676,11 +675,21 @@ bool PublisherImpl::get_monitoring_status(
{
if (writer->guid() == entity_guid)
{
switch (status_id)
switch (status._d())
{
case statistics::StatusKind::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 @@ -693,19 +702,27 @@ bool PublisherImpl::get_monitoring_status(
}*/
case statistics::StatusKind::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::StatusKind::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 @@ -34,7 +34,7 @@
#include <fastdds/dds/publisher/qos/PublisherQos.hpp>

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

namespace eprosima {
Expand Down Expand Up @@ -202,8 +202,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 3891c3f

Please sign in to comment.