Commit 19ba2a63 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Send notification only including active NF profiles to the subscribed NFs

parent 7ae2ec1f
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "nrf_profile.hpp" #include "nrf_profile.hpp"
#include <unistd.h> #include <unistd.h>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/split.hpp>
...@@ -84,22 +85,31 @@ nf_type_t nrf_profile::get_nf_type() const { ...@@ -84,22 +85,31 @@ nf_type_t nrf_profile::get_nf_type() const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
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()); Logger::nrf_app().debug("Set NF status to %s", status.c_str());
std::unique_lock lock(heartbeart_mutex); std::unique_lock lock(nf_profile_mutex);
nf_status = status; nf_status = status;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_profile::get_nf_status(std::string& status) const { void nrf_profile::get_nf_status(std::string& status) const {
std::shared_lock lock(heartbeart_mutex); std::shared_lock lock(nf_profile_mutex);
status = nf_status; status = nf_status;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::string nrf_profile::get_nf_status() const { std::string nrf_profile::get_nf_status() const {
std::shared_lock lock(heartbeart_mutex); std::shared_lock lock(nf_profile_mutex);
return nf_status; return nf_status;
} }
//------------------------------------------------------------------------------
bool nrf_profile::is_nf_active() const {
std::shared_lock lock(nf_profile_mutex);
if (boost::iequals(nf_status, "REGISTERED")) {
return true;
}
return false;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_profile::set_nf_heartBeat_timer(const int32_t& timer) { void nrf_profile::set_nf_heartBeat_timer(const int32_t& timer) {
heartBeat_timer = timer; heartBeat_timer = timer;
...@@ -755,19 +765,19 @@ void nrf_profile::handle_heartbeart_timeout_nfupdate(uint64_t ms) { ...@@ -755,19 +765,19 @@ void nrf_profile::handle_heartbeart_timeout_nfupdate(uint64_t ms) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_profile::set_status_updated(bool status) { void nrf_profile::set_status_updated(bool status) {
std::unique_lock lock(heartbeart_mutex); std::unique_lock lock(nf_profile_mutex);
is_updated = status; is_updated = status;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_profile::get_status_updated(bool& status) { void nrf_profile::get_status_updated(bool& status) {
std::shared_lock lock(heartbeart_mutex); std::shared_lock lock(nf_profile_mutex);
status = is_updated; status = is_updated;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool nrf_profile::get_status_updated() { bool nrf_profile::get_status_updated() {
std::shared_lock lock(heartbeart_mutex); std::shared_lock lock(nf_profile_mutex);
return is_updated; return is_updated;
} }
......
...@@ -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> {
priority(0), priority(0),
capacity(0), capacity(0),
nf_services(), nf_services(),
heartbeart_mutex() { nf_profile_mutex() {
nf_instance_name = ""; nf_instance_name = "";
nf_status = ""; nf_status = "";
json_data = {}; json_data = {};
...@@ -84,7 +84,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -84,7 +84,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
priority(0), priority(0),
capacity(0), capacity(0),
nf_services(), nf_services(),
heartbeart_mutex() { nf_profile_mutex() {
nf_instance_name = ""; nf_instance_name = "";
nf_status = ""; nf_status = "";
json_data = {}; json_data = {};
...@@ -105,7 +105,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -105,7 +105,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
capacity(0), capacity(0),
nf_services(), nf_services(),
nf_type(NF_TYPE_UNKNOWN), nf_type(NF_TYPE_UNKNOWN),
heartbeart_mutex() { nf_profile_mutex() {
nf_instance_name = ""; nf_instance_name = "";
nf_status = ""; nf_status = "";
json_data = {}; json_data = {};
...@@ -184,6 +184,13 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -184,6 +184,13 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
*/ */
std::string get_nf_status() const; std::string get_nf_status() const;
/*
* Verify NF status
* @param
* @return true if NF status is REGISTERED, otherwise return false
*/
bool is_nf_active() const;
/* /*
* Get NF type * Get NF type
* @param * @param
...@@ -519,7 +526,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -519,7 +526,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
// (after NF Registration) // (after NF Registration)
bool first_update; bool first_update;
bool is_updated; bool is_updated;
mutable std::shared_mutex heartbeart_mutex; mutable std::shared_mutex nf_profile_mutex;
// From NFProfile (Section 6.1.6.2.2@3GPP TS 29.510 V16.0.0 (2019-06)) // From NFProfile (Section 6.1.6.2.2@3GPP TS 29.510 V16.0.0 (2019-06))
std::string nf_instance_id; std::string nf_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