2 # ==================================================================================
3 # Copyright (c) 2020 HCL Technologies Limited.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 # ==================================================================================
21 void signalHandler( int signum ) {
22 cout << "Interrupt signal (" << signum << ") received.\n";
26 int main(int argc, char *argv[]){
29 std::thread::id my_id = std::this_thread::get_id();
30 std::stringstream thread_id;
35 mdclog_write(MDCLOG_INFO, "Starting thread %s", thread_id.str().c_str());
39 //change the priority depending upon application requirement
40 config.loadDefaultSettings();
41 config.loadEnvVarSettings();
42 config.loadCmdlineSettings(argc, argv);
44 //Register signal handler to stop
45 signal(SIGINT, signalHandler);
46 signal(SIGTERM, signalHandler);
48 //getting the listening port and xapp name info
49 std::string port = config[XappSettings::SettingName::BOUNCER_PORT];
50 std::string name = config[XappSettings::SettingName::XAPP_NAME];
53 std::unique_ptr<XappRmr> rmr = std::make_unique<XappRmr>(port);
54 rmr->xapp_rmr_init(true);
57 //Create Subscription Handler if Xapp deals with Subscription.
58 //std::unique_ptr<SubscriptionHandler> sub_handler = std::make_unique<SubscriptionHandler>();
60 SubscriptionHandler sub_handler;
62 //create Bouncer Xapp Instance.
63 std::unique_ptr<Xapp> b_xapp;
64 b_xapp = std::make_unique<Xapp>(std::ref(config),std::ref(*rmr));
66 mdclog_write(MDCLOG_INFO, "Created Bouncer Xapp Instance");
67 //Startup E2 subscription
68 b_xapp->startup(sub_handler);
73 //start listener threads and register message handlers.
74 int num_threads = std::stoi(config[XappSettings::SettingName::THREADS]);
75 mdclog_write(MDCLOG_INFO, "Starting Listener Threads. Number of Workers = %d", num_threads);
77 std::unique_ptr<XappMsgHandler> mp_handler = std::make_unique<XappMsgHandler>(config[XappSettings::SettingName::XAPP_ID], sub_handler);
79 b_xapp->start_xapp_receiver(std::ref(*mp_handler));