swh.objstorage.backends.winery.objstorage module#

class swh.objstorage.backends.winery.objstorage.WineryObjStorage(database: Database, shards: Shards, shards_pool: ShardsPool, packer: Packer | None = None, readonly: bool = False, allow_delete: bool = False, name: str = 'winery', readers_cache_size: int = 1000)[source]#

Bases: ObjStorage

primary_hash: Literal['sha1', 'sha256'] = 'sha256'#
name: str = 'winery'#

Default objstorage name; can be overloaded at instantiation time giving a ‘name’ argument to the constructor

reader: WineryReader#
writer: WineryWriter | None#
get(obj_id: HashDict) bytes[source]#

Retrieve the content of a given object.

Parameters:

obj_id – object id.

Returns:

the content of the requested object as bytes.

Raises:

ObjNotFoundError – if the requested object is missing.

check_config(*, check_write: bool) bool[source]#

Check whether the object storage is properly configured.

Parameters:
  • check_write (bool) – if True, check if writes to the object storage

  • succeed. (can)

Returns:

True if the configuration check worked, False if ‘check_write’ is True and the object storage is actually read only, and an exception if the check failed.

add(content: bytes, obj_id: HashDict, check_presence: bool = True) None[source]#

Add a new object to the object storage.

Parameters:
  • content – object’s raw content to add in storage.

  • obj_id – dict of checksums.

  • check_presence (bool) – indicate if the presence of the content should be verified before adding the file.

Returns:

the id (bytes) of the object into the storage.

add_batch(contents: list[tuple[HashDict, bytes]], check_presence: bool = True) Dict[source]#

contents should be pairs of (obj_id, content)

delete(obj_id: HashDict)[source]#

Delete an object.

Parameters:

obj_id – object identifier.

Raises:

ObjNotFoundError – if the requested object is missing.

on_shutdown()[source]#
map_contents: Callable#
class swh.objstorage.backends.winery.objstorage.LRUDict(capacity: int)[source]#

Bases: OrderedDict

class swh.objstorage.backends.winery.objstorage.WineryReader(pool: Pool, database: Database, cache_size: int = 1000)[source]#

Bases: object

list_signatures(after_id: bytes | None = None, limit: int | None = None) Iterator[bytes][source]#
roshard(name) ROShard | None[source]#
rwshard(name) RWShard[source]#
get(obj_id: bytes) bytes[source]#
on_shutdown()[source]#
class swh.objstorage.backends.winery.objstorage.WineryWriter(packer_settings: Packer, shards_settings: Shards, shards_pool_settings: ShardsPool, database_settings: Database)[source]#

Bases: object

release_shard(shard: RWShard | None = None, from_idle_handler: bool = False, new_state: ShardState = ShardState.STANDBY)[source]#

Release the currently locked shard

property shard#

Lock a shard to be able to use it. Release it after idle_timeout.

add(content: bytes, obj_id: bytes) None[source]#
add_batch(contents: List[Tuple[bytes, bytes]]) Dict[source]#

contents should be pairs of (obj_id, content)

delete(obj_id: bytes)[source]#
check(obj_id: HashDict) None[source]#
pack(shard_name: str)[source]#
on_shutdown()[source]#