INET Framework for OMNeT++/OMNEST
|
Manages operations like shutdown/restart, suspend/resume, crash/recover and similar operations for nodes (routers, hosts, etc), interfaces, and protocols. More...
#include <LifecycleController.h>
Classes | |
class | Callback |
Public Member Functions | |
LifecycleController () | |
~LifecycleController () | |
virtual void | initialize () override |
virtual void | handleMessage (cMessage *msg) override |
virtual void | processCommand (const cXMLElement &node) override |
Called by ScenarioManager whenever a script command needs to be carried out by the module. More... | |
virtual bool | initiateOperation (LifecycleOperation *operation, IDoneCallback *completionCallback=nullptr) |
Initiate an operation. More... | |
Public Member Functions inherited from inet::IScriptable | |
virtual | ~IScriptable () |
Protected Member Functions | |
virtual bool | resumeOperation (LifecycleOperation *operation) |
virtual void | doOneStage (LifecycleOperation *operation, cModule *submodule) |
virtual void | moduleOperationStageCompleted (Callback *callback) |
Protected Attributes | |
Callback * | spareCallback |
Manages operations like shutdown/restart, suspend/resume, crash/recover and similar operations for nodes (routers, hosts, etc), interfaces, and protocols.
Overview and usage are described in the NED file, you are advised to read that first. The rest of this documentation concentrates on the C++ API.
Operations are represented by C++ class derived from LifecycleOperation. Simple modules that wish to participate in an operation need to implement the ILifecycle interface (C++ class).
An operation is initiated by calling the initiateStateChange(cModule *module, LifecycleOperation *operation)
method of this class. (This is often done from a ScenarioManager script). This method applies the operation to the given module (usually a host, router or network interface compound module).
Operations may have multiple stages (think multi-stage initialization), where each stage may take nonzero simulation time. The number of stages are defined by the operation (its getNumStages() method). Within a stage, the submodule tree is traversed, and initiateStateChange() is invoked on each module that implements ILifecycle.
Operations may take nonzero simulation time. A module that needs nonzero simulation time to complete a stage (e.g. it wants to close TCP connections or model finite shutdown/reboot time) can signal that in the return value of initiateStateChange(). When it is done, it can signal that to LifecycleController by invoking the callback passed to it in initiateStateChange(). LifecycleController only regards the stage as completed (and goes on to the next stage) when all participating modules have indicated that they are done.
Operations can be nested, that is, it's possible to initiate another operation while one is underway.
|
inline |
|
inline |
|
protectedvirtual |
Referenced by resumeOperation().
|
overridevirtual |
|
virtual |
Initiate an operation.
See the class documentation and ILifecycle for details. The target module will be taken from the operation object.
The return value indicates whether the operation has been completed inside the call (true), or is pending because it will take several events and likely nonzero simulation time to complete (false). In the latter case, and if you provided a completionCallback as parameter, you will be notified via the callback when the operation completes.
Referenced by inet::power::SimpleEpEnergyManagement::executeNodeOperation(), inet::power::SimpleCcBattery::executeNodeOperation(), inet::power::SimpleEpEnergyStorage::executeNodeOperation(), and processCommand().
|
protectedvirtual |
Referenced by inet::LifecycleController::Callback::invoke().
|
overridevirtual |
Called by ScenarioManager whenever a script command needs to be carried out by the module.
The command is represented by the XML element or element tree. The command name can be obtained as:
const char *command = node->getTagName()
Parameters are XML attributes, e.g. a "neighbour" parameter can be retrieved as:
const char *attr = node->getAttribute("neighbour")
More complex input can be passed in child elements.
Implements inet::IScriptable.
|
protectedvirtual |
Referenced by initiateOperation(), and moduleOperationStageCompleted().
|
protected |
Referenced by doOneStage().