Skip to content

Commit

Permalink
Enable reloading of Mirror configuration
Browse files Browse the repository at this point in the history
Mirror attribute is reset with the latest configuration when "reload" is used as
value on a Alter Mirror command

Re ECFLOW-1986
  • Loading branch information
marcosbento committed Nov 12, 2024
1 parent 27d1cdc commit 13eca73
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion libs/base/src/ecflow/base/cts/user/AlterCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ const char* AlterCmd::desc() {
" For change:\n"
" [ variable | clock_type | clock_gain | clock_date | clock_sync | event | meter | label |\n"
" trigger | complete | repeat | limit_max | limit_value | defstatus | late | time |\n"
" today, aviso, mirror ]\n"
" today | aviso | mirror ]\n"
" *NOTE* If the clock is changed, then the suite will need to be re-queued in order for\n"
" the change to take effect fully.\n"
" For add:\n"
Expand Down
15 changes: 12 additions & 3 deletions libs/node/src/ecflow/node/MirrorAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ void MirrorAttr::reset() {
start_controller();
}

void MirrorAttr::reload() {
if (controller_) {
state_change_no_ = Ecf::incr_state_change_no();
stop_controller();
start_controller();
}
}

void MirrorAttr::finish() {
stop_controller();
}
Expand Down Expand Up @@ -190,7 +198,7 @@ std::string MirrorAttr::resolve_cfg(const std::string& value,
}

void MirrorAttr::start_controller() {
if (controller_ == nullptr) {
if (!controller_) {

// Resolve variables in configuration
// In the case of the 'remote_host', we have to resolve the configuration
Expand All @@ -217,7 +225,8 @@ void MirrorAttr::start_controller() {

SLOG(D,
"MirrorAttr: start polling Mirror attribute '" << absolute_name() << "', from " << remote_path_ << " @ "
<< remote_host << ':' << remote_port << ")");
<< remote_host << ':' << remote_port << ") using polling: "
<< polling << " s");

std::uint32_t polling_value;
try {
Expand Down Expand Up @@ -247,7 +256,7 @@ void MirrorAttr::start_controller() {
}

void MirrorAttr::stop_controller() {
if (controller_ != nullptr) {
if (controller_) {
SLOG(D,
"MirrorAttr: finishing polling for Mirror attribute \"" << parent_->absNodePath() << ":" << name_
<< "\", from host: " << remote_host_
Expand Down
9 changes: 9 additions & 0 deletions libs/node/src/ecflow/node/MirrorAttr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class MirrorAttr {
static constexpr const char* fallback_polling = "120";
static constexpr const char* fallback_remote_auth = "";

static constexpr const char* reload_option_value = "reload";

static bool is_valid_name(const std::string& name);

/**
Expand Down Expand Up @@ -104,8 +106,15 @@ class MirrorAttr {

/**
* Initialises the Mirror procedure, which effectively starts the background polling mechanism.
* Typically, called when traversing the tree -- does nothing if Mirror service is already set up.
*/
void reset();
/**
* Restarts the Mirror procedure, which effectively stops before restarting the background polling mechanism.
* Typicallly, called explicitly via Alter command -- forces the reinitialisation of the Mirror service,
* guaranteeing that parameters, given as ECF variables, are reevaluated.
*/
void reload();
void finish();

/**
Expand Down
14 changes: 9 additions & 5 deletions libs/node/src/ecflow/node/NodeChange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,15 @@ void Node::changeMirror(const std::string& name, const std::string& value) {
throw std::runtime_error("Node::changeMirror: Could not find mirror " + name);
}

auto attr = MirrorParser::parse_mirror_line(value, name, this);

// The following delete/add enforces the reconfiguration of the attribute backend thread
this->deleteMirror(name); // delete the mirror if it exists (to avoid duplicates
this->addMirror(attr);
if (value == MirrorAttr::reload_option_value) {
found->reload();
} else {
auto attr = MirrorParser::parse_mirror_line(value, name, this);

// The following delete/add enforces the reconfiguration of the attribute backend thread
this->deleteMirror(name); // delete the mirror if it exists (to avoid duplicates
this->addMirror(attr);
}

state_change_no_ = Ecf::incr_state_change_no();
}
Expand Down

0 comments on commit 13eca73

Please sign in to comment.