Commit 421287b2 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Fix issue for NF Heart-beat/code cleanup

parent b2f0ddab
...@@ -144,7 +144,7 @@ void NFInstanceIDDocumentApiImpl::update_nf_instance( ...@@ -144,7 +144,7 @@ void NFInstanceIDDocumentApiImpl::update_nf_instance(
const std::string &nfInstanceID, const std::vector<PatchItem> &patchItem, const std::string &nfInstanceID, const std::vector<PatchItem> &patchItem,
Pistache::Http::ResponseWriter &response) { Pistache::Http::ResponseWriter &response) {
Logger::nrf_sbi().info( Logger::nrf_sbi().info(
"Got a request to update an NF instance, Instance ID: %s", "\nGot a request to update an NF instance, Instance ID: %s",
nfInstanceID.c_str()); nfInstanceID.c_str());
int http_code = 0; int http_code = 0;
......
...@@ -55,7 +55,7 @@ using namespace oai::nrf; ...@@ -55,7 +55,7 @@ using namespace oai::nrf;
bool api_conv::profile_api_to_nrf_profile( bool api_conv::profile_api_to_nrf_profile(
const NFProfile &api_profile, std::shared_ptr<nrf_profile> &profile) { const NFProfile &api_profile, std::shared_ptr<nrf_profile> &profile) {
Logger::nrf_app().debug( Logger::nrf_app().debug(
"Convert a json-type profile a NF profile (profile ID: %s)", "Convert a json-type profile to a NF profile (profile ID: %s)",
api_profile.getNfInstanceId().c_str()); api_profile.getNfInstanceId().c_str());
profile.get()->set_nf_instance_id(api_profile.getNfInstanceId()); profile.get()->set_nf_instance_id(api_profile.getNfInstanceId());
......
...@@ -107,7 +107,7 @@ void nrf_app::handle_register_nf_instance( ...@@ -107,7 +107,7 @@ void nrf_app::handle_register_nf_instance(
nf_type_t type = api_conv::string_to_nf_type(nf_profile.getNfType()); nf_type_t type = api_conv::string_to_nf_type(nf_profile.getNfType());
// Create a new NF profile or Update an existing NF profile // Create a new NF profile or Update an existing NF profile
Logger::nrf_app().debug("NF Profile with (ID %s, NF type %s)", Logger::nrf_app().debug("NF Profile with ID %s, NF type %s",
nf_instance_id.c_str(), nf_instance_id.c_str(),
nf_profile.getNfType().c_str()); nf_profile.getNfType().c_str());
...@@ -147,6 +147,8 @@ void nrf_app::handle_register_nf_instance( ...@@ -147,6 +147,8 @@ void nrf_app::handle_register_nf_instance(
m_event_sub.nf_status_registered(nf_instance_id); // from nrf_app m_event_sub.nf_status_registered(nf_instance_id); // from nrf_app
// display the info // display the info
Logger::nrf_app().debug(
"Added/Updated NF Profile with the NF instance info");
sn.get()->display(); sn.get()->display();
} else { } else {
// error // error
...@@ -192,7 +194,10 @@ void nrf_app::handle_update_nf_instance( ...@@ -192,7 +194,10 @@ void nrf_app::handle_update_nf_instance(
switch (op) { switch (op) {
case PATCH_OP_REPLACE: { case PATCH_OP_REPLACE: {
if (path.compare("nfStatus") == 0) is_heartbeart_procedure = true; if (path.compare("nfStatus") == 0) {
is_heartbeart_procedure = true;
Logger::nrf_app().debug("NF Heart-Beat procedure!");
}
if (sn.get()->replace_profile_info(path, p.getValue())) { if (sn.get()->replace_profile_info(path, p.getValue())) {
update_nf_profile(nf_instance_id, sn); update_nf_profile(nf_instance_id, sn);
http_code = HTTP_STATUS_CODE_200_OK; http_code = HTTP_STATUS_CODE_200_OK;
...@@ -243,7 +248,8 @@ void nrf_app::handle_update_nf_instance( ...@@ -243,7 +248,8 @@ void nrf_app::handle_update_nf_instance(
std::chrono::system_clock::now().time_since_epoch()) std::chrono::system_clock::now().time_since_epoch())
.count(); .count();
Logger::nrf_app().debug("Received a NF update for Heartbeat update, current time %ld", ms); Logger::nrf_app().debug(
"NF update for Heartbeat, current time %ld", ms);
// If this happens before the first Heartbeattimer expires -> remove this // If this happens before the first Heartbeattimer expires -> remove this
// timer // timer
if (sn.get()->unsubscribe_heartbeat_timeout_nfregistration()) { if (sn.get()->unsubscribe_heartbeat_timeout_nfregistration()) {
...@@ -261,7 +267,7 @@ void nrf_app::handle_update_nf_instance( ...@@ -261,7 +267,7 @@ void nrf_app::handle_update_nf_instance(
// sn.get()->subscribe_heartbeat_timeout_nfupdate(ms); // sn.get()->subscribe_heartbeat_timeout_nfupdate(ms);
// update NF updated flag // update NF updated flag
sn.get()->set_status_updated(true); sn.get()->set_status_updated(true);
//update NF status // update NF status
sn.get()->set_nf_status("REGISTERED"); sn.get()->set_nf_status("REGISTERED");
return; return;
} }
...@@ -894,7 +900,7 @@ void nrf_app::subscribe_nf_status() { ...@@ -894,7 +900,7 @@ void nrf_app::subscribe_nf_status() {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_app::subscribe_nf_status_registered() { void nrf_app::subscribe_nf_status_registered() {
Logger::nrf_app().debug("Subscribe to NF status registered"); Logger::nrf_app().debug("Subscribe to NF status registered event");
bs2::connection c = m_event_sub.subscribe_nf_status_registered( bs2::connection c = m_event_sub.subscribe_nf_status_registered(
boost::bind(&nrf_app::handle_nf_status_registered, this, _1)); boost::bind(&nrf_app::handle_nf_status_registered, this, _1));
connections.push_back(c); connections.push_back(c);
...@@ -902,7 +908,7 @@ void nrf_app::subscribe_nf_status_registered() { ...@@ -902,7 +908,7 @@ void nrf_app::subscribe_nf_status_registered() {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_app::handle_nf_status_registered(const std::string &profile_id) { void nrf_app::handle_nf_status_registered(const std::string &profile_id) {
Logger::nrf_app().info("Handle NF status registered, profile id %s", Logger::nrf_app().info("Handle NF status registered event, profile id %s",
profile_id.c_str()); profile_id.c_str());
std::shared_ptr<nrf_profile> profile = {}; std::shared_ptr<nrf_profile> profile = {};
...@@ -927,7 +933,7 @@ void nrf_app::handle_nf_status_registered(const std::string &profile_id) { ...@@ -927,7 +933,7 @@ void nrf_app::handle_nf_status_registered(const std::string &profile_id) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_app::subscribe_nf_status_deregistered() { void nrf_app::subscribe_nf_status_deregistered() {
Logger::nrf_app().debug("Subscribe to NF status deregistered"); Logger::nrf_app().debug("Subscribe to NF status deregistered event");
bs2::connection c = m_event_sub.subscribe_nf_status_deregistered( bs2::connection c = m_event_sub.subscribe_nf_status_deregistered(
boost::bind(&nrf_app::handle_nf_status_deregistered, this, _1)); boost::bind(&nrf_app::handle_nf_status_deregistered, this, _1));
connections.push_back(c); connections.push_back(c);
...@@ -935,18 +941,22 @@ void nrf_app::subscribe_nf_status_deregistered() { ...@@ -935,18 +941,22 @@ void nrf_app::subscribe_nf_status_deregistered() {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_app::handle_nf_status_deregistered(const std::string &profile_id) { void nrf_app::handle_nf_status_deregistered(const std::string &profile_id) {
Logger::nrf_app().info("Handle NF status deregistered, profile id %s", Logger::nrf_app().info("Handle NF status deregistered event, profile id %s",
profile_id.c_str()); profile_id.c_str());
std::shared_ptr<nrf_profile> profile = {}; std::shared_ptr<nrf_profile> profile = {};
Logger::nrf_app().info("\tFind a NF profile with ID %s", profile_id.c_str());
find_nf_profile(profile_id, profile); find_nf_profile(profile_id, profile);
if (profile.get() != nullptr) { if (profile.get() != nullptr) {
std::vector<std::string> notification_uris = {}; std::vector<std::string> notification_uris = {};
get_subscription_list(profile_id, NOTIFICATION_TYPE_NF_DEREGISTERED, get_subscription_list(profile_id, NOTIFICATION_TYPE_NF_DEREGISTERED,
notification_uris); notification_uris);
// send notifications // send notifications
nrf_client_inst->notify_subscribed_event( if (notification_uris.size() > 0)
profile, NOTIFICATION_TYPE_NF_DEREGISTERED, notification_uris); nrf_client_inst->notify_subscribed_event(
profile, NOTIFICATION_TYPE_NF_DEREGISTERED, notification_uris);
else
Logger::nrf_app().debug("\tNo subscription found");
} else { } else {
Logger::nrf_app().error("NF profile not found, profile id %s", Logger::nrf_app().error("NF profile not found, profile id %s",
...@@ -956,7 +966,7 @@ void nrf_app::handle_nf_status_deregistered(const std::string &profile_id) { ...@@ -956,7 +966,7 @@ void nrf_app::handle_nf_status_deregistered(const std::string &profile_id) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_app::subscribe_nf_status_profile_changed() { void nrf_app::subscribe_nf_status_profile_changed() {
Logger::nrf_app().debug("Subscribe to NF status profile changed"); Logger::nrf_app().debug("Subscribe to NF status profile changed event");
bs2::connection c = m_event_sub.subscribe_nf_status_profile_changed( bs2::connection c = m_event_sub.subscribe_nf_status_profile_changed(
boost::bind(&nrf_app::handle_nf_status_profile_changed, this, _1)); boost::bind(&nrf_app::handle_nf_status_profile_changed, this, _1));
connections.push_back(c); connections.push_back(c);
...@@ -964,9 +974,11 @@ void nrf_app::subscribe_nf_status_profile_changed() { ...@@ -964,9 +974,11 @@ void nrf_app::subscribe_nf_status_profile_changed() {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_app::handle_nf_status_profile_changed(const std::string &profile_id) { void nrf_app::handle_nf_status_profile_changed(const std::string &profile_id) {
Logger::nrf_app().info("Handle NF status profile changed, profile id %s", Logger::nrf_app().info(
profile_id.c_str()); "Handle NF status profile changed event, profile id %s",
profile_id.c_str());
std::shared_ptr<nrf_profile> profile = {}; std::shared_ptr<nrf_profile> profile = {};
Logger::nrf_app().info("\tFind a NF profile with ID %s", profile_id.c_str());
find_nf_profile(profile_id, profile); find_nf_profile(profile_id, profile);
if (profile.get() != nullptr) { if (profile.get() != nullptr) {
std::vector<std::string> notification_uris = {}; std::vector<std::string> notification_uris = {};
...@@ -975,8 +987,11 @@ void nrf_app::handle_nf_status_profile_changed(const std::string &profile_id) { ...@@ -975,8 +987,11 @@ void nrf_app::handle_nf_status_profile_changed(const std::string &profile_id) {
// Notification data includes NF profile (other alternative, includes // Notification data includes NF profile (other alternative, includes
// profile_changes) // profile_changes)
// send notifications // send notifications
nrf_client_inst->notify_subscribed_event( if (notification_uris.size() > 0)
profile, NOTIFICATION_TYPE_NF_PROFILE_CHANGED, notification_uris); nrf_client_inst->notify_subscribed_event(
profile, NOTIFICATION_TYPE_NF_PROFILE_CHANGED, notification_uris);
else
Logger::nrf_app().debug("\tNo subscription found");
} else { } else {
Logger::nrf_app().error("NF profile not found, profile id %s", Logger::nrf_app().error("NF profile not found, profile id %s",
profile_id.c_str()); profile_id.c_str());
......
...@@ -511,8 +511,9 @@ void nrf_profile::handle_heartbeart_timeout_nfregistration(uint64_t ms) { ...@@ -511,8 +511,9 @@ void nrf_profile::handle_heartbeart_timeout_nfregistration(uint64_t ms) {
// Set status to SUSPENDED and unsubscribe to the HBT // Set status to SUSPENDED and unsubscribe to the HBT
if (!is_updated) { if (!is_updated) {
set_nf_status("SUSPENDED"); set_nf_status("SUSPENDED");
set_status_updated(false);
} }
set_status_updated(false);
unsubscribe_heartbeat_timeout_nfregistration(); unsubscribe_heartbeat_timeout_nfregistration();
} }
...@@ -528,8 +529,8 @@ void nrf_profile::handle_heartbeart_timeout_nfupdate(uint64_t ms) { ...@@ -528,8 +529,8 @@ void nrf_profile::handle_heartbeart_timeout_nfupdate(uint64_t ms) {
nf_instance_id.c_str(), ms, current_ms); nf_instance_id.c_str(), ms, current_ms);
if (!is_updated) { if (!is_updated) {
set_nf_status("SUSPENDED"); set_nf_status("SUSPENDED");
set_status_updated(false);
} }
set_status_updated(false);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -665,15 +666,14 @@ void smf_profile::get_smf_info(smf_info_t &infos) const { infos = smf_info; } ...@@ -665,15 +666,14 @@ void smf_profile::get_smf_info(smf_info_t &infos) const { infos = smf_info; }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void smf_profile::display() { void smf_profile::display() {
nrf_profile::display(); nrf_profile::display();
Logger::nrf_app().debug("............SMF Info"); Logger::nrf_app().debug("\tSMF Info");
for (auto s : smf_info.snssai_smf_info_list) { for (auto s : smf_info.snssai_smf_info_list) {
Logger::nrf_app().debug( Logger::nrf_app().debug(
"....................SNSSAI SMF Info List, SNSSAI (SD: %s, SST: %d)", "\t\tSNSSAI SMF Info List, SNSSAI (SD: %s, SST: %d)",
s.snssai.sD.c_str(), s.snssai.sST); s.snssai.sD.c_str(), s.snssai.sST);
for (auto d : s.dnn_smf_info_list) { for (auto d : s.dnn_smf_info_list) {
Logger::nrf_app().debug( Logger::nrf_app().debug("\t\tSNSSAI SMF Info List, DNN List: %s",
"....................SNSSAI SMF Info List, DNN List: %s", d.dnn.c_str());
d.dnn.c_str());
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment