Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
4a909584
Commit
4a909584
authored
Jun 21, 2018
by
Steven Murray
Browse files
cta/CTA#287 Admin users should be cached
Done.
parent
eeabd288
Changes
2
Hide whitespace changes
Inline
Side-by-side
catalogue/RdbmsCatalogue.cpp
View file @
4a909584
...
...
@@ -54,7 +54,8 @@ RdbmsCatalogue::RdbmsCatalogue(
m_tapeCopyToPoolCache
(
10
),
m_groupMountPolicyCache
(
10
),
m_userMountPolicyCache
(
10
),
m_expectedNbArchiveRoutesCache
(
10
)
{
m_expectedNbArchiveRoutesCache
(
10
),
m_isAdminCache
(
10
)
{
}
//------------------------------------------------------------------------------
...
...
@@ -4378,6 +4379,38 @@ RequesterAndGroupMountPolicies RdbmsCatalogue::getMountPolicies(
// isAdmin
//------------------------------------------------------------------------------
bool
RdbmsCatalogue
::
isAdmin
(
const
common
::
dataStructures
::
SecurityIdentity
&
admin
)
const
{
try
{
return
isCachedAdmin
(
admin
);
}
catch
(
exception
::
UserError
&
)
{
throw
;
}
catch
(
exception
::
Exception
&
ex
)
{
ex
.
getMessage
().
str
(
std
::
string
(
__FUNCTION__
)
+
": "
+
ex
.
getMessage
().
str
());
throw
;
}
}
//------------------------------------------------------------------------------
// isCachedAdmin
//------------------------------------------------------------------------------
bool
RdbmsCatalogue
::
isCachedAdmin
(
const
common
::
dataStructures
::
SecurityIdentity
&
admin
)
const
{
try
{
auto
getNonCachedValue
=
[
&
]
{
return
isNonCachedAdmin
(
admin
);
};
return
m_isAdminCache
.
getCachedValue
(
admin
,
getNonCachedValue
);
}
catch
(
exception
::
UserError
&
)
{
throw
;
}
catch
(
exception
::
Exception
&
ex
)
{
ex
.
getMessage
().
str
(
std
::
string
(
__FUNCTION__
)
+
": "
+
ex
.
getMessage
().
str
());
throw
;
}
}
//------------------------------------------------------------------------------
// isNonCachedAdmin
//------------------------------------------------------------------------------
bool
RdbmsCatalogue
::
isNonCachedAdmin
(
const
common
::
dataStructures
::
SecurityIdentity
&
admin
)
const
{
try
{
const
char
*
const
sql
=
"SELECT "
...
...
catalogue/RdbmsCatalogue.hpp
View file @
4a909584
...
...
@@ -1143,6 +1143,24 @@ protected:
*/
void
checkTapeFileWrittenFieldsAreSet
(
const
std
::
string
&
callingFunc
,
const
TapeFileWritten
&
event
)
const
;
/**
* Returns a cached version of the result of calling isAdmin().
*
* @param admin The administrator.
* @return True if the specified user has administrator privileges.
*/
bool
isCachedAdmin
(
const
common
::
dataStructures
::
SecurityIdentity
&
admin
)
const
;
/**
* Returns true if the specified user has administrator privileges.
*
* Please note that this method always queries the Catalogue database.
*
* @param admin The administrator.
* @return True if the specified user has administrator privileges.
*/
bool
isNonCachedAdmin
(
const
common
::
dataStructures
::
SecurityIdentity
&
admin
)
const
;
/**
* Cached versions of tape copy to tape tape pool mappings for specific
* storage classes.
...
...
@@ -1167,6 +1185,11 @@ protected:
*/
mutable
TimeBasedCache
<
StorageClass
,
uint64_t
>
m_expectedNbArchiveRoutesCache
;
/**
* Cached version of isAdmin() results.
*/
mutable
TimeBasedCache
<
common
::
dataStructures
::
SecurityIdentity
,
bool
>
m_isAdminCache
;
};
// class RdbmsCatalogue
}
// namespace catalogue
...
...
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