Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
eos
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
JIRA
JIRA
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dss
eos
Commits
e71d3201
Commit
e71d3201
authored
Feb 11, 2019
by
Georgios Bitzes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MGM: Refactor some duplicated code in QDG config engine
parent
659083e0
Pipeline
#699724
canceled with stages
in 4 minutes and 12 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
49 deletions
+28
-49
IConfigEngine.hh
mgm/config/IConfigEngine.hh
+0
-8
QuarkDBConfigEngine.cc
mgm/config/QuarkDBConfigEngine.cc
+26
-39
QuarkDBConfigEngine.hh
mgm/config/QuarkDBConfigEngine.hh
+2
-2
No files found.
mgm/config/IConfigEngine.hh
View file @
e71d3201
...
...
@@ -275,14 +275,6 @@ public:
mAutosave
=
val
;
}
//----------------------------------------------------------------------------
//! Get the autosave mode
//----------------------------------------------------------------------------
bool
GetAutoSave
()
{
return
mAutosave
;
}
static
std
::
string
formFullKey
(
const
char
*
prefix
,
const
char
*
key
)
{
if
(
prefix
)
{
...
...
mgm/config/QuarkDBConfigEngine.cc
View file @
e71d3201
...
...
@@ -191,28 +191,15 @@ QuarkDBConfigEngine::SaveConfig(XrdOucEnv& env, XrdOucString& err)
std
::
string
hash_key
=
formConfigHashKey
(
name
);
qclient
::
QHash
q_hash
(
*
mQcl
,
hash_key
);
if
(
q_hash
.
hlen
()
>
0
)
{
if
(
force
)
{
// Create backup
std
::
string
hash_key_backup
=
formBackupConfigHashKey
(
name
,
time
(
NULL
));
// Backup hash
mQcl
->
exec
(
"hclone"
,
hash_key
,
hash_key_backup
).
get
();
// Clear
mQcl
->
exec
(
"del"
,
hash_key
).
get
();
}
else
{
errno
=
EEXIST
;
err
=
"error: a configuration with name
\"
"
;
err
+=
name
;
err
+=
"
\"
exists already!"
;
return
false
;
}
}
{
XrdSysMutexHelper
lock
(
mMutex
);
storeIntoQuarkDB
(
hash_key
);
if
(
q_hash
.
hlen
()
>
0
&&
!
force
)
{
errno
=
EEXIST
;
err
=
"error: a configuration with name
\"
"
;
err
+=
name
;
err
+=
"
\"
exists already!"
;
return
false
;
}
storeIntoQuarkDB
(
name
);
std
::
ostringstream
changeLogValue
;
if
(
force
)
{
...
...
@@ -548,26 +535,15 @@ QuarkDBConfigEngine::PushToQuarkDB(XrdOucEnv& env, XrdOucString& err)
std
::
string
hash_key
=
formConfigHashKey
(
name
.
c_str
());
qclient
::
QHash
q_hash
(
*
mQcl
,
hash_key
);
if
(
q_hash
.
hlen
()
>
0
)
{
if
(
force
)
{
// Create backup
std
::
string
hash_key_backup
=
formBackupConfigHashKey
(
name
.
c_str
(),
time
(
NULL
));
// Backup hash
mQcl
->
exec
(
"hclone"
,
hash_key
,
hash_key_backup
);
// Clear
mQcl
->
exec
(
"del"
,
hash_key
);
}
else
{
errno
=
EEXIST
;
err
=
"error: a configuration with name
\"
"
;
err
+=
name
.
c_str
();
err
+=
"
\"
exists already on QuarkDB!"
;
return
false
;
}
if
(
q_hash
.
hlen
()
>
0
&&
!
force
)
{
errno
=
EEXIST
;
err
=
"error: a configuration with name
\"
"
;
err
+=
name
.
c_str
();
err
+=
"
\"
exists already on QuarkDB!"
;
return
false
;
}
mMutex
.
Lock
();
storeIntoQuarkDB
(
hash_key
);
mMutex
.
UnLock
();
storeIntoQuarkDB
(
name
);
mChangelog
->
AddEntry
(
"exported config"
,
name
.
c_str
(),
"successfully"
);
mConfigFile
=
name
.
c_str
();
return
true
;
...
...
@@ -585,9 +561,20 @@ QuarkDBConfigEngine::PushToQuarkDB(XrdOucEnv& env, XrdOucString& err)
//------------------------------------------------------------------------------
// Store configuration into given keyname
//------------------------------------------------------------------------------
void
QuarkDBConfigEngine
::
storeIntoQuarkDB
(
const
std
::
string
&
keyname
)
{
void
QuarkDBConfigEngine
::
storeIntoQuarkDB
(
const
std
::
string
&
name
)
{
// Create backup
std
::
string
hash_key_backup
=
formBackupConfigHashKey
(
name
.
c_str
(),
time
(
NULL
));
std
::
string
keyname
=
formConfigHashKey
(
name
);
// Backup hash
mQcl
->
exec
(
"hclone"
,
keyname
,
hash_key_backup
);
// Clear
mQcl
->
exec
(
"del"
,
keyname
);
std
::
vector
<
std
::
future
<
qclient
::
redisReplyPtr
>>
replies
;
XrdSysMutexHelper
lock
(
mMutex
);
for
(
auto
it
=
sConfigDefinitions
.
begin
();
it
!=
sConfigDefinitions
.
end
();
it
++
)
{
replies
.
emplace_back
(
mQcl
->
exec
(
"hset"
,
keyname
,
it
->
first
,
it
->
second
));
}
...
...
mgm/config/QuarkDBConfigEngine.hh
View file @
e71d3201
...
...
@@ -196,9 +196,9 @@ public:
private
:
//----------------------------------------------------------------------------
// Store configuration into given
key
name
// Store configuration into given name
//----------------------------------------------------------------------------
void
storeIntoQuarkDB
(
const
std
::
string
&
key
name
);
void
storeIntoQuarkDB
(
const
std
::
string
&
name
);
QdbContactDetails
mQdbContactDetails
;
qclient
::
QClient
*
mQcl
;
...
...
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