swh.objstorage.backends.winery.roshard module#
- swh.objstorage.backends.winery.roshard.record_shard_mapped(base: SharedBase, shard_name: str)[source]#
Record a shard as mapped, bailing out after a few attempts.
Multiple attempts are used to handle a race condition when two hosts attempt to record the shard as mapped at the same time. In this situation, one of the two hosts will succeed and the other one will fail, the sleep delay can be kept short and linear.
- swh.objstorage.backends.winery.roshard.manage_images(pool: Pool, base_dsn: str, manage_rw_images: bool, wait_for_image: Callable[[int], None], stop_running: Callable[[], bool], only_prefix: str | None = None, application_name: str | None = None) None[source]#
Manage RBD image creation and mapping automatically.
- Parameters:
base_dsn – the DSN of the connection to the SharedBase
manage_rw_images – whether RW images should be created and mapped
wait_for_image – function which is called at each loop iteration, with an attempt number, if no images had to be mapped recently
stop_running – callback that returns True when the manager should stop running
only_prefix – only map images with the given name prefix
application_name – the application name sent to PostgreSQL
- class swh.objstorage.backends.winery.roshard.ROShardCreator(name: str, count: int, pool: ~swh.objstorage.backends.winery.pools.Pool, rbd_create_images: bool = True, rbd_wait_for_image: ~typing.Callable[[int], None] = <function sleep_exponential.<locals>.sleep>, **kwargs)[source]#
Bases:
objectHelper for Read-Only shard creation.
- Parameters:
name – Name of the shard to be initialized
count – Number of objects to provision in the shard
rbd_create_images – whether the ROShardCreator should create the rbd image, or delegate to the rbd_shard_manager
rbd_wait_for_image – function called when waiting for a shard to be mapped
shard_max_size – the size of the shard, passed to
Poolrbd_* – other RBD-related
Poolarguments