X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fhw_xapp_main.cc;h=655f4522123f06b1ac7fa1dc8ce105c0b820c2f8;hb=23dad813c70c0d79cd1bd16009e00895e6509fd2;hp=aa51d201e78e657fee9b07125f5749900baf4223;hpb=91d30a6530398a9c7e50a15ea1cf9a027953bd39;p=ric-app%2Fhw.git diff --git a/src/hw_xapp_main.cc b/src/hw_xapp_main.cc index aa51d20..655f452 100644 --- a/src/hw_xapp_main.cc +++ b/src/hw_xapp_main.cc @@ -1,6 +1,6 @@ /* ================================================================================== - Copyright (c) 2018-2019 AT&T Intellectual Property. + Copyright (c) 2019-2020 AT&T Intellectual Property. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -51,21 +51,47 @@ int main(int argc, char *argv[]){ signal(SIGTERM, signalHandler); //getting the listening port and xapp name info - std::string port = config[XappSettings::SettingName::HW_PORTS]; + std::string port = config[XappSettings::SettingName::HW_PORT]; std::string name = config[XappSettings::SettingName::XAPP_NAME]; //initialize rmr - std::unique_ptr rmr; - rmr = std::make_unique(port); - rmr->xapp_rmr_init(); + std::unique_ptr rmr = std::make_unique(port); + rmr->xapp_rmr_init(true); - std::unique_ptr hw_xapp = std::make_unique(std::ref(config),std::ref(*rmr)); - //hw_xapp->startup(); + //Create Subscription Handler if Xapp deals with Subscription. + bool sub_required = true; + std::unique_ptr sub_handler = std::make_unique(); - std::unique_ptr mp_handler = std::make_unique(config[XappSettings::SettingName::XAPP_ID]); - //hw_xapp->register_handler(std::bind(&XappMsgHandler::operator (),mp_handler.get(),std::placeholders::_1,std::placeholders::_2)); - hw_xapp->start_xapp_receiver(std::ref(*mp_handler)); + //create HelloWorld Xapp Instance. + std::unique_ptr hw_xapp; + if(sub_required) + hw_xapp = std::make_unique(std::ref(config),std::ref(*rmr), std::ref(*sub_handler)); + else + hw_xapp = std::make_unique(std::ref(config),std::ref(*rmr)); + + mdclog_write(MDCLOG_INFO, "Created Hello World Xapp Instance"); + + sleep(1); + //Startup E2 subscription and A1 policy + hw_xapp->startup(); + + + //start listener threads and register message handlers. + int num_threads = std::stoi(config[XappSettings::SettingName::THREADS]); + for(int j=0; j < num_threads; j++) { + std::unique_ptr mp_handler; + if(sub_required) + mp_handler = std::make_unique(config[XappSettings::SettingName::XAPP_ID], std::ref(*sub_handler)); + else + mp_handler = std::make_unique(config[XappSettings::SettingName::XAPP_ID]); + + hw_xapp->register_handler(std::ref(*mp_handler)); + } + + mdclog_write(MDCLOG_INFO, "Starting Listener Threads. Number of Workers = %d", num_threads); + + hw_xapp->Run(); //Delete all subscriptions if any based on Xapp Mode. //xapp->shutdown();