Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-NRF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-NRF
Commits
6531cc64
Commit
6531cc64
authored
Dec 14, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unsubscribe function
parent
e86d2677
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
28 deletions
+44
-28
src/nrf_app/nrf_app.cpp
src/nrf_app/nrf_app.cpp
+11
-18
src/nrf_app/nrf_event.cpp
src/nrf_app/nrf_event.cpp
+16
-0
src/nrf_app/nrf_event.hpp
src/nrf_app/nrf_event.hpp
+4
-0
src/nrf_app/nrf_profile.cpp
src/nrf_app/nrf_profile.cpp
+10
-9
src/nrf_app/nrf_profile.hpp
src/nrf_app/nrf_profile.hpp
+3
-1
No files found.
src/nrf_app/nrf_app.cpp
View file @
6531cc64
...
...
@@ -81,17 +81,17 @@ void nrf_app::handle_register_nf_instance(
std
::
shared_ptr
<
nrf_profile
>
sn
=
{
};
switch
(
type
)
{
case
NF_TYPE_AMF
:
{
sn
=
std
::
make_shared
<
amf_profile
>
(
m_event_sub
);
sn
=
std
::
make_shared
<
amf_profile
>
(
m_event_sub
);
}
break
;
case
NF_TYPE_SMF
:
{
sn
=
std
::
make_shared
<
smf_profile
>
(
m_event_sub
);
sn
=
std
::
make_shared
<
smf_profile
>
(
m_event_sub
);
}
break
;
default:
{
sn
=
std
::
make_shared
<
nrf_profile
>
(
m_event_sub
);
sn
=
std
::
make_shared
<
nrf_profile
>
(
m_event_sub
);
}
}
...
...
@@ -107,10 +107,10 @@ void nrf_app::handle_register_nf_instance(
add_nf_profile
(
nf_instance_id
,
sn
);
//get current time
uint64_t
ms
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
//
uint64_t ms = std::chrono::duration_cast < std::chrono::milliseconds
//
> (std::chrono::system_clock::now().time_since_epoch()).count();
subscribe_task_tick
(
ms
);
//
subscribe_task_tick(ms);
Logger
::
nrf_app
().
debug
(
"Added/Updated NF Profile to the DB"
);
//display the info
...
...
@@ -141,9 +141,9 @@ void nrf_app::handle_update_nf_instance(
bool
op_success
=
true
;
//get current time
uint64_t
ms
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
subscribe_task_tick2
(
ms
);
//
uint64_t ms = std::chrono::duration_cast < std::chrono::milliseconds
//
> (std::chrono::system_clock::now().time_since_epoch()).count();
//
subscribe_task_tick2(ms);
if
(
sn
.
get
()
!=
nullptr
)
{
for
(
auto
p
:
patchItem
)
{
...
...
@@ -275,6 +275,7 @@ bool nrf_app::update_nf_profile(const std::string &profile_id,
Logger
::
nrf_app
().
info
(
"Update a NF profile to the list (profile ID %s)"
,
profile_id
.
c_str
());
instance_id2nrf_profile
.
at
(
profile_id
)
=
p
;
p
.
get
()
->
unsubscribe_task_tick
();
return
true
;
}
else
{
Logger
::
nrf_app
().
info
(
"NF profile (ID %d) not found"
,
profile_id
.
c_str
());
...
...
@@ -381,14 +382,10 @@ void nrf_app::subscribe_task_tick(uint64_t ms) {
const
uint64_t
interval
=
its
.
it_value
.
tv_sec
*
1000
+
its
.
it_value
.
tv_nsec
/
1000000
;
// convert sec, nsec to msec
//uint64_t interval =10;
// m_event_sub.subscribe_task_tick(
// boost::bind<void>(&nrf_app::handle_heartbeart_timeout, _1), interval, 0 /* start at time 0 */);
Logger
::
nrf_app
().
debug
(
"subscribe_task_tick1: %d"
,
ms
);
m_event_sub
.
subscribe_task_tick
(
boost
::
bind
(
&
nrf_app
::
handle_heartbeart_timeout
,
this
,
_1
),
interval
,
ms
%
20000
/* start at time 0 */
);
ms
%
20000
);
}
...
...
@@ -402,10 +399,6 @@ void nrf_app::subscribe_task_tick2(uint64_t ms) {
const
uint64_t
interval
=
its
.
it_value
.
tv_sec
*
1000
+
its
.
it_value
.
tv_nsec
/
1000000
;
// convert sec, nsec to msec
//uint64_t interval =10;
// m_event_sub.subscribe_task_tick(
// boost::bind<void>(&nrf_app::handle_heartbeart_timeout, _1), interval, 0 /* start at time 0 */);
Logger
::
nrf_app
().
debug
(
"subscribe_task_tick2 %d"
,
ms
);
m_event_sub
.
subscribe_task_tick
(
boost
::
bind
(
&
nrf_app
::
handle_heartbeart_timeout2
,
this
,
_1
),
interval
,
...
...
src/nrf_app/nrf_event.cpp
View file @
6531cc64
...
...
@@ -49,4 +49,20 @@ bs2::connection nrf_event::subscribe_task_tick(
return
task_tick
.
connect
(
f
);
}
//------------------------------------------------------------------------------
bs2
::
connection
nrf_event
::
subscribe_task_tick_extended
(
const
task_sig_t
::
extended_slot_type
&
sig
,
uint64_t
period
,
uint64_t
start
)
{
/* Wrap the actual callback in a lambda. The latter checks whether the
* current time is after start time, and ensures that the callback is only
* called every X ms with X being the period time. This way, it is possible
* to register to be notified every X ms instead of every ms, which provides
* greater freedom to implementations. */
auto
f
=
[
period
,
start
,
sig
]
(
const
bs2
::
connection
&
c
,
uint64_t
t
)
{
if
(
t
>=
start
&&
(
t
-
start
)
%
period
==
0
)
sig
(
c
,
t
);
};
return
task_tick
.
connect_extended
(
f
);
}
src/nrf_app/nrf_event.hpp
View file @
6531cc64
...
...
@@ -66,6 +66,10 @@ class nrf_event {
bs2
::
connection
subscribe_task_tick
(
const
task_sig_t
::
slot_type
&
sig
,
uint64_t
period
,
uint64_t
start
=
0
);
bs2
::
connection
subscribe_task_tick_extended
(
const
task_sig_t
::
extended_slot_type
&
sig
,
uint64_t
period
,
uint64_t
start
=
0
);
private:
task_sig_t
task_tick
;
...
...
src/nrf_app/nrf_profile.cpp
View file @
6531cc64
...
...
@@ -453,26 +453,27 @@ void nrf_profile::to_json(nlohmann::json &data) const {
void
nrf_profile
::
subscribe_task_tick
(
uint64_t
ms
)
{
struct
itimerspec
its
;
its
.
it_value
.
tv_sec
=
10
;
//seconds
its
.
it_value
.
tv_sec
=
HEART_BEAT_TIMER
;
//seconds
its
.
it_value
.
tv_nsec
=
0
;
//100 * 1000 * 1000; //100ms
const
uint64_t
interval
=
its
.
it_value
.
tv_sec
*
1000
+
its
.
it_value
.
tv_nsec
/
1000000
;
// convert sec, nsec to msec
//uint64_t interval =10;
// m_event_sub.subscribe_task_tick(
// boost::bind<void>(&nrf_app::handle_heartbeart_timeout, _1), interval, 0 /* start at time 0 */);
Logger
::
nrf_app
().
debug
(
"subscribe_task_tick2 %d"
,
ms
);
m_event_sub
.
subscribe_task_tick
(
task_connection
=
m_event_sub
.
subscribe_task_tick
(
boost
::
bind
(
&
nrf_profile
::
handle_heartbeart_timeout
,
this
,
_1
),
interval
,
ms
%
10000
/* start at time 0 */
);
ms
%
(
HEART_BEAT_TIMER
*
1000
)
/* start at time 0 */
);
}
//------------------------------------------------------------------------------
void
nrf_profile
::
unsubscribe_task_tick
()
{
task_connection
.
disconnect
();
Logger
::
nrf_app
().
debug
(
"Un subscribe_task_tick"
);
}
//------------------------------------------------------------------------------
void
nrf_profile
::
handle_heartbeart_timeout
(
uint64_t
ms
)
{
Logger
::
nrf_app
().
info
(
"NRF PROFILE handle_heartbeart_timeout1 %d, PROFILE ID %s"
,
ms
,
nf_instance_id
.
c_str
());
Logger
::
nrf_app
().
info
(
"Handle heartbeart timeout profile %s, time %d"
,
nf_instance_id
.
c_str
(),
ms
);
set_nf_status
(
"SUSPENDED"
);
}
...
...
src/nrf_app/nrf_profile.hpp
View file @
6531cc64
...
...
@@ -94,7 +94,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
nrf_profile
(
nrf_profile
&
b
)
=
delete
;
virtual
~
nrf_profile
()
{
task_connection
.
disconnect
();
}
/*
...
...
@@ -321,8 +321,10 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
virtual
void
subscribe_task_tick
(
uint64_t
ms
);
virtual
void
handle_heartbeart_timeout
(
uint64_t
ms
);
virtual
void
unsubscribe_task_tick
();
protected:
nrf_event
&
m_event_sub
;
bs2
::
connection
task_connection
;
//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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment