p2p::RoutingRules

class kanzi::connect::p2p::RoutingRules

Entity that manages messge routing rules for a single service instance.

Public Types

typedef vector<shared_ptr<Endpoint>>::iterator EndpointIterator
typedef map<string, RouteSharedPtr>::iterator Iterator
typedef shared_ptr<Route> RouteSharedPtr

Public Functions

RoutingRules(const string &xml, const string interfacename = "", bool verboseLogging = false)

Constructor.

Parameters
  • xml: The XML document describing the routing.

  • interfacename: The name of the interface.

~RoutingRules()

Destructor.

void addEndpoint(shared_ptr<Endpoint> ep)

Inserts an endpoint to list of endpoints.

Parameters
  • ep: the endpoint to insert.

bool addRoute(const string &xml)

Add new route.

Return

True if route was added successfully

Parameters
  • xml: Contains the route definition in xml

EndpointIterator beginEndpoints()

Get iterator to beginning of endpoints.

Return

iterator

Iterator beginEvents()

begin iteration of events

Return

iterator

Iterator beginMethods()

begin iteration of methods

Return

iterator

void clearEndpoints()

Clears all existing endpoints.

vector<shared_ptr<RoutingRules::Endpoint>> collectRequiredEndpoints(const string &reliableBearer, const string &unreliableBearer)

Used on service side where routing rules are analyzed and then a list of required endpoints is collected.

Return

vector of endpoints required.

Parameters
  • reliableBearer: name of the reliable bearer

  • unreliableBearer: name of the unreliable bearer

EndpointIterator endEndpoints()

Get iterator to end of endpoints.

Return

iterator

Iterator endEvents()

Return

end iterator

Iterator endMethods()

Return

end iterator

int getMetaDataInt(const string &name, int def = -1)

return integer from metadata

Return

retrieved value.

Parameters
  • name: the name of the meta element to retrieve

  • def: default value to return if not found

string getMetaDataString(const string &name)

return stringfrom metadata

Return

retrieved value. empty string if not found.

Parameters
  • name: the name of the meta element to retrieve

inline bool isEmpty() const

Is the object empty i.e.

no routing information included

Return

true if empty.

bool removeRouteForRuntimeData()

Remove route for runtime data.

Return

True if removed successfully, false if not found

bool removeRouteForSubject(const string &subjectName)

Remove route for given subject.

Return

True if removed successfully, false if not found

Parameters
  • subjectName: Name of the method or event identifying the route to remove

bool requireDirectLink() const

Does any of the referred routing rules require direct link(s) or is this service server only.

Return

true if direct link might be required.

RouteSharedPtr routeForEvent(const string &eventName)

Returns a preferred route for a specific event.

Return

The route to apply.

Parameters
  • eventName: The name of the event to ask.

RouteSharedPtr routeForEventMessage(const string &eventMessageName)

Returns a preferred route for a specific event.

Return

The route to apply.

Parameters
  • eventMessageName: The name of the event message to ask.

RouteSharedPtr routeForMethod(const string &methodName)

Returns a preferred route for a specific method.

Return

The route to apply.

Parameters
  • methodName: The name of the method to ask.

RouteSharedPtr routeForMethodMessage(const string &methodMessageName)

Returns a preferred route for a specific method.

Return

The route to apply.

Parameters
  • methodMessageName: The name of the method message to ask.

RouteSharedPtr routeForRuntimeData()

Returns a preferred route for a runtime data.

Return

The route to apply.

string toXml(RouteAttributes *metadata = nullptr)

Converts the routing information to XML.

Return

the xml representation of the routing information.

Parameters
  • metadata: Optional meta information put into the XML document. Name-value pairs.

class Endpoint

Endpoint for communication.

Public Types

typedef RouteAttributes::iterator AttributeIterator

Public Functions

inline Endpoint()

Constructor.

inline AttributeIterator beginAttributes()

Return beginning of attributes.

Return

iterator to beginning of attributes

inline AttributeIterator endAttributes()

Return end of attributes iterator.

Return

iterator to end of attributes

inline bool equals(const Endpoint &o) const

Compares this and passed object by all information.

Return

true if equals

Parameters
  • o: the object to compare to

inline bool equalsByAddress(const Endpoint &o) const

Compares this and passed object by address information.

Return

true if equals by address

Parameters
  • o: object to compare to

inline bool equalsByAddressAndReliability(const Endpoint &o) const

Compares this and passed object by address and relialibility information.

Return

true if equals by address

Parameters
  • o: object to compare to

inline const RouteAttributes &getAttributes() const

Retrieve attribute references.

Return

reference to attribute container

inline const string &getBearer() const

Getter for bearer information.

Return

the bearer information

inline const string &getConnectIdentifier() const

Retrieve previously set connect identifier.

Return

connectIdentifier value.

inline const string &getIdentifier() const

Retrieves then endpoint identifier.

Return

endpoint identifier

inline const string &getIP() const

Getter for IP Address.

Return

IP Address

inline MessageDispatcher *getMessageDispatcher() const

Getter for message dispatcher.

Return

message dispatcher

inline const string &getPort() const

Getter for port information.

Return

port number

inline bool getReliable() const

Getter for reliable.

Return

true if reliable.

inline bool getUnreliable() const

Getter for unreliable flag.

Return

true if unreliable

inline void setAttributes(const RouteAttributes &attributes)

Stores the attributes specific for the route.

Parameters
  • attributes: the attributes

inline void setBearer(const string &bearer)

Setter for bearer information.

Parameters
  • bearer: the bearer to set

inline void setConnectIdentifier(const string &connectIdentifier)

Sets the connection identifier.

Parameters
  • connectIdentifier: some identifier using which the client can reach this service with selected bearer.

inline void setIdentifier(const string &identifier)

sets the endpoint identifier

Parameters
  • identifier: the name of the endpoint

inline void setIP(const string &ip)

Setter for IP Address.

For server side IP defines the interface to bind into.

Parameters
  • ip: the ip address

inline void setMessageDispatcher(MessageDispatcher *dsp)

Attach message dispatcher.

Parameters
  • dsp: the dispatcher to attach

inline void setPort(const string &port)

Setter for port information.

Parameters
  • port: the port information to set in string format

inline void setPort(int port)

Setter for port information.

Parameters
  • port: the port information

inline void setReliable(bool reliable)

Setter for reliable flag.

Parameters
  • reliable: state of the endpoint

inline void setUnreliable(bool unreliable = true)

Setter for unreliable flag.

Parameters
  • unreliable: unreliability state of the endpoint

string toString() const

Get stringular representation of the endpoint.

Return

stringified representation of the object

inline bool valid() const

Checks is object valid.

Return

true if valid.

class Route

Defines a route for a single communications element.

Public Types

typedef RouteAttributes::iterator AttributeIterator
enum RouteDef

Values:

enumerator Server

Route via Server.

enumerator Direct

Route directly.

Public Functions

inline Route(RouteDef r, string link)

Constructor.

Parameters
  • r: route

  • link: link

inline AttributeIterator beginAttributes()

Return beginning of attributes.

Return

iterator to beginning of attributes

inline bool directRouteEnabled() const

Is direct route enabled.

Return

true if direct route enabled

inline bool directRoutePossible() const

Determines whether route is direct and it is possible.

Return

true if direct route is possible

inline AttributeIterator endAttributes()

Return end of attributes iterator.

Return

iterator to end of attributes

inline bool equals(const RoutingRules::Route &other) const

Compares routes.

Return

true if routes equal.

Parameters
  • other: the other route to compare this object to

inline const RouteAttributes &getAttributes() const

Retrieve attribute references.

Return

reference to attribute container

inline const string &getBearer() const

Retrieve bearer information.

Return

bearer

inline shared_ptr<Endpoint> getEndpoint() const

Getter for endpoint.

Return

endpoint information

inline const string &getLink() const

Getter for link information.

Return

link information

inline bool getReliable() const
inline RouteDef getRoute() const

Getter for route.

Return

route information

inline const string &getSubject() const

Getter for subject information.

Return

subject information

inline bool serverRouteEnabled() const

Routing via server enabled.

Return

true if route via server enabled.

inline void setAttributes(const RouteAttributes &attributes)

Stores the attributes specific for the route.

Parameters
  • attributes: the attributes

inline void setBearer(string bearer)

Stores bearer information.

Parameters
  • bearer: the bearer information

inline void setEndpoint(shared_ptr<Endpoint> &ep)

Setter for endpoint.

Parameters
  • ep: endpoint to store

inline void setLink(const string &link)

Setter for link.

Parameters
  • link: link informaiton

inline void setReliable(bool reliable)
inline void setRoute(RouteDef route)

Setter for route information.

Parameters
  • route: route

inline void setSubject(const string &subject)

Setter for subject information.

Parameters
  • subject: subject information