X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=include%2Fanna%2Fdiameter.comm%2FServer.hpp;h=711fdcdb41c28f7f58ff62bdb18ff98b4e59e651;hb=5a6cba5fde2b2f538a7515f8293cc0a8d9589dfa;hp=ba0d284c6b890a37ea56ca2d4ff60abf6aef9b31;hpb=3e258840b15577cb8bda3cdedd0b9b88e16404b3;p=anna.git diff --git a/include/anna/diameter.comm/Server.hpp b/include/anna/diameter.comm/Server.hpp index ba0d284..711fdcd 100644 --- a/include/anna/diameter.comm/Server.hpp +++ b/include/anna/diameter.comm/Server.hpp @@ -1,37 +1,9 @@ -// ANNA - Anna is Not Nothingness Anymore -// -// (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo -// -// https://bitbucket.org/testillano/anna -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Authors: eduardo.ramos.testillano@gmail.com -// cisco.tierra@gmail.com +// ANNA - Anna is Not Nothingness Anymore // +// // +// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo // +// // +// See project site at http://redmine.teslayout.com/projects/anna-suite // +// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE // #ifndef anna_diameter_comm_Server_hpp @@ -41,14 +13,17 @@ // STL #include #include +#include +// Project #include #include - #include #include #include -#include +#include + + namespace anna { @@ -92,30 +67,28 @@ class Server { // Activity anna::Millisecond a_lastIncomingActivityTime; // last unix timestamp (in milliseconds) when message reception was managed over this server anna::Millisecond a_lastOutgoingActivityTime; // last unix timestamp (in milliseconds) when message sending was managed over this server - void updateIncomingActivityTime() throw(); - void updateOutgoingActivityTime() throw(); + void updateIncomingActivityTime() ; + void updateOutgoingActivityTime() ; // Engine Engine *a_engine; // Statistics - int a_processing_time__StatisticConceptId; - int a_received_message_size__StatisticConceptId; - anna::statistics::Accumulator a_statisticsAccumulator; - void initializeStatisticConcepts() throw(); - void resetStatistics() throw(); + MessageStatistics a_messageStatistics; + void initializeStatisticResources() ; + void resetStatistics() ; // Availability bool a_available; // any of the client-sessions must be bound - void availabilityLost() throw(); - void availabilityRecovered() throw(); - bool refreshAvailability() throw(); // return true if change - void assertReady() throw(anna::RuntimeException); - void initialize() throw(); - void childIdle() const throw(); + void availabilityLost() ; + void availabilityRecovered() ; + bool refreshAvailability() ; // return true if change + void assertReady() noexcept(false); + void initialize() ; + void childIdle() const ; // Private close/destroy method - void close(bool destroy) throw(anna::RuntimeException); + void close(bool destroy) noexcept(false); public: @@ -128,13 +101,16 @@ public: */ Server(int maxClientSessions = 1) : a_maxClientSessions(maxClientSessions) { initialize(); } + /** Destructor */ + virtual ~Server() {;} + /** * Add a server to the entity and create all the client-sessions configured at #setSocketsPerDiameterServer within that server. * * \param socketId Diameter socket identifier within the server. */ - void addClientSession(int socketId) throw(anna::RuntimeException); + void addClientSession(int socketId) noexcept(false); /** Set timeout to consider failed a request. @@ -143,34 +119,34 @@ public: Timers are internally managed and automatically activated. */ - void setClassCodeTimeout(const ClassCode::_v v, const anna::Millisecond & millisecond) throw(); + void setClassCodeTimeout(const ClassCode::_v v, const anna::Millisecond & millisecond) ; /** * Binds server client-sessions. * * @return Returns true if all client-session were successfully bound */ - bool bind() throw(anna::RuntimeException); + bool bind() noexcept(false); /** * Propagate auto recovery configuration to client-sessions within server * * @param autoRecovery Auto recovery indicator. True by default. */ - void raiseAutoRecovery(bool autoRecovery = true) throw(anna::RuntimeException); + void raiseAutoRecovery(bool autoRecovery = true) noexcept(false); // Sent a message to the server using a certain client-session by mean round-robin between socketId's for // multiple client client-sessions functionality. If a specific socketId is provided, then uses such specific client-session. // Last used delivery resource could be known through #getLastUsedResource(). - bool send(const Message*, int socketId = -1 /* client-sessions round-robin */) throw(anna::RuntimeException); - bool send(const Message& message, int socketId = -1 /* client-sessions round-robin */) throw(anna::RuntimeException) { return send(&message, socketId); } + bool send(const Message*, int socketId = -1 /* client-sessions round-robin */) noexcept(false); + bool send(const Message& message, int socketId = -1 /* client-sessions round-robin */) noexcept(false) { return send(&message, socketId); } /** Gets the last used resource (client session) during sending. Broadcast doesn't updates this information. */ - ClientSession *getLastUsedResource() const throw() { return (a_lastUsedResource); } + ClientSession *getLastUsedResource() const { return (a_lastUsedResource); } /** Sent a message to all the server client-sessions (socketId's) for multiple client client-sessions functionality. @@ -178,53 +154,53 @@ public: Returns true (success) only when broadcast is success over all the server client-sessions. If any client-session fails, then false is returned. Broadcast try to send all over the resources in spite of any fail. */ - bool broadcast(const Message*) throw(anna::RuntimeException); - bool broadcast(const Message& message) throw(anna::RuntimeException) { return broadcast(&message); } + bool broadcast(const Message*) noexcept(false); + bool broadcast(const Message& message) noexcept(false) { return broadcast(&message); } /** Close all the server client-sessions. Depending on client-session configuration ('OnDisconnect' behaviour), pending answers will be wait (graceful) or ignored (immediate-abrupt close). Resources are not destroyed. */ - void close() throw(anna::RuntimeException) { close(false /* no destroy */); } + void close() noexcept(false) { close(false /* no destroy */); } /** Diameter parent entity. \return Diameter parent entity. */ - const Entity *getParent() const throw() { return a_parent; } + const Entity *getParent() const { return a_parent; } /** Returns true when any of the server client-sessions is Bound. False when all not-bound. */ - bool isAvailable() const throw() { return a_available; } + bool isAvailable() const { return a_available; } - std::vector::iterator begin() throw() { return a_clientSessions.begin(); } - std::vector::iterator end() throw() { return a_clientSessions.end(); } - std::vector::const_iterator begin() const throw() { return a_clientSessions.begin(); } - std::vector::const_iterator end() const throw() { return a_clientSessions.end(); } + std::vector::iterator begin() { return a_clientSessions.begin(); } + std::vector::iterator end() { return a_clientSessions.end(); } + std::vector::const_iterator begin() const { return a_clientSessions.begin(); } + std::vector::const_iterator end() const { return a_clientSessions.end(); } - int getNumberOfClientSessions() const throw() { return a_clientSessions.size(); } - int getMaxClientSessions() const throw() { return a_maxClientSessions; } - void setMaxClientSessions(int maxClientSessions) throw() { a_maxClientSessions = maxClientSessions; } + int getNumberOfClientSessions() const { return a_clientSessions.size(); } + int getMaxClientSessions() const { return a_maxClientSessions; } + void setMaxClientSessions(int maxClientSessions) { a_maxClientSessions = maxClientSessions; } /** Diameter server address (IP or hostname) \return Diameter server address. */ - const std::string& getAddress() const throw() { return a_socket.first; } + const std::string& getAddress() const { return a_socket.first; } /** Diameter server port. \return Diameter server port. */ - int getPort() const throw() { return a_socket.second; } + int getPort() const { return a_socket.second; } /** Server presentation as 'ADDRESS:PORT' */ - std::string socketAsString() const throw(); + std::string socketAsString() const ; /** @@ -232,14 +208,14 @@ public: @return Last incoming activity timestamp. */ - const anna::Millisecond & getLastIncomingActivityTime() const throw() { return a_lastIncomingActivityTime; } + const anna::Millisecond & getLastIncomingActivityTime() const { return a_lastIncomingActivityTime; } /** Gets the timestamp for last outgoing activity over the server. @return Last outgoing activity timestamp. */ - const anna::Millisecond & getLastOutgoingActivityTime() const throw() { return a_lastOutgoingActivityTime; } + const anna::Millisecond & getLastOutgoingActivityTime() const { return a_lastOutgoingActivityTime; } /** @@ -247,58 +223,58 @@ public: @return OTA messages. */ - int getOTARequests() const throw(); + int getOTARequests() const ; /** Returns idle state (no pending answers). @return Idle state. */ - bool idle() const throw() { return (getOTARequests() == 0); } + bool idle() const { return (getOTARequests() == 0); } /** Deny resources for delivery restriction. Deny all its client sessions */ - void hide() throw(); + void hide() ; /** Allow resource for delivery permission. Allow all its client sessions */ - void show() throw(); + void show() ; /** Returns true when all its client session resources are hidden for application messages delivery */ - bool hidden() const throw(); + bool hidden() const ; /** Returns true when all its client session resources are shown for application messages delivery */ - bool shown() const throw(); + bool shown() const ; /** Class string representation \return String with relevant information for this instance. */ - std::string asString() const throw(); + std::string asString() const ; /** Class xml representation \param parent Parent XML node on which hold this instance information. \return XML document with relevant information for this instance. */ - anna::xml::Node* asXML(anna::xml::Node* parent) const throw(); + anna::xml::Node* asXML(anna::xml::Node* parent) const ; // Statistics - void updateProcessingTimeStatisticConcept(const double &value) throw(); - void updateReceivedMessageSizeStatisticConcept(const double &value) throw(); - int getProcessingTimeStatisticConcept() const throw() { return a_processing_time__StatisticConceptId; } - int getReceivedMessageSizeStatisticConcept() const throw() { return a_received_message_size__StatisticConceptId; } + void updateProcessingTimeStatisticConcept(const double &value, const anna::diameter::CommandId &cid) ; + void updateReceivedMessageSizeStatisticConcept(const double &value, const anna::diameter::CommandId &cid) ; +// int getProcessingTimeStatisticConcept() const { return a_processing_time__StatisticConceptId; } +// int getReceivedMessageSizeStatisticConcept() const { return a_received_message_size__StatisticConceptId; } protected: @@ -307,14 +283,21 @@ protected: When notified, ANNA.diameter.comm generates an diameter::comm::Entity::eventResponse for every request with pending answers. */ - virtual void eventPeerShutdown(const ClientSession*) throw(); + virtual void eventPeerShutdown(const ClientSession*) ; + + /** + Handler about a request retransmission over the session. + + \param request Message retransmitted + */ + virtual void eventRequestRetransmission(const ClientSession*, Message *request) ; /** Handler for diameter server (client-session) responses \param response Answer container object for corresponding diameter request */ - virtual void eventResponse(const Response & response) throw(anna::RuntimeException); + virtual void eventResponse(const Response & response) noexcept(false); /** Handler for diameter server (client-session) requests @@ -322,8 +305,8 @@ protected: \param clientSession ClientSession from which request has been received \param request Diameter request message received */ - virtual void eventRequest(ClientSession *clientSession, const anna::DataBlock &request) throw(anna::RuntimeException); - //virtual void eventRequest(ClientSession *clientSession, const Message & request) throw(anna::RuntimeException); + virtual void eventRequest(ClientSession *clientSession, const anna::DataBlock &request) noexcept(false); + //virtual void eventRequest(ClientSession *clientSession, const Message & request) noexcept(false); /** Handler for diameter server (client-session) responses out of context @@ -331,7 +314,16 @@ protected: \param clientSession ClientSession from which request has been received \param response Answer data block object without context match */ - virtual void eventUnknownResponse(ClientSession *clientSession, const anna::DataBlock& response) throw(anna::RuntimeException); + virtual void eventUnknownResponse(ClientSession *clientSession, const anna::DataBlock& response) noexcept(false); + + /** + Handler for diameter server (client-session) Disconnect-Peer-Answer messages + + \param clientSession ClientSession from which request has been received + \param response Answer data block object without context match + */ + virtual void eventDPA(ClientSession *clientSession, const anna::DataBlock& response) noexcept(false); + friend class Engine; @@ -343,4 +335,3 @@ protected: } #endif -