X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=Bouncer%2Fsrc%2Fxapp.cc;h=2a07ff410339258fd0f92d95f7d70cbf9bcd7216;hb=eb27c05c05b5042d115480c40cffa16e7d473d80;hp=94d190e9523ba80df499bc5f89f8c65bdacea1e3;hpb=c87d0bba9607c802e025053ba4cf59c5b3841ca0;p=ric-app%2Fbouncer.git diff --git a/Bouncer/src/xapp.cc b/Bouncer/src/xapp.cc index 94d190e..2a07ff4 100644 --- a/Bouncer/src/xapp.cc +++ b/Bouncer/src/xapp.cc @@ -17,8 +17,21 @@ */ #include "xapp.hpp" +#include +#include +#include +#include +#include +#include +#include +using namespace utility; +using namespace web; +using namespace web::http; +using namespace web::http::client; +using namespace concurrency::streams; +using jsonn = nlohmann::json; #define BUFFER_SIZE 1024 - +extern std::vectorSubscriptionIds; Xapp::Xapp(XappSettings &config, XappRmr &rmr){ rmr_ref = &rmr; @@ -105,35 +118,247 @@ void Xapp::start_xapp_receiver(XappMsgHandler& mp_handler){ } void Xapp::shutdown(){ - return; + + sleep(70); + //send subscriptions delete. + shutdown_subscribe_deletes(); + return; } +void Xapp::shutdown_subscribe_deletes(void ) +{ + + bool res; + size_t data_size = ASN_BUFF_MAX_SIZE; + unsigned char data[data_size]; + //unsigned char meid[RMR_MAX_MEID]; + char meid[RMR_MAX_MEID]; + std::string xapp_id = config_ref->operator [](XappSettings::SettingName::XAPP_ID); + + mdclog_write(MDCLOG_INFO,"Preparing to send subscription Delete in file= %s, line=%d",__FILE__,__LINE__); + + auto gnblist = get_rnib_gnblist(); + + int sz = gnblist.size(); + mdclog_write(MDCLOG_INFO,"GNBList size : %d", sz); + + if(sz <= 0) + mdclog_write(MDCLOG_INFO,"Subscriptions Delete cannot be sent as GNBList in RNIB is NULL"); + + for(int i = 0; i0) + { + auto delJson = pplx::create_task([i,meid]() { + utility::string_t port = U("8088"); + utility::string_t address = U("http://service-ricplt-submgr-http.ricplt.svc.cluster.local:"); + address.append(port); + address.append(U("/ric/v1/subscriptions/")); + address.append( utility::string_t(SubscriptionIds.back())); + SubscriptionIds.pop_back(); + uri_builder uri(address); + auto addr = uri.to_uri().to_string(); + http_client client(addr); + ucout << utility::string_t(U("making requests at: ")) << addr <manage_subscription_delete_request(gnblist[i], transmitter); + + if(result==SUBSCR_SUCCESS) + { + + mdclog_write(MDCLOG_INFO,"Subscription Delete SUCCESSFUL in file= %s, line=%d for MEID %s",__FILE__,__LINE__, meid); + } + else + { + mdclog_write(MDCLOG_ERR,"Subscription Delete FAILED in file= %s, line=%d for MEID %s",__FILE__,__LINE__, meid); + } + */ + } +} void Xapp::startup_subscribe_requests(void ){ - bool res; size_t data_size = ASN_BUFF_MAX_SIZE; unsigned char data[data_size]; - unsigned char meid[RMR_MAX_MEID]; + char meid[RMR_MAX_MEID]; std::string xapp_id = config_ref->operator [](XappSettings::SettingName::XAPP_ID); - + //int a =std::stoi(xapp_id); mdclog_write(MDCLOG_INFO,"Preparing to send subscription in file= %s, line=%d",__FILE__,__LINE__); auto gnblist = get_rnib_gnblist(); int sz = gnblist.size(); - + mdclog_write(MDCLOG_INFO,"GNBList size : %d", sz); if(sz <= 0) mdclog_write(MDCLOG_INFO,"Subscriptions cannot be sent as GNBList in RNIB is NULL"); for(int i = 0; i