Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-archiver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Platform
Development
swh-archiver
Commits
d049805b
Commit
d049805b
authored
8 years ago
by
Antoine R. Dumont
Browse files
Options
Downloads
Patches
Plain Diff
Archiver: Adapt ArchiverToBackendDirector to latest storage api
parent
fa1acdf9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/archiver/director.py
+11
-15
11 additions, 15 deletions
swh/archiver/director.py
with
11 additions
and
15 deletions
swh/archiver/director.py
+
11
−
15
View file @
d049805b
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
import
abc
import
abc
import
click
import
click
from
swh.core
import
config
from
swh.core
import
config
,
utils
from
swh.scheduler.celery_backend.config
import
app
from
swh.scheduler.celery_backend.config
import
app
from
.
import
tasks
# noqa
from
.
import
tasks
# noqa
...
@@ -177,11 +177,10 @@ class ArchiverToBackendDirector(ArchiverDirectorBase):
...
@@ -177,11 +177,10 @@ class ArchiverToBackendDirector(ArchiverDirectorBase):
self
.
storage
=
Storage
(
storage
[
'
dbconn
'
],
storage
[
'
objroot
'
])
self
.
storage
=
Storage
(
storage
[
'
dbconn
'
],
storage
[
'
objroot
'
])
self
.
destination_host
=
self
.
config
[
'
destination
'
][
'
host
'
]
self
.
destination_host
=
self
.
config
[
'
destination
'
][
'
host
'
]
def
read_cache_content_from_storage
(
self
,
last_content
=
None
):
def
read_cache_content_from_storage_by_batch
(
self
,
batch_max_size
):
for
content
in
self
.
storage
.
cache_content_get
(
for
contents
in
utils
.
grouper
(
self
.
storage
.
cache_content_get
(),
last_content
=
last_content
,
batch_max_size
):
limit
=
self
.
config
[
'
batch_max_size
'
]):
yield
contents
yield
{
'
content_id
'
:
content
[
'
sha1
'
]}
def
get_contents_to_archive
(
self
):
def
get_contents_to_archive
(
self
):
"""
Create batch of contents that needs to be archived
"""
Create batch of contents that needs to be archived
...
@@ -190,24 +189,21 @@ class ArchiverToBackendDirector(ArchiverDirectorBase):
...
@@ -190,24 +189,21 @@ class ArchiverToBackendDirector(ArchiverDirectorBase):
sha1 of content to archive
sha1 of content to archive
"""
"""
last_content
=
None
for
contents
in
self
.
read_cache_content_from_storage_by_batch
(
while
True
:
self
.
config
[
'
batch_max_size
'
]):
content_ids
=
list
(
content_ids
=
[{
'
content_id
'
:
c
[
'
sha1
'
]}
for
c
in
contents
]
self
.
read_cache_content_from_storage
(
last_content
))
if
not
content_ids
:
if
not
content_ids
:
return
continue
# Keep the last known content
last_content
=
content_ids
[
-
1
][
'
content_id
'
]
# Filter the known
content_ids
=
list
(
content_ids
=
list
(
self
.
archiver_storage
.
content_archive_get_missing
(
self
.
archiver_storage
.
content_archive_get_missing
(
content_ids
=
content_ids
,
content_ids
=
content_ids
,
backend_name
=
self
.
destination_host
))
backend_name
=
self
.
destination_host
))
if
not
content_ids
:
if
not
content_ids
:
return
continue
print
(
'
Sending %s new contents for archive
'
%
len
(
content_ids
))
print
(
'
Sending %s new contents for archive
'
%
len
(
content_ids
))
...
...
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