X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;ds=sidebyside;f=source%2Fdiameter.comm%2FApplicationMessageOamModule.cpp;h=8f3dfa0fb8c28915eeac295354a7fd9ff796f854;hb=64cc135e716c2ef018227375fc4f15ff0670fdf7;hp=bba049c497686140327797e59aaa7baf5d8950ce;hpb=3d71e5185fa9c93bde7363a668aecf96240ae2e9;p=anna.git
diff --git a/source/diameter.comm/ApplicationMessageOamModule.cpp b/source/diameter.comm/ApplicationMessageOamModule.cpp
index bba049c..8f3dfa0 100644
--- a/source/diameter.comm/ApplicationMessageOamModule.cpp
+++ b/source/diameter.comm/ApplicationMessageOamModule.cpp
@@ -36,7 +36,7 @@ anna_assign_enum(anna::diameter::comm::ApplicationMessageOamModule::Counter) = {
NULL /* list end indicator */
};
-void anna::diameter::comm::ApplicationMessageOamModule::createStackCounterScope(int scopeId, unsigned int stackId) throw(anna::RuntimeException) {
+void anna::diameter::comm::ApplicationMessageOamModule::createStackCounterScope(int scopeId, unsigned int stackId) noexcept(false) {
initializeCounterScope(scopeId, anna::functions::asString("Application Message Events for stack id %lu", stackId));
@@ -47,7 +47,7 @@ void anna::diameter::comm::ApplicationMessageOamModule::createStackCounterScope(
a_stackMap[stackId] = scopeId;
}
-void anna::diameter::comm::ApplicationMessageOamModule::count (int messageCode, unsigned int stackId, const int & type, const int & amount) throw(anna::RuntimeException) {
+void anna::diameter::comm::ApplicationMessageOamModule::count (int messageCode, int resultCode, unsigned int stackId, const int & type, const int & amount) noexcept(false) {
// Optimization:
// Checkings
@@ -55,7 +55,7 @@ void anna::diameter::comm::ApplicationMessageOamModule::count (int messageCode,
LOGDEBUG
(
std::string msg = "Count operation ignored over module '";
- msg += getClassName();
+ msg += getName();
msg += "': counters are disabled";
anna::Logger::debug(msg, ANNA_FILE_LOCATION);
);
@@ -64,27 +64,35 @@ void anna::diameter::comm::ApplicationMessageOamModule::count (int messageCode,
anna::Guard guard(a_mutex, "ApplicationMessageOamModule::count"); // counter scope switch
- std::map::const_iterator stackMap_it = a_stackMap.find(stackId);
+ int scopeId = monoStackScopeId();
+ if (scopeId == -1) {
+ std::map::const_iterator stackMap_it = a_stackMap.find(stackId);
- if (stackMap_it == a_stackMap.end()) {
- LOGDEBUG(anna::Logger::debug(anna::functions::asString("Unregistered stack id %lu", stackId), ANNA_FILE_LOCATION));
- return;
+ if (stackMap_it == a_stackMap.end()) {
+ LOGDEBUG(anna::Logger::debug(anna::functions::asString("Unregistered stack id %lu", stackId), ANNA_FILE_LOCATION));
+ return;
+ }
+
+ scopeId = stackMap_it->second;
}
// Select counter scope
- setActiveCounterScope(stackMap_it->second);
-
- std::map::const_iterator messageMap_it = a_messageMap.find(messageCode);
- int baseOffset = messageMap_it->second;
+ setActiveCounterScope(scopeId);
+
+ // Build event id: _
+ std::string eventId = anna::functions::asString("%d_%d", messageCode, resultCode);
+
+ std::map::const_iterator eventMap_it = a_eventMap.find(eventId);
+ int baseOffset;
- if (messageMap_it == a_messageMap.end()) {
+ if (eventMap_it == a_eventMap.end()) {
int capacity = anna::oam::CounterScope::MaxCounter / getCounterTypes();
- if (a_messageMap.size() > capacity) {
+ if (a_eventMap.size() > capacity) {
LOGDEBUG(anna::Logger::debug(anna::functions::asString("No more holes to register new application message counters in the scope (up to %d message codes)", capacity), ANNA_FILE_LOCATION));
return;
}
- baseOffset = getCounterTypes() * a_messageMap.size(); // N counter types for each message code
- a_messageMap[messageCode] = baseOffset;
+ baseOffset = getCounterTypes() * a_eventMap.size(); // N counter types for each message code / rc
+ a_eventMap[eventId] = baseOffset;
// Counter name:
std::string counterNamePrefix = anna::functions::asString("ApplicationMessageCode_%d", messageCode); // default
@@ -107,8 +115,23 @@ void anna::diameter::comm::ApplicationMessageOamModule::count (int messageCode,
}
if (counterNamePrefix[counterNamePrefix.size() - 1] != '-') counterNamePrefix += "-";
- for (int offset = 0; offset < getCounterTypes(); offset++)
- registerCounter(baseOffset + offset, counterNamePrefix + getDefaultInternalCounterDescription(offset), baseOffset + offset);
+ std::string counterName;
+ /*
+ for (int offset = 0; offset < getCounterTypes(); offset++) {
+ counterName = counterNamePrefix + getDefaultInternalCounterDescription(offset);
+ if (resultCode != -1) counterName += anna::functions::asString("-ResultCode_%d", resultCode);
+ registerCounter(baseOffset + offset, counterName, baseOffset + offset);
+ }
+ */
+ // Register only affected one:
+ int offset = baseOffset + type;
+ counterName = counterNamePrefix + getDefaultInternalCounterDescription(type);
+ if (resultCode != -1) counterName += anna::functions::asString("-ResultCode_%d", resultCode);
+ registerCounter(offset, counterName, offset);
+
+ }
+ else {
+ baseOffset = eventMap_it->second;
}
// Count