Commit b2f0ddab authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Fix issue to allow sending response for the first NF update

parent f813c1ee
...@@ -173,6 +173,7 @@ void NFInstanceIDDocumentApiImpl::update_nf_instance( ...@@ -173,6 +173,7 @@ void NFInstanceIDDocumentApiImpl::update_nf_instance(
// content type // content type
response.headers().add<Pistache::Http::Header::ContentType>( response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(content_type)); Pistache::Http::Mime::MediaType(content_type));
if (http_code != HTTP_STATUS_CODE_204_NO_CONTENT) if (http_code != HTTP_STATUS_CODE_204_NO_CONTENT)
response.send(Pistache::Http::Code(http_code), json_data.dump().c_str()); response.send(Pistache::Http::Code(http_code), json_data.dump().c_str());
else else
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this * the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the * file except in compliance with the License. You may obtain a copy of the
*License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -237,18 +237,18 @@ void nrf_app::handle_update_nf_instance( ...@@ -237,18 +237,18 @@ void nrf_app::handle_update_nf_instance(
} }
// for NF Heartbeat procedure // for NF Heartbeat procedure
if (is_heartbeart_procedure && (http_code = HTTP_STATUS_CODE_200_OK)) { if (is_heartbeart_procedure and (http_code == HTTP_STATUS_CODE_200_OK)) {
http_code = HTTP_STATUS_CODE_204_NO_CONTENT; http_code = HTTP_STATUS_CODE_204_NO_CONTENT;
uint64_t ms = std::chrono::duration_cast<std::chrono::milliseconds>( uint64_t ms = std::chrono::duration_cast<std::chrono::milliseconds>(
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 %ld", ms); Logger::nrf_app().debug("Received a NF update for Heartbeat update, 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()) {
// Sleep 100ms to avoid Boost connection related issue // Sleep 10ms to avoid Boost connection related issue
unsigned int microsecond = 100000; // 100ms unsigned int microsecond = 10000; // 10ms
usleep(microsecond); usleep(microsecond);
ms = std::chrono::duration_cast<std::chrono::milliseconds>( ms = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch()) std::chrono::system_clock::now().time_since_epoch())
...@@ -261,6 +261,9 @@ void nrf_app::handle_update_nf_instance( ...@@ -261,6 +261,9 @@ 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
sn.get()->set_nf_status("REGISTERED");
return;
} }
} else { } else {
...@@ -696,7 +699,7 @@ bool nrf_app::update_nf_profile(const std::string &profile_id, ...@@ -696,7 +699,7 @@ bool nrf_app::update_nf_profile(const std::string &profile_id,
// if profile with this id exist, return false // if profile with this id exist, return false
if (instance_id2nrf_profile.count(profile_id) > 0) { if (instance_id2nrf_profile.count(profile_id) > 0) {
// if not, update to the list // if not, update to the list
Logger::nrf_app().info("Update a NF profile to the list (profile ID %s)", Logger::nrf_app().info("Updated the NF profile (profile ID %s)",
profile_id.c_str()); profile_id.c_str());
instance_id2nrf_profile.at(profile_id) = p; instance_id2nrf_profile.at(profile_id) = p;
return true; return true;
...@@ -905,7 +908,7 @@ void nrf_app::handle_nf_status_registered(const std::string &profile_id) { ...@@ -905,7 +908,7 @@ void nrf_app::handle_nf_status_registered(const std::string &profile_id) {
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()); 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 != 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_REGISTERED, get_subscription_list(profile_id, NOTIFICATION_TYPE_NF_REGISTERED,
notification_uris); notification_uris);
...@@ -937,7 +940,7 @@ void nrf_app::handle_nf_status_deregistered(const std::string &profile_id) { ...@@ -937,7 +940,7 @@ void nrf_app::handle_nf_status_deregistered(const std::string &profile_id) {
std::shared_ptr<nrf_profile> profile = {}; std::shared_ptr<nrf_profile> profile = {};
find_nf_profile(profile_id, profile); find_nf_profile(profile_id, profile);
if (profile != 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);
...@@ -965,7 +968,7 @@ void nrf_app::handle_nf_status_profile_changed(const std::string &profile_id) { ...@@ -965,7 +968,7 @@ void nrf_app::handle_nf_status_profile_changed(const std::string &profile_id) {
profile_id.c_str()); profile_id.c_str());
std::shared_ptr<nrf_profile> profile = {}; std::shared_ptr<nrf_profile> profile = {};
find_nf_profile(profile_id, profile); find_nf_profile(profile_id, profile);
if (profile != 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_PROFILE_CHANGED, get_subscription_list(profile_id, NOTIFICATION_TYPE_NF_PROFILE_CHANGED,
notification_uris); notification_uris);
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this * the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the * file except in compliance with the License. You may obtain a copy of the
*License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this * the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the * file except in compliance with the License. You may obtain a copy of the
*License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this * the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the * file except in compliance with the License. You may obtain a copy of the
*License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -76,6 +76,7 @@ nf_type_t nrf_profile::get_nf_type() const { return nf_type; } ...@@ -76,6 +76,7 @@ nf_type_t nrf_profile::get_nf_type() const { return nf_type; }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_profile::set_nf_status(const std::string &status) { void nrf_profile::set_nf_status(const std::string &status) {
Logger::nrf_app().debug("Set NF status to %s", status.c_str());
std::unique_lock lock(heartbeart_mutex); std::unique_lock lock(heartbeart_mutex);
nf_status = status; nf_status = status;
} }
...@@ -458,13 +459,13 @@ void nrf_profile::subscribe_heartbeat_timeout_nfupdate(uint64_t ms) { ...@@ -458,13 +459,13 @@ void nrf_profile::subscribe_heartbeat_timeout_nfupdate(uint64_t ms) {
"%d, current time %ld", "%d, current time %ld",
HEART_BEAT_TIMER, ms); HEART_BEAT_TIMER, ms);
if (!first_update) { if (first_update) {
ms = ms + 2000; // Not a realtime NF: adding 2000ms interval between the ms = ms + 2000; // Not a realtime NF: adding 2000ms interval between the
// expected NF update message and HBT // expected NF update message and HBT
task_connection = m_event_sub.subscribe_task_tick( task_connection = m_event_sub.subscribe_task_tick(
boost::bind(&nrf_profile::handle_heartbeart_timeout_nfupdate, this, _1), boost::bind(&nrf_profile::handle_heartbeart_timeout_nfupdate, this, _1),
interval, ms + interval); interval, ms + interval);
first_update = true; first_update = false;
} }
} }
......
...@@ -64,7 +64,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -64,7 +64,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
nf_instance_name = ""; nf_instance_name = "";
nf_status = ""; nf_status = "";
json_data = {}; json_data = {};
first_update = false; first_update = true;
is_updated = false; is_updated = false;
} }
nrf_profile(nrf_event &ev, const nf_type_t type) nrf_profile(nrf_event &ev, const nf_type_t type)
...@@ -79,7 +79,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -79,7 +79,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
nf_instance_name = ""; nf_instance_name = "";
nf_status = ""; nf_status = "";
json_data = {}; json_data = {};
first_update = false; first_update = true;
is_updated = false; is_updated = false;
} }
...@@ -96,7 +96,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -96,7 +96,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
nf_instance_name = ""; nf_instance_name = "";
nf_status = ""; nf_status = "";
json_data = {}; json_data = {};
first_update = false; first_update = true;
is_updated = false; is_updated = false;
} }
...@@ -114,6 +114,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -114,6 +114,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
* @return void * @return void
*/ */
void set_nf_instance_id(const std::string &instance_id); void set_nf_instance_id(const std::string &instance_id);
/* /*
* Get NF instance ID * Get NF instance ID
* @param [std::string &] instance_id: store instance id * @param [std::string &] instance_id: store instance id
......
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