Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-UDR
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-UDR
Commits
6d3d788e
Commit
6d3d788e
authored
Jun 20, 2022
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update for support event inside MySQL class
parent
e3ae3afc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
4 deletions
+71
-4
src/udr_app/database_wrapper.hpp
src/udr_app/database_wrapper.hpp
+10
-0
src/udr_app/database_wrapper_abstraction.hpp
src/udr_app/database_wrapper_abstraction.hpp
+18
-1
src/udr_app/mysql_db.cpp
src/udr_app/mysql_db.cpp
+40
-2
src/udr_app/mysql_db.hpp
src/udr_app/mysql_db.hpp
+3
-1
No files found.
src/udr_app/database_wrapper.hpp
View file @
6d3d788e
...
@@ -212,6 +212,16 @@ class database_wrapper : public database_wrapper_abstraction {
...
@@ -212,6 +212,16 @@ class database_wrapper : public database_wrapper_abstraction {
return
derived
->
query_smf_select_data
(
ue_id
,
serving_plmn_id
,
json_data
);
return
derived
->
query_smf_select_data
(
ue_id
,
serving_plmn_id
,
json_data
);
}
}
void
start_event_connection_handling
()
{
auto
derived
=
static_cast
<
DerivedT
*>
(
this
);
return
derived
->
start_event_connection_handling
();
}
void
trigger_connection_handling_procedure
(
uint64_t
ms
)
{
auto
derived
=
static_cast
<
DerivedT
*>
(
this
);
return
derived
->
trigger_connection_handling_procedure
(
ms
);
}
protected:
protected:
};
};
}
// namespace oai::udr::app
}
// namespace oai::udr::app
...
...
src/udr_app/database_wrapper_abstraction.hpp
View file @
6d3d788e
...
@@ -41,15 +41,18 @@
...
@@ -41,15 +41,18 @@
#include "Snssai.h"
#include "Snssai.h"
#include "logger.hpp"
#include "logger.hpp"
#include "udr.h"
#include "udr.h"
#include "udr_event.hpp"
namespace
oai
::
udr
::
app
{
namespace
oai
::
udr
::
app
{
class
database_wrapper_abstraction
{
class
database_wrapper_abstraction
{
public:
public:
database_wrapper_abstraction
(){};
database_wrapper_abstraction
(
udr_event
&
ev
)
:
m_event_sub
(
ev
){};
virtual
~
database_wrapper_abstraction
(){};
virtual
~
database_wrapper_abstraction
(){};
// virtual std::unique_ptr<database_wrapper_abstraction> clone() const = 0;
// virtual std::unique_ptr<database_wrapper_abstraction> clone() const = 0;
udr_event
&
m_event_sub
;
/*
/*
* Initialize the DB and establish the connection between UDR and the DB
* Initialize the DB and establish the connection between UDR and the DB
* @param void
* @param void
...
@@ -289,6 +292,20 @@ class database_wrapper_abstraction {
...
@@ -289,6 +292,20 @@ class database_wrapper_abstraction {
virtual
bool
query_smf_select_data
(
virtual
bool
query_smf_select_data
(
const
std
::
string
&
ue_id
,
const
std
::
string
&
serving_plmn_id
,
const
std
::
string
&
ue_id
,
const
std
::
string
&
serving_plmn_id
,
nlohmann
::
json
&
json_data
)
=
0
;
nlohmann
::
json
&
json_data
)
=
0
;
/*
* Start event connection handling procedure
* @param [void]
* @return void
*/
virtual
void
start_event_connection_handling
()
=
0
;
/*
* Trigger connection handling procedure (kind of NF Heartbeat)
* @param [uint64_t] ms:
* @return void
*/
virtual
void
trigger_connection_handling_procedure
(
uint64_t
ms
)
=
0
;
};
};
}
// namespace oai::udr::app
}
// namespace oai::udr::app
...
...
src/udr_app/mysql_db.cpp
View file @
6d3d788e
...
@@ -42,10 +42,12 @@ using namespace oai::udr::config;
...
@@ -42,10 +42,12 @@ using namespace oai::udr::config;
extern
udr_config
udr_cfg
;
extern
udr_config
udr_cfg
;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
mysql_db
::
mysql_db
(
)
:
database_wrapper
<
mysql_db
>
(
)
{}
mysql_db
::
mysql_db
(
udr_event
&
ev
)
:
database_wrapper
<
mysql_db
>
(
ev
)
{}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
mysql_db
::~
mysql_db
()
{}
mysql_db
::~
mysql_db
()
{
if
(
db_connection
.
connected
())
db_connection
.
disconnect
();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool
mysql_db
::
initialize
()
{
bool
mysql_db
::
initialize
()
{
...
@@ -74,6 +76,42 @@ bool mysql_db::close_connection() {
...
@@ -74,6 +76,42 @@ bool mysql_db::close_connection() {
return
true
;
return
true
;
}
}
//---------------------------------------------------------------------------------------------
void
mysql_db
::
start_event_connection_manager
()
{
// get current time
uint64_t
ms
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
())
.
count
();
struct
itimerspec
its
;
its
.
it_value
.
tv_sec
=
DB_CONNECTION_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
db_connection
=
m_event_sub
.
subscribe_task_db_connection_manager
(
boost
::
bind
(
&
mysql_db
::
trigger_connection_verification_procedure
,
this
,
_1
),
interval
,
ms
+
interval
);
}
//---------------------------------------------------------------------------------------------
void
mysql_db
::
trigger_connection_verification_procedure
(
uint64_t
ms
)
{
_unused
(
ms
);
if
(
!
mysql_real_connect
(
&
mysql_connector
,
udr_cfg
.
mysql
.
mysql_server
.
c_str
(),
udr_cfg
.
mysql
.
mysql_user
.
c_str
(),
udr_cfg
.
mysql
.
mysql_pass
.
c_str
(),
udr_cfg
.
mysql
.
mysql_db
.
c_str
(),
0
,
0
,
0
))
{
Logger
::
udr_mysql
().
error
(
"An error occurred while connecting to MySQL DB: %s"
,
mysql_error
(
&
mysql_connector
));
// Reset the connection
close_connection
();
initialize
();
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool
mysql_db
::
insert_authentication_subscription
(
bool
mysql_db
::
insert_authentication_subscription
(
const
std
::
string
&
id
,
const
std
::
string
&
id
,
...
...
src/udr_app/mysql_db.hpp
View file @
6d3d788e
...
@@ -34,12 +34,13 @@
...
@@ -34,12 +34,13 @@
#include "Amf3GppAccessRegistration.h"
#include "Amf3GppAccessRegistration.h"
#include "database_wrapper.hpp"
#include "database_wrapper.hpp"
#include "udr_event.hpp"
namespace
oai
::
udr
::
app
{
namespace
oai
::
udr
::
app
{
class
mysql_db
:
public
database_wrapper
<
mysql_db
>
{
class
mysql_db
:
public
database_wrapper
<
mysql_db
>
{
public:
public:
mysql_db
();
mysql_db
(
udr_event
&
ev
);
virtual
~
mysql_db
();
virtual
~
mysql_db
();
bool
initialize
();
bool
initialize
();
...
@@ -127,6 +128,7 @@ class mysql_db : public database_wrapper<mysql_db> {
...
@@ -127,6 +128,7 @@ class mysql_db : public database_wrapper<mysql_db> {
private:
private:
MYSQL
mysql_connector
;
MYSQL
mysql_connector
;
bs2
::
connection
db_connection
;
};
};
}
// namespace oai::udr::app
}
// namespace oai::udr::app
...
...
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