Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
dcdb
dcdb
Commits
10efbb0e
Commit
10efbb0e
authored
Oct 28, 2019
by
Carla Guillen
Browse files
Call once to initialize MariaDB.
parent
7fe40599
Changes
2
Hide whitespace changes
Inline
Side-by-side
analytics/operators/persystsql/MariaDB.cpp
View file @
10efbb0e
...
...
@@ -63,6 +63,7 @@ public:
MariaDB
*
MariaDB
::
instance
=
nullptr
;
std
::
mutex
MariaDB
::
mut
;
std
::
once_flag
MariaDB
::
init_once
;
void
MariaDB
::
print_error
(){
LOG
(
error
)
<<
"Error("
<<
mysql_errno
(
_mysql
)
<<
") ["
<<
mysql_sqlstate
(
_mysql
)
<<
"]
\"
"
<<
mysql_error
(
_mysql
)
<<
"
\"
"
;
...
...
@@ -75,14 +76,13 @@ void MariaDB::print_error(){
MariaDB
::
MariaDB
()
:
_mysql
(
NULL
),
_rotation
(
EVERY_MONTH
),
_every_x_days
(
0
),
_end_aggregate_timestamp
(
0
),
_initialized
(
false
)
{
}
MariaDB
*
MariaDB
::
getInstance
(){
// no lock here
if
(
instance
)
return
instance
;
std
::
lock_guard
<
std
::
mutex
>
lock
(
mut
);
if
(
instance
)
return
instance
;
void
MariaDB
::
initialize
(){
instance
=
new
MariaDB
();
}
return
instance
=
new
MariaDB
();
MariaDB
*
MariaDB
::
getInstance
(){
std
::
call_once
(
init_once
,
&
MariaDB
::
initialize
);
return
instance
;
}
bool
MariaDB
::
initializeConnection
(
const
std
::
string
&
host
,
const
std
::
string
&
user
,
...
...
analytics/operators/persystsql/MariaDB.h
View file @
10efbb0e
...
...
@@ -62,6 +62,7 @@ protected:
MariaDB
();
virtual
~
MariaDB
();
static
void
initialize
();
MYSQL
*
_mysql
;
Rotation_t
_rotation
;
...
...
@@ -72,6 +73,7 @@ protected:
static
MariaDB
*
instance
;
static
std
::
mutex
mut
;
static
std
::
once_flag
init_once
;
bool
_initialized
;
std
::
map
<
std
::
string
,
Job_info_t
>
_jobCache
;
const
std
::
size_t
JOB_CACHE_MAX_SIZE
=
10000
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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