Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion score/launch_manager/src/daemon/src/alive_monitor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cc_library(
strip_include_prefix = "/score/launch_manager/src/daemon/src/alive_monitor",
visibility = ["//score:__subpackages__"],
deps = [
"//score/launch_manager/src/daemon/src/supervision_control_client:isupervision_factory",
"//score/launch_manager/src/daemon/src/alive_monitor:isupervision_factory",
],
)

Expand All @@ -43,3 +43,50 @@ cc_library(
"@googletest//:gtest_main",
],
)

cc_library(
name = "ialive_supervision_handle",
hdrs = ["ialive_supervision_handle.hpp"],
include_prefix = "score/mw/launch_manager/alive_monitor",
strip_include_prefix = "/score/launch_manager/src/daemon/src/alive_monitor",
visibility = ["//score:__subpackages__"],
)

cc_library(
name = "isupervision_factory",
hdrs = ["isupervision_factory.hpp"],
include_prefix = "score/mw/launch_manager/alive_monitor",
strip_include_prefix = "/score/launch_manager/src/daemon/src/alive_monitor",
visibility = ["//score:__subpackages__"],
deps = [
"//score/launch_manager/src/daemon/src/alive_monitor/details/ifexm:supervision_handle",
"//score/launch_manager/src/daemon/src/common:identifier_hash",
"//score/launch_manager/src/daemon/src/configuration:component_config",
],
)

cc_library(
name = "mock_alive_supervision_handle",
testonly = True,
hdrs = ["mock_alive_supervision_handle.hpp"],
include_prefix = "score/mw/launch_manager/alive_monitor",
strip_include_prefix = "/score/launch_manager/src/daemon/src/alive_monitor",
visibility = ["//score:__subpackages__"],
deps = [
":ialive_supervision_handle",
"@googletest//:gtest_main",
],
)

cc_library(
name = "mock_supervision_factory",
testonly = True,
hdrs = ["mock_supervision_factory.hpp"],
include_prefix = "score/mw/launch_manager/alive_monitor",
strip_include_prefix = "/score/launch_manager/src/daemon/src/alive_monitor",
visibility = ["//score:__subpackages__"],
deps = [
":isupervision_factory",
"@googletest//:gtest_main",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef SAF_DAEMON_ALIVE_MONITOR_HPP_INCLUDED
#define SAF_DAEMON_ALIVE_MONITOR_HPP_INCLUDED

#include "score/mw/launch_manager/supervision_control_client/isupervision_factory.hpp"
#include "score/mw/launch_manager/alive_monitor/isupervision_factory.hpp"

namespace score::mw::lifecycle::internal::saf::daemon
{
Expand All @@ -26,11 +26,11 @@ class IAliveMonitor

/// @brief Start the monitor thread
/// @warning Not valid if @c init() failed
virtual void start() = 0;
virtual void startMonitoring() = 0;

/// @brief Stop the monitor thread
/// @warning Not valid if @c init() failed
virtual void stop() = 0;
virtual void stopMonitoring() = 0;

/// @brief Returns an interface for components to register their alive supervision
/// @warning Not valid if @c init() failed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ bool AliveMonitorImpl::init() noexcept
return false;
}

void AliveMonitorImpl::start() noexcept
void AliveMonitorImpl::startMonitoring() noexcept
{
alive_monitor_thread_ = std::thread([this]() {
threadFn(stop_thread_);
});
}

void AliveMonitorImpl::stop() noexcept
void AliveMonitorImpl::stopMonitoring() noexcept
{
stop_thread_.store(true);
if (alive_monitor_thread_.joinable())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class AliveMonitorImpl : public IAliveMonitor
const std::size_t supervised_components);

/// @brief @see IAliveMonitor definition
void start() noexcept override;
void startMonitoring() noexcept override;

/// @brief @see IAliveMonitor definition
void stop() noexcept override;
void stopMonitoring() noexcept override;

/// @brief @see IAliveMonitor definition
[[nodiscard]] ISupervisionFactory& getSupervisionFactory() const noexcept override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ cc_library(
deps = [
":phm_daemon_config",
":sw_cluster_handler",
"//score/launch_manager/src/daemon/src/alive_monitor:isupervision_factory",
"//score/launch_manager/src/daemon/src/alive_monitor/details/common:einitcode",
"//score/launch_manager/src/daemon/src/alive_monitor/details/factory:flat_cfg_factory",
"//score/launch_manager/src/daemon/src/alive_monitor/details/ifappl:monitor_if_daemon",
Expand All @@ -60,7 +61,6 @@ cc_library(
"//score/launch_manager/src/daemon/src/alive_monitor/details/timers:cycle_timer",
"//score/launch_manager/src/daemon/src/alive_monitor/details/timers:timers_os_clock",
"//score/launch_manager/src/daemon/src/common:log",
"//score/launch_manager/src/daemon/src/supervision_control_client:isupervision_factory",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include "score/mw/launch_manager/alive_monitor/details/timers/CycleTimeValidator.hpp"
#include "score/mw/launch_manager/alive_monitor/details/timers/CycleTimer.hpp"
#include "score/mw/launch_manager/alive_monitor/details/timers/TimeConversion.hpp"
#include "score/mw/launch_manager/alive_monitor/isupervision_factory.hpp"
#include "score/mw/launch_manager/configuration/config.hpp"
#include "score/mw/launch_manager/supervision_control_client/isupervision_factory.hpp"

namespace score::mw::lifecycle::internal::saf::daemon
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//tests/utils/bazel:unit_test.bzl", "lm_cc_test")

cc_library(
name = "observable_event",
Expand All @@ -20,9 +21,9 @@ cc_library(
strip_include_prefix = "/score/launch_manager/src/daemon/src/alive_monitor/details/ifexm",
visibility = ["//score/launch_manager/src/daemon/src/alive_monitor:__subpackages__"],
deps = [
":supervision_event",
"//score/launch_manager/src/daemon/src/alive_monitor/details/common:observer",
"//score/launch_manager/src/daemon/src/alive_monitor/details/timers:timers_os_clock",
"//score/launch_manager/src/daemon/src/supervision_control_client:supervision_event",
],
)

Expand All @@ -35,10 +36,46 @@ cc_library(
visibility = ["//score/launch_manager/src/daemon/src/alive_monitor:__subpackages__"],
deps = [
":observable_event",
":supervision_event",
"//score/launch_manager:error_event",
"//score/launch_manager/src/daemon/src/alive_monitor/details/timers:time_conversion",
"//score/launch_manager/src/daemon/src/alive_monitor/details/timers:timers_os_clock",
"//score/launch_manager/src/daemon/src/common:log",
"//score/launch_manager/src/daemon/src/supervision_control_client:supervision_event",
],
)

cc_library(
name = "supervision_event",
hdrs = ["supervision_event.hpp"],
include_prefix = "score/mw/launch_manager/alive_monitor/details/ifexm",
strip_include_prefix = "/score/launch_manager/src/daemon/src/alive_monitor/details/ifexm",
visibility = ["//score:__subpackages__"],
deps = [
"//externals/ipc_dropin",
"//score/launch_manager/src/daemon/src/common:identifier_hash",
],
)

cc_library(
name = "supervision_handle",
hdrs = ["supervision_handle.hpp"],
include_prefix = "score/mw/launch_manager/alive_monitor/details/ifexm",
strip_include_prefix = "/score/launch_manager/src/daemon/src/alive_monitor/details/ifexm",
visibility = ["//score/launch_manager/src/daemon/src/alive_monitor:__subpackages__"],
deps = [
":supervision_event",
"//score/launch_manager/src/daemon/src/alive_monitor:ialive_supervision_handle",
"//score/launch_manager/src/daemon/src/common:alive_interface_path",
"//score/launch_manager/src/daemon/src/common:identifier_hash",
"//score/launch_manager/src/daemon/src/common:log",
],
)

lm_cc_test(
name = "supervision_control_client_ut",
srcs = ["supervision_control_client_ut.cpp"],
deps = [
":supervision_handle",
"@googletest//:gtest_main",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "score/mw/launch_manager/alive_monitor/details/timers/Timers_OsClock.hpp"
#include <string>

#include "score/mw/launch_manager/supervision_control_client/supervision_event.hpp"
#include "score/mw/launch_manager/alive_monitor/details/ifexm/supervision_event.hpp"

namespace score::mw::lifecycle::internal::saf::ifexm
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include <map>

#include "score/mw/launch_manager/alive_monitor/details/ifexm/ObservableEvent.hpp"
#include "score/mw/launch_manager/alive_monitor/details/ifexm/supervision_event.hpp"
#include "score/mw/launch_manager/alive_monitor/details/timers/Timers_OsClock.hpp"
#include "score/mw/launch_manager/supervision_control_client/supervision_event.hpp"

#include "score/result/result.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
#include "score/mw/launch_manager/supervision_control_client/supervision_handle.hpp"
#include "score/mw/launch_manager/alive_monitor/details/ifexm/supervision_handle.hpp"
#include <gtest/gtest.h>
#include <memory>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
#ifndef SUPERVISION_HANDLE_HPP_INCLUDED
#define SUPERVISION_HANDLE_HPP_INCLUDED

#include "score/mw/launch_manager/alive_monitor/details/ifexm/supervision_event.hpp"
#include "score/mw/launch_manager/alive_monitor/ialive_supervision_handle.hpp"
#include "score/mw/launch_manager/common/alive_interface_path.hpp"
#include "score/mw/launch_manager/common/identifier_hash.hpp"
#include "score/mw/launch_manager/common/log.hpp"
#include "score/mw/launch_manager/supervision_control_client/ialive_supervision_handle.hpp"
#include "score/mw/launch_manager/supervision_control_client/supervision_event.hpp"

#include <ctime>

namespace score
Expand All @@ -37,7 +39,7 @@ class SupervisionHandle : public IAliveSupervisionHandle
/// @param process_id Identifier of the process being supervised.
/// @param buffer Buffer to push supervision events to.
explicit SupervisionHandle(IdentifierHash process_id, std::shared_ptr<SupervisionBufferType> buffer)
: process_id_(process_id), buffer_(buffer)
: process_id_(process_id), buffer_(buffer), ipc_path_(std::move(internal::aliveInterfacePath(process_id_)))
{
}

Expand All @@ -53,6 +55,12 @@ class SupervisionHandle : public IAliveSupervisionHandle
return queueSupervisionEvent({process_id_, SupervisionEventType::kDeactivation, time});
}

/// @brief Get the name of the IPC file alive indications are sent to.
std::string_view getConnectionId() const noexcept override

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is named getConnectionId but it returns a path, should it be called something like getIPCPath instead?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment its a shared memory path. However, in the future this could be a mw::com instance specifier as there are requests to remove custom IPC implementation from the launch manager code and only use mw::com/message_passing

{
return ipc_path_;
}

private:
/// @brief Attempts to push a supervision event so that the alive monitor can be informed about it.
/// @param[in] f_event The SupervisionEvent to be queued
Expand All @@ -74,6 +82,8 @@ class SupervisionHandle : public IAliveSupervisionHandle
const IdentifierHash process_id_;
/// @brief Buffer to push supervision events to
std::shared_ptr<SupervisionBufferType> buffer_;
/// @brief IPC path for alive indications
std::string ipc_path_;
};

} // namespace mw::lifecycle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define IALIVE_SUPERVISION_HANDLE_HPP_INCLUDED

#include <ctime>
#include <string_view>

namespace score::mw::lifecycle
{
Expand All @@ -30,6 +31,9 @@ class IAliveSupervisionHandle

/// @brief Request that the calling process stops supervision at @param time
virtual bool deactivateSupervision(timespec time) noexcept = 0;

/// @brief Get the name of the IPC file alive indications are sent to.
virtual std::string_view getConnectionId() const noexcept = 0;
};

} // namespace score::mw::lifecycle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#include <sys/types.h>
#include <ctime>

#include "score/mw/launch_manager/alive_monitor/details/ifexm/supervision_handle.hpp"
#include "score/mw/launch_manager/common/identifier_hash.hpp"
#include "score/mw/launch_manager/configuration/component_config.hpp"
#include "score/mw/launch_manager/supervision_control_client/supervision_handle.hpp"

namespace score
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ namespace score::mw::lifecycle::internal::saf::daemon
class MockAliveMonitor : public IAliveMonitor
{
public:
MOCK_METHOD(void, start, (), (override));
MOCK_METHOD(void, stop, (), (override));
MOCK_METHOD(void, startMonitoring, (), (override));
MOCK_METHOD(void, stopMonitoring, (), (override));
MOCK_METHOD(ISupervisionFactory&, getSupervisionFactory, (), (const, override));
MOCK_METHOD(bool, init, (), (noexcept, override));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef MOCK_ALIVE_SUPERVISION_HANDLE_HPP_INCLUDED
#define MOCK_ALIVE_SUPERVISION_HANDLE_HPP_INCLUDED

#include "score/mw/launch_manager/supervision_control_client/ialive_supervision_handle.hpp"
#include "score/mw/launch_manager/alive_monitor/ialive_supervision_handle.hpp"
#include <gmock/gmock.h>

namespace score::mw::lifecycle
Expand All @@ -24,6 +24,7 @@ class MockAliveSupervisionHandle : public IAliveSupervisionHandle
public:
MOCK_METHOD(bool, activateSupervision, (timespec time), (override, noexcept));
MOCK_METHOD(bool, deactivateSupervision, (timespec time), (override, noexcept));
MOCK_METHOD(std::string_view, getConnectionId, (), (const, override, noexcept));
};

} // namespace score::mw::lifecycle
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/********************************************************************************
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
#ifndef MOCK_ALIVE_SUPERVISION_HANDLE_HPP_INCLUDED
#define MOCK_ALIVE_SUPERVISION_HANDLE_HPP_INCLUDED

#include "score/mw/launch_manager/alive_monitor/ialive_supervision_handle.hpp"
#include <gmock/gmock.h>

namespace score::mw::lifecycle
{

class MockAliveSupervisionHandle : public IAliveSupervisionHandle
{
public:
MOCK_METHOD(bool, activateSupervision, (timespec time), (override, noexcept));
MOCK_METHOD(bool, deactivateSupervision, (timespec time), (override, noexcept));
MOCK_METHOD(std::string_view, getConnectionId, (), (const, override, noexcept));
};

} // namespace score::mw::lifecycle

#endif // MOCK_ALIVE_SUPERVISION_HANDLE_HPP_INCLUDED
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#ifndef MOCK_SUPERVISION_FACTORY_HPP_INCLUDED
#define MOCK_SUPERVISION_FACTORY_HPP_INCLUDED

#include "score/mw/launch_manager/supervision_control_client/isupervision_factory.hpp"
#include "score/mw/launch_manager/alive_monitor/isupervision_factory.hpp"
#include <gmock/gmock.h>

namespace score::mw::lifecycle
Expand Down
Loading
Loading