Commit b84a4bbe authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen
Browse files

Fix issue for HeartBeat mechanism

parent 14dcfa72
......@@ -140,7 +140,7 @@ void nrf_app::handle_register_nf_instance(
uint64_t ms = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
sn.get()->subscribe_task_tick(ms);
// sn.get()->subscribe_heartbeat_timeout_nfregistration(ms);
// Notify NF status change event
m_event_sub.nf_status_registered(nf_instance_id); // from nrf_app
......@@ -238,6 +238,25 @@ void nrf_app::handle_update_nf_instance(
// for NF Heartbeat procedure
if (is_heartbeart_procedure && (http_code = HTTP_STATUS_CODE_200_OK)) {
http_code = HTTP_STATUS_CODE_204_NO_CONTENT;
uint64_t ms = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
Logger::nrf_app().debug("Received a NF update %ld, %d", ms,
ms % (HEART_BEAT_TIMER * 1000));
// If this happens before the first Heartbeattimer expires -> remove this
// timer
/* if (sn.get()->unsubscribe_heartbeat_timeout_nfregistration()) {
// Heartbeart management for this NF profile
// get current time
sn.get()->subscribe_heartbeat_timeout_nfupdate(ms);
}
*/
sn.get()->subscribe_heartbeat_timeout_nfupdate(ms);
// update NF updated flag
sn.get()->set_status_updated(true);
}
} else {
......
This diff is collapsed.
......@@ -59,10 +59,13 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
snssais(),
ipv4_addresses(),
priority(0),
capacity(0) {
capacity(0),
heartbeart_mutex(){
nf_instance_name = "";
nf_status = "";
json_data = {};
first_update = false;
is_updated = false;
}
nrf_profile(nrf_event &ev, const nf_type_t type)
: m_event_sub(ev),
......@@ -71,10 +74,13 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
snssais(),
ipv4_addresses(),
priority(0),
capacity(0) {
capacity(0),
heartbeart_mutex(){
nf_instance_name = "";
nf_status = "";
json_data = {};
first_update = false;
is_updated = false;
}
nrf_profile(nrf_event &ev, const std::string &id)
......@@ -85,10 +91,13 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
ipv4_addresses(),
priority(0),
capacity(0),
nf_type(NF_TYPE_UNKNOWN) {
nf_type(NF_TYPE_UNKNOWN),
heartbeart_mutex(){
nf_instance_name = "";
nf_status = "";
json_data = {};
first_update = false;
is_updated = false;
}
nrf_profile(nrf_profile &b) = delete;
......@@ -96,6 +105,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
virtual ~nrf_profile() {
Logger::nrf_app().debug("Delete NRF Profile instance...");
if (task_connection.connected()) task_connection.disconnect();
if (first_hb_connection.connected()) first_hb_connection.disconnect();
}
/*
......@@ -338,26 +348,40 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
* @param [uint64_t] ms: current time
* @return void
*/
void subscribe_task_tick(uint64_t ms);
void subscribe_heartbeat_timeout_nfupdate(uint64_t ms);
void subscribe_heartbeat_timeout_nfregistration(uint64_t ms);
/*
* Handle heartbeart timeout event
* @param [uint64_t] ms: current time
* @return void
*/
void handle_heartbeart_timeout(uint64_t ms);
void handle_heartbeart_timeout_nfregistration(uint64_t ms);
void handle_heartbeart_timeout_nfupdate(uint64_t ms);
/*
* Unubscribe to task tick event
* @param void
* @return void
*/
void unsubscribe_task_tick();
bool unsubscribe_heartbeat_timeout_nfupdate();
bool unsubscribe_heartbeat_timeout_nfregistration();
/*
* Set status updated to true
* @param void
* @return void
*/
void set_status_updated(bool status);
protected:
nrf_event &m_event_sub;
bs2::connection task_connection;
bs2::connection task_connection; //connection for the task tick for heartbeart
bs2::connection first_hb_connection; //connection for the first heartbearttimer
bool first_update;
bool is_updated;
mutable std::shared_mutex heartbeart_mutex;
// 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_name;
......@@ -530,6 +554,7 @@ class smf_profile : public nrf_profile {
*/
void get_smf_info(smf_info_t &infos) const;
/*
* Print related-information for a SMF profile
* @param void
......
......@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* 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 License at
* 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
*License at
*
* http://www.openairinterface.org/?page_id=698
*
......@@ -29,18 +29,16 @@
#include "task_manager.hpp"
#include <thread>
#include <unistd.h>
#include <iostream>
#include <thread>
#include "logger.hpp"
using namespace oai::nrf::app;
//------------------------------------------------------------------------------
task_manager::task_manager(nrf_event &ev)
:
event_sub_(ev) {
task_manager::task_manager(nrf_event &ev) : event_sub_(ev) {
struct itimerspec its;
sfd = timerfd_create(CLOCK_MONOTONIC, 0);
......@@ -57,13 +55,14 @@ task_manager::task_manager(nrf_event &ev)
}
//------------------------------------------------------------------------------
void task_manager::run() {
manage_tasks();
}
void task_manager::run() { manage_tasks(); }
//------------------------------------------------------------------------------
void task_manager::manage_tasks() {
uint64_t t = 0;
// starting from current time
uint64_t t = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
while (1) {
event_sub_.task_tick(t);
......
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