Class that manages all the RDK plugin hook libraries.
More...
#include <DobbyRdkPluginManager.h>
|
| DobbyRdkPluginManager (std::shared_ptr< rt_dobby_schema > containerConfig, const std::string &rootfsPath, const std::string &pluginPath, const std::shared_ptr< DobbyRdkPluginUtils > &utils) |
| Create instance of DobbyRdkPlugin Manager and load all plugins that can be found in pluginPath. More...
|
|
| ~DobbyRdkPluginManager () |
|
const std::vector< std::string > | listLoadedPlugins () const |
| Just return a list of all loaded plugin names.
|
|
const std::vector< std::string > | listLoadedLoggers () const |
| Just return a list of all loaded logging plugin names.
|
|
bool | runPlugins (const IDobbyRdkPlugin::HintFlags &hookPoint, const uint timeoutMs=0) const |
| Run the plugins specified in the container config at the given hook point. Returns true if all required plugins execute successfully. If non-required plugins fail or are not loaded, then it logs an error but continues running other plugins. More...
|
|
std::shared_ptr< IDobbyRdkLoggingPlugin > | getContainerLogger () const |
| Get the logging plugin specified in the container config. Each container can only have a single plugin for logging, otherwise there is a chance of conflicts whilst reading the container stdout/err. More...
|
|
void | setExitStatus (int status) const |
| Set the exit status of the container. More...
|
|
std::shared_ptr< rt_dobby_schema > | getContainerConfig () const |
|
|
bool | mValid |
|
std::map< std::string, std::pair< void *, std::shared_ptr< IDobbyRdkLoggingPlugin > > > | mLoggers |
|
std::map< std::string, std::pair< void *, std::shared_ptr< IDobbyRdkPlugin > > > | mPlugins |
|
std::set< std::string > | mRequiredPlugins |
|
std::shared_ptr< rt_dobby_schema > | mContainerConfig |
|
const std::string | mRootfsPath |
|
const std::string | mPluginPath |
|
const std::shared_ptr< DobbyRdkPluginUtils > | mUtils |
|
std::unique_ptr< DobbyRdkPluginDependencySolver > | mDependencySolver |
|
Class that manages all the RDK plugin hook libraries.
At creation time it loads all the plugin libraries.
◆ DobbyRdkPluginManager()
DobbyRdkPluginManager::DobbyRdkPluginManager |
( |
std::shared_ptr< rt_dobby_schema > |
containerConfig, |
|
|
const std::string & |
rootfsPath, |
|
|
const std::string & |
pluginPath, |
|
|
const std::shared_ptr< DobbyRdkPluginUtils > & |
utils |
|
) |
| |
Create instance of DobbyRdkPlugin Manager and load all plugins that can be found in pluginPath.
- Parameters
-
[in] | containerConfig | Pointer to the libocispec struct for the container config |
[in] | pluginPath | Where to search for plugins |
◆ ~DobbyRdkPluginManager()
DobbyRdkPluginManager::~DobbyRdkPluginManager |
( |
| ) |
|
Unload all plugins on destruction
◆ executeHook()
Runs the specified hook for a given plugin
- Parameters
-
[in] | pluginName | Name of the plugin to run |
[in] | hook | Which hook to execute |
- Returns
- True if the hook executed successfully
◆ executeHookTimeout()
bool DobbyRdkPluginManager::executeHookTimeout |
( |
const std::string & |
pluginName, |
|
|
const IDobbyRdkPlugin::HintFlags |
hook, |
|
|
const uint |
timeoutMs |
|
) |
| const |
|
private |
Runs the specified hook for a given plugin, checks if execution takes less than timeoutMs value, and if so kills the process.
- Parameters
-
[in] | pluginName | Name of the plugin to run |
[in] | hook | Which hook to execute |
[in] | timeoutMs | Timeout value in miliseconds |
- Returns
- True if the hook executed successfully
◆ getContainerLogger()
Get the logging plugin specified in the container config. Each container can only have a single plugin for logging, otherwise there is a chance of conflicts whilst reading the container stdout/err.
- Parameters
-
[in] | name | The name of the plugin. |
- Returns
- The logging plugin
◆ getLogger()
Get the logger with the name, or nullptr if no plugin.
- Parameters
-
[in] | name | The name of the plugin. |
- Returns
- The plugin interface shared pointer.
◆ getPlugin()
std::shared_ptr< IDobbyRdkPlugin > DobbyRdkPluginManager::getPlugin |
( |
const std::string & |
name | ) |
const |
|
inlineprivate |
Get the plugin with the name, or nullptr if no plugin.
- Parameters
-
[in] | name | The name of the plugin. |
- Returns
- The plugin interface shared pointer.
◆ HookPointToString()
Converts hook point into human readable string
- Parameters
-
[in] | hook | Which hook to translate |
- Returns
- std::string with representation, empty if not found.
◆ implementsHook()
Check if a plugin implements the specified hook.
- Parameters
-
[in] | pluginName | The name of the plugin to check |
[in] | hook | The hook to check if the plugin implements |
- Returns
- True if plugin implements specified hook
◆ isLoaded()
bool DobbyRdkPluginManager::isLoaded |
( |
const std::string & |
pluginName | ) |
const |
|
private |
Check if a plugin is loaded.
- Parameters
-
[in] | pluginName | The name of the plugin to check. |
- Returns
- True if a plugin is loaded, false if not.
◆ isRequired()
bool DobbyRdkPluginManager::isRequired |
( |
const std::string & |
pluginName | ) |
const |
|
private |
Check if a plugin is required.
- Parameters
-
[in] | pluginName | The name of the plugin to check. |
- Returns
- True if a plugin is required, false if not.
◆ loadPlugins()
bool DobbyRdkPluginManager::loadPlugins |
( |
| ) |
|
|
private |
Scans the given path for any shared objects that implement the plugin entry points.
This calls dlopen() on all the executable files in the given path (although it doesn't recurse into subdirs), if the file has symbols createIDobbyRdkPlugin and destroyIDobbyRdkPlugin then it's deemed to be a 'rdk' plugin.
If loaded successfully the plugins are stored in an internal map, keyed off the plugin name.
- Returns
- False if unable to open the given directory, true otherwise.
◆ preprocessPlugins()
bool DobbyRdkPluginManager::preprocessPlugins |
( |
| ) |
|
|
private |
Prepares the dependency solver and required plugins data structures.
This method scans the container config and based on its contents:
- Adds all the plugins, along with their dependencies, to the plugin dependency solver,
- Creates a list of the required plugins,
- Checks if the required plugins are loaded.
- Returns
- False if a required plugin is not loaded or if one of the dependencies is not a known plugin. True otherwise.
◆ runPlugins()
Run the plugins specified in the container config at the given hook point. Returns true if all required plugins execute successfully. If non-required plugins fail or are not loaded, then it logs an error but continues running other plugins.
- Parameters
-
[in] | hookPoint | Which hook point to execute |
[in] | timeoutMs | Timeout in miliseconds, if 0 (default value) then there will be no timeout. |
- Returns
- True if all required plugins ran successfully
◆ setExitStatus()
void DobbyRdkPluginManager::setExitStatus |
( |
int |
status | ) |
const |
Set the exit status of the container.
- Parameters
-
[in] | status | The exit status of the container. |
- Returns
- void
The documentation for this class was generated from the following files: