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

#include <LocalServer.hpp>

Public Member Functions

 LocalServer ()
 
 ~LocalServer ()
 
void setKey (const socket_t &key)
 
void setDescription (const std::string description)
 
void setClassCodeTimeout (const ClassCode::_v v, const anna::Millisecond &millisecond)
 
void setCategory (int category)
 
void setMaxConnections (int maxConnections) noexcept(false)
 
void setAllowedInactivityTime (const anna::Millisecond &allowedInactivityTime)
 
void setEngine (Engine *e)
 
const socket_tgetKey () const
 
int getMaxConnections () const
 
int getCurrentConnections () const
 
const anna::MillisecondgetAllowedInactivityTime () const
 
bool isAvailable () const
 
void disable (bool lock=false) noexcept(false)
 
void enable (bool unlock=false) noexcept(false)
 
int getOTARequests () const
 
bool idle () const
 
void close () noexcept(false)
 
void resetConnectionsMargin () noexcept(false)
 
ServerSessionfindServerSession (const anna::comm::ClientSocket &clientSocket, anna::Exception::Mode::_v emode=anna::Exception::Mode::Throw) noexcept(false)
 
ServerSessionfindServerSession (int socketId, anna::Exception::Mode::_v emode=anna::Exception::Mode::Throw) noexcept(false)
 
bool send (const Message *, int socketId=-1) noexcept(false)
 
bool send (const Message &message, int socketId=-1) noexcept(false)
 
ServerSessiongetLastUsedResource () const
 
virtual int readSocketId (const Message *message) const
 
bool broadcast (const Message *message) noexcept(false)
 
bool broadcast (const Message &message) noexcept(false)
 
std::string asString () const
 
anna::xml::NodeasXML (anna::xml::Node *parent) const
 
void updateProcessingTimeStatisticConcept (const double &value, const anna::diameter::CommandId &cid)
 
void updateReceivedMessageSizeStatisticConcept (const double &value, const anna::diameter::CommandId &cid)
 

Protected Member Functions

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

Friends

class anna::diameter::comm::Timer
 
class Engine
 
class ServerSocket
 
class ServerSession
 
class ServerSessionReceiver
 

Detailed Description

Diameter server socket

Constructor & Destructor Documentation

◆ LocalServer()

anna::diameter::comm::LocalServer::LocalServer ( )

Constructor

◆ ~LocalServer()

anna::diameter::comm::LocalServer::~LocalServer ( )
inline

Destructor

129 { close(); }
void close() noexcept(false)

Member Function Documentation

◆ asString()

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

Class string representation

Returns
String with relevant information for this instance.

◆ asXML()

anna::xml::Node* anna::diameter::comm::LocalServer::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.

◆ broadcast() [1/2]

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

Sent a message to all the server sessions. 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::LocalServer::broadcast ( const Message message)
inlinenoexcept
332 { return broadcast(&message); }
bool broadcast(const Message *message) noexcept(false)
Here is the call graph for this function:

◆ close()

void anna::diameter::comm::LocalServer::close ( )
noexcept

Close the local server means two things: close the server socket and close all the server sessions born from this local server freeing such server sessions resources.

◆ disable()

void anna::diameter::comm::LocalServer::disable ( bool  lock = false)
noexcept

Disables local server socket (listener) keeping current server sessions alive. Note that applications should not close the listen port directly to keep coherence (see resetConnectionsMargin)

Parameters
lockLocks disabled state (make it permanent even if new connections margin is reached). Used during diameter agent isolation (lost of service, maintenance, etc.)

◆ enable()

void anna::diameter::comm::LocalServer::enable ( bool  unlock = false)
noexcept

Enables local server socket (listener)

Parameters
unlockUnlocks permanent disabled states

◆ eventDPA()

virtual void anna::diameter::comm::LocalServer::eventDPA ( ServerSession serverSession,
const anna::DataBlock response,
const anna::diameter::comm::OriginHost myNode 
)
protectedpure virtualnoexcept

Handler for diameter client Disconnect-Peer-Answer messages

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

◆ eventPeerShutdown()

virtual void anna::diameter::comm::LocalServer::eventPeerShutdown ( const ServerSession serverSession)
protectedvirtual

Handler about event break connection from diameter client over this server-session. When notified, ANNA.diameter.comm generates an diameter::comm::ServerSession::eventResponse for every request with pending answers. Default implementation traces warning event

Parameters
serverSessionServerSession from which shutdown has been received

◆ eventRequest()

virtual void anna::diameter::comm::LocalServer::eventRequest ( ServerSession serverSession,
const anna::DataBlock request,
const anna::diameter::comm::OriginHost myNode 
)
protectedpure virtualnoexcept

Handler for diameter client requests

Parameters
serverSessionServerSession from which request has been received
requestRequest data block object for corresponding diameter reception
myNodeOwn origin host

◆ eventRequestRetransmission()

virtual void anna::diameter::comm::LocalServer::eventRequestRetransmission ( const ServerSession serverSession,
Message request 
)
protectedvirtual

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

Parameters
serverSessionServerSession from which retransmission happened
requestRetransmitted request message

◆ eventResponse()

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

Handler for diameter client responses

Parameters
responseAnswer container object for corresponding diameter request
myNodeOwn origin host

◆ eventUnknownResponse()

virtual void anna::diameter::comm::LocalServer::eventUnknownResponse ( ServerSession serverSession,
const anna::DataBlock response,
const anna::diameter::comm::OriginHost myNode 
)
protectedpure virtualnoexcept

Handler for diameter client responses out of context

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

◆ findServerSession() [1/2]

ServerSession* anna::diameter::comm::LocalServer::findServerSession ( const anna::comm::ClientSocket clientSocket,
anna::Exception::Mode::_v  emode = anna::Exception::Mode::Throw 
)
noexcept

Returns server-session instance identified by client socket provided.

Parameters
clientSocketClient socket associated to the server session
emodeAction when no client-session is found with provided parameters (Throw/Ignore).
Returns
The server-session instance identified by client socket provided.
Warning
If no server-session found, an exception is launched by default.

◆ findServerSession() [2/2]

ServerSession* anna::diameter::comm::LocalServer::findServerSession ( int  socketId,
anna::Exception::Mode::_v  emode = anna::Exception::Mode::Throw 
)
noexcept

Returns server-session instance identified by socket id provided (hash over serialized client socket information).

Parameters
socketIdSocket id which is key for the server session
emodeAction when no client-session is found with provided parameters (Throw/Ignore).
Returns
The server-session instance identified by client socket provided.
Warning
If no server-session found, an exception is launched by default.

◆ getAllowedInactivityTime()

const anna::Millisecond& anna::diameter::comm::LocalServer::getAllowedInactivityTime ( ) const
inline

Gets the maximum allowed inactivity time on server sessions born over the local server before being reset

Returns
Inactivity time allowed
210 { return a_allowedInactivityTime; }

◆ getCurrentConnections()

int anna::diameter::comm::LocalServer::getCurrentConnections ( ) const
inline

Gets the number of current connections being established through server socket

203 { return a_currentConnections; }

◆ getKey()

const socket_t& anna::diameter::comm::LocalServer::getKey ( ) const
inline

Gets the local server key

Returns
LocalServer key
193 { return a_key; }

◆ getLastUsedResource()

ServerSession* anna::diameter::comm::LocalServer::getLastUsedResource ( ) const
inline

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

306 { return (a_lastUsedResource); }

◆ getMaxConnections()

int anna::diameter::comm::LocalServer::getMaxConnections ( ) const
inline

Gets the number of maximum accepted connections that server socket is configured to handle

198 { return a_maxConnections; }

◆ getOTARequests()

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

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

Returns
OTA messages.

◆ idle()

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

Returns idle state (no pending answers).

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

◆ isAvailable()

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

Returns true when any of the server-sessions is Bound. False when all not-bound.

215 { return a_available; }

◆ readSocketId()

virtual int anna::diameter::comm::LocalServer::readSocketId ( const Message message) const
inlinevirtual

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

Default implementation performs round-robin (value '-1' for socketId) but any other kind of application could re-implement this method and change the behaviour.

Parameters
messageMessage which is being sent.
Returns
Socket-id (hash over serialized client socket information). Value '-1' if round-robin is desired. If socket-id is unkonwn, send procedure will throw an exception.
320 { return -1; }

◆ resetConnectionsMargin()

void anna::diameter::comm::LocalServer::resetConnectionsMargin ( )
inlinenoexcept

Performs coherent server socket close procedure zeroing margin between current established connections and maximum allowed.

257 { setMaxConnections(a_currentConnections); }
void setMaxConnections(int maxConnections) noexcept(false)

◆ send() [1/2]

bool anna::diameter::comm::LocalServer::send ( const Message ,
int  socketId = -1 
)
noexcept

Sent a message to the client using a certain server-session provided or defined by readSocketId if not. 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 #LocalServer::eventResponse. This timeout value will be configured at setClassCodeTimeout.

Parameters
messageMessage sent.
socketIdServer session socket id INetAddress serialization. By default, readSocketId is invoked to get the socket id used (which uses round-robin if not re-implemented)
Returns
Boolean about success in send operation. True when any of the server sessions could send the message. False, when neither of the server sessions was available or fail to send the message. Broadcast try to send all over the resources in spite of any fail. If a specific socket id is provided, only this socket is used without trying any other and returning false if fails.

◆ send() [2/2]

bool anna::diameter::comm::LocalServer::send ( const Message message,
int  socketId = -1 
)
inlinenoexcept
300 { return send(&message, socketId); }
bool send(const Message *, int socketId=-1) noexcept(false)
Here is the call graph for this function:

◆ setAllowedInactivityTime()

void anna::diameter::comm::LocalServer::setAllowedInactivityTime ( const anna::Millisecond allowedInactivityTime)
inline

Sets the maximum allowed inactivity time on server sessions born over the local server before being reset. Communication engine assign a default value of 90000 msecs.

Parameters
allowedInactivityTimeInactivity time allowed
179 { a_allowedInactivityTime = allowedInactivityTime; }

◆ setCategory()

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

Sets the server socket optional category

Parameters
descriptionServer socket category
161 { a_category = category; }

◆ setClassCodeTimeout()

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

Set timeout to consider failed a request.

Parameters
vRequests class code.
millisecondMilliseconds wait before considering the requests failed.

Timers are internally managed and automatically activated.

◆ setDescription()

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

Sets the server socket optional description

Parameters
descriptionServer socket description
145 { a_description = description; }

◆ setEngine()

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

Sets the diameter::comm::Engine

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

◆ setKey()

void anna::diameter::comm::LocalServer::setKey ( const socket_t key)
inline

Sets the local server key

Parameters
LocalServerkey
138 { a_key = key; }

◆ setMaxConnections()

void anna::diameter::comm::LocalServer::setMaxConnections ( int  maxConnections)
noexcept

Sets the maximum supported connections. If provided value is negative or lesser than the number of current connections, an exception will be launched. If all the connections was established, a new maximum will open the listen port. when margin is zeroed (maximum configured is equal to current connections), listen port will be closed.

Parameters
maxConnectionsNumber of maximum connections allowed

◆ updateProcessingTimeStatisticConcept()

void anna::diameter::comm::LocalServer::updateProcessingTimeStatisticConcept ( const double &  value,
const anna::diameter::CommandId cid 
)

◆ updateReceivedMessageSizeStatisticConcept()

void anna::diameter::comm::LocalServer::updateReceivedMessageSizeStatisticConcept ( const double &  value,
const anna::diameter::CommandId cid 
)

Friends And Related Function Documentation

◆ anna::diameter::comm::Timer

friend class anna::diameter::comm::Timer
friend

◆ Engine

friend class Engine
friend

◆ ServerSession

friend class ServerSession
friend

◆ ServerSessionReceiver

friend class ServerSessionReceiver
friend

◆ ServerSocket

friend class ServerSocket
friend

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