Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 7 additions & 9 deletions score/launch_manager/src/alive/src/details/AliveImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
********************************************************************************/

#include "score/mw/launch_manager/alive_monitor/details/AliveImpl.h"
#include "score/launch_manager/src/daemon/src/common/log.hpp"

#include <unistd.h>

Expand All @@ -23,11 +24,8 @@ namespace score::mw::lifecycle
{

AliveImpl::AliveImpl(const std::string_view& f_instanceSpecifier_r,
std::unique_ptr<CheckpointIpcClient> f_ipcClient) noexcept(false)
: k_instanceSpecifierPath(f_instanceSpecifier_r),
ipcClient(std::move(f_ipcClient)),
logger_r(
score::lcm::saf::logging::PhmLogger::getLogger(score::lcm::saf::logging::PhmLogger::EContext::supervision))
std::unique_ptr<CheckpointIpcClient> f_ipcClient) noexcept(false)
: k_instanceSpecifierPath(f_instanceSpecifier_r), ipcClient(std::move(f_ipcClient))
{
// coverity[autosar_cpp14_a15_5_2_violation] This warning comes from pipc-sa(external library)
connectToPhmDaemon();
Expand All @@ -43,7 +41,7 @@ void AliveImpl::connectToPhmDaemon(void) noexcept(false)
const auto ipc_path_res = readInterfacePath();
if (ipc_path_res == std::nullopt)
{
logger_r.LogError() << "Failed to load interface path for Alive instance (" << k_instanceSpecifierPath << ")";
LM_LOG_ERROR() << "Failed to load interface path for Alive instance (" << k_instanceSpecifierPath << ")";
throw std::runtime_error("Failed to get interface path");
}
CheckpointIpcClient::EIpcInitResult initResult{ipcClient->init(ipc_path_res.value())};
Expand All @@ -54,11 +52,11 @@ void AliveImpl::connectToPhmDaemon(void) noexcept(false)
else if (initResult == CheckpointIpcClient::EIpcInitResult::kPermissionDenied)
{
const uid_t uid{geteuid()};
logger_r.LogError() << "Connection to PHM daemon failed (permission denied for effective uid" << uid
<< "), for the Alive instance (" << k_instanceSpecifierPath << ")";
LM_LOG_ERROR() << "Connection to PHM daemon failed (permission denied for effective uid" << uid
<< "), for the Alive instance (" << k_instanceSpecifierPath << ")";
return;
}
logger_r.LogError() << "Connection to PHM daemon failed, for the Alive instance (" << k_instanceSpecifierPath << ")";
LM_LOG_ERROR() << "Connection to PHM daemon failed, for the Alive instance (" << k_instanceSpecifierPath << ")";
}

std::optional<std::string_view> AliveImpl::readInterfacePath() noexcept
Expand Down
3 changes: 0 additions & 3 deletions score/launch_manager/src/alive/src/details/AliveImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <string>
#include "score/mw/launch_manager/alive_monitor/details/ifappl/DataStructures.hpp"
#include "score/mw/launch_manager/alive_monitor/details/ipc/IpcClient.hpp"
#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp"

namespace score::mw::lifecycle
{
Expand Down Expand Up @@ -86,8 +85,6 @@ class AliveImpl
/// @brief IPC Connection to PHM Daemon
/// Class needs to be mutable to use in "const" reportCheckpoint method
mutable std::unique_ptr<CheckpointIpcClient> ipcClient;
/// Logger object
score::lcm::saf::logging::PhmLogger& logger_r;
};

} // namespace score::mw::lifecycle
Expand Down
2 changes: 1 addition & 1 deletion score/launch_manager/src/alive/src/details/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ cc_library(
"//score/launch_manager/src/daemon/src/alive_monitor/config",
"//score/launch_manager/src/daemon/src/alive_monitor/details/ifappl:data_structures",
"//score/launch_manager/src/daemon/src/alive_monitor/details/ipc:ipc_if",
"//score/launch_manager/src/daemon/src/alive_monitor/details/logging:phm_logging",
"//score/launch_manager/src/daemon/src/alive_monitor/details/timers:timers_os_clock",
"//score/launch_manager/src/daemon/src/common:log",
"@score_baselibs//score/flatbuffers:flatbufferscpp",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <score/assert.hpp>

#include "score/mw/launch_manager/alive_monitor/details/daemon/AliveMonitorImpl.hpp"
#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp"
#include "score/mw/launch_manager/alive_monitor/details/watchdog/WatchdogImpl.hpp"

namespace score
Expand All @@ -37,7 +36,6 @@ AliveMonitorImpl::AliveMonitorImpl(SptrIRecoveryClient recovery_client,
const Config& config)
: m_recovery_client(recovery_client),
m_watchdog(std::move(watchdog)),
m_logger{score::lcm::saf::logging::PhmLogger::getLogger(score::lcm::saf::logging::PhmLogger::EContext::factory)},
m_process_state_receiver{std::move(process_state_receiver)},
m_config(config)
{
Expand All @@ -48,7 +46,6 @@ AliveMonitorImpl::AliveMonitorImpl(SptrIRecoveryClient recovery_client,
UptrIProcessStateReceiver process_state_receiver)
: m_recovery_client(recovery_client),
m_watchdog(std::move(watchdog)),
m_logger{score::lcm::saf::logging::PhmLogger::getLogger(score::lcm::saf::logging::PhmLogger::EContext::factory)},
m_process_state_receiver{std::move(process_state_receiver)}
{
}
Expand All @@ -61,7 +58,7 @@ EInitCode AliveMonitorImpl::init() noexcept
{
m_osClock.startMeasurement();

m_daemon = std::make_unique<PhmDaemon>(m_osClock, m_logger, std::move(m_watchdog),
m_daemon = std::make_unique<PhmDaemon>(m_osClock, std::move(m_watchdog),
std::move(m_process_state_receiver));
#ifdef USE_NEW_CONFIGURATION
initResult = m_daemon->init(m_recovery_client, m_config);
Expand All @@ -72,12 +69,11 @@ EInitCode AliveMonitorImpl::init() noexcept
if (initResult == EInitCode::kNoError)
{
const long ms{m_osClock.endMeasurement()};
m_logger.LogDebug() << "AliveMonitor: Initialization took " << ms << " ms";
LM_LOG_DEBUG() << "AliveMonitor: Initialization took " << ms << " ms";
}
else
{
m_logger.LogError() << "AliveMonitor: Initialization failed with error code:"
<< static_cast<int>(initResult);
LM_LOG_ERROR() << "AliveMonitor: Initialization failed with error code:" << static_cast<int>(initResult);
}
}
catch (const std::exception& e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ namespace daemon {
using SptrIRecoveryClient = std::shared_ptr<score::lcm::IRecoveryClient>;
using UptrIWatchdogIf = std::unique_ptr<watchdog::IWatchdogIf>;
using UptrIProcessStateReceiver = std::unique_ptr<score::lcm::IProcessStateReceiver>;
using Logger = score::lcm::saf::logging::PhmLogger;
using UptrPhmDaemon = std::unique_ptr<score::lcm::saf::daemon::PhmDaemon>;
using OsClock = score::lcm::saf::timers::OsClockInterface;
#ifdef USE_NEW_CONFIGURATION
Expand All @@ -64,7 +63,6 @@ class AliveMonitorImpl : public IAliveMonitor {
private:
SptrIRecoveryClient m_recovery_client{nullptr};
UptrIWatchdogIf m_watchdog{nullptr};
Logger& m_logger;
UptrPhmDaemon m_daemon{nullptr};
OsClock m_osClock{};
UptrIProcessStateReceiver m_process_state_receiver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ cc_library(
"//score/launch_manager/src/daemon/src/alive_monitor/details/ifappl:monitor_if_daemon",
"//score/launch_manager/src/daemon/src/alive_monitor/details/ifexm:process_state",
"//score/launch_manager/src/daemon/src/alive_monitor/details/ifexm:process_state_reader",
"//score/launch_manager/src/daemon/src/alive_monitor/details/logging:phm_logging",
"//score/launch_manager/src/daemon/src/alive_monitor/details/supervision:alive",
"//score/launch_manager/src/daemon/src/alive_monitor/details/timers:timers_os_clock",
"//score/launch_manager/src/daemon/src/common:log",
] + select({
"//config:lm_use_new_configuration": [
"//score/launch_manager/src/daemon/src/configuration:config",
Expand Down Expand Up @@ -69,12 +69,12 @@ cc_library(
"//score/launch_manager/src/daemon/src/alive_monitor/details/factory:machine_config_factory",
"//score/launch_manager/src/daemon/src/alive_monitor/details/ifappl:monitor_if_daemon",
"//score/launch_manager/src/daemon/src/alive_monitor/details/ifexm:process_state_reader",
"//score/launch_manager/src/daemon/src/alive_monitor/details/logging:phm_logging",
"//score/launch_manager/src/daemon/src/alive_monitor/details/supervision:alive",
"//score/launch_manager/src/daemon/src/alive_monitor/details/timers:cycle_time_validator",
"//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/alive_monitor/details/watchdog:i_watchdog_if",
"//score/launch_manager/src/daemon/src/common:log",
"//score/launch_manager/src/lifecycle_client",
] + select({
"//config:lm_use_new_configuration": [
Expand Down Expand Up @@ -106,7 +106,6 @@ cc_library(
visibility = ["//score/launch_manager/src/daemon:__subpackages__"],
deps = [
":i_health_monitor",
"//score/launch_manager/src/daemon/src/alive_monitor/details/logging:phm_logging",
"//score/launch_manager/src/daemon/src/alive_monitor/details/watchdog:watchdog_impl",
"@score_baselibs//score/language/futurecpp",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ namespace daemon
/* RULECHECKER_comment(0, 4, check_incomplete_data_member_construction, "Default constructor is used for\
processStateReader.", true_no_defect) */
PhmDaemon::PhmDaemon(OsClock& f_osClock,
Logger& f_logger_r,
std::unique_ptr<Watchdog> f_watchdog,
std::unique_ptr<ProcessStateReceiver> f_process_state_receiver)
: osClock{f_osClock},
cycleTimer{&osClock},
logger_r{f_logger_r},
swClusterHandlers{},
processStateReader{std::move(f_process_state_receiver)},
watchdog(std::move(f_watchdog))
Expand Down Expand Up @@ -93,16 +91,15 @@ bool PhmDaemon::construct(const SupervisionBufferConfig& f_bufferConfig_r) noexc
score::Result<std::vector<std::string>> listSwClustersPhm{{"MainCluster"}};
if (!listSwClustersPhm.has_value())
{
logger_r.LogError()
<< "Phm Daemon: retrieving the list of PHM software cluster configurations failed with error:"
<< listSwClustersPhm.error().Message();
LM_LOG_ERROR() << "Phm Daemon: retrieving the list of PHM software cluster configurations failed with error:"
<< listSwClustersPhm.error().Message();
isSuccess = false;
}
else
{
if (listSwClustersPhm.value().size() == 0U)
{
logger_r.LogWarn() << "Phm Daemon: is starting without any software cluster configurations!";
LM_LOG_WARN() << "Phm Daemon: is starting without any software cluster configurations!";
}

// Reserve the vector swClusterHandlers obtained from flatcfg before constructing the SwClusters
Expand All @@ -118,8 +115,8 @@ bool PhmDaemon::construct(const SupervisionBufferConfig& f_bufferConfig_r) noexc
#endif
if (!isSuccess)
{
logger_r.LogError() << "Phm Daemon: failed to create worker objects for swclusterhandler:"
<< strSwClusterName;
LM_LOG_ERROR() << "Phm Daemon: failed to create worker objects for swclusterhandler:"
<< strSwClusterName;
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@
#include <cerrno>
#include <memory>

#include <vector>
#include "score/mw/lifecycle/control_client.h"
#include "score/launch_manager/src/daemon/src/common/log.hpp"
#include "score/mw/launch_manager/alive_monitor/details/daemon/PhmDaemonConfig.hpp"
#include "score/mw/launch_manager/alive_monitor/details/daemon/SwClusterHandler.hpp"
#include "score/mw/launch_manager/alive_monitor/details/factory/MachineConfigFactory.hpp"
#include "score/mw/launch_manager/alive_monitor/details/ifexm/ProcessStateReader.hpp"
#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp"
#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/watchdog/IWatchdogIf.hpp"
Expand Down Expand Up @@ -62,7 +60,6 @@ class PhmDaemon
{
public:
using OsClock = score::lcm::saf::timers::OsClockInterface;
using Logger = logging::PhmLogger;
using Watchdog = watchdog::IWatchdogIf;
using ProcessStateReceiver = score::lcm::IProcessStateReceiver;
using RecoveryClient = score::lcm::IRecoveryClient;
Expand All @@ -78,15 +75,15 @@ class PhmDaemon

/* RULECHECKER_comment(0, 4, check_expensive_to_copy_in_parameter, "f_supervisionErrorInfo name is passed by value\
as same as generated function", true_no_defect) */
/// @brief Set the OS clock interface and the logger
/// @brief Set the OS clock interface
/// @param[in] f_osClock Access to the system clock (dependency injection possible in tests)
/// @param[in] f_logger_r Reference to the logger (dependency injection possible in tests)
/// @param[in] f_watchdog watchdog implementation (dependency injection possible in tests)
/// @param[in] f_process_state_receiver process state receiver implementation (dependency injection possible in tests)
/* RULECHECKER_comment(3,1, check_expensive_to_copy_in_parameter, "Move only types cannot be passed by const ref",
true_no_defect) */
PhmDaemon(OsClock& f_osClock, Logger& f_logger_r, std::unique_ptr<Watchdog> f_watchdog,
std::unique_ptr<ProcessStateReceiver> f_process_state_receiver);
PhmDaemon(OsClock& f_osClock,
std::unique_ptr<Watchdog> f_watchdog,
std::unique_ptr<ProcessStateReceiver> f_process_state_receiver);

/* RULECHECKER_comment(0, 4, check_min_instructions, "Default destructor is not provided\
a function body", true_no_defect) */
Expand Down Expand Up @@ -142,26 +139,26 @@ class PhmDaemon
const int64_t timerInit{cycleTimer.init(cycleTimeModified)};
if (timerInit > 0)
{
logger_r.LogInfo() << "Phm Daemon: The (configured) periodicity in [ns] is set to:"
<< static_cast<uint64_t>(cycleTimeModified);
logger_r.LogDebug() << "Phm Daemon: The accuracy of the monotonic system clock in [ns] is:"
<< static_cast<uint64_t>(CycleTimeValidator::getMonotonicClockAccuracy(osClock));
LM_LOG_INFO() << "Phm Daemon: The (configured) periodicity in [ns] is set to:"
<< static_cast<uint64_t>(cycleTimeModified);
LM_LOG_DEBUG() << "Phm Daemon: The accuracy of the monotonic system clock in [ns] is:"
<< static_cast<uint64_t>(CycleTimeValidator::getMonotonicClockAccuracy(osClock));
}
else
{
logger_r.LogError() << "Phm Daemon: Initialization of CycleTimer instance failed!";
LM_LOG_ERROR() << "Phm Daemon: Initialization of CycleTimer instance failed!";
return EInitCode::kCycleTimeInitFailed;
}

if (!watchdog->init(cycleTimeModified, machineConfig))
{
logger_r.LogError() << "Phm Daemon: Initialization of watchdog failed!";
LM_LOG_ERROR() << "Phm Daemon: Initialization of watchdog failed!";
return EInitCode::kWatchdogInitFailed;
}

if (!watchdog->enable())
{
logger_r.LogError() << "Phm Daemon: Enabling of watchdog failed!";
LM_LOG_ERROR() << "Phm Daemon: Enabling of watchdog failed!";
return EInitCode::kWatchdogEnableFailed;
}

Expand Down Expand Up @@ -194,7 +191,7 @@ class PhmDaemon
NanoSecondType startTimestamp{cycleTimer.start()};
if (startTimestamp == 0U)
{
logger_r.LogError() << "Phm Daemon: Failed to get initial timestamp";
LM_LOG_ERROR() << "Phm Daemon: Failed to get initial timestamp";
return false;
}

Expand All @@ -216,26 +213,26 @@ class PhmDaemon
const int sleepResult{cycleTimer.sleep(f_terminateCond, nsOverDeadline)};
if (sleepResult == EINTR)
{
logger_r.LogInfo() << "Phm Daemon: Sleep was interrupted by termination signal";
LM_LOG_INFO() << "Phm Daemon: Sleep was interrupted by termination signal";
break;
}
else if (sleepResult == CycleTimer::kDeadlineAlreadyOver)
{
logger_r.LogDebug() << "Phm Daemon: Phm cycle took"
<< (static_cast<double>(nsOverDeadline) / 1000000.0 /*ns per ms*/)
<< "ms longer than the configured cycle time";
LM_LOG_DEBUG() << "Phm Daemon: Phm cycle took"
<< (static_cast<double>(nsOverDeadline) / 1000000.0 /*ns per ms*/)
<< "ms longer than the configured cycle time";
}
else if (sleepResult != 0)
{
logger_r.LogError() << "Phm Daemon: Error during sleep system call, Code:"
<< static_cast<uint64_t>(sleepResult);
LM_LOG_ERROR() << "Phm Daemon: Error during sleep system call, Code:"
<< static_cast<uint64_t>(sleepResult);
}
else
{
/* sleeping successfully */
}
}
logger_r.LogInfo() << "Phm Daemon: Received termination request - shutting down";
LM_LOG_INFO() << "Phm Daemon: Received termination request - shutting down";

watchdog->disable();
return true;
Expand All @@ -262,9 +259,6 @@ class PhmDaemon
/// @brief For fixed time-step execution during the cyclic execution
CycleTimer cycleTimer;

/// @brief Logging entity for warnings, errors used in init() phase and the cyclic() phase
Logger& logger_r;

/// @brief Recovery interface to Launch Manager
std::shared_ptr<RecoveryClient> recoveryClient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
********************************************************************************/

#include "score/mw/launch_manager/alive_monitor/details/daemon/SwClusterHandler.hpp"

#include "score/launch_manager/src/daemon/src/common/log.hpp"
#include "score/mw/launch_manager/alive_monitor/details/factory/FlatCfgFactory.hpp"
#include "score/mw/launch_manager/alive_monitor/details/ifappl/Checkpoint.hpp"
#include "score/mw/launch_manager/alive_monitor/details/ifappl/MonitorIfDaemon.hpp"
Expand All @@ -28,8 +28,7 @@ namespace daemon
{

SwClusterHandler::SwClusterHandler(const std::string& f_swClusterName_r)
: logger_r(logging::PhmLogger::getLogger(logging::PhmLogger::EContext::factory)),
f_swClusterName(f_swClusterName_r),
: f_swClusterName(f_swClusterName_r),
processStates{},
aliveIfIpcs{},
aliveInterfaces{},
Expand All @@ -38,7 +37,7 @@ SwClusterHandler::SwClusterHandler(const std::string& f_swClusterName_r)
{
if (f_swClusterName_r.empty())
{
logger_r.LogError() << "Software Cluster Handler: Software cluster name is empty!";
LM_LOG_ERROR() << "Software Cluster Handler: Software cluster name is empty!";
}
}

Expand All @@ -65,7 +64,7 @@ bool SwClusterHandler::constructWorkers(
#endif
if (isSuccess)
{
logger_r.LogDebug() << "Software Cluster Handler starts constructing workers:" << f_swClusterName;
LM_LOG_DEBUG() << "Software Cluster Handler starts constructing workers:" << f_swClusterName;
isSuccess = flatCfgFactory.createProcessStates(processStates, f_processStateReader_r);
}
if (isSuccess)
Expand All @@ -87,7 +86,7 @@ bool SwClusterHandler::constructWorkers(
}
if (isSuccess == false)
{
logger_r.LogError() << "Software Cluster Handler is unable to construct the required worker objects.";
LM_LOG_ERROR() << "Software Cluster Handler is unable to construct the required worker objects.";
}
return isSuccess;
}
Expand Down
Loading
Loading