From 3be133fb6c81f066a72e5dcc27c2514888ee6b4e Mon Sep 17 00:00:00 2001 From: Ron Shacham Date: Tue, 26 May 2020 13:43:44 -0400 Subject: [PATCH] Fixed parsing issue for incoming prediction message Signed-off-by: Ron Shacham Change-Id: I7960269c8dfa482c585819bdec167b4cbc5ac0d9 --- container-tag.yaml | 2 +- docs/rel-notes.rst | 4 +++ src/ts_xapp/ts_xapp.cpp | 74 ++++++++++++++++++++++++++---------------- test/populatedb/populate_db.sh | 2 ++ xapp-descriptor/config.json | 2 +- 5 files changed, 54 insertions(+), 30 deletions(-) diff --git a/container-tag.yaml b/container-tag.yaml index ebb2f87..ee0c040 100644 --- a/container-tag.yaml +++ b/container-tag.yaml @@ -1,3 +1,3 @@ # this is used by CI jobs to apply a tag when it builds the image --- -tag: '1.0.6' +tag: '1.0.7' diff --git a/docs/rel-notes.rst b/docs/rel-notes.rst index 3f25bbd..f49b075 100644 --- a/docs/rel-notes.rst +++ b/docs/rel-notes.rst @@ -9,6 +9,10 @@ Traffic Steering xAPP ===================== +2020 May 26 Version 1.0.7 +---------------------------- + Fix issue with parsing of prediction message + 2020 May 20 Version 1.0.5 ---------------------------- Support parsing of A1 Policy Create message diff --git a/src/ts_xapp/ts_xapp.cpp b/src/ts_xapp/ts_xapp.cpp index 5a760e6..c42e616 100644 --- a/src/ts_xapp/ts_xapp.cpp +++ b/src/ts_xapp/ts_xapp.cpp @@ -154,27 +154,36 @@ struct PolicyHandler : public BaseReaderHandler, PolicyHandler> { }; struct PredictionHandler : public BaseReaderHandler, PredictionHandler> { - unordered_map cell_pred; + unordered_map cell_pred_down; + unordered_map cell_pred_up; std::string ue_id; bool ue_id_found = false; string curr_key = ""; string curr_value = ""; + bool down_val = true; bool Null() { cout << "Null()" << endl; return true; } bool Bool(bool b) { cout << "Bool(" << boolalpha << b << ")" << endl; return true; } bool Int(int i) { cout << "Int(" << i << ")" << endl; return true; } - bool Uint(unsigned u) { cout << "Uint(" << u << ")" << endl; return true; } + bool Uint(unsigned u) { + cout << "Uint(" << u << ")" << endl; + if (down_val) { + cell_pred_down[curr_key] = u; + cout << "Setting xput down val for " << curr_key << " to " << u << endl; + down_val = false; + } else { + cell_pred_up[curr_key] = u; + cout << "Setting xput up val for " << curr_key << " to " << u << endl; + down_val = true; + } + + return true; + + } bool Int64(int64_t i) { cout << "Int64(" << i << ")" << endl; return true; } bool Uint64(uint64_t u) { cout << "Uint64(" << u << ")" << endl; return true; } bool Double(double d) { cout << "Double(" << d << ")" << endl; return true; } bool String(const char* str, SizeType length, bool copy) { cout << "String(" << str << ", " << length << ", " << boolalpha << copy << ")" << endl; - if (curr_key.compare("") != 0) { - cout << "Found throughput\n"; - curr_value = str; - cell_pred[curr_key] = curr_value; - curr_key = ""; - curr_value = ""; - } return true; } @@ -330,9 +339,6 @@ void policy_callback( Message& mbuf, int mtype, int subid, int len, Msg_componen fprintf( stderr, "Policy Callback got a message, type=%d , length=%d\n" , mtype, len); fprintf(stderr, "payload is %s\n", payload.get()); - //fprintf( stderr, "callback 1 got a message type = %d len = %d\n", mtype, len ); - mbuf.Send_response( 101, -1, 5, (unsigned char *) "OK1\n" ); // validate that we can use the same buffer for 2 rts calls - mbuf.Send_response( 101, -1, 5, (unsigned char *) "OK2\n" ); const char *arg = (const char*)payload.get(); @@ -346,6 +352,10 @@ void policy_callback( Message& mbuf, int mtype, int subid, int len, Msg_componen if (handler.found_threshold) { rsrp_threshold = handler.threshold; } + + mbuf.Send_response( 101, -1, 5, (unsigned char *) "OK1\n" ); // validate that we can use the same buffer for 2 rts calls + mbuf.Send_response( 101, -1, 5, (unsigned char *) "OK2\n" ); + } @@ -431,28 +441,33 @@ void prediction_callback( Message& mbuf, int mtype, int subid, int len, Msg_comp int rmtype; // received message type int delay = 1000000; // mu-sec delay; default 1s - fprintf( stderr, "Prediction Callback got a message, type=%d , length=%d\n" , mtype, len); - fprintf(stderr, "payload is %s\n", payload.get()); - - mbuf.Send_response( 101, -1, 5, (unsigned char *) "OK1\n" ); // validate that we can use the same buffer for 2 rts calls - mbuf.Send_response( 101, -1, 5, (unsigned char *) "OK2\n" ); + cout << "Prediction Callback got a message, type=" << mtype << " , length=" << len << "\n"; + cout << "payload is " << payload.get() << "\n"; mtype = 0; - fprintf(stderr, "cb 1\n"); + cout << "prediction callback 1" << endl; const char* arg = (const char*)payload.get(); + cout << "ready to parse " << arg << endl; + PredictionHandler handler; - Reader reader; - StringStream ss(arg); - reader.Parse(ss,handler); - std::string pred_ue_id = handler.ue_id; + try { + Reader reader; + StringStream ss(arg); + reader.Parse(ss,handler); + } catch (...) { + cout << "got an exception on stringstream read parse\n"; + } + + std::string pred_ue_id = handler.ue_id; + cout << "Prediction for " << pred_ue_id << endl; - - unordered_map throughput_map = handler.cell_pred; + + unordered_map throughput_map = handler.cell_pred_down; cout << endl; @@ -480,7 +495,7 @@ void prediction_callback( Message& mbuf, int mtype, int subid, int len, Msg_comp cout << map_iter->first << " : " << map_iter->second << endl; std::string curr_cellid = map_iter->first; cout << "Cell ID is " << curr_cellid; - int curr_throughput = stoi(map_iter->second, &str_size); + int curr_throughput = map_iter->second; cout << "Throughput is " << curr_throughput << endl; if (curr_cellid.compare(serving_cell_id) == 0) { @@ -496,7 +511,7 @@ void prediction_callback( Message& mbuf, int mtype, int subid, int len, Msg_comp cout << map_iter->first << " : " << map_iter->second << endl; std::string curr_cellid = map_iter->first; cout << "Cell ID is " << curr_cellid; - int curr_throughput = stoi(map_iter->second, &str_size); + int curr_throughput = map_iter->second; cout << "Throughput is " << curr_throughput << endl; if (curr_throughput > serving_cell_throughput) { @@ -511,6 +526,9 @@ void prediction_callback( Message& mbuf, int mtype, int subid, int len, Msg_comp cout << "Source cell " << serving_cell_id << endl; cout << "Target cell " << highest_throughput_cell_id << endl; } + + mbuf.Send_response( 101, -1, 5, (unsigned char *) "OK1\n" ); // validate that we can use the same buffer for 2 rts calls + mbuf.Send_response( 101, -1, 5, (unsigned char *) "OK2\n" ); } @@ -520,7 +538,7 @@ void prediction_callback( Message& mbuf, int mtype, int subid, int len, Msg_comp void run_loop() { - fprintf(stderr, "in run_loop()\n"); + cout << "in run_loop()\n"; unordered_map uemap; @@ -528,7 +546,7 @@ void run_loop() { while (1) { - fprintf(stderr, "in while loop\n"); + cout << "in while loop\n"; uemap = get_sdl_ue_data(); diff --git a/test/populatedb/populate_db.sh b/test/populatedb/populate_db.sh index 115e664..6ae5d03 100755 --- a/test/populatedb/populate_db.sh +++ b/test/populatedb/populate_db.sh @@ -17,6 +17,8 @@ #!/bin/bash +helm delete --purge dbprepop + docker build --tag localhost:5000/ts-write-sdl:0.0.1 . helm install helm --name dbprepop --namespace ricplt diff --git a/xapp-descriptor/config.json b/xapp-descriptor/config.json index bb96b65..d2561f8 100644 --- a/xapp-descriptor/config.json +++ b/xapp-descriptor/config.json @@ -7,7 +7,7 @@ "image": { "registry": "nexus3.o-ran-sc.org:10002", "name": "o-ran-sc/ric-app-ts", - "tag": "1.0.6" + "tag": "1.0.7" } } ], -- 2.16.6