Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
chaosframework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
chaos-lnf-control
chaosframework
Commits
996210c6
Commit
996210c6
authored
3 years ago
by
Andrea Michelotti
Browse files
Options
Downloads
Patches
Plain Diff
fixing map issue
parent
7a373981
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
chaos/common/caching_system/CacheDriver.cpp
+18
-21
18 additions, 21 deletions
chaos/common/caching_system/CacheDriver.cpp
chaos/common/data/cache/AttributeCache.cpp
+2
-2
2 additions, 2 deletions
chaos/common/data/cache/AttributeCache.cpp
with
20 additions
and
23 deletions
chaos/common/caching_system/CacheDriver.cpp
+
18
−
21
View file @
996210c6
...
...
@@ -26,9 +26,9 @@ using namespace chaos::common::cache_system;
CacheDriver
::
CacheDriver
(
std
::
string
alias
)
:
NamedService
(
alias
)
{
enable_cache_for_ms
.
clear
();
first_level_cache
.
clear
();
}
enable_cache_for_ms
.
clear
();
first_level_cache
.
clear
();
}
CacheDriver
::~
CacheDriver
()
{}
...
...
@@ -47,16 +47,15 @@ void CacheDriver::init(void* init_data) {
}
//! deinit
void
CacheDriver
::
deinit
()
{
void
CacheDriver
::
deinit
()
{
enable_cache_for_ms
.
clear
();
first_level_cache
.
clear
();
}
chaos
::
common
::
data
::
CDWShrdPtr
CacheDriver
::
getData
(
const
std
::
string
&
key
)
{
if
((
enable_cache_for_ms
.
count
(
key
))
&&
(
first_level_cache
.
count
(
key
)))
{
uint64_t
now
=
chaos
::
common
::
utility
::
TimingUtil
::
getTimeStamp
();
if
((
now
-
first_level_cache
[
key
].
first
)
<
enable_cache_for_ms
[
key
])
{
// LDBG_ << "retrive from caching:" << key;
// LDBG_ << "retrive from caching:" << key;
return
first_level_cache
[
key
].
second
;
}
...
...
@@ -69,8 +68,7 @@ chaos::common::data::CDWShrdPtr CacheDriver::getData(const std::string& key) {
ret
.
reset
(
tmp
);
if
(
enable_cache_for_ms
.
count
(
key
))
{
uint64_t
now
=
chaos
::
common
::
utility
::
TimingUtil
::
getTimeStamp
();
// LDBG_ << "mupdate caching:" << key;
// LDBG_ << "mupdate caching:" << key;
first_level_cache
[
key
]
=
{
now
,
ret
};
}
}
...
...
@@ -100,17 +98,17 @@ std::vector<chaos::common::data::CDWShrdPtr> CacheDriver::getData(const ChaosStr
}
else
{
ChaosStringVector
nocached
;
for
(
ChaosStringVector
::
const_iterator
i
=
keys
.
begin
();
i
!=
keys
.
end
();
i
++
)
{
if
((
enable_cache_for_ms
.
count
(
*
i
))
&&
(
first_level_cache
.
count
(
*
i
))){
if
((
now
-
first_level_cache
[
*
i
].
first
)
<
enable_cache_for_ms
[
*
i
])
{
if
((
enable_cache_for_ms
.
count
(
*
i
))
&&
(
first_level_cache
.
count
(
*
i
)))
{
if
((
now
-
first_level_cache
[
*
i
].
first
)
<
enable_cache_for_ms
[
*
i
])
{
is_cached
[
*
i
]
=
true
;
}
else
{
nocached
.
push_back
(
*
i
);
is_cached
[
*
i
]
=
false
;
}
}
else
{
}
}
else
{
nocached
.
push_back
(
*
i
);
is_cached
[
*
i
]
=
false
;
}
}
res
=
getData
(
nocached
,
multi_cached_data
);
}
...
...
@@ -126,22 +124,21 @@ std::vector<chaos::common::data::CDWShrdPtr> CacheDriver::getData(const ChaosStr
}
else
{
chaos
::
common
::
data
::
CDWShrdPtr
r
=
chaos
::
common
::
data
::
CDWShrdPtr
(
new
chaos
::
common
::
data
::
CDataWrapper
(
cached_element
->
data
(),
cached_element
->
size
()));
ret
.
push_back
(
r
);
if
(
enable_cache_for_ms
.
count
(
*
it
)){
if
(
enable_cache_for_ms
[
*
it
]
>
0
)
{
// LDBG_ << "mupdate caching:" << *it;
first_level_cache
[
*
it
]
=
{
now
,
r
};
}
if
(
enable_cache_for_ms
.
count
(
*
it
))
{
if
(
enable_cache_for_ms
[
*
it
]
>
0
)
{
// LDBG_ << "mupdate caching:" << *it;
first_level_cache
[
*
it
]
=
{
now
,
r
};
}
}
}
}
else
{
// LDBG_ << "mretrive from caching:" << *it;
// LDBG_ << "mretrive from caching:" << *it;
ret
.
push_back
(
first_level_cache
[
*
it
].
second
);
}
}
}
else
{
LERR_
<<
__PRETTY_FUNCTION__
<<
" Error getting data from cache, ret:"
<<
res
;
LERR_
<<
__PRETTY_FUNCTION__
<<
" Error getting data from cache, ret:"
<<
res
;
}
return
ret
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
chaos/common/data/cache/AttributeCache.cpp
+
2
−
2
View file @
996210c6
...
...
@@ -49,7 +49,7 @@ void AttributeCache::addAttribute(const string& name,
chaos
::
DataType
::
DataType
type
,
const
std
::
vector
<
chaos
::
DataType
::
BinarySubtype
>&
sub_type
)
{
if
(
mapAttributeNameIndex
.
count
(
name
))
{
//
L
ERR
_<<__PRETTY_FUNCTION__<<" Attribute name '"<<name<<"' exists";
L
DBG
_
<<
__PRETTY_FUNCTION__
<<
" Attribute name '"
<<
name
<<
"' exists"
;
return
;
}
...
...
@@ -88,7 +88,7 @@ void AttributeCache::addAttribute(const string& name,
void
AttributeCache
::
addAttribute
(
const
std
::
string
&
name
,
const
chaos
::
common
::
data
::
CDataVariant
&
value
)
{
if
(
mapAttributeNameIndex
.
count
(
name
))
{
L
ERR
_
<<
__PRETTY_FUNCTION__
<<
" Attribute name '"
<<
name
<<
"' exists"
;
L
DBG
_
<<
__PRETTY_FUNCTION__
<<
" Attribute name '"
<<
name
<<
"' exists"
;
return
;
}
uint32_t
size
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment