代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/drbd 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From bc1fbb31f92c2ac59a7e3a9021e044fe6349ec9e Mon Sep 17 00:00:00 2001
From: Robert Altnoeder <robert.altnoeder@linbit.com>
Date: Tue, 19 Mar 2024 14:30:45 +0100
Subject: [PATCH 081/100] DRBDmon: Pass-through the monitor environment
---
user/drbdmon/DrbdMon.cpp | 45 +++++++++----------
user/drbdmon/DrbdMon.h | 5 +--
user/drbdmon/drbdmon_main.cpp | 1 -
user/drbdmon/terminal/DisplayController.cpp | 48 ++++++++++-----------
user/drbdmon/terminal/DisplayController.h | 10 ++---
5 files changed, 47 insertions(+), 62 deletions(-)
diff --git a/user/drbdmon/DrbdMon.cpp b/user/drbdmon/DrbdMon.cpp
index 2d27f2a0..b9ac34d8 100644
--- a/user/drbdmon/DrbdMon.cpp
+++ b/user/drbdmon/DrbdMon.cpp
@@ -71,15 +71,14 @@ DrbdMon::DrbdMon(
char* argv[],
MonitorEnvironment& mon_env_ref
):
- sys_api(*(mon_env_ref.sys_api)),
+ mon_env(mon_env_ref),
arg_count(argc),
arg_values(argv),
- fail_data(mon_env_ref.fail_data),
log(*(mon_env_ref.log)),
debug_log(*(mon_env_ref.debug_log)),
- node_name(mon_env_ref.node_name_mgr.get()),
config(*(mon_env_ref.config))
{
+ mon_env.fin_action = DrbdMonCore::finish_action::RESTART_IMMED;
rsc_dir_mgr = std::unique_ptr<ResourceDirectory>(
new ResourceDirectory(*(mon_env_ref.log), *(mon_env_ref.debug_log))
);
@@ -92,7 +91,7 @@ DrbdMon::~DrbdMon() noexcept
SystemApi& DrbdMon::get_system_api() const noexcept
{
- return sys_api;
+ return *(mon_env.sys_api);
}
// @throws std::bad_alloc
@@ -158,14 +157,10 @@ void DrbdMon::run()
ResourcesMap& prb_rsc_map = rsc_dir->get_problem_resources_map();
display_impl = new DisplayController(
*core_instance,
- sys_api,
+ mon_env,
*sub_proc_obs,
rsc_map,
- prb_rsc_map,
- log,
- debug_log,
- config,
- node_name
+ prb_rsc_map
);
}
@@ -239,7 +234,7 @@ void DrbdMon::run()
case CoreIo::signal_type::SIGNAL_EXIT:
{
// Terminate main loop
- fin_action = DrbdMonCore::finish_action::TERMINATE;
+ mon_env.fin_action = DrbdMonCore::finish_action::TERMINATE;
shutdown_flag = true;
break;
}
@@ -257,7 +252,7 @@ void DrbdMon::run()
}
case CoreIo::signal_type::SIGNAL_DEBUG:
{
- fin_action = DrbdMonCore::finish_action::DEBUG_MODE;
+ mon_env.fin_action = DrbdMonCore::finish_action::DEBUG_MODE;
shutdown_flag = true;
break;
}
@@ -346,8 +341,8 @@ void DrbdMon::run()
MessageLog::log_level::ALERT,
"The connection to the DRBD events source failed due to an I/O error"
);
- fin_action = DrbdMonCore::finish_action::RESTART_DELAYED;
- fail_data = DrbdMonCore::fail_info::EVENTS_IO;
+ mon_env.fin_action = DrbdMonCore::finish_action::RESTART_DELAYED;
+ mon_env.fail_data = DrbdMonCore::fail_info::EVENTS_IO;
}
catch (EventsSourceException& src_exc)
{
@@ -371,8 +366,8 @@ void DrbdMon::run()
*debug_info
);
}
- fin_action = DrbdMonCore::finish_action::RESTART_DELAYED;
- fail_data = DrbdMonCore::fail_info::EVENTS_SOURCE;
+ mon_env.fin_action = DrbdMonCore::finish_action::RESTART_DELAYED;
+ mon_env.fail_data = DrbdMonCore::fail_info::EVENTS_SOURCE;
}
catch (EventsIoException& io_exc)
{
@@ -396,8 +391,8 @@ void DrbdMon::run()
*debug_info
);
}
- fin_action = DrbdMonCore::finish_action::RESTART_DELAYED;
- fail_data = DrbdMonCore::fail_info::EVENTS_IO;
+ mon_env.fin_action = DrbdMonCore::finish_action::RESTART_DELAYED;
+ mon_env.fail_data = DrbdMonCore::fail_info::EVENTS_IO;
}
catch (EventException& event_exc)
{
@@ -437,15 +432,15 @@ void DrbdMon::run()
);
}
- fin_action = DrbdMonCore::finish_action::RESTART_DELAYED;
- fail_data = DrbdMonCore::fail_info::GENERIC;
+ mon_env.fin_action = DrbdMonCore::finish_action::RESTART_DELAYED;
+ mon_env.fail_data = DrbdMonCore::fail_info::GENERIC;
}
catch (ConfigurationException&)
{
// A ConfigurationException is thrown to abort and exit
// while configuring options
// (--help uses this too)
- fin_action = DrbdMonCore::finish_action::TERMINATE_NO_CLEAR;
+ mon_env.fin_action = DrbdMonCore::finish_action::TERMINATE_NO_CLEAR;
}
}
catch (std::bad_alloc&)
@@ -459,7 +454,7 @@ void DrbdMon::run()
void DrbdMon::shutdown(const DrbdMonCore::finish_action action) noexcept
{
- fin_action = action;
+ mon_env.fin_action = action;
shutdown_flag = true;
}
@@ -556,7 +551,7 @@ void DrbdMon::process_event_message(
// Report recovering from errors that triggered reinitialization
// of the DrbdMon instance
- switch (fail_data)
+ switch (mon_env.fail_data)
{
case DrbdMonCore::fail_info::NONE:
// no-op
@@ -597,7 +592,7 @@ void DrbdMon::process_event_message(
// In case that multiple "exists -" lines are received,
// which is actually not supposed to happen, avoid spamming
// the message log
- fail_data = fail_info::NONE;
+ mon_env.fail_data = fail_info::NONE;
}
}
else
@@ -697,7 +692,7 @@ void DrbdMon::process_event_message(
*/
DrbdMonCore::finish_action DrbdMon::get_fin_action() const
{
- return fin_action;
+ return mon_env.fin_action;
}
/**
diff --git a/user/drbdmon/DrbdMon.h b/user/drbdmon/DrbdMon.h
index 586417f7..3515446c 100644
--- a/user/drbdmon/DrbdMon.h
+++ b/user/drbdmon/DrbdMon.h
@@ -137,7 +137,7 @@ class DrbdMon : public DrbdMonCore, public Configurable, public Configurator
}
option_entry;
- SystemApi& sys_api;
+ MonitorEnvironment& mon_env;
using OptionsMap = QTree<const std::string, DrbdMon::option_entry>;
@@ -149,11 +149,8 @@ class DrbdMon : public DrbdMonCore, public Configurable, public Configurator
std::unique_ptr<OptionsMap> options;
- DrbdMonCore::fail_info& fail_data;
- DrbdMonCore::finish_action fin_action {DrbdMonCore::finish_action::RESTART_IMMED};
MessageLog& log;
MessageLog& debug_log;
- const std::string* const node_name;
Configuration& config;
bool shutdown_flag {false};
diff --git a/user/drbdmon/drbdmon_main.cpp b/user/drbdmon/drbdmon_main.cpp
index f92f70ac..be29b5ac 100644
--- a/user/drbdmon/drbdmon_main.cpp
+++ b/user/drbdmon/drbdmon_main.cpp
@@ -216,7 +216,6 @@ static void drbdmon::monitor_loop(
new DrbdMon(argc, argv, mon_env)
);
dm_instance->run();
- mon_env.fin_action = dm_instance->get_fin_action();
if (mon_env.fin_action != DrbdMon::finish_action::TERMINATE_NO_CLEAR)
{
drbdmon::clear_screen();
diff --git a/user/drbdmon/terminal/DisplayController.cpp b/user/drbdmon/terminal/DisplayController.cpp
index 6d44e956..2eff7be6 100644
--- a/user/drbdmon/terminal/DisplayController.cpp
+++ b/user/drbdmon/terminal/DisplayController.cpp
@@ -41,21 +41,17 @@ const std::string DisplayController::INITIAL_WAIT_MSG = "Reading initial DRBD
// @throws std::bad_alloc, std::logic_error
DisplayController::DisplayController(
DrbdMonCore& core_instance_ref,
- SystemApi& sys_api_ref,
+ MonitorEnvironment& mon_env_ref,
SubProcessObserver& sub_proc_obs_ref,
ResourcesMap& rsc_map_ref,
- ResourcesMap& prb_rsc_map_ref,
- MessageLog& log_ref,
- MessageLog& debug_log_ref,
- Configuration& config_ref,
- const std::string* const node_name_ptr
+ ResourcesMap& prb_rsc_map_ref
):
- core_instance(core_instance_ref)
+ core_instance(core_instance_ref),
+ mon_env(mon_env_ref)
{
- SystemApi& sys_api = core_instance.get_system_api();
dsp_map = std::unique_ptr<DisplayMap>(new DisplayMap(&comparators::compare_string));
- term_ctl_mgr = sys_api.create_terminal_control();
+ term_ctl_mgr = mon_env.sys_api->create_terminal_control();
dsp_comp_hub_mgr = std::unique_ptr<ComponentsHub>(new ComponentsHub());
dsp_io_mgr = std::unique_ptr<DisplayIo>(new DisplayIo(STDOUT_FILENO));
@@ -66,32 +62,32 @@ DisplayController::DisplayController(
sub_proc_queue_mgr = std::unique_ptr<SubProcessQueue>(new SubProcessQueue());
dsp_comp_hub_mgr->core_instance = &core_instance;
- dsp_comp_hub_mgr->sys_api = &sys_api_ref;
+ dsp_comp_hub_mgr->sys_api = &(mon_env.sys_api);
dsp_comp_hub_mgr->dsp_selector = dynamic_cast<DisplaySelector*> (this);
dsp_comp_hub_mgr->dsp_io = dsp_io_mgr.get();
dsp_comp_hub_mgr->dsp_shared = dsp_shared_mgr.get();
dsp_comp_hub_mgr->term_size = dynamic_cast<TermSize*> (term_size_mgr.get());
dsp_comp_hub_mgr->rsc_map = &rsc_map_ref;
dsp_comp_hub_mgr->prb_rsc_map = &prb_rsc_map_ref;
- dsp_comp_hub_mgr->log = &log_ref;
- dsp_comp_hub_mgr->debug_log = &debug_log_ref;
- dsp_comp_hub_mgr->node_name = node_name_ptr;
+ dsp_comp_hub_mgr->log = &(mon_env.log);
+ dsp_comp_hub_mgr->debug_log = &(mon_env.debug_log);
+ dsp_comp_hub_mgr->node_name = mon_env.node_name_mgr.get();
dsp_comp_hub_mgr->style_coll = dsp_styles_mgr.get();
dsp_comp_hub_mgr->ansi_ctl = ansi_ctl_mgr.get();
dsp_comp_hub_mgr->sub_proc_queue = sub_proc_queue_mgr.get();
- dsp_comp_hub_mgr->config = &config_ref;
+ dsp_comp_hub_mgr->config = mon_env.config.get();
dsp_comp_hub_mgr->have_term_size = false;
dsp_comp_hub_mgr->term_cols = 100;
dsp_comp_hub_mgr->term_rows = 30;
{
const DisplayStyleCollection::ColorStyle selected_color_style =
- dsp_styles_mgr->get_color_style_by_numeric_id(config_ref.color_scheme);
+ dsp_styles_mgr->get_color_style_by_numeric_id(mon_env.config->color_scheme);
dsp_comp_hub_mgr->active_color_table =
&(dsp_styles_mgr->get_color_table(selected_color_style));
const DisplayStyleCollection::CharacterStyle selected_character_style =
- dsp_styles_mgr->get_character_style_by_numeric_id(config_ref.character_set);
+ dsp_styles_mgr->get_character_style_by_numeric_id(mon_env.config->character_set);
dsp_comp_hub_mgr->active_character_table =
&(dsp_styles_mgr->get_character_table(selected_character_style));
}
@@ -108,16 +104,16 @@ DisplayController::DisplayController(
dsp_comp_hub_mgr->drbd_cmd_exec = dynamic_cast<DrbdCommands*> (drbd_cmd_exec_mgr.get());
global_cmd_exec_mgr = std::unique_ptr<GlobalCommandsImpl>(
- new GlobalCommandsImpl(*dsp_comp_hub_mgr, config_ref)
+ new GlobalCommandsImpl(*dsp_comp_hub_mgr, *(mon_env.config))
);
dsp_comp_hub_mgr->global_cmd_exec = dynamic_cast<GlobalCommands*> (global_cmd_exec_mgr.get());
dsp_comp_hub_mgr->sub_proc_queue->set_observer(&sub_proc_obs_ref);
// Sub process queue configuration
- sub_proc_queue_mgr->set_discard_succeeded_tasks(config_ref.discard_succ_tasks);
- sub_proc_queue_mgr->set_discard_finished_tasks(config_ref.discard_fail_tasks);
- dsp_shared_mgr->activate_tasks = !(config_ref.suspend_new_tasks);
+ sub_proc_queue_mgr->set_discard_succeeded_tasks(mon_env.config->discard_succ_tasks);
+ sub_proc_queue_mgr->set_discard_finished_tasks(mon_env.config->discard_fail_tasks);
+ dsp_shared_mgr->activate_tasks = !(mon_env.config->suspend_new_tasks);
dsp_stack = std::unique_ptr<DisplayStack>(new DisplayStack(&DisplayController::compare_display_id));
@@ -228,23 +224,23 @@ DisplayController::DisplayController(
dynamic_cast<ModularDisplay*> (new MDspHelp(dsp_comp_hub))
);
log_view_mgr = std::unique_ptr<ModularDisplay>(
- dynamic_cast<ModularDisplay*> (new MDspLogViewer(dsp_comp_hub, log_ref))
+ dynamic_cast<ModularDisplay*> (new MDspLogViewer(dsp_comp_hub, *(mon_env.log)))
);
debug_log_view_mgr = std::unique_ptr<ModularDisplay>(
- dynamic_cast<ModularDisplay*> (new MDspLogViewer(dsp_comp_hub, debug_log_ref))
+ dynamic_cast<ModularDisplay*> (new MDspLogViewer(dsp_comp_hub, *(mon_env.debug_log)))
);
msg_view_mgr = std::unique_ptr<ModularDisplay>(
- dynamic_cast<ModularDisplay*> (new MDspMessage(dsp_comp_hub, log_ref))
+ dynamic_cast<ModularDisplay*> (new MDspMessage(dsp_comp_hub, *(mon_env.log)))
);
debug_msg_view_mgr = std::unique_ptr<ModularDisplay>(
- dynamic_cast<ModularDisplay*> (new MDspMessage(dsp_comp_hub, debug_log_ref))
+ dynamic_cast<ModularDisplay*> (new MDspMessage(dsp_comp_hub, *(mon_env.debug_log)))
);
pgm_info_mgr = std::unique_ptr<ModularDisplay>(
dynamic_cast<ModularDisplay*> (new MDspPgmInfo(dsp_comp_hub))
);
// Pass a mutable components hub to the configuration display
config_mgr = std::unique_ptr<ModularDisplay>(
- dynamic_cast<ModularDisplay*> (new MDspConfiguration(*dsp_comp_hub_mgr, config_ref))
+ dynamic_cast<ModularDisplay*> (new MDspConfiguration(*dsp_comp_hub_mgr, *(mon_env.config)))
);
wait_msg_mgr = std::unique_ptr<MDspWaitMsg>(new MDspWaitMsg(dsp_comp_hub));
@@ -256,7 +252,7 @@ DisplayController::DisplayController(
DisplayIo* dsp_io = dsp_comp_hub_mgr->dsp_io;
dsp_io->write_text(ansi_ctl->ANSI_ALTBFR_ON.c_str());
dsp_io->write_text(ansi_ctl->ANSI_CURSOR_OFF.c_str());
- if (config_ref.enable_mouse_nav)
+ if (mon_env.config->enable_mouse_nav)
{
dsp_io->write_text(ansi_ctl->ANSI_MOUSE_ON.c_str());
}
diff --git a/user/drbdmon/terminal/DisplayController.h b/user/drbdmon/terminal/DisplayController.h
index 2108faba..4dee5300 100644
--- a/user/drbdmon/terminal/DisplayController.h
+++ b/user/drbdmon/terminal/DisplayController.h
@@ -25,6 +25,7 @@
#include <configuration/Configuration.h>
#include <platform/SystemApi.h>
#include <DrbdMonCore.h>
+#include <MonitorEnvironment.h>
#include <MessageLog.h>
#include <map_types.h>
#include <VList.h>
@@ -48,14 +49,10 @@ class DisplayController : public GenericDisplay, public DisplaySelector
// @throws std::bad_alloc, std::logic_error
DisplayController(
DrbdMonCore& core_instance_ref,
- SystemApi& sys_api_ref,
+ MonitorEnvironment& mon_env_ref,
SubProcessObserver& sub_proc_obs_ref,
ResourcesMap& rsc_map_ref,
- ResourcesMap& prb_rsc_map_ref,
- MessageLog& log_ref,
- MessageLog& debug_log_ref,
- Configuration& config_ref,
- const std::string* const node_name_ptr
+ ResourcesMap& prb_rsc_map_ref
);
virtual ~DisplayController() noexcept;
DisplayController(const DisplayController& other) = delete;
@@ -87,6 +84,7 @@ class DisplayController : public GenericDisplay, public DisplaySelector
using DisplayStack = VList<DisplayId::display_page>;
DrbdMonCore& core_instance;
+ MonitorEnvironment& mon_env;
std::unique_ptr<DisplayMap> dsp_map;
--
2.33.1.windows.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。