\Drupal\strata\Tier TierPlacementRebuilder

Rebuilds the placement index by listing every tier.

The placement table is a cache over which bucket holds which key, so it has to be reproducible from the buckets alone - an uninstall drops it, a restore into a fresh site starts without it, and a stale row is faster to rebuild than to repair. All three are this operation, and it is the reason the tier is never part of an object's name: the answer is recoverable by looking, and a name that encoded it would have to be rewritten instead.

Every tier is listed independently, so an object present in two of them ends up recorded in both rather than in whichever answered first.

A tier that cannot be listed is reported and its rows are left alone rather than cleared. Clearing them would turn an unreachable bucket into an empty one, and the whole point of the placement record is to be able to say where something is even while the bucket holding it is down.

Summary

Methods
Properties
Constants
__construct
rebuild
No public properties found
PAGE
No protected methods found
No protected properties found
No protected constants found
keysIn
router
placement
logger
No private constants found

Constant

PAGE

PAGE = 1000

How many keys to ask for per listing page.

Properties

$router

$router : \Drupal\strata\Tier\TieredProvider

Type

TieredProvider

$logger

$logger : \Psr\Log\LoggerInterface

Type

LoggerInterface

Methods

__construct()

__construct(\Drupal\strata\Tier\TieredProvider  $router, \Drupal\strata\Tier\PlacementIndexInterface  $placement, \Psr\Log\LoggerInterface  $logger) : mixed

Constructs a rebuilder.

Parameters

\Drupal\strata\Tier\TieredProvider $router

The store, listed one tier at a time.

\Drupal\strata\Tier\PlacementIndexInterface $placement

The index being rebuilt.

\Psr\Log\LoggerInterface $logger

Records progress, since a full rebuild over several buckets is not quick.

Returns

mixed —

rebuild()

rebuild(bool  $fresh = true, list  $problems = []) : array{objects: int, tiers: int}

Lists every tier and records what each one holds.

Parameters

bool $fresh

TRUE to drop the table first, which is the only way a row for an object that has moved goes away. FALSE tops up an index that is known to be merely incomplete. A fresh rebuild is downgraded to a top-up when any tier could not be listed, because clearing rows for a bucket nobody could read would report it as empty.

list $problems

Collects one line per tier that could not be listed.

Returns

array{objects: int, tiers: int} —

How many placements were recorded and how many tiers were read.

keysIn()

keysIn(int  $index) : array<string,int>

Every key one tier holds, with its size.

The whole tier rather than one site's prefix: a placement row describes where an object is, and an object shared between sites is in one place whoever asks.

Parameters

int $index

Tier index.

Returns

array

Object key keyed to its size.