Fix and feature
authorEduardo Ramos Testillano <eduardo.ramos.testillano@ericsson.com>
Tue, 25 Oct 2016 12:53:54 +0000 (14:53 +0200)
committerEduardo Ramos Testillano <eduardo.ramos.testillano@ericsson.com>
Tue, 25 Oct 2016 12:53:54 +0000 (14:53 +0200)
Fix: when timeout or another anomaly, testing manager must not invoked with receiveMessage, or message could not be decoded and a core dump is created.
Feature: access working node from application

example/diameter/launcher/Launcher.cpp
example/diameter/launcher/Launcher.hpp
example/diameter/launcher/MyDiameterEntity.cpp
example/diameter/launcher/MyLocalServer.cpp

index aebebec..2b51caf 100644 (file)
@@ -528,6 +528,13 @@ void Launcher::updateOperatedOriginHostWithMessage(const anna::diameter::codec::
     a_operatedHost = getOriginHost(message);
 }
 
+OriginHost *Launcher::getWorkingNode() const throw(anna::RuntimeException) {
+  if(!a_workingNode)
+    throw anna::RuntimeException("Working node not identified (try to load services)", ANNA_FILE_LOCATION);
+
+  return a_workingNode;
+}
+
 OriginHost *Launcher::getOperatedHost() const throw(anna::RuntimeException) {
   if(!a_operatedHost)
     throw anna::RuntimeException("Node not identified (try to force a specific Origin-Host with 'node' operation)", ANNA_FILE_LOCATION);
@@ -1539,7 +1546,14 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
     std::string args = ((operation.find("dynamic|") == 0) && (op_size > 8)) ? operation.substr(8) : "";
     if (args == "" && op_size != 7)
       throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
-    p.execute(args, response_content);
+    try {
+      p.execute(args, response_content);
+    }
+    catch(anna::RuntimeException &ex) {
+      ex.trace();
+      response_content = ex.asString();
+      return;
+    }
     return;
   }
 
index dcc684d..8f272d9 100644 (file)
@@ -102,6 +102,7 @@ public:
 
   // Operated host for communication resources smart assignment ////////////////////////////////////////////////////////////
   void updateOperatedOriginHostWithMessage(const anna::diameter::codec::Message &message) throw(anna::RuntimeException);
+  OriginHost *getWorkingNode() const throw(anna::RuntimeException);
   OriginHost *getOperatedHost() const throw(anna::RuntimeException);
   MyDiameterEntity *getOperatedEntity() const throw(anna::RuntimeException);
   MyLocalServer *getOperatedServer() const throw(anna::RuntimeException);
index 5e78ab3..3d36c7a 100644 (file)
@@ -271,7 +271,7 @@ throw(anna::RuntimeException) {
   if(isOK || contextExpired) my_node->sendBurstMessage();
 
   // Testing:
-  TestManager::instantiate().receiveMessage(*message, my_node, clientSession);
+  if(isOK) TestManager::instantiate().receiveMessage(*message, my_node, clientSession);
 }
 
 void MyDiameterEntity::eventUnknownResponse(anna::diameter::comm::ClientSession *clientSession, const anna::DataBlock &message)
index 7d34b46..af7aa43 100644 (file)
@@ -229,7 +229,7 @@ throw(anna::RuntimeException) {
   }
 
   // Testing:
-  TestManager::instantiate().receiveMessage(*message, my_node, serverSession);
+  if(isOK) TestManager::instantiate().receiveMessage(*message, my_node, serverSession);
 }
 
 void MyLocalServer::eventUnknownResponse(anna::diameter::comm::ServerSession *serverSession, const anna::DataBlock &message)