-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SDL-0117] Configurable time before shutdown #3740
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -411,3 +411,9 @@ RpcPassThroughTimeout = 10000 | |
[RCModuleConsent] | ||
; The period (in days) after which consent for module_id should be removed. | ||
PeriodForConsentExpiration = 30 | ||
|
||
[Logger] | ||
; Write all logs in queue to file system before shutdown | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the comment "write all logs in queue" may not be correct, and it is misleading There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
FlushLogMessagesBeforeShutdown = false | ||
; Maximum time to wait for writing all data before exit SDL in seconds | ||
ShobhitAd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
MaxTimeBeforeShutdown = 30 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ | |
#include "protocol_handler/protocol_handler_settings.h" | ||
#include "smart_objects/smart_object.h" | ||
#include "transport_manager/transport_manager_settings.h" | ||
#include "utils/logger/logger_settings.h" | ||
#include "utils/macro.h" | ||
|
||
namespace profile { | ||
|
@@ -59,7 +60,8 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, | |
public media_manager::MediaManagerSettings, | ||
public policy::PolicySettings, | ||
public transport_manager::TransportManagerSettings, | ||
public application_manager::ApplicationManagerSettings { | ||
public application_manager::ApplicationManagerSettings, | ||
public logger::LoggerSettings { | ||
public: | ||
// Methods section | ||
|
||
|
@@ -589,6 +591,18 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, | |
|
||
const std::vector<std::string>& embedded_services() const OVERRIDE; | ||
const std::string hmi_origin_id() const OVERRIDE; | ||
|
||
/** | ||
* @brief Returns true if writing all logs to file system before shutdown is | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please remove "all" in comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yang1070 Done |
||
* enabled | ||
*/ | ||
bool flush_log_messages_before_shutdown() const OVERRIDE; | ||
/** | ||
* @brief Returns waximum time to wait for writing all data before exit SDL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo waximum There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yang1070 Done |
||
* in seconds | ||
*/ | ||
uint16_t max_time_before_shutdown() const OVERRIDE; | ||
|
||
/** | ||
* @brief Reads a string value from the profile | ||
* | ||
|
@@ -1164,6 +1178,8 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, | |
int ignition_off_signal_offset_; | ||
uint32_t rpc_pass_through_timeout_; | ||
uint16_t period_for_consent_expiration_; | ||
bool flush_log_messages_before_shutdown_; | ||
uint16_t max_time_before_shutdown_; | ||
|
||
std::vector<std::string> embedded_services_; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,10 +74,14 @@ class LoggerImpl : public Logger, public LoggerInitializer { | |
bool IsEnabledFor(const std::string& component, | ||
LogLevel log_level) const override; | ||
void PushLog(const LogMessage& log_message) override; | ||
void InitLoggerSettings(LoggerSettings* settings) override; | ||
void InitFlushLogsTimePoint(const TimePoint& time_point) override; | ||
|
||
std::unique_ptr<ThirdPartyLoggerInterface> impl_; | ||
LoggerSettings* settings_; | ||
LoopThreadPtr<LogMessageLoopThread> loop_thread_; | ||
bool use_message_loop_thread_; | ||
TimePoint flush_logs_time_point_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the default value of flush_logs_time_point_ if it is not initialized? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default constructor, creates a time_point representing the Clock's epoch (i.e., time_since_epoch() is zero). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @VladSemenyuk Got it. Thank you |
||
}; | ||
|
||
} // namespace logger | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_LOGGER_SETTINGS_H_ | ||
#define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_LOGGER_SETTINGS_H_ | ||
|
||
#include <stdint.h> | ||
ShobhitAd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
namespace logger { | ||
class LoggerSettings { | ||
public: | ||
virtual bool flush_log_messages_before_shutdown() const = 0; | ||
virtual uint16_t max_time_before_shutdown() const = 0; | ||
}; | ||
|
||
} // namespace logger | ||
|
||
#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_LOGGER_SETTINGS_H_ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,9 @@ | |
namespace logger { | ||
|
||
LoggerImpl::LoggerImpl(bool use_message_loop_thread) | ||
: impl_(nullptr), use_message_loop_thread_(use_message_loop_thread) {} | ||
: impl_(nullptr) | ||
, settings_(nullptr) | ||
, use_message_loop_thread_(use_message_loop_thread) {} | ||
|
||
void LoggerImpl::Init(std::unique_ptr<ThirdPartyLoggerInterface>&& impl) { | ||
assert(impl_ == nullptr); | ||
|
@@ -71,9 +73,20 @@ void LoggerImpl::DeInit() { | |
} | ||
|
||
void LoggerImpl::Flush() { | ||
if (use_message_loop_thread_) { | ||
if (loop_thread_) { | ||
if (use_message_loop_thread_ && loop_thread_) { | ||
assert(settings_); | ||
|
||
if (0 == flush_logs_time_point_.time_since_epoch().count()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we have such a condition? it seems impossible to me that count() is zero, thus impossible to execute next line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default constructor, creates a time_point representing the Clock's epoch (i.e., time_since_epoch() is zero). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @VladSemenyuk in file on_exit_all_applications_notification.cc and function void OnExitAllApplicationsNotification::Run() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, ExitAllApplicationsNotification is not the only exit point for SDL. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @VladSemenyuk could you list what are other conditions or exit point to call logger Flush()? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yang1070 The proposal is old and at the time it was written the logger worked differently, and now it does`nt match the proposal. So before this implementation SDL flushed all logs always on logger deinitialization, and now configurable timeout shutdown for IGNITION_OFF situation is added. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @VladSemenyuk in that case I'm not sure the proposal is still valid and whether or not we need this change. the proposal solves the problem that SDL drops off log and give options to continue write the log with maximum allowed time configured by the SDL settings in ini file. Now (before this PR), SDL get some update, it always flush the log, SDL no long drop off the log, the old problem does not exist any more. The problem may change to SDL takes too much time for flushing the logs? Why we still need to implement the proposal? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@yang1070 Yes. Problem is it takes too much time for flushing the logs in some cases on weak environment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @VladSemenyuk in that case, I would like to see an update of SDL-117 and get the update proposal approved first There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since the default SDL behavior is to flush log, |
||
loop_thread_->WaitDumpQueue(); | ||
} else if (settings_->flush_log_messages_before_shutdown()) { | ||
// Calculate elapsed seconds since IGNITION_OFF | ||
const auto seconds = std::chrono::duration_cast<std::chrono::seconds>( | ||
std::chrono::high_resolution_clock::now() - flush_logs_time_point_); | ||
int16_t seconds_before_shutdown = | ||
settings_->max_time_before_shutdown() - seconds.count(); | ||
if (0 < seconds_before_shutdown) { | ||
loop_thread_->TimedWaitDumpQueue(seconds_before_shutdown); | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -116,6 +129,14 @@ void LogMessageLoopThread::Handle(const LogMessage message) { | |
force_log_(message); | ||
} | ||
|
||
void LoggerImpl::InitLoggerSettings(LoggerSettings* settings) { | ||
settings_ = settings; | ||
} | ||
|
||
void LoggerImpl::InitFlushLogsTimePoint(const TimePoint& time_point) { | ||
flush_logs_time_point_ = time_point; | ||
} | ||
|
||
LogMessageLoopThread::~LogMessageLoopThread() { | ||
// we'll have to drop messages | ||
// while deleting logger thread | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is marked "not ready for review" in the PR summary , is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means the PR is not ready for the Project Maintainer review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KhrystynaDubovyk got it, thank you