private UpstreamState findUpstreamState(Upstream upstream) {
        for (UpstreamState upstreamState : upstreamStates) {
            if (upstreamState.getUpstream().equals(upstream)) {
                return upstreamState;
            }
        }
        throw new IllegalArgumentException("Upstream is not found: " + upstream);
    }
Tiered load balancer. Each next() call returns an available upstream from the highest tier (lowest tier value in config).
If the whole tier (highest) is unavailable, balancer start routing upstreams from next tier (lower) if any.
server/src/main/java/com/epam/aidial/core/server/upstream/TieredBalancer.java