Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
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
RadioObservatory
LOFAR
Commits
87fcd3f8
Commit
87fcd3f8
authored
6 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
SW-448
: skip already updated cache entries
parent
7c264775
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/DataManagement/StorageQueryService/cache.py
+21
-17
21 additions, 17 deletions
SAS/DataManagement/StorageQueryService/cache.py
with
21 additions
and
17 deletions
SAS/DataManagement/StorageQueryService/cache.py
+
21
−
17
View file @
87fcd3f8
...
...
@@ -307,20 +307,24 @@ class CacheManager:
for
i
,
cache_entry
in
enumerate
(
updateable_entries
):
try
:
path
=
cache_entry
.
get
(
'
path
'
)
if
path
:
logger
.
info
(
'
_updateOldEntriesInCache: examining entry %s/%s. timestamp:%s age:%s needs_update:%s path:
\'
%s
\'
'
,
i
,
len
(
updateable_entries
),
cache_entry
[
'
cache_timestamp
'
],
format_timedelta
(
now
-
cache_entry
[
'
cache_timestamp
'
]),
cache_entry
.
get
(
'
needs_update
'
,
False
),
path
)
#du a full update from disk, which might be (really) slow.
result
=
du_getDiskUsageForPath
(
path
)
logger
.
debug
(
'
trying to update old entry in cache: %s
'
,
result
)
self
.
_updateCache
(
result
)
# it might be that the cache_entry was already updated via another way
# so only update it if still to old or needs_update
now
=
datetime
.
datetime
.
utcnow
()
if
now
-
cache_entry
[
'
cache_timestamp
'
]
>
MAX_CACHE_ENTRY_AGE
or
cache_entry
.
get
(
'
needs_update
'
,
False
):
path
=
cache_entry
.
get
(
'
path
'
)
if
path
:
logger
.
info
(
'
_updateOldEntriesInCache: examining entry %s/%s. timestamp:%s age:%s needs_update:%s path:
\'
%s
\'
'
,
i
,
len
(
updateable_entries
),
cache_entry
[
'
cache_timestamp
'
],
format_timedelta
(
now
-
cache_entry
[
'
cache_timestamp
'
]),
cache_entry
.
get
(
'
needs_update
'
,
False
),
path
)
#du a full update from disk, which might be (really) slow.
result
=
du_getDiskUsageForPath
(
path
)
logger
.
debug
(
'
trying to update old entry in cache: %s
'
,
result
)
self
.
_updateCache
(
result
)
except
Exception
as
e
:
logger
.
error
(
str
(
e
))
...
...
@@ -328,8 +332,8 @@ class CacheManager:
logger
.
info
(
'
exiting _updateCacheThread
'
)
return
if
datetime
.
datetime
.
utcnow
()
-
cacheUpdateStart
>
datetime
.
timedelta
(
minutes
=
5
):
# break out of cache update loop if full update takes more than
5
min
if
datetime
.
datetime
.
utcnow
()
-
cacheUpdateStart
>
datetime
.
timedelta
(
minutes
=
10
):
# break out of cache update loop if full update takes more than
1
min
# next loop we'll start with the oldest cache entries again
logger
.
info
(
'
skipping remaining %s old cache entries updates, they will be updated next time
'
,
len
(
updateable_entries
)
-
i
)
break
...
...
@@ -338,7 +342,7 @@ class CacheManager:
self
.
_updateCEP4CapacitiesInRADB
()
#sleep for a while, (or stop if requested)
for
i
in
range
(
3
0
):
for
i
in
range
(
1
0
):
sleep
(
1
)
if
not
self
.
_cacheThreadsRunning
:
logger
.
info
(
'
exiting _updateCacheThread
'
)
...
...
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