version 4.0.7 02/3102/1
authoraa7133@att.com <aa7133@att.com>
Wed, 1 Apr 2020 21:10:46 +0000 (00:10 +0300)
committeraa7133@att.com <aa7133@att.com>
Wed, 1 Apr 2020 21:11:10 +0000 (00:11 +0300)
Patch on stat
Add convert E2SM to xml

Change-Id: I12213ea2ec37588054f40116721e82d67097f186
Signed-off-by: aa7133@att.com <aa7133@att.com>
RIC-E2-TERMINATION/CMakeLists.txt
RIC-E2-TERMINATION/Dockerfile
RIC-E2-TERMINATION/sctpThread.cpp
RIC-E2-TERMINATION/statCollector.h

index 19d3829..2de0895 100644 (file)
@@ -43,6 +43,7 @@ endif ()
 include_directories(RIC-E2-TERMINATION
         RIC-E2-TERMINATION/3rdparty/oranE2
         RIC-E2-TERMINATION/3rdparty/oranE2SM
+        RIC-E2-TERMINATION/3rdparty/cxxopts/include
         RIC-E2-TERMINATION/3rdparty
         cmake-modules)
 
@@ -95,6 +96,7 @@ link_libraries(nsl
         boost_thread
         boost_system
         rt
+        tbb
         boost_filesystem
         cgreen
         pthread)
@@ -107,7 +109,10 @@ add_executable(e2 RIC-E2-TERMINATION/sctpThread.cpp
         RIC-E2-TERMINATION/base64.cpp
         RIC-E2-TERMINATION/ReadConfigFile.h
         RIC-E2-TERMINATION/BuildRunName.h
-        RIC-E2-TERMINATION/statCollector.h)
+        RIC-E2-TERMINATION/statCollector.h
+        RIC-E2-TERMINATION/3rdparty/pugixml/src/pugiconfig.hpp
+        RIC-E2-TERMINATION/3rdparty/pugixml/src/pugixml.cpp
+        RIC-E2-TERMINATION/3rdparty/pugixml/src/pugixml.hpp)
 target_link_libraries(e2 libasn1ce2smcodec.a)
 target_link_libraries(e2 librmr_nng.a)
 target_link_libraries(e2 librmr_si.a)
index 46d9c29..c1b0bd2 100644 (file)
@@ -44,7 +44,7 @@ RUN wget --content-disposition https://github.com/cgreen-devs/cgreen/releases/do
          && wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr-dev_3.6.2_amd64.deb/download.deb \
          && dpkg -i rmr-dev_3.6.2_amd64.deb
 
-RUN apt-get install -y libcurl4-gnutls-dev gawk  \
+RUN apt-get install -y libcurl4-gnutls-dev gawk libtbb-dev  libtbb-doc libtbb2 libtbb2-dbg \
     && cd /opt/e2/RIC-E2-TERMINATION/3rdparty && git clone https://github.com/oktal/pistache.git && cd pistache \
     && git submodule update --init && mkdir build && cd build \
     && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DPISTACHE_BUILD_DOCS=false \
@@ -53,10 +53,10 @@ RUN apt-get install -y libcurl4-gnutls-dev gawk  \
     && git clone http://gerrit.o-ran-sc.org/r/com/log \
     && cd log && ./autogen.sh && ./configure && make && make install && ldconfig \
     && cd /opt/e2/RIC-E2-TERMINATION/3rdparty && git clone https://github.com/jarro2783/cxxopts.git \
-    && cd cxxopts && mkdir build && cd build && cmake .. && make install && ldconfig \
+#    && cd cxxopts && mkdir build && cd build && cmake .. && make install && ldconfig \
     && cd /opt/e2/RIC-E2-TERMINATION/3rdparty && git clone https://github.com/Tencent/rapidjson.git \
-    && cd rapidjson && mkdir build && cd build && cmake .. && make install && ldconfig \
-    && cd /opt/e2/RIC-E2-TERMINATION/3rdparty \
+#    && cd rapidjson && mkdir build && cd build && cmake .. && make install && ldconfig \
+    && cd /opt/e2/RIC-E2-TERMINATION/3rdparty && git clone https://github.com/zeux/pugixml.git \
     && cd /opt/e2/ && git clone https://github.com/bilke/cmake-modules.git \
     && cd /opt/e2/ && /usr/local/bin/cmake -D CMAKE_BUILD_TYPE=$BUILD_TYPE . && make \
     && echo "3" > /opt/e2/rmr.verbose
@@ -103,9 +103,18 @@ COPY --from=ubuntu /usr/local/lib/librmr_nng.so  /usr/local/lib/librmr_nng.so
 COPY --from=ubuntu /usr/local/lib/libmdclog.so.0 /usr/local/lib/libmdclog.so.0
 
 COPY --from=ubuntu /usr/lib/x86_64-linux-gnu/libcgreen.so /usr/local/libcgreen.so
-COPY --from=ubuntu //usr/lib/x86_64-linux-gnu/libcgreen.so.1 /usr/local/libcgreen.so.1
+COPY --from=ubuntu /usr/lib/x86_64-linux-gnu/libcgreen.so.1 /usr/local/libcgreen.so.1
 COPY --from=ubuntu /usr/lib/x86_64-linux-gnu/libcgreen.so.1.2.0 /usr/local/libcgreen.so.1.2.0
 
+COPY --from=ubuntu /usr/lib/x86_64-linux-gnu/libtbb.so /usr/local/libtbb.so
+COPY --from=ubuntu /usr/lib/x86_64-linux-gnu/libtbb.so.2 /usr/local/libtbb.so.2
+
+COPY --from=ubuntu /usr/lib/x86_64-linux-gnu/libtbbmalloc.so /usr/local/libtbbmalloc.so
+COPY --from=ubuntu /usr/lib/x86_64-linux-gnu/libtbbmalloc.so.2 /usr/local/libtbbmalloc.so.2
+
+COPY --from=ubuntu /usr/lib/x86_64-linux-gnu/libtbbmalloc_proxy.so /usr/local/libtbbmalloc_proxy.so
+COPY --from=ubuntu /usr/lib/x86_64-linux-gnu/libtbbmalloc_proxy.so.2 /usr/local/libtbbmalloc_proxy.so.2
+
 COPY --from=ubuntu /usr/lib/libboost_log_setup.so /usr/lib/libboost_log_setup.so
 COPY --from=ubuntu /usr/lib/libboost_log_setup.so.1.69.0 /usr/lib/libboost_log_setup.so.1.69.0
 
index 4b956ea..f9a56dd 100644 (file)
 #include "sctpThread.h"
 #include "BuildRunName.h"
 
-//#define asn_DEF_E2SM_gNB_NRT_RANfunction_Definition e2sm_asn_DEF_E2SM_gNB_NRT_RANfunction_Definition
-//#define __gcov_init e2sm___gcov_init
-//#define __gcov_merge_add e2sm___gcov_merge_add
-//#define calloc e2sm_calloc
-
 #include "3rdparty/oranE2SM/E2SM-gNB-NRT-RANfunction-Definition.h"
 
-//#undef calloc
-//#undef __gcov_merge_add
-//#undef __gcov_init
-//#undef asn_DEF_E2SM_gNB_NRT_RANfunction_Definition
+#include "pugixml/src/pugixml.hpp"
 
 using namespace std;
 //using namespace std::placeholders;
@@ -1211,7 +1203,8 @@ int receiveDataFromSctp(struct epoll_event *events,
 
 static void buildAndsendSetupRequest(ReportingMessages_t &message,
                                      RmrMessagesBuffer_t &rmrMessageBuffer,
-                                     E2AP_PDU_t *pdu) {
+                                     E2AP_PDU_t *pdu,
+                                     vector<string> repValues) {
     auto logLevel = mdclog_level_get();
 
     // now we can send the data to e2Mgr
@@ -1232,6 +1225,60 @@ static void buildAndsendSetupRequest(ReportingMessages_t &message,
                      (int) buffer_size,
                      asn_DEF_E2AP_PDU.name, __func__, __LINE__);
     } else {
+        // we have the XML
+        pugi::xml_document doc;
+        pugi::xml_parse_result result = doc.load_string((const char *)buffer);
+        if (result) {
+            unsigned int index = 0;
+            for (auto tool : doc.child("E2AP-PDU")
+                    .child("initiatingMessage")
+                    .child("value")
+                    .child("E2setupRequest")
+                    .child("protocolIEs")
+                    .children("E2setupRequestIEs")) {
+                for (auto n : tool.child("value").child("RANfunctions-List").child(
+                        "ProtocolIE-SingleContainer").children()) {
+                    //ProtocolIE-SingleContainer
+                    //cout << "\t1 " << n.name() << endl;
+                    if (strcmp(n.name(), "value") == 0) {
+                        for (auto l : tool.child("value").children()) {
+                            //cout << "\t\t2 " << l.name() << endl;
+                            for (auto f : l.children()) {
+                                //cout << "\t\t\t3 " << f.name() << endl;
+                                for (auto g : f.child("value").children()) {
+                                    //cout << "\t\t\t\t4 " << g.name() << endl;
+                                    for (auto a : g.children()) {
+                                        if (strcmp(a.name(), "ranFunctionDefinition") == 0) {
+                                            if (repValues.size() > index) {
+                                                a.remove_children();
+                                                string val = repValues.at(index++);
+                                                // here we get vector with counter
+                                                a.append_child(pugi::node_pcdata).set_value(val.c_str());
+
+                                            }
+                                        }
+                                        //cout << "\t\t\t\t\t5 " << a.name() << " " << a.child_value() << endl;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+
+//            memstream strinBuf(buffer, RECEIVE_SCTP_BUFFER_SIZE * 2);
+//
+//            strinBuf.read(, RECEIVE_SCTP_BUFFER_SIZE * 2);
+
+            streambuf *oldCout = cout.rdbuf();
+            ostringstream memCout;
+            // create new cout
+            cout.rdbuf(memCout.rdbuf());
+            doc.save(std::cout);
+            //return to the normal cout
+            cout.rdbuf(oldCout);
+            memcpy(buffer, memCout.str().c_str(), memCout.str().length());
+        }
         rmrMsg->len = snprintf((char *)rmrMsg->payload, RECEIVE_SCTP_BUFFER_SIZE * 2, "%s:%d|%s",
                                message.peerInfo->sctpParams->myIP.c_str(),
                                message.peerInfo->sctpParams->rmrPort,
@@ -1319,6 +1366,9 @@ void asnInitiatingRequest(E2AP_PDU_t *pdu,
             }
             std::string xmlString(setup_xml_buffer_size,  setup_xml_buffer_size + er.encoded);
 
+            vector <string> runFunDEFXML_v;
+            runFunDEFXML_v.clear();
+            string runFuncStr = {};
             auto failed = false;
             memset(message.peerInfo->enodbName, 0 , MAX_ENODB_NAME_SIZE);
             for (auto i = 0; i < pdu->choice.initiatingMessage->value.choice.E2setupRequest.protocolIEs.list.count; i++) {
@@ -1389,7 +1439,9 @@ void asnInitiatingRequest(E2AP_PDU_t *pdu,
                                                      asn_DEF_E2SM_gNB_NRT_RANfunction_Definition.name,
                                                      xml_buffer);
                                     }
-                                    //TODO replace the ranFunctionDefinition with the XML data
+                                    //TODO replace the ranFunctionDefinition with the XML
+                                    string runFuncs = (char *)(xml_buffer);
+                                    runFunDEFXML_v.emplace_back(runFuncs);
                                 }
 
                             }
@@ -1406,7 +1458,7 @@ void asnInitiatingRequest(E2AP_PDU_t *pdu,
 
             //build all parts and send the XML (need to copy the XML with the header to the rmrMessageBuffer payload
             //TODO replace with new function
-            buildAndsendSetupRequest(message, rmrMessageBuffer, pdu);
+            buildAndsendSetupRequest(message, rmrMessageBuffer, pdu, runFunDEFXML_v);
             break;
         }
         case ProcedureCode_id_ErrorIndication: {
index bb4ce5d..706426d 100644 (file)
@@ -33,6 +33,9 @@
 #include <ctime>
 #include <iomanip>
 #include <mdclog/mdclog.h>
+#include <tbb/concurrent_unordered_map.h>
+
+using namespace tbb;
 
 typedef struct statResult {
     std::string ranName;
@@ -72,10 +75,10 @@ public:
         for (auto const &e : recvMessages) {
             statResult_t result {};
             result.ranName = e.first;
-            result.receivedMessages = e.second.load(std::memory_order_acquire);
+            result.receivedMessages = e.second;
             auto found = sentMessages.find(result.ranName);
             if (found != sentMessages.end()) {
-                result.sentMessages = found->second.load(std::memory_order_acquire);
+                result.sentMessages = found->second;
             } else {
               result.sentMessages = 0;
             }
@@ -89,29 +92,68 @@ public:
     StatCollector& operator=(const StatCollector&)= delete;
 
 private:
-    std::unordered_map<std::string, std::atomic<int>> sentMessages;
-    std::unordered_map<std::string, std::atomic<int>> recvMessages;
+    tbb::concurrent_unordered_map<std::string, int> sentMessages;
+    //std::unordered_map<std::string, int> sentMessages;
+    //std::unordered_map<std::string, int> recvMessages;
+    tbb::concurrent_unordered_map<std::string, int> recvMessages;
     std::vector<statResult_t> results;
 
 
-    StatCollector() = default;
+//    StatCollector() = default;
+    StatCollector() {
+        sentMessages.clear();
+        recvMessages.clear();
+    }
     ~StatCollector() = default;
 
 
-    void inline static increment(std::unordered_map<std::string, std::atomic<int>> &map, const std::string &key) {
-        auto found = map.find(key);
-        if (found != map.end()) { //inc
-            map[key].fetch_add(1, std::memory_order_release);
-        } else { //add
-            //sentMessages.emplace(std::make_pair(std::string(key), std::atomic<int>(0)));
-            map.emplace(std::piecewise_construct,
-                                 std::forward_as_tuple(key),
-                                 std::forward_as_tuple(0));
+    void increment(tbb::concurrent_unordered_map<std::string, int> &map, const std::string &key);
+
+};
+
+void StatCollector::increment(tbb::concurrent_unordered_map<std::string, int> &map, const std::string &key) {
+    if (mdclog_level_get() >= MDCLOG_DEBUG) {
+        mdclog_write(MDCLOG_INFO, "in file %s at  finction %s in line %d", __FILE__, __func__, __LINE__);
+    }
+    if (map.empty()) {
+        if (mdclog_level_get() >= MDCLOG_DEBUG) {
+            mdclog_write(MDCLOG_INFO, "in file %s at  finction %s in line %d", __FILE__, __func__, __LINE__);
+        }
+        map.emplace(std::piecewise_construct,
+                    std::forward_as_tuple(key),
+                    std::forward_as_tuple(1));
+        if (mdclog_level_get() >= MDCLOG_DEBUG) {
+            mdclog_write(MDCLOG_INFO, "in file %s at  finction %s in line %d", __FILE__, __func__, __LINE__);
+        }
+        return;
+    }
+    if (mdclog_level_get() >= MDCLOG_DEBUG) {
+        mdclog_write(MDCLOG_INFO, "in file %s at  finction %s in line %d", __FILE__, __func__, __LINE__);
+    }
+    auto found = map.find(key);
+    if (mdclog_level_get() >= MDCLOG_DEBUG) {
+        mdclog_write(MDCLOG_INFO, "in file %s at  finction %s in line %d", __FILE__, __func__, __LINE__);
+    }
+    if (found != map.end()) { //inc
+        if (mdclog_level_get() >= MDCLOG_DEBUG) {
+            mdclog_write(MDCLOG_INFO, "in file %s at  finction %s in line %d", __FILE__, __func__, __LINE__);
+        }
+        map[key]++;
+    } else { //add
+        //sentMessages.emplace(std::make_pair(std::string(key), std::atomic<int>(0)));
+        if (mdclog_level_get() >= MDCLOG_DEBUG) {
+            mdclog_write(MDCLOG_INFO, "in file %s at  finction %s in line %d", __FILE__, __func__, __LINE__);
         }
 
+        map.emplace(std::piecewise_construct,
+                    std::forward_as_tuple(key),
+                    std::forward_as_tuple(1));
+        if (mdclog_level_get() >= MDCLOG_DEBUG) {
+            mdclog_write(MDCLOG_INFO, "in file %s at  finction %s in line %d", __FILE__, __func__, __LINE__);
+        }
     }
 
-};
+}
 
 
 // must define this to allow StatCollector private variables to be known to compiler linker