\Drupal\strata\Tier TierMap

The storage ladder, nearest first.

Shaped like LevelPolicy on purpose - an ordered list, validated to increase, folded coarsest-last

  • because it answers the same kind of question about the same history. It is a separate list rather than a tier key on each retention level for one reason: the retention ladder decides how coarse a segment's window becomes, and a site with five rollup levels and two buckets would otherwise have to invent three more buckets. The two dials stay independent and the settings form prints the retention cutoffs next to the age thresholds so they can be aligned deliberately.

Four rules are refused rather than warned about, because each one produces a store that looks configured and is not:

  • The nearest tier holds everything, so its age threshold is zero.
  • Thresholds increase. A tier that accepted younger objects than the tier below it would claim every object the tier below already holds.
  • Names are unique. A name is what a per-tier request count is filed under, and two tiers under one name make every figure downstream wrong.
  • Bucket addresses are unique. Two tiers pointing at one bucket turn a move into a delete and a replica into a claim about durability that is not true.

Summary

Methods
Properties
Constants
__construct
fromSettings
count
all
nearest
coldest
at
has
indexes
names
forAge
isSplit
jsonSerialize
No public properties found
MAX_TIERS
No protected methods found
No protected properties found
No protected constants found
No private methods found
tiers
No private constants found

Constant

MAX_TIERS

MAX_TIERS = 8

Most tiers one ladder may have.

An absent key costs one request per tier to establish that it is absent, so the ladder depth is a direct multiplier on the cost of every miss. Eight is far past any real deployment and is here to stop a mistyped configuration turning one head into hundreds.

Properties

$tiers

$tiers : list<\Drupal\strata\Tier\Tier>

The tiers, nearest first.

Type

array<int, Tier> —

Methods

__construct()

__construct(list<\Drupal\strata\Tier\Tier>  $tiers) : mixed

Constructs a ladder.

Parameters

list<\Drupal\strata\Tier\Tier> $tiers

The tiers, nearest first. Indexes are taken from position rather than from the objects, so a caller cannot build a ladder whose indexes disagree with its order.

Throws

\InvalidArgumentException

When the ladder is empty, deeper than TierMap::MAX_TIERS, has a non-zero nearest threshold, has thresholds that do not increase, or repeats a name or a bucket address.

Returns

mixed —

fromSettings()

fromSettings(bool  $enabled, array>  $configured) : self|null

Builds a ladder from the module's settings, or nothing when tiering is off.

A single tier is not tiering. One tier is exactly what an untiered site already does, so returning NULL there keeps Engine on the single-provider path rather than wrapping it in a router that would route to one place.

Parameters

bool $enabled

The tiers.enabled setting.

array> $configured

The tiers.levels setting.

Throws

\InvalidArgumentException

When the configured ladder breaks one of the four rules.

Returns

self|null —

The ladder, or NULL when tiering is off or fewer than two tiers are configured.

count()

count() : int

How many tiers the ladder has.

Returns

int —

The count.

all()

all() : list<\Drupal\strata\Tier\Tier>

Every tier, nearest first.

Returns

list<\Drupal\strata\Tier\Tier> —

The tiers.

nearest()

nearest() : \Drupal\strata\Tier\Tier

The tier writes land in.

Returns

\Drupal\strata\Tier\Tier —

Tier zero.

coldest()

coldest() : \Drupal\strata\Tier\Tier

The furthest tier.

Returns

\Drupal\strata\Tier\Tier —

The last tier on the ladder.

at()

at(int  $index) : \Drupal\strata\Tier\Tier

One tier by index.

Parameters

int $index

Position on the ladder.

Throws

\InvalidArgumentException

When the index is not on the ladder.

Returns

\Drupal\strata\Tier\Tier —

The tier.

has()

has(int  $index) : bool

Whether an index names a tier.

Parameters

int $index

Position on the ladder.

Returns

bool —

TRUE when the tier exists.

indexes()

indexes() : list<int>

Every tier index, nearest first.

Returns

list

The indexes.

names()

names() : array<int,string>

Tier names keyed by index.

Returns

array

Names, for a report table and for the per-tier request counts.

forAge()

forAge(int  $age) : \Drupal\strata\Tier\Tier

The tier an object of a given age belongs in.

The coldest tier whose threshold the age has reached, so an object older than every threshold lands at the end of the ladder rather than partway along it.

Parameters

int $age

Seconds since the object was last written.

Returns

\Drupal\strata\Tier\Tier —

The tier, which is the nearest one for anything younger than the first threshold.

isSplit()

isSplit() : bool

Whether any tier moves objects rather than replicating them.

A ladder where every tier retains the copy below it keeps the near tier complete, so a read never reaches a far tier and a far tier being down costs nothing but the second copy. A ladder with one destination tier splits history across buckets, and that is what makes a far tier's reachability part of whether a restore can run.

Returns

bool —

TRUE when at least one tier discards the copy below it.

jsonSerialize()

jsonSerialize() : list<array<string,mixed>>

{@inheritdoc}

Returns

list> —

The ladder as plain arrays for a report table.