version 4.0.3
start internal stats

Change-Id: I521f71e35c49f0d7f9096eac60ff61b64fdda4c0
Signed-off-by: aa7133@att.com <aa7133@att.com>
diff --git a/RIC-E2-TERMINATION/sctpThread.cpp b/RIC-E2-TERMINATION/sctpThread.cpp
index a271d05..9fc72b4 100644
--- a/RIC-E2-TERMINATION/sctpThread.cpp
+++ b/RIC-E2-TERMINATION/sctpThread.cpp
@@ -277,6 +277,8 @@
     return 0;
 }
 
+
+
 int main(const int argc, char **argv) {
     sctp_params_t sctpParams;
 
@@ -363,6 +365,9 @@
         }
     }
 
+    auto statFlag = false;
+    auto statThread = std::thread(statColectorThread, (void *)&statFlag);
+
     //loop over term_init until first message from xApp
     handleTermInit(sctpParams);
 
@@ -370,6 +375,9 @@
         t.join();
     }
 
+    statFlag = true;
+    statThread.join();
+
     return 0;
 }
 
@@ -544,6 +552,8 @@
         rmrMessageBuffer.sendBufferedMessages[i] = rmr_alloc_msg(rmrMessageBuffer.rmrCtx, RECEIVE_XAPP_BUFFER_SIZE);
     }
 
+    message.statCollector = StatCollector::GetInstance();
+
     while (true) {
         if (mdclog_level_get() >= MDCLOG_DEBUG) {
             mdclog_write(MDCLOG_DEBUG, "Start EPOLL Wait");
@@ -963,7 +973,7 @@
             m->erase(key);
             return -1;
         }
-        peerInfo->sentMesgs++;
+        message.statCollector->incSentMessage(string(message.message.enodbName));
         message.message.direction = 'D';
         // send report.buffer of size
         buildJsonMessage(message);
@@ -1021,7 +1031,7 @@
     // get the identity of the interface
     message.peerInfo = (ConnectedCU_t *)events->data.ptr;
 
-
+    message.statCollector = StatCollector::GetInstance();
     struct timespec start{0, 0};
     struct timespec decodestart{0, 0};
     struct timespec end{0, 0};
@@ -1043,8 +1053,9 @@
             mdclog_write(MDCLOG_DEBUG, "Finish Read from SCTP %d fd message length = %ld",
                     message.peerInfo->fileDescriptor, message.message.asnLength);
         }
-        message.peerInfo->rcvMsgs++;
+
         memcpy(message.message.enodbName, message.peerInfo->enodbName, sizeof(message.peerInfo->enodbName));
+        message.statCollector->incRecvMessage(string(message.message.enodbName));
         message.message.direction = 'U';
         message.message.time.tv_nsec = ts.tv_nsec;
         message.message.time.tv_sec = ts.tv_sec;