xorp

ModuleManager Class Reference

Inheritance diagram for ModuleManager:
GenericModuleManager

List of all members.

Classes

class  Process

Public Member Functions

 ModuleManager (EventLoop &eventloop, Rtrmgr &rtrmgr, bool do_restart, bool verbose, const string &xorp_root_dir, const string &xorp_module_dir)
 Constructor.
virtual ~ModuleManager ()
 The default destructor.
bool new_module (const string &module_name, const string &path, string &error_msg)
 Create a new module.
int start_module (const string &module_name, bool do_exec, bool is_verification, XorpCallback1< void, bool >::RefPtr cb)
 Start a module.
int kill_module (const string &module_name, XorpCallback0< void >::RefPtr cb)
 Kill a module.
bool module_is_running (const string &module_name) const
 Test whether a module is running.
bool module_has_started (const string &module_name) const
 Test whether a module has been started.
void shutdown ()
 Shutdown the module manager.
bool is_shutdown_completed () const
 Test whether the shutdown has been completed.
void module_status_changed (const string &module_name, Module::ModuleStatus old_status, Module::ModuleStatus new_status)
 Change the status of a module.
list< string > get_module_names () const
 Get the module names.
list< Module * > find_running_modules_by_path (const string &expath)
 Get the running modules that match an executional path.
int execute_process (const string &expath, string &error_msg)
 Execute a process.
void process_exited (const string &expath, bool success, bool is_signal_terminated, int term_signal, bool is_coredumped)
 A method called when a process has exited.
void process_stopped (const string &expath, int stop_signal)
 A method called when a process has been stopped.
ModuleManager::Processfind_process_by_path (const string &expath)
 Find a process by its expanded path.
const string & xorp_root_dir () const
 Get the XORP root directory.
const string & xorp_module_dir () const
 Get the XORP module directory.
MasterConfigTreemaster_config_tree () const
 Get the master configuration tree.
void set_master_config_tree (MasterConfigTree *v)
 Set the master configuration tree.
bool do_restart () const
 Test if processes that have failed should be restarted.

Private Member Functions

void module_shutdown_cb (string module_name)
int expand_execution_path (const string &path, string &expath, string &error_msg)

Private Attributes

Rtrmgr_rtrmgr
MasterConfigTree_master_config_tree
map< string, Process * > _expath2process
bool _do_restart
bool _verbose
string _xorp_root_dir
string _xorp_module_dir

Constructor & Destructor Documentation

ModuleManager::ModuleManager ( EventLoop eventloop,
Rtrmgr rtrmgr,
bool  do_restart,
bool  verbose,
const string &  xorp_root_dir,
const string &  xorp_module_dir 
)

Constructor.

Parameters:
eventloopthe event loop to use.
rtrmgrthe router manager to use.
do_restartif true, then restart a module if it failed.
verboseif true, then output trace messages.
xorp_root_dirthe XORP root directory.
xorp_module_dirthe XORP module directory.

Member Function Documentation

bool ModuleManager::do_restart ( ) const [inline]

Test if processes that have failed should be restarted.

Returns:
true if failed processes should be restarted, otherwise false.
int ModuleManager::execute_process ( const string &  expath,
string &  error_msg 
)

Execute a process.

Parameters:
expaththe expanded path for the process to execute.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
ModuleManager::Process * ModuleManager::find_process_by_path ( const string &  expath)

Find a process by its expanded path.

Parameters:
expaththe expanded path for the process to find.
Returns:
the corresponding process if found, otherwise NULL.
list< Module * > ModuleManager::find_running_modules_by_path ( const string &  expath)

Get the running modules that match an executional path.

Parameters:
expaththe path to match.
Returns:
a list of modules that are running and match expath.
list< string > ModuleManager::get_module_names ( ) const

Get the module names.

Returns:
a list with the module names.
bool ModuleManager::is_shutdown_completed ( ) const

Test whether the shutdown has been completed.

Returns:
true if the shutdown has been completed, otherwise false.
int ModuleManager::kill_module ( const string &  module_name,
XorpCallback0< void >::RefPtr  cb 
)

Kill a module.

Parameters:
module_namethe module name.
cbthe callback to dispatch when the module is terminated.
Returns:
XORP_OK on success, otherwise XORP_ERROR.
MasterConfigTree* ModuleManager::master_config_tree ( ) const [inline]

Get the master configuration tree.

Returns:
the master configuration tree.
bool ModuleManager::module_has_started ( const string &  module_name) const

Test whether a module has been started.

Parameters:
module_namethe module name.
Returns:
true if the module has been started, otherwise false.
bool ModuleManager::module_is_running ( const string &  module_name) const

Test whether a module is running.

Parameters:
module_namethe module name.
Returns:
true if the module is running, otherwise false.
void ModuleManager::module_status_changed ( const string &  module_name,
Module::ModuleStatus  old_status,
Module::ModuleStatus  new_status 
)

Change the status of a module.

Parameters:
module_namethe module name.
old_statusthe old status.
new_statusthe new status.
bool ModuleManager::new_module ( const string &  module_name,
const string &  path,
string &  error_msg 
)

Create a new module.

Parameters:
module_namethe module name.
paththe path to the executable program for this module. It could be either the relative or expanded absolute path.
error_msgthe error message (if error).
Returns:
true on success, otherwise false.
void ModuleManager::process_exited ( const string &  expath,
bool  success,
bool  is_signal_terminated,
int  term_signal,
bool  is_coredumped 
)

A method called when a process has exited.

Parameters:
expaththe expanded path for the process that has exited.
successif true, the exit status of the process indicates success, otherwise failure.
is_signal_terminatedif true the process has been terminated by a signal.
term_signalif is_signal_terminated is true, this contains the terminating signal.
is_coredumpedif true the process has generated a coredump.
void ModuleManager::process_stopped ( const string &  expath,
int  stop_signal 
)

A method called when a process has been stopped.

Parameters:
expaththe expanded path for the process that has been stopped.
stop_signalthe signal that has stopped the process.
void ModuleManager::set_master_config_tree ( MasterConfigTree v) [inline]

Set the master configuration tree.

Parameters:
vthe master configuration tree to set.
int ModuleManager::start_module ( const string &  module_name,
bool  do_exec,
bool  is_verification,
XorpCallback1< void, bool >::RefPtr  cb 
)

Start a module.

Parameters:
module_namethe module name.
do_execif true then indeed execute the executable program, otherwise just process the execution machinery.
is_verificationif true then this is verification of the execution machinery.
cbthe callback to dispatch at the end of the startup process.
Returns:
XORP_OK on success, otherwise XORP_ERROR.
const string& ModuleManager::xorp_module_dir ( ) const [inline]

Get the XORP module directory.

Returns:
the XORP module directory.
const string& ModuleManager::xorp_root_dir ( ) const [inline]

Get the XORP root directory.

Returns:
the XORP root directory.

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations