ANNA Suite  2020b
Multipurpose development suite for Telco applications
Classes | Public Member Functions | Protected Member Functions | Friends | List of all members
anna::diameter::comm::Entity Class Referenceabstract

#include <Entity.hpp>

Classes

struct  SessionBasedModelsType
 

Public Member Functions

 Entity (int maxServers=2)
 
void setMaxServers (int maxServers)
 
int getMaxServers () const
 
void setDescription (const std::string &description)
 
const std::string & getDescription () const
 
void setEngine (Engine *e)
 
EnginegetEngine () const
 
void addServer (const socket_t &serverId) noexcept(false)
 
bool bind () noexcept(false)
 
void raiseAutoRecovery (bool autoRecovery=true) noexcept(false)
 
void setClassCodeTimeout (const ClassCode::_v v, const anna::Millisecond &millisecond)
 
void setCategory (int category)
 
int getCategory () const
 
ServergetLastUsedResource () const
 
void setBalance (bool balance)
 
bool getBalance () const
 
bool send (const Message *message) noexcept(false)
 
bool send (const Message &message) noexcept(false)
 
void setSessionBasedModelsType (const SessionBasedModelsType::_v sessionBasedModelsType)
 
SessionBasedModelsType::_v getSessionBasedModelsType () const
 
virtual int readSocketId (const Message *message, int maxClientSessions) const
 
bool broadcast (const Message *message) noexcept(false)
 
bool broadcast (const Message &message) noexcept(false)
 
bool isAvailable () const
 
bool isDeprecated () const
 
void setDeprecated (bool deprecated=true)
 
int getOTARequests () const
 
bool idle () const
 
std::vector< Server * >::iterator begin ()
 
std::vector< Server * >::iterator end ()
 
std::vector< Server * >::const_iterator begin () const
 
std::vector< Server * >::const_iterator end () const
 
void close () noexcept(false)
 
int getNumberOfServers () const
 
int getMaxServerss () const
 
socket_v getAddressPortList () const
 
void hide ()
 
void show ()
 
bool hidden () const
 
bool shown () const
 
std::string asString () const
 
anna::xml::NodeasXML (anna::xml::Node *parent) const
 

Protected Member Functions

virtual void eventPeerShutdown (const ClientSession *clientSession)
 
virtual void eventRequestRetransmission (const ClientSession *clientSession, Message *request)
 
virtual void eventResponse (const Response &response, const anna::diameter::comm::OriginHost *myNode) noexcept(false)=0
 
virtual void eventRequest (ClientSession *clientSession, const anna::DataBlock &request, const anna::diameter::comm::OriginHost *myNode) noexcept(false)=0
 
virtual void eventUnknownResponse (ClientSession *clientSession, const anna::DataBlock &response, const anna::diameter::comm::OriginHost *myNode) noexcept(false)=0
 
virtual void eventDPA (ClientSession *clientSession, const anna::DataBlock &response, const anna::diameter::comm::OriginHost *myNode) noexcept(false)=0
 

Friends

class Engine
 
class Server
 

Detailed Description

Generic diameter server list (N-servers entity)

Constructor & Destructor Documentation

◆ Entity()

anna::diameter::comm::Entity::Entity ( int  maxServers = 2)
inline

Default constructor. Entities should be create through diameter::comm::Engine

Parameters
maxServersMaximum number of servers managed by the entity. Default is 2 (standard/dual entity). The value -1, means no limit to add servers.
114 : a_maxServers(maxServers) { initialize(); }

Member Function Documentation

◆ addServer()

void anna::diameter::comm::Entity::addServer ( const socket_t serverId)
noexcept

Add a server to the entity and create all the servers configured at #setSocketsPerDiameterServer within that server.

Parameters
serverIdDiameter server ip/port.
Returns
Returns success on send operation over any server within the entity

◆ asString()

std::string anna::diameter::comm::Entity::asString ( ) const

Class string representation

Returns
String with relevant information for this instance.

◆ asXML()

anna::xml::Node* anna::diameter::comm::Entity::asXML ( anna::xml::Node parent) const

Class xml representation

Parameters
parentParent XML node on which hold this instance information.
Returns
XML document with relevant information for this instance.

◆ begin() [1/2]

std::vector<Server*>::iterator anna::diameter::comm::Entity::begin ( )
inline
390 { return a_servers.begin(); }

◆ begin() [2/2]

std::vector<Server*>::const_iterator anna::diameter::comm::Entity::begin ( ) const
inline
392 { return a_servers.begin(); }

◆ bind()

bool anna::diameter::comm::Entity::bind ( )
noexcept

Binds entity servers.

Returns
Returns true if all client-session were successfully bound

◆ broadcast() [1/2]

bool anna::diameter::comm::Entity::broadcast ( const Message message)
noexcept

Sent a message to all the entity servers. It is used, i.e., in Disconnect-Peer-Request procedure over a certain entity.

Parameters
messageMessage which is being sent.
Returns
Returns true (success) only when broadcast is success over all the entity servers. If any server fails, then false is returned.

◆ broadcast() [2/2]

bool anna::diameter::comm::Entity::broadcast ( const Message message)
inlinenoexcept
356 { return broadcast(&message); }
bool broadcast(const Message *message) noexcept(false)
Here is the call graph for this function:

◆ close()

void anna::diameter::comm::Entity::close ( )
inlinenoexcept

Close all the entity servers (close client-sessions within them). Depending on client-session configuration ('OnDisconnect' behaviour), pending answers will be wait (graceful) or ignored (immediate-abrupt close). Resources are not destroyed.

400 { close(false /* no destroy */); }
void close() noexcept(false)
Definition: Entity.hpp:400
Here is the call graph for this function:

◆ end() [1/2]

std::vector<Server*>::iterator anna::diameter::comm::Entity::end ( )
inline
391 { return a_servers.end(); }

◆ end() [2/2]

std::vector<Server*>::const_iterator anna::diameter::comm::Entity::end ( ) const
inline
393 { return a_servers.end(); }

◆ eventDPA()

virtual void anna::diameter::comm::Entity::eventDPA ( ClientSession clientSession,
const anna::DataBlock response,
const anna::diameter::comm::OriginHost myNode 
)
protectedpure virtualnoexcept

Handler for diameter session Disconnect-Peer-Answer messages

Parameters
clientSessionClientSession from which request has been received
responseAnswer data block object without context match
myNodeOwn origin host

◆ eventPeerShutdown()

virtual void anna::diameter::comm::Entity::eventPeerShutdown ( const ClientSession clientSession)
protectedvirtual

Handler about event break connection from diameter server (server) over this entity. When notified, ANNA.diameter.comm generates an diameter::comm::Entity::eventResponse for every request with pending answers. Default implementation traces warning event

Parameters
clientSessionClientSession from which shutdown has been received

◆ eventRequest()

virtual void anna::diameter::comm::Entity::eventRequest ( ClientSession clientSession,
const anna::DataBlock request,
const anna::diameter::comm::OriginHost myNode 
)
protectedpure virtualnoexcept

Handler for diameter server (server) requests

Parameters
clientSessionClientSession from which request has been received
requestDiameter request message received
myNodeOwn origin host

◆ eventRequestRetransmission()

virtual void anna::diameter::comm::Entity::eventRequestRetransmission ( const ClientSession clientSession,
Message request 
)
protectedvirtual

Handler about a request retransmission over the session. Default implementation traces warning event

Parameters
clientSessionClientSession from which retransmission happened
requestRetransmitted request message

◆ eventResponse()

virtual void anna::diameter::comm::Entity::eventResponse ( const Response response,
const anna::diameter::comm::OriginHost myNode 
)
protectedpure virtualnoexcept

Handler for diameter server (server) responses

Parameters
responseAnswer container object for corresponding diameter request
myNodeOwn origin host

◆ eventUnknownResponse()

virtual void anna::diameter::comm::Entity::eventUnknownResponse ( ClientSession clientSession,
const anna::DataBlock response,
const anna::diameter::comm::OriginHost myNode 
)
protectedpure virtualnoexcept

Handler for diameter session responses out of context

Parameters
clientSessionClientSession from which request has been received
responseAnswer data block object without context match
myNodeOwn origin host

◆ getAddressPortList()

socket_v anna::diameter::comm::Entity::getAddressPortList ( ) const

List of (address,port) pairs defining entity servers

◆ getBalance()

bool anna::diameter::comm::Entity::getBalance ( ) const
inline

Gets the balance mode

Returns
True if balance over entity servers is enabled, false if standard behaviour is configured (default).
224 { return a_balance; }

◆ getCategory()

int anna::diameter::comm::Entity::getCategory ( ) const
inline

Gets entity category. Used by application in order to categorize or clasify.

Returns
Entity category
202 { return a_category; }

◆ getDescription()

const std::string& anna::diameter::comm::Entity::getDescription ( ) const
inline

Gets the entity description.

Returns
Entity description.
144 { return a_description; }

◆ getEngine()

Engine* anna::diameter::comm::Entity::getEngine ( ) const
inline

Gets the diameter::comm::Engine

Returns
Diameter::comm::Engine
157 { return a_engine; }

◆ getLastUsedResource()

Server* anna::diameter::comm::Entity::getLastUsedResource ( ) const
inline

Gets the last used resource (server) during sending. Broadcast doesn't updates this information.

208 { return (a_lastUsedResource); }

◆ getMaxServers()

int anna::diameter::comm::Entity::getMaxServers ( ) const
inline

Gets the maximum number of servers managed by the entity.

Returns
Maximum number of servers managed by the entity.
129 { return a_maxServers; }

◆ getMaxServerss()

int anna::diameter::comm::Entity::getMaxServerss ( ) const
inline

Number of maximum allowed servers

412 { return a_maxServers; }

◆ getNumberOfServers()

int anna::diameter::comm::Entity::getNumberOfServers ( ) const
inline

Number of currently configured servers

407 { return a_servers.size(); }

◆ getOTARequests()

int anna::diameter::comm::Entity::getOTARequests ( ) const

Gets the number of requests messages over-the-air.

Returns
OTA messages.

◆ getSessionBasedModelsType()

SessionBasedModelsType::_v anna::diameter::comm::Entity::getSessionBasedModelsType ( ) const
inline

Returns sessions based models type.

Returns
Session based models type: RoundRobin, SessionIdLowPart, SessionIdHighPart or SessionIdOptionalPart.
285 { return a_sessionBasedModelsType; }

◆ hidden()

bool anna::diameter::comm::Entity::hidden ( ) const

Returns true when all its servers resources are hidden for application messages delivery

◆ hide()

void anna::diameter::comm::Entity::hide ( )

Deny resources for delivery restriction. Deny all its servers

◆ idle()

bool anna::diameter::comm::Entity::idle ( ) const
inline

Returns idle state (no pending answers).

Returns
Idle state.
387 { return (getOTARequests() == 0); }

◆ isAvailable()

bool anna::diameter::comm::Entity::isAvailable ( ) const
inline

Returns true when any of the entity servers is Bound. False when all not-bound.

362 { return a_available; }

◆ isDeprecated()

bool anna::diameter::comm::Entity::isDeprecated ( ) const
inline

Returns true when the entity has been selected as deprecated

367 { return a_deprecated; }

◆ raiseAutoRecovery()

void anna::diameter::comm::Entity::raiseAutoRecovery ( bool  autoRecovery = true)
noexcept

Propagate auto recovery configuration to servers within entity

Parameters
autoRecoveryAuto recovery indicator. True by default.

◆ readSocketId()

virtual int anna::diameter::comm::Entity::readSocketId ( const Message message,
int  maxClientSessions 
) const
virtual

Before sending a message over each entity server, socketId could be specified to select which client session within such server will manage the message.

Default implementation has been focused on charging applications but any other kind of application could re-implement this method and change the behaviour:

Charging involves two peers:
   Charging Trigger Function (CTF): Makes decisions on how to charge the user for specific
                                    services, issues requests to the server (OCF).
   Online Charging Function (OCF):  Performs actual charging based on received message type,
                                    service logic and user profile information.
There are three main scenarios:
   Immediate Event Charging (IEC): The CTF sends a one time request. This request contains
                                   a predefined set of AVPs indicating which service has
                                   been activated or how many units have been consumed
                                   (this depends on application logic).
   Event Charging with Unit Reservation (ECUR): The CTF issues a request which indicates the
                                                desired unit count for reservation. On service
                                                delivery, the CTF issues another request which
                                                indicates how many units were actually consumed.
                                                Units can be of any type, as they are application
                                                specific.
   Session Charging with Unit Reservation(SCUR): As above, however reservation can happen more than once.
In order to minimize race conditions within trasactions, default implementation will select the connection
fixed by an stickiness value (Session-Id will be used) for ECUR and SCUR models (Data, Voice and Content
traffic). IEC model, represented by SMS ans MMS traffic will use round-robin between sockets. The type
of traffic will be analyzed by mean Service-Context-Id AVP. If traffic type is not reconized, value of
'-1' will be returned doing round-robin socket selection within active server.
Diameter session-oriented load balancing enables to distribute Diameter signaling traffic across
multiple client sessions for the selected entity server. Application could re-implement different
load balancing policies, including support for session stickiness and business decisions, and
subscriber and service aware contextual load balancing strategies. By default, Session-Id avp
is used to select the resource. Session-Id is split into 4 sections: diameter identity, high
part, low part and optional part. Default implementation analizes 'low' part, returning its
value as reference for socket selection. Use  to change this behaviour.

When server is configured as single client session (max client sessions equal to 1), entity will ignore this method being more efficient, because former algorithms would not affect the session selection.

Parameters
messageMessage which is being sent.
maxClientSessionsNumber of client-sessions on specific server prepared for send.
Returns
Socket-id used within range [0,maxClientSessions-1]. Value '-1' if round-robin is desired. If socket-id is return out of range, send procedure will throw an exception.

◆ send() [1/2]

bool anna::diameter::comm::Entity::send ( const Message message)
noexcept

Sent a message to the entity. First uses primary server, secondary if fails and so on to the last defined resource (server) within entity. Another sending algorithm (non standard) could be enabled (balance boolean parameter): it consist in round-robin server selection without trying any one if fails (standard behaviour tries all servers from FIRST defined). Anyway, last used delivery resource could be known through getLastUsedResource().

When the message is a request, a timer will be set automatically to control the response time. If expires, the ResultCode Timeout will be finally notified on #Entity::eventResponse. This timeout value will be configured at setClassCodeTimeout.

Parameters
messageMessage sent.
balanceFalse by default (standard beaviour), but useful to balance over servers within entity.
Returns
Boolean about success in send operation. Standard behaviour (no balance) implies true result when any of the entity servers could send the message, and false when neither of the servers was available or fail to send the message. Broadcast try to send all over the resources in spite of any fail, and balanced sendings fails when next selected resource fail to send the message (and no alarm or error counter is generated in this case because it can't be understood/ensured as entity-sending fail. Sent a message to the entity. First uses primary server, secondary if fails and so on to the last defined resource (server) within entity. Another sending algorithm (non standard) could be enabled (): it consist in round-robin server selection to set the first resource in a complete cycle (standard behaviour tries all servers from FIRST defined). Anyway, last used delivery resource could be known through getLastUsedResource().

When the message is a request, a timer will be set automatically to control the response time. If expires, the ResultCode Timeout will be finally notified on #Entity::eventResponse. This timeout value will be configured at setClassCodeTimeout.

Parameters
messageMessage sent.
Returns
Boolean about success in send operation. Implies true result when any of the entity servers could send the message, and false when neither of the servers was available or fail to send the message (an alarm and error counter will be generated in this case). Broadcast try to send all over the resources in spite of any fail.

◆ send() [2/2]

bool anna::diameter::comm::Entity::send ( const Message message)
inlinenoexcept
273 { return send(&message); }
bool send(const Message *message) noexcept(false)
Here is the call graph for this function:

◆ setBalance()

void anna::diameter::comm::Entity::setBalance ( bool  balance)
inline

Balance over entity servers or use standard behaviour (first primary, secondary if fails, etc.). New created entities have balance disabled.

Parameters
balanceTrue or false to enable or disable.
217 { a_balance = balance; }

◆ setCategory()

void anna::diameter::comm::Entity::setCategory ( int  category)
inline

Sets entity category. Used by application in order to categorize or clasify.

Parameters
categoryEntity category
195 { a_category = category; }

◆ setClassCodeTimeout()

void anna::diameter::comm::Entity::setClassCodeTimeout ( const ClassCode::_v  v,
const anna::Millisecond millisecond 
)

Sets timeout for wait responses for any class code request for all entity servers

Parameters
vDiameter request type.
millisecondMilliseconds for timeout

◆ setDeprecated()

void anna::diameter::comm::Entity::setDeprecated ( bool  deprecated = true)
inline

Sets the entity deprecated state

372 { a_deprecated = deprecated; }

◆ setDescription()

void anna::diameter::comm::Entity::setDescription ( const std::string &  description)
inline

Sets the entity description.

Parameters
descriptionEntity description. Empty by default.
137 { a_description = description; }

◆ setEngine()

void anna::diameter::comm::Entity::setEngine ( Engine e)
inline

Sets the diameter::comm::Engine

Parameters
eDiameter::comm::Engine
151 { a_engine = e; }

◆ setMaxServers()

void anna::diameter::comm::Entity::setMaxServers ( int  maxServers)
inline

Sets the maximum number of servers managed by the entity.

Parameters
maxServersMaximum number of servers managed by the entity.
122 { a_maxServers = maxServers; }

◆ setSessionBasedModelsType()

void anna::diameter::comm::Entity::setSessionBasedModelsType ( const SessionBasedModelsType::_v  sessionBasedModelsType)
inline

Sets sessions based models type.

Parameters
sessionBasedModelsTypeSession based models type: RoundRobin, SessionIdLowPart (default), SessionIdHighPart or SessionIdOptionalPart.
279 { a_sessionBasedModelsType = sessionBasedModelsType; }

◆ show()

void anna::diameter::comm::Entity::show ( )

Allow resource for delivery permission. Allow all its servers

◆ shown()

bool anna::diameter::comm::Entity::shown ( ) const

Returns true when all its servers resources are shown for application messages delivery

Friends And Related Function Documentation

◆ Engine

friend class Engine
friend

◆ Server

friend class Server
friend

The documentation for this class was generated from the following file: