Main interface to the OpFlex framework.
More...
#include <opflex/ofcore/OFFramework.h>
|
| OFFramework () |
| Create a new framework instance.
|
|
virtual | ~OFFramework () |
| Destroy the framework instance.
|
|
void | setModel (const modb::ModelMetadata &model) |
| Add the given model metadata to the managed object database. More...
|
|
void | setOpflexIdentity (const std::string &name, const std::string &domain) |
| Set the opflex identity information for this framework instance. More...
|
|
void | setOpflexIdentity (const std::string &name, const std::string &domain, const std::string &location) |
| Set the opflex identity information for this framework instance. More...
|
|
virtual void | start () |
| Start the framework. More...
|
|
virtual void | stop () |
| Cleanly stop the framework.
|
|
virtual MainLoopAdaptor * | startSync () |
| Start the framework in synchronous mode using a main loop adaptor. More...
|
|
virtual void | dumpMODB (const std::string &file) |
| Dump the managed object database to the file specified as a JSON blob. More...
|
|
virtual void | dumpMODB (FILE *file) |
| Dump the managed object database to the file specified as a JSON blob. More...
|
|
virtual void | prettyPrintMODB (std::ostream &output, bool tree=true, bool includeProps=true, bool utf8=true, size_t truncate=0) |
| Pretty print the current MODB to the provided output stream. More...
|
|
virtual void | enableSSL (const std::string &caStorePath, bool verifyPeers=true) |
| Enable SSL for connections to opflex peers. More...
|
|
virtual void | enableSSL (const std::string &caStorePath, const std::string &keyAndCertFilePath, const std::string &passphrase, bool verifyPeers=true) |
| Enable SSL for connections to opflex peers. More...
|
|
virtual void | enableInspector (const std::string &socketName) |
| Enable the MODB inspector service. More...
|
|
virtual void | addPeer (const std::string &hostname, int port) |
| Add an OpFlex peer. More...
|
|
virtual void | registerPeerStatusListener (PeerStatusListener *listener) |
| Register the given peer status listener to get updates on the health of the connection pool and on individual connections. More...
|
|
|
static const std::vector< int > & | getVersion () |
| Get the library version as an vector of three version numbers: major, minor, and release.
|
|
static const std::string & | getVersionStr () |
| Get the library version as a string of the format [major]. More...
|
|
static OFFramework & | defaultInstance () |
| Get the static default instance of the framework.
|
|
|
class | OFFrameworkImpl |
|
class | modb::Mutator |
|
class | modb::mointernal::MO |
|
class | MockOFFramework |
|
Main interface to the OpFlex framework.
This class manages configuration and lifecycle for the framework, and provides the primary interface point into the framework. You can create your own instance, or rely on the static default instance.
You must first initialize the framework by calling setModel() with your model and then calling start():
You can shut down the framework by calling stop():
Once the framework is initialized, you can interact with the model using the generated model classes, which include static methods for resolving objects from the managed object store.
◆ addPeer()
virtual void opflex::ofcore::OFFramework::addPeer |
( |
const std::string & |
hostname, |
|
|
int |
port |
|
) |
| |
|
virtual |
Add an OpFlex peer.
If the framework is started, this will immediately initiate a new connection asynchronously.
When connecting to the peer, that peer may provide an additional list of peers to connect to, which will be automatically added as peers. If the peer does not include itself in the list, then the framework will disconnect from that peer and add the peers in the list. In this way, it is possible to automatically bootstrap the correct set of peers using a known hostname or IP address or a known, fixed anycast IP address.
- Parameters
-
hostname | the hostname or IP address to connect to |
port | the TCP port to connect on |
◆ dumpMODB() [1/2]
virtual void opflex::ofcore::OFFramework::dumpMODB |
( |
const std::string & |
file | ) |
|
|
virtual |
Dump the managed object database to the file specified as a JSON blob.
- Parameters
-
file | the file to write to. |
◆ dumpMODB() [2/2]
virtual void opflex::ofcore::OFFramework::dumpMODB |
( |
FILE * |
file | ) |
|
|
virtual |
Dump the managed object database to the file specified as a JSON blob.
- Parameters
-
file | the file to write to. |
◆ enableInspector()
virtual void opflex::ofcore::OFFramework::enableInspector |
( |
const std::string & |
socketName | ) |
|
|
virtual |
Enable the MODB inspector service.
The service will listen on the specified UNIX domain socket for connections from the inspector client.
- Parameters
-
socketName | A path to the UNIX domain socket |
◆ enableSSL() [1/2]
virtual void opflex::ofcore::OFFramework::enableSSL |
( |
const std::string & |
caStorePath, |
|
|
bool |
verifyPeers = true |
|
) |
| |
|
virtual |
Enable SSL for connections to opflex peers.
- Parameters
-
caStorePath | the filesystem path to a directory containing CA certificates, or to a file containing a specific CA certificate. |
verifyPeers | set to true to verify that peer certificates properly chain to a trusted root |
◆ enableSSL() [2/2]
virtual void opflex::ofcore::OFFramework::enableSSL |
( |
const std::string & |
caStorePath, |
|
|
const std::string & |
keyAndCertFilePath, |
|
|
const std::string & |
passphrase, |
|
|
bool |
verifyPeers = true |
|
) |
| |
|
virtual |
Enable SSL for connections to opflex peers.
- Parameters
-
caStorePath | the filesystem path to a directory containing CA certificates, or to a file containing a specific CA certificate. |
keyAndCertFilePath | the path to the PEM file for this peer, containing its certificate and its private key, possibly encrypted. |
passphrase | the passphrase to be used to decrypt the private key within this peer's PEM file |
verifyPeers | set to true to verify that peer certificates properly chain to a trusted root |
◆ getVersionStr()
static const std::string& opflex::ofcore::OFFramework::getVersionStr |
( |
| ) |
|
|
static |
Get the library version as a string of the format [major].
[minor].[release]-[build]
◆ prettyPrintMODB()
virtual void opflex::ofcore::OFFramework::prettyPrintMODB |
( |
std::ostream & |
output, |
|
|
bool |
tree = true , |
|
|
bool |
includeProps = true , |
|
|
bool |
utf8 = true , |
|
|
size_t |
truncate = 0 |
|
) |
| |
|
virtual |
Pretty print the current MODB to the provided output stream.
- Parameters
-
output | the output stream to write to |
tree | print in a tree format |
includeProps | include the object properties |
utf8 | output tree using UTF-8 box drawing |
truncate | truncate lines to the specified number of characters. 0 means do not truncate. |
◆ registerPeerStatusListener()
virtual void opflex::ofcore::OFFramework::registerPeerStatusListener |
( |
PeerStatusListener * |
listener | ) |
|
|
virtual |
Register the given peer status listener to get updates on the health of the connection pool and on individual connections.
Must be called before calling start() on the framework.
- Parameters
-
listener | the listener to register |
◆ setModel()
Add the given model metadata to the managed object database.
Must be called before start()
- Parameters
-
model | the model metadata to add to the object database |
◆ setOpflexIdentity() [1/2]
void opflex::ofcore::OFFramework::setOpflexIdentity |
( |
const std::string & |
name, |
|
|
const std::string & |
domain |
|
) |
| |
Set the opflex identity information for this framework instance.
- Parameters
-
name | the unique name for this opflex component within the policy domain |
domain | the globally unique name for this policy domain |
◆ setOpflexIdentity() [2/2]
void opflex::ofcore::OFFramework::setOpflexIdentity |
( |
const std::string & |
name, |
|
|
const std::string & |
domain, |
|
|
const std::string & |
location |
|
) |
| |
Set the opflex identity information for this framework instance.
- Parameters
-
name | the unique name for this opflex component within the policy domain |
domain | the globally unique name for this policy domain |
location | the location string for this policy element. |
◆ start()
virtual void opflex::ofcore::OFFramework::start |
( |
| ) |
|
|
virtual |
Start the framework.
This will start all the framework threads and attempt to connect to configured OpFlex peers.
Reimplemented in opflex::ofcore::MockOFFramework.
◆ startSync()
Start the framework in synchronous mode using a main loop adaptor.
You will be responsible for calling MainLoopAdaptor::runOnce in each iteration of your main loop so libopflex can make progress.
- Returns
- the MainLoopAdaptor you will need to call. The memory is owned by the framework and the pointer will become invalid when stop() is called.
The documentation for this class was generated from the following file: