#include <stdlib.h> // rand()
#include <time.h>
-// XXXXXXXXXX
-#include <iostream>
-
-
-
using namespace std;
using namespace anna::diameter;
{ initialize(); }
-void ClientSession::initialize() throw() {
+void ClientSession::initialize() {
Session::initialize();
a_autoRecovery = true;
a_parent = NULL;
//ClientSession::~ClientSession() {;}
-const std::string& ClientSession::getAddress() const throw() {
+const std::string& ClientSession::getAddress() const {
return a_parent->getAddress();
}
-int ClientSession::getPort() const throw() {
+int ClientSession::getPort() const {
return a_parent->getPort();
}
-void ClientSession::setState(State::_v state) throw() {
+void ClientSession::setState(State::_v state) {
Session::setState(state);
// Inform father server (availability changes):
- bool changes = a_parent->refreshAvailability();
+ a_parent->refreshAvailability();
}
-void ClientSession::bind() throw(anna::RuntimeException) {
+void ClientSession::bind() noexcept(false) {
LOGMETHOD(anna::TraceMethod traceMethod(a_className, "bind", ANNA_FILE_LOCATION));
if(a_state != State::Closed)
}
-void ClientSession::setCERandDWR(const anna::DataBlock & cer, const anna::DataBlock & dwr) throw(anna::RuntimeException) {
+void ClientSession::setCERandDWR(const anna::DataBlock & cer, const anna::DataBlock & dwr) noexcept(false) {
if(codec::functions::getCommandId(cer) != helpers::base::COMMANDID__Capabilities_Exchange_Request) {
throw anna::RuntimeException("The message provided as 'CER' is not a Capabilities-Exchange-Request", ANNA_FILE_LOCATION);
}
}
-const Response* ClientSession::send(const Message* message) throw(anna::RuntimeException) {
+const Response* ClientSession::send(const Message* message) noexcept(false) {
LOGMETHOD(anna::TraceMethod traceMethod(a_className, "send", ANNA_FILE_LOCATION));
if(!message)
}
bool ClientSession::unbind(bool forceDisconnect)
-throw(anna::RuntimeException) {
+noexcept(false) {
LOGMETHOD(anna::TraceMethod traceMethod(a_className, "unbind", ANNA_FILE_LOCATION));
if(a_state == State::Closed)
return false;
}
-void ClientSession::eventPeerShutdown() throw() {
+void ClientSession::eventPeerShutdown() {
// Inform father server:
a_parent->eventPeerShutdown(this);
}
-void ClientSession::eventRequestRetransmission(Message *request) throw() {
+void ClientSession::eventRequestRetransmission(Message *request) {
+
+ // OAM
+ OamModule &oamModule = OamModule::instantiate();
+ oamModule.count(OamModule::Counter::RequestRetransmitted);
+ oamModule.count(OamModule::Counter::RequestRetransmittedOnClientSession);
+
// Inform father server:
a_parent->eventRequestRetransmission(this, request);
}
-void ClientSession::eventResponse(const Response& response) throw(anna::RuntimeException) {
+void ClientSession::eventResponse(const Response& response) noexcept(false) {
// Inform father server:
a_parent->eventResponse(response);
}
-void ClientSession::eventRequest(const anna::DataBlock &request) throw(anna::RuntimeException) {
+void ClientSession::eventRequest(const anna::DataBlock &request) noexcept(false) {
// Inform father server:
a_parent->eventRequest(this, request);
}
-void ClientSession::eventUnknownResponse(const anna::DataBlock& response) throw(anna::RuntimeException) {
+void ClientSession::eventUnknownResponse(const anna::DataBlock& response) noexcept(false) {
// Inform father server:
a_parent->eventUnknownResponse(this, response);
}
-void ClientSession::eventDPA(const anna::DataBlock& response) throw(anna::RuntimeException) {
+void ClientSession::eventDPA(const anna::DataBlock& response) noexcept(false) {
// Inform father server:
a_parent->eventDPA(this, response);
}
// Se invoca desde el diameter::comm::Receiver
//------------------------------------------------------------------------------------------
void ClientSession::receive(const anna::comm::Message& message)
-throw(anna::RuntimeException) {
+noexcept(false) {
LOGMETHOD(anna::TraceMethod traceMethod(a_className, "receive", ANNA_FILE_LOCATION));
// Activity:
updateIncomingActivityTime();
}
}
);
+
// Main counters:
OamModule &oamModule = OamModule::instantiate();
oamModule.count(isRequest ? OamModule::Counter::RequestReceived : OamModule::Counter::AnswerReceived);
oamModule.count(isRequest ? OamModule::Counter::RequestReceivedOnClientSession : OamModule::Counter::AnswerReceivedOnClientSession);
// 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) {
/////////////////////////////
try {
// application message counters
- ApplicationMessageOamModule::instantiate().count(cid.first, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Request_Received_AsClient);
+ ApplicationMessageOamModule::instantiate().count(cid.first, -1 /* no result code */, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Request_Received_AsClient);
eventRequest(db);
} catch(anna::RuntimeException& ex) {
/////////////////////////////
bool doUnbind = false;
bool immediateUnbind = false;
- int resultCode = 0;
+ int resultCode = -1;
try {
resultCode = helpers::base::functions::getResultCode(db);
} catch(anna::RuntimeException& ex) {
- ex.trace();
+ // Not always mandatory ...
+ //ex.trace();
}
// Received CEA
setState(State::Bound);
//activateTimer(); // Ya se invoca al inicio de este metodo ::receive
// Inform father server (availability changes):
- bool changes = a_parent->refreshAvailability();
+ a_parent->refreshAvailability();
//startClock();
}
}
oamModule.activateAlarm(OamModule::Alarm::AnswerReceivedOnClientSessionUnknown);
// application message counters
- ApplicationMessageOamModule::instantiate().count(cid.first, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Answer_UnknownReceived_AsClient);
+ ApplicationMessageOamModule::instantiate().count(cid.first, resultCode, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Answer_UnknownReceived_AsClient);
eventUnknownResponse(db);
string msg(asString());
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 server (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 server (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<Message*>(response->getRequest());
requestMessage->setRequestServerSessionKey(response->getRequest()->getRequestServerSessionKey()); // -1 means unkown/unset
// application message counters
if(cid != helpers::base::COMMANDID__Capabilities_Exchange_Answer)
- ApplicationMessageOamModule::instantiate().count(cid.first, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Answer_Received_AsClient);
+ ApplicationMessageOamModule::instantiate().count(cid.first, resultCode, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Answer_Received_AsClient);
eventResponse(*response);
} catch(anna::RuntimeException& ex) {
unbind(immediateUnbind);
}
-void ClientSession::finalize() throw() {
+void ClientSession::finalize() {
LOGMETHOD(anna::TraceMethod traceMethod(a_className, "finalize", ANNA_FILE_LOCATION));
Session::finalize();
- // Check deprecated entity:
- const Entity *entity = getParent() /* server */ ->getParent() /* entity */;
// Inform father server (availability changes):
- bool changes = a_parent->refreshAvailability();
+ a_parent->refreshAvailability();
// OAM
const Server *server = getParent();
bool multipleConnections = (server->getMaxClientSessions() > 1);
}
}
-void ClientSession::recover() throw() {
+void ClientSession::recover() {
LOGMETHOD(anna::TraceMethod traceMethod(a_className, "recover", ANNA_FILE_LOCATION));
try {
}
// Inform father server (availability changes):
- bool changes = a_parent->refreshAvailability();
+ a_parent->refreshAvailability();
// OAM
const Server *server = getParent();
bool multipleConnections = (server->getMaxClientSessions() > 1);
}
void ClientSession::sendDWAToServer(const anna::DataBlock& dwrDB)
-throw(anna::RuntimeException) {
+noexcept(false) {
LOGMETHOD(anna::TraceMethod traceMethod(a_className, "sendDWAToServer", ANNA_FILE_LOCATION));
anna::DataBlock dwa(true);
a_engine->readDWA(dwa, dwrDB); // Asume that DWA is valid ...
// Se invoca desde diameter::comm::Timer
//-------------------------------------------------------------------------
void ClientSession::expireResponse(diameter::comm::Response* response)
-throw() {
+{
LOGMETHOD(anna::TraceMethod traceMethod(a_className, "expireResponse", ANNA_FILE_LOCATION));
Session::expireResponse(response);
// OAM
std::string ClientSession::asString() const
-throw() {
+{
string result = Session::asString();
result += " | Parent Server: ";
result += anna::functions::socketLiteralAsString(getAddress(), getPort());
}
anna::xml::Node* ClientSession::asXML(anna::xml::Node* parent) const
-throw() {
+{
anna::xml::Node* result = Session::asXML(parent);
parent->createChild("diameter.comm.ClientSession");
result->createAttribute("ParentServer", anna::functions::socketLiteralAsString(getAddress(), getPort()));
const char* ClientSession::asText(const WatchdogState::_v watchdogState)
-throw() {
+{
static const char* text [] = { "TimerStopped", "WaitingTimerExpiration", "WaitingDWA" };
return text [watchdogState];
}
//------------------------------------------------------------------------------
//------------------------------------------------------ ClientSession::expire()
//------------------------------------------------------------------------------
-void ClientSession::expire(anna::timex::Engine *timeController) throw(anna::RuntimeException) {
+void ClientSession::expire(anna::timex::Engine *timeController) noexcept(false) {
LOGMETHOD(anna::TraceMethod traceMethod(a_className, "expire (watchdog timer)", ANNA_FILE_LOCATION));
// The client MUST NOT close the primary connection until the
activateTimer();
}
-void ClientSession::setWatchdogPeriod(const anna::Millisecond & watchdogPeriod) throw() {
+void ClientSession::setWatchdogPeriod(const anna::Millisecond & watchdogPeriod) {
setTimeout(watchdogPeriod);
}
-void ClientSession::setWatchdogState(WatchdogState::_v wState) throw() {
+void ClientSession::setWatchdogState(WatchdogState::_v wState) {
LOGDEBUG(
if(wState != a_watchdogState) {
}
-void ClientSession::timerStopped() throw() {
+void ClientSession::timerStopped() {
LOGDEBUG(anna::Logger::debug("Watchdog timer stopped", ANNA_FILE_LOCATION));
setWatchdogState(WatchdogState::TimerStopped);
}
-void ClientSession::timerStarted() throw() {
+void ClientSession::timerStarted() {
LOGDEBUG(anna::Logger::debug("Watchdog timer started", ANNA_FILE_LOCATION));
if(a_watchdogState == WatchdogState::WaitingDWA) return;
//------------------------------------------------------------------------------
//---------------------------------- ClientSession::updateIncomingActivityTime()
//------------------------------------------------------------------------------
-void ClientSession::updateIncomingActivityTime() throw() {
+void ClientSession::updateIncomingActivityTime() {
Session::updateIncomingActivityTime();
a_parent->updateIncomingActivityTime();
}
//------------------------------------------------------------------------------
//---------------------------------- ClientSession::updateOutgoingActivityTime()
//------------------------------------------------------------------------------
-void ClientSession::updateOutgoingActivityTime(void) throw() {
+void ClientSession::updateOutgoingActivityTime(void) {
Session::updateOutgoingActivityTime();
a_parent->updateOutgoingActivityTime();
}
//------------------------------------------------------------------------------
//----------------------------------------------- ClientSession::countSendings()
//------------------------------------------------------------------------------
-void ClientSession::countSendings(const diameter::CommandId & cid, unsigned int aid, bool ok)throw() {
+void ClientSession::countSendings(const diameter::CommandId & cid, unsigned int aid, bool ok){
OamModule &oamModule = OamModule::instantiate();
ApplicationMessageOamModule &appMsgOamModule = ApplicationMessageOamModule::instantiate();
else if(cid == helpers::base::COMMANDID__Disconnect_Peer_Answer) oamModule.count(OamModule::Counter::DPASentOK);
// Application messages:
else {
- appMsgOamModule.count(cid.first, aid, isRequest ? ApplicationMessageOamModule::Counter::Request_SentOK_AsClient : ApplicationMessageOamModule::Counter::Answer_SentOK_AsClient);
+ appMsgOamModule.count(cid.first, -1 /* no result code */, aid, isRequest ? ApplicationMessageOamModule::Counter::Request_SentOK_AsClient : ApplicationMessageOamModule::Counter::Answer_SentOK_AsClient);
}
} else {
// Main counters:
else if(cid == helpers::base::COMMANDID__Disconnect_Peer_Answer) oamModule.count(OamModule::Counter::DPASentNOK);
// Application messages:
else {
- appMsgOamModule.count(cid.first, aid, isRequest ? ApplicationMessageOamModule::Counter::Request_SentNOK_AsClient : ApplicationMessageOamModule::Counter::Answer_SentNOK_AsClient);
+ appMsgOamModule.count(cid.first, -1 /* no result code */, aid, isRequest ? ApplicationMessageOamModule::Counter::Request_SentNOK_AsClient : ApplicationMessageOamModule::Counter::Answer_SentNOK_AsClient);
}
}
}