Skip to content

Commit bd9b620

Browse files
authored
feat(chunkserver): add plugin reload mechanism (#821)
feat(chunkserver): add plugin reload mechanism Introduce a plugin-wide reload mechanism to allow runtime reconfiguration without requiring a chunkserver restart. Signed-off-by: GigaCronos <jorge.cabrera@leil.io>
1 parent c43cb31 commit bd9b620

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

src/chunkserver/chunkserver-common/iplugin.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class BOOST_SYMBOL_VISIBLE IPlugin {
3838
/// needed.
3939
virtual bool initialize() = 0;
4040

41+
/// Called on chunkserver reload to refresh plugin configuration parameters.
42+
virtual void reload() = 0;
43+
4144
/// Returns the plugin name
4245
virtual std::string name() = 0;
4346
/// Returns the plugin version

src/chunkserver/chunkserver-common/plugin_manager.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ bool PluginManager::checkVersion(IPlugin *plugin) {
118118
return false;
119119
}
120120

121+
void PluginManager::reloadPlugins() {
122+
for (auto &[name, plugin] : diskPlugins_) {
123+
if (plugin) {
124+
safs::log_info("Reloading plugin {}", plugin->toString());
125+
plugin->reload();
126+
}
127+
}
128+
}
129+
121130
void PluginManager::cleanupPlugins() {
122131
for (auto &[name, plugin] : diskPlugins_) {
123132
if (plugin) {

src/chunkserver/chunkserver-common/plugin_manager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class PluginManager {
4949
/// True if this plugin manager can handle the plugin based on the version.
5050
bool checkVersion(IPlugin *plugin);
5151

52+
/// Reload plugins options for all the needed plugins.
53+
void reloadPlugins();
54+
5255
/// Cleanup resources for all the needed plugins.
5356
void cleanupPlugins();
5457

src/chunkserver/hddspacemgr.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,6 +2845,9 @@ void hddReload(void) {
28452845
} catch (const Exception& ex) {
28462846
safs_pretty_syslog(LOG_ERR, "%s", ex.what());
28472847
}
2848+
2849+
// Request plugins to reload
2850+
pluginManager.reloadPlugins();
28482851
}
28492852

28502853
int hddLateInit() {

0 commit comments

Comments
 (0)