Class MetroRegistry
MetroId so lookups
work for metros the MetroCode enum does not list. This is the authoritative, always-current
set of metros (and their IBX data centers) - built by loading fabric.metros().list() once
and caching the result - for code that needs to discover or validate metros rather than hard-code
the enum.
Cross-source enrichment. Fabric's metros carry the metro-level picture (centroid
coordinates, connected-metro latency, IBX codes) but no per-IBX detail; that lives in
EIA's /internetAccess/v2/ibxs (per-IBX coordinates, country, metro association). When
built with EquinixConfig.enrichMetroRegistry (or via load(Metros, Collection)),
the registry merges both so it is the SDK's most complete location directory: ibx(String)
returns the full EIA Ibx - ready for design.geo.SpeedOfLightLatency IBX-to-IBX
math. The registry is deliberately cross-domain in that mode (fabric + internetaccess data, one
lookup surface).
Each snapshot is immutable and swapped atomically: refresh() re-reads the same
sources the registry was loaded from (the Metros API, plus the per-IBX source when enriched) and
publishes a new snapshot in place, so every existing reference to the registry sees the fresh
catalogue. Fabric.reloadMetroRegistry() delegates to it.
MetroRegistry registry = fabric.metroRegistry();
registry.get("SV").ifPresent(m -> System.out.println(m.getName() + " " + m.getIbxs()));
boolean exists = registry.contains(newMetroCode); // works even if not in the MetroCode enum
registry.refresh(); // re-pull metros (+ IBX detail) at runtime
// With EquinixConfig.enrichMetroRegistry(true):
Ibx sv5 = registry.ibx("SV5").orElseThrow();
double ms = SpeedOfLightLatency.roundTrip().millisBetween(sv5, registry.ibx("LA4").orElseThrow());
- Author:
- ianjones
-
Method Summary
Modifier and TypeMethodDescriptionall()booleanbooleanLooks up per-IBX detail (coordinates, country, metro association) merged in at load time.ibxDetails(String metroCode) Returns the enriched per-IBX records associated with a metro (matched on the record's ownmetroCode).booleanstatic MetroRegistryLoads the registry by fetching every metro from the Metros API.static MetroRegistryload(Metros metros, Collection<? extends Ibx> ibxDetails) Loads the registry and enriches it with a fixed set of per-IBX records.static MetroRegistryload(Metros metros, Supplier<Collection<? extends Ibx>> ibxSource) Loads the registry with a re-invocable per-IBX source (typically the EIA ibx catalogue - see the class notes on cross-source enrichment).metroIds()refresh()Re-reads this registry's sources - the Metros API, and the per-IBX source when it was loaded with one - and atomically replaces the cached snapshot, so the registry reflects the live catalogue (new metros, new IBXes, coordinate updates) without rebuilding references to it.intsize()
-
Method Details
-
load
Loads the registry by fetching every metro from the Metros API. Metros are keyed by theirMetroId(the exact wire code), so distinct unlisted metros do not collide.- Parameters:
metros- the Metros client to read from (e.g.fabric.metros())- Returns:
- a populated registry
-
load
Loads the registry and enriches it with a fixed set of per-IBX records.refresh()re-reads the Metros API but re-applies these same records; preferload(Metros, Supplier)when the per-IBX source should also be re-queried at refresh time.- Parameters:
metros- the Metros client to read from (e.g.fabric.metros())ibxDetails- per-IBX records to merge in (empty for an un-enriched registry)- Returns:
- a populated registry
-
load
Loads the registry with a re-invocable per-IBX source (typically the EIA ibx catalogue - see the class notes on cross-source enrichment). The source is queried once now and again on everyrefresh(). IBXes are keyed case-insensitively byibxCode; duplicates keep the first occurrence.- Parameters:
metros- the Metros client to read from (e.g.fabric.metros())ibxSource- supplies per-IBX records to merge in (empty collection for un-enriched)- Returns:
- a populated registry
-
refresh
Re-reads this registry's sources - the Metros API, and the per-IBX source when it was loaded with one - and atomically replaces the cached snapshot, so the registry reflects the live catalogue (new metros, new IBXes, coordinate updates) without rebuilding references to it. Thread-safe: readers see either the old snapshot or the new one, never a mix.- Returns:
- this registry, refreshed
-
get
-
get
-
get
-
contains
- Parameters:
code- the raw metro code; case-insensitive- Returns:
trueif this registry contains a metro with that code
-
contains
- Parameters:
code- a well-known metro code- Returns:
trueif this registry contains that metro
-
all
- Returns:
- all metros in the registry (unmodifiable)
-
metroIds
-
ibxs
-
size
public int size()- Returns:
- the number of metros in the registry
-
ibx
Looks up per-IBX detail (coordinates, country, metro association) merged in at load time. Populated only when the registry was built with enrichment - seeEquinixConfig.enrichMetroRegistryand the class notes.- Parameters:
ibxCode- the IBX data-center code (e.g."SV5"); case-insensitive- Returns:
- the IBX record, or empty if unknown or the registry is not enriched
-
ibxDetails
Returns the enriched per-IBX records associated with a metro (matched on the record's ownmetroCode). Empty when the registry is not enriched or the metro has no records -ibxs(String)still lists the metro's IBX codes from Fabric either way.- Parameters:
metroCode- the metro code (e.g."SV"); case-insensitive- Returns:
- the IBX records within that metro (unmodifiable)
-
isEnriched
public boolean isEnriched()- Returns:
trueif this registry carries merged per-IBX detail (built withEquinixConfig.enrichMetroRegistryand the EIA fetch succeeded)
-