Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-objstorage
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Show more breadcrumbs
Antoine Lambert
swh-objstorage
Commits
b08f4b08
Commit
b08f4b08
authored
3 years ago
by
Loïc Dachary
Committed by
Phabricator Migration user
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add winery backend
Summary: Related to: T3432 Reviewers: #reviewers
parent
37dcacf1
Branches
generated-differential-D6006-source
No related tags found
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/objstorage/backends/winery/__init__.py
+66
-0
66 additions, 0 deletions
swh/objstorage/backends/winery/__init__.py
swh/objstorage/tests/test_objstorage_winery.py
+18
-0
18 additions, 0 deletions
swh/objstorage/tests/test_objstorage_winery.py
with
84 additions
and
0 deletions
swh/objstorage/backends/winery/__init__.py
0 → 100644
+
66
−
0
View file @
b08f4b08
# Copyright (C) 2021 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import
abc
from
swh.objstorage.exc
import
Error
,
ObjNotFoundError
from
swh.objstorage.objstorage
import
ObjStorage
,
compute_hash
class
WineryObjStorageDriver
(
object
):
pass
class
WineryObjStorage
(
ObjStorage
,
metaclass
=
abc
.
ABCMeta
):
"""
ObjStorage that connect to a winery object storage
https://wiki.softwareheritage.org/wiki/A_practical_approach_to_efficiently_store_100_billions_small_objects_in_Ceph
Args:
kwargs: extra arguments are passed through to the winery
"""
def
__init__
(
self
,
**
kwargs
,
):
super
().
__init__
(
**
kwargs
)
self
.
driver
=
WineryObjStorageDriver
()
def
check_config
(
self
,
*
,
check_write
):
return
True
def
__contains__
(
self
,
obj_id
,
*
args
,
**
kwargs
):
return
obj_id
in
self
.
driver
def
add
(
self
,
content
,
obj_id
=
None
,
check_presence
=
True
,
*
args
,
**
kwargs
):
if
check_presence
is
True
:
if
obj_id
in
self
.
driver
:
return
obj_id
if
obj_id
is
None
:
obj_id
=
compute_hash
(
content
)
self
.
driver
[
obj_id
]
=
content
return
obj_id
def
get
(
self
,
obj_id
,
*
args
,
**
kwargs
):
if
obj_id
not
in
self
.
driver
:
raise
ObjNotFoundError
(
obj_id
)
return
self
.
driver
[
obj_id
]
def
check
(
self
,
obj_id
,
*
args
,
**
kwargs
):
if
obj_id
not
in
self
.
driver
:
raise
ObjNotFoundError
(
obj_id
)
if
obj_id
!=
compute_hash
(
self
.
driver
[
obj_id
]):
raise
Error
(
obj_id
)
def
delete
(
self
,
obj_id
,
*
args
,
**
kwargs
):
super
().
delete
(
obj_id
)
# Check delete permission
if
obj_id
not
in
self
.
driver
:
raise
ObjNotFoundError
(
obj_id
)
del
self
.
driver
[
obj_id
]
return
True
def
__iter__
(
self
):
for
k
in
sorted
(
self
.
driver
.
keys
()):
yield
k
This diff is collapsed.
Click to expand it.
swh/objstorage/tests/test_objstorage_winery.py
0 → 100644
+
18
−
0
View file @
b08f4b08
# Copyright (C) 2021 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import
unittest
from
..backends.winery
import
WineryObjStorage
from
.objstorage_testing
import
ObjStorageTestFixture
class
TestWineryObjStorage
(
ObjStorageTestFixture
,
unittest
.
TestCase
):
compression
=
"
none
"
def
setUp
(
self
):
super
().
setUp
()
self
.
url
=
"
http://127.0.0.1/test
"
self
.
storage
=
WineryObjStorage
()
self
.
storage
.
driver
=
{}
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