X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=source%2Fdiameter.comm%2FServerSession.cpp;h=b88da8d89d2b0554628e9640c5d05960b79b062f;hb=64cc135e716c2ef018227375fc4f15ff0670fdf7;hp=3c493d0bd01b3b0603c74f15b37cb6c58db8d05f;hpb=3d71e5185fa9c93bde7363a668aecf96240ae2e9;p=anna.git diff --git a/source/diameter.comm/ServerSession.cpp b/source/diameter.comm/ServerSession.cpp index 3c493d0..b88da8d 100644 --- a/source/diameter.comm/ServerSession.cpp +++ b/source/diameter.comm/ServerSession.cpp @@ -55,10 +55,10 @@ const anna::Millisecond ServerSession::DefaultAllowedInactivityTime(90000); // I ServerSession::ServerSession() : Session("diameter::comm::ServerSession", "Diameter Inactivity Detection Timer"), a_receiverFactory(this), a_cer(ClassCode::Bind), - a_dwr(ClassCode::ApplicationMessage) // realmente no es necesario, los Message son por defecto de aplicacion + a_dwr(ClassCode::ApplicationMessage) // not actually needed; Message is application type by default { initialize(); } -void ServerSession::initialize() throw() { +void ServerSession::initialize() { Session::initialize(); a_parent = NULL; a_clientSocket = NULL; @@ -67,22 +67,21 @@ void ServerSession::initialize() throw() { //ServerSession::~ServerSession() {;} -void ServerSession::setClientSocket(anna::comm::ClientSocket *clientSocket) throw() { +void ServerSession::setClientSocket(anna::comm::ClientSocket *clientSocket) { a_clientSocket = clientSocket; a_clientSocket->setReceiverFactory(a_receiverFactory); } -const std::string& ServerSession::getAddress() const throw() { +const std::string& ServerSession::getAddress() const { return a_parent->getKey().first; } -int ServerSession::getPort() const throw() { +int ServerSession::getPort() const { return a_parent->getKey().second; } - -const Response* ServerSession::send(const Message* message) throw(anna::RuntimeException) { +const Response* ServerSession::send(const Message* message) noexcept(false) { LOGMETHOD(anna::TraceMethod traceMethod(a_className, "send", ANNA_FILE_LOCATION)); if(!message) @@ -215,11 +214,18 @@ const Response* ServerSession::send(const Message* message) throw(anna::RuntimeE // Trace non-application messages: LOGDEBUG( - if((cid == helpers::base::COMMANDID__Device_Watchdog_Request) || - (cid == helpers::base::COMMANDID__Disconnect_Peer_Request)) { - anna::Logger::debug("Sent DataBlock to XML representation:", ANNA_FILE_LOCATION); - try { anna::diameter::codec::Message msg; msg.decode(message->getBody()); /* decode to be traced */ } catch(anna::RuntimeException&) {;} - } + if( (cid == helpers::base::COMMANDID__Device_Watchdog_Request) || + (cid == helpers::base::COMMANDID__Disconnect_Peer_Request)) { + anna::Logger::debug("Sent DataBlock to XML representation:", ANNA_FILE_LOCATION); + try { + anna::diameter::codec::Message msg(a_engine->getBaseProtocolCodecEngine()); msg.decode(message->getBody()); /* decode to be traced */ + } + catch(anna::RuntimeException &ex) { + std::string msg = ex.getText(); + msg += " | Use diameter::comm::Engine::setBaseProtocolCodecEngine() to allow internal base protocol messages full tracing"; + anna::Logger::debug(msg, ANNA_FILE_LOCATION); + } + } ); // Restore sequences: @@ -254,7 +260,7 @@ const Response* ServerSession::send(const Message* message) throw(anna::RuntimeE -bool ServerSession::unbind(bool forceDisconnect) throw(anna::RuntimeException) { +bool ServerSession::unbind(bool forceDisconnect) noexcept(false) { LOGMETHOD(anna::TraceMethod traceMethod(a_className, "unbind", ANNA_FILE_LOCATION)); if(a_state == State::Closed) @@ -301,27 +307,38 @@ bool ServerSession::unbind(bool forceDisconnect) throw(anna::RuntimeException) { return false; } -void ServerSession::eventPeerShutdown() throw() { +void ServerSession::eventPeerShutdown() { // Inform father server: a_parent->eventPeerShutdown(this); } -void ServerSession::eventResponse(const Response& response) throw(anna::RuntimeException) { +void ServerSession::eventRequestRetransmission(Message *request) { + + // OAM + OamModule &oamModule = OamModule::instantiate(); + oamModule.count(OamModule::Counter::RequestRetransmitted); + oamModule.count(OamModule::Counter::RequestRetransmittedOnServerSession); + + // Inform father server: + a_parent->eventRequestRetransmission(this, request); +} + +void ServerSession::eventResponse(const Response& response) noexcept(false) { // Inform father server: a_parent->eventResponse(response); } -void ServerSession::eventRequest(const anna::DataBlock &request) throw(anna::RuntimeException) { +void ServerSession::eventRequest(const anna::DataBlock &request) noexcept(false) { // Inform father server: a_parent->eventRequest(this, request); } -void ServerSession::eventUnknownResponse(const anna::DataBlock& response) throw(anna::RuntimeException) { +void ServerSession::eventUnknownResponse(const anna::DataBlock& response) noexcept(false) { // Inform father server: a_parent->eventUnknownResponse(this, response); } -void ServerSession::eventDPA(const anna::DataBlock& response) throw(anna::RuntimeException) { +void ServerSession::eventDPA(const anna::DataBlock& response) noexcept(false) { // Inform father server: a_parent->eventDPA(this, response); } @@ -330,7 +347,7 @@ void ServerSession::eventDPA(const anna::DataBlock& response) throw(anna::Runtim // Se invoca desde el diameter::comm::Receiver //------------------------------------------------------------------------------------------ void ServerSession::receive(const anna::comm::Message& message) -throw(anna::RuntimeException) { +noexcept(false) { LOGMETHOD(anna::TraceMethod traceMethod(a_className, "receive", ANNA_FILE_LOCATION)); // Activity: updateIncomingActivityTime(); @@ -344,15 +361,24 @@ throw(anna::RuntimeException) { msg += anna::diameter::functions::commandIdAsPairString(cid); anna::Logger::debug(msg, ANNA_FILE_LOCATION); - if((cid == helpers::base::COMMANDID__Capabilities_Exchange_Request) || (cid.first == helpers::base::COMMANDID__Device_Watchdog_Request.first)) - try { anna::diameter::codec::Message dmsg; dmsg.decode(db); /* decode to be traced */ } catch(anna::RuntimeException&) {;} -); + if( (cid == helpers::base::COMMANDID__Capabilities_Exchange_Request) || + (cid.first == helpers::base::COMMANDID__Device_Watchdog_Request.first)) { + try { + anna::diameter::codec::Message dmsg(a_engine->getBaseProtocolCodecEngine()); dmsg.decode(db); /* decode to be traced */ + } + catch(anna::RuntimeException &ex) { + std::string msg = ex.getText(); + msg += " | Use diameter::comm::Engine::setBaseProtocolCodecEngine() to allow internal base protocol messages full tracing"; + anna::Logger::debug(msg, ANNA_FILE_LOCATION); + } + } + ); // Main counters: OamModule &oamModule = OamModule::instantiate(); oamModule.count(isRequest ? OamModule::Counter::RequestReceived : OamModule::Counter::AnswerReceived); oamModule.count(isRequest ? OamModule::Counter::RequestReceivedOnServerSession : OamModule::Counter::AnswerReceivedOnServerSession); // Statistic (size) - a_parent->updateReceivedMessageSizeStatisticConcept(message.getSize()); // only on reception (application could manage sent sizes) + a_parent->updateReceivedMessageSizeStatisticConcept(message.getSize(), cid); // only on reception (application could manage sent sizes) if(isRequest) { // Si recibo un request, el message solo tiene fiable el DataBlock. Como por defecto se construye como ApplicationMessage, @@ -371,6 +397,9 @@ throw(anna::RuntimeException) { } a_cer.setBody(db); + // Basic DRA: + getParent()->getEngine()->manageDrDhServerSession(this, true /* register */); + sendCEA(); //activateTimer(); // Ya se invoca al inicio de este metodo ::receive //bool changes = a_parent->refreshAvailability(); @@ -399,7 +428,7 @@ throw(anna::RuntimeException) { try { // application message counters - ApplicationMessageOamModule::instantiate().count(cid.first, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Request_Received_AsServer); + ApplicationMessageOamModule::instantiate().count(cid.first, -1 /* no result code */, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Request_Received_AsServer); eventRequest(db); } catch(anna::RuntimeException& ex) { @@ -452,7 +481,7 @@ throw(anna::RuntimeException) { oamModule.activateAlarm(OamModule::Alarm::AnswerReceivedOnServerSessionUnknown); // application message counters - ApplicationMessageOamModule::instantiate().count(cid.first, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Answer_UnknownReceived_AsServer); + ApplicationMessageOamModule::instantiate().count(cid.first, resultCode, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Answer_UnknownReceived_AsServer); eventUnknownResponse(db); @@ -474,14 +503,14 @@ throw(anna::RuntimeException) { anna::Millisecond current = (anna::Millisecond)anna::functions::millisecond(); anna::Millisecond request = response->getRequest()->getRequestTimestampMs(); anna::Millisecond timeToAnswerMs = current - request; - a_parent->updateProcessingTimeStatisticConcept(timeToAnswerMs); - LOGDEBUG - ( - std::string msg = "This diameter request context lasted "; - msg += anna::functions::asString(timeToAnswerMs); - msg += " milliseconds at diameter client (included network time)"; - anna::Logger::debug(msg, ANNA_FILE_LOCATION); - ); + a_parent->updateProcessingTimeStatisticConcept(timeToAnswerMs, cid); + //LOGDEBUG + //( + // std::string msg = "This diameter request context lasted "; + // msg += anna::functions::asString(timeToAnswerMs); + // msg += " milliseconds at diameter client (included network time)"; + // anna::Logger::debug(msg, ANNA_FILE_LOCATION); + //); // Progress origin for tracking purposes on asyncronous boxes with both diameter interfaces (entities and clients) Message * requestMessage = const_cast(response->getRequest()); requestMessage->setRequestClientSessionKey(response->getRequest()->getRequestClientSessionKey()); // "" means unkown/unset @@ -503,7 +532,7 @@ throw(anna::RuntimeException) { diameter::codec::functions::setEndToEnd((anna::DataBlock&)db, response->getRequest()->getRequestEndToEnd()); // application message counters - ApplicationMessageOamModule::instantiate().count(cid.first, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Answer_Received_AsServer); + ApplicationMessageOamModule::instantiate().count(cid.first, resultCode, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Answer_Received_AsServer); eventResponse(*response); @@ -519,7 +548,7 @@ throw(anna::RuntimeException) { unbind(true /* always immediate */); } -void ServerSession::finalize() throw() { +void ServerSession::finalize() { LOGMETHOD(anna::TraceMethod traceMethod(a_className, "finalize", ANNA_FILE_LOCATION)); // Configuration overiddings setOnDisconnect(OnDisconnect::IgnorePendings); @@ -538,7 +567,7 @@ void ServerSession::finalize() throw() { } // Inform father local server (availability changes): - bool changes = getParent()->refreshAvailability(); + getParent()->refreshAvailability(); // OAM bool multipleConnections = (getParent()->getMaxConnections() > 1); std::string socket = anna::functions::socketLiteralAsString(getAddress(), getPort()); @@ -556,7 +585,7 @@ void ServerSession::finalize() throw() { void ServerSession::sendCEA() -throw(anna::RuntimeException) { +noexcept(false) { LOGMETHOD(anna::TraceMethod traceMethod(a_className, "sendCEA", ANNA_FILE_LOCATION)); anna::DataBlock cea(true); a_engine->readCEA(cea, a_cer.getBody()); // Asume that CEA is valid ... @@ -571,7 +600,7 @@ throw(anna::RuntimeException) { if(cea.isEmpty()) { LOGDEBUG(anna::Logger::debug("Empty CEA message. Remote client never will bound this connection at application level", ANNA_FILE_LOCATION)); - LOGWARNING(anna::Logger::warning("Discarding received CER without sending CEA (consider to send CEA with Result-Code DIAMETER_UNKNOWN_PEER)", ANNA_FILE_LOCATION)); + LOGWARNING(anna::Logger::warning("Discarding received CER: cannot send empty CEA (consider to send CEA with Result-Code DIAMETER_UNKNOWN_PEER)", ANNA_FILE_LOCATION)); return; } @@ -607,7 +636,7 @@ throw(anna::RuntimeException) { } void ServerSession::sendDWA() -throw(anna::RuntimeException) { +noexcept(false) { LOGMETHOD(anna::TraceMethod traceMethod(a_className, "sendDWA", ANNA_FILE_LOCATION)); anna::DataBlock dwa(true); a_engine->readDWA(dwa, a_dwr.getBody()); // Asume that DWA is valid ... @@ -625,7 +654,7 @@ throw(anna::RuntimeException) { // Se invoca desde diameter::comm::Timer //------------------------------------------------------------------------- void ServerSession::expireResponse(diameter::comm::Response* response) -throw() { +{ LOGMETHOD(anna::TraceMethod traceMethod(a_className, "expireResponse", ANNA_FILE_LOCATION)); Session::expireResponse(response); // OAM @@ -638,7 +667,7 @@ throw() { } std::string ServerSession::asString() const -throw() { +{ string result = Session::asString(); result += " | Parent Local Server: "; result += anna::functions::socketLiteralAsString(getAddress(), getPort()); @@ -653,7 +682,7 @@ throw() { } anna::xml::Node* ServerSession::asXML(anna::xml::Node* parent) const -throw() { +{ anna::xml::Node* result = Session::asXML(parent); parent->createChild("diameter.comm.ServerSession"); result->createAttribute("ParentLocalServer", anna::functions::socketLiteralAsString(getAddress(), getPort())); @@ -668,7 +697,7 @@ throw() { //------------------------------------------------------------------------------ //------------------------------------------------------ ServerSession::expire() //------------------------------------------------------------------------------ -void ServerSession::expire(anna::timex::Engine *timeController) throw(anna::RuntimeException) { +void ServerSession::expire(anna::timex::Engine *timeController) noexcept(false) { LOGMETHOD(anna::TraceMethod traceMethod(a_className, "expire (inactivity check timer)", ANNA_FILE_LOCATION)); LOGWARNING(anna::Logger::warning("Detecting anomaly (too inactivity time) over server session. Resetting", ANNA_FILE_LOCATION)); // OAM @@ -687,14 +716,14 @@ void ServerSession::expire(anna::timex::Engine *timeController) throw(anna::Runt unbind(true /* always immediate */); // no delegamos en un planning o similar } -void ServerSession::setAllowedInactivityTime(const anna::Millisecond & allowedInactivityTime) throw() { +void ServerSession::setAllowedInactivityTime(const anna::Millisecond & allowedInactivityTime) { setTimeout(allowedInactivityTime); } //------------------------------------------------------------------------------ //---------------------------------- ServerSession::updateIncomingActivityTime() //------------------------------------------------------------------------------ -void ServerSession::updateIncomingActivityTime() throw() { +void ServerSession::updateIncomingActivityTime() { Session::updateIncomingActivityTime(); a_parent->updateIncomingActivityTime(); } @@ -703,7 +732,7 @@ void ServerSession::updateIncomingActivityTime() throw() { //------------------------------------------------------------------------------ //---------------------------------- ServerSession::updateOutgoingActivityTime() //------------------------------------------------------------------------------ -void ServerSession::updateOutgoingActivityTime(void) throw() { +void ServerSession::updateOutgoingActivityTime(void) { Session::updateOutgoingActivityTime(); a_parent->updateOutgoingActivityTime(); } @@ -712,7 +741,7 @@ void ServerSession::updateOutgoingActivityTime(void) throw() { //------------------------------------------------------------------------------ //----------------------------------------------- ServerSession::countSendings() //------------------------------------------------------------------------------ -void ServerSession::countSendings(const diameter::CommandId & cid, unsigned int aid, bool ok)throw() { +void ServerSession::countSendings(const diameter::CommandId & cid, unsigned int aid, bool ok){ OamModule &oamModule = OamModule::instantiate(); ApplicationMessageOamModule &appMsgOamModule = ApplicationMessageOamModule::instantiate(); @@ -730,7 +759,7 @@ void ServerSession::countSendings(const diameter::CommandId & cid, unsigned int else if(cid == helpers::base::COMMANDID__Disconnect_Peer_Request) oamModule.count(OamModule::Counter::DPRSentOK); // Application messages: else { - appMsgOamModule.count(cid.first, aid, isRequest ? ApplicationMessageOamModule::Counter::Request_SentOK_AsServer : ApplicationMessageOamModule::Counter::Answer_SentOK_AsServer); + appMsgOamModule.count(cid.first, -1 /* no result code */, aid, isRequest ? ApplicationMessageOamModule::Counter::Request_SentOK_AsServer : ApplicationMessageOamModule::Counter::Answer_SentOK_AsServer); } } else { // Main counters: @@ -744,7 +773,7 @@ void ServerSession::countSendings(const diameter::CommandId & cid, unsigned int else if(cid == helpers::base::COMMANDID__Disconnect_Peer_Request) oamModule.count(OamModule::Counter::DPRSentNOK); // Application messages: else { - appMsgOamModule.count(cid.first, aid, isRequest ? ApplicationMessageOamModule::Counter::Request_SentNOK_AsServer : ApplicationMessageOamModule::Counter::Answer_SentNOK_AsServer); + appMsgOamModule.count(cid.first, -1 /* no result code */, aid, isRequest ? ApplicationMessageOamModule::Counter::Request_SentNOK_AsServer : ApplicationMessageOamModule::Counter::Answer_SentNOK_AsServer); } } }