Use the count of healthy dependencies to choose a primary, fallback, or cache route.

route fallback The route degrades from primary to fallback to cache as healthy dependencies drop away.

Dependency Fallback Remediation Report

healthyDeps
DependencyFallbackRemediationReport.java
Replay: real traced execution (multi-file project)
public class DependencyFallbackRemediationReport {
    public static void main(String[] args) {
        int healthyDeps = 3;
        int totalDeps = 3;
        int degraded = totalDeps - healthyDeps;
        String route = "primary";

        if (healthyDeps < totalDeps) {
            route = "fallback";
        }
        if (healthyDeps == 0) {
            route = "cache";
        }

        System.out.println("healthy=" + healthyDeps + " degraded=" + degraded + " route=" + route);
    }
}
public class DependencyFallbackRemediationReport {
    public static void main(String[] args) {
        int healthyDeps = 0;
        int totalDeps = 3;
        int degraded = totalDeps - healthyDeps;
        String route = "primary";

        if (healthyDeps < totalDeps) {
            route = "fallback";
        }
        if (healthyDeps == 0) {
            route = "cache";
        }

        System.out.println("healthy=" + healthyDeps + " degraded=" + degraded + " route=" + route);
    }
}
public class DependencyFallbackRemediationReport {
    public static void main(String[] args) {
        int healthyDeps = 1;
        int totalDeps = 3;
        int degraded = totalDeps - healthyDeps;
        String route = "primary";

        if (healthyDeps < totalDeps) {
            route = "fallback";
        }
        if (healthyDeps == 0) {
            route = "cache";
        }

        System.out.println("healthy=" + healthyDeps + " degraded=" + degraded + " route=" + route);
    }
}
  1. healthyDeps ← 3, totalDeps ← 3, degraded ← 0, route ← primary

    1public class DependencyFallbackRemediationReport {2    public static void main(String[] args) {3        int healthyDeps→ 3 = 3;  //@healthyDeps=1, 04        int totalDeps→ 3 = 3;5        int degraded→ 0 = totalDeps3 - healthyDeps3;6        String route→ primary = "primary";78        if (healthyDeps < totalDeps) {9            route = "fallback";10        }11        if (healthyDeps == 0) {12            route = "cache";13        }1415        System.out.println("healthy=" + healthyDeps3 + " degraded=" + degraded0 + " route=" + routeprimary);16    }
    outputhealthy=3 degraded=0 route=primary
  1. healthyDeps ← 0, totalDeps ← 3, degraded ← 3, route ← primary

    1public class DependencyFallbackRemediationReport {2    public static void main(String[] args) {3        int healthyDeps→ 0 = 0;4        int totalDeps→ 3 = 3;5        int degraded→ 3 = totalDeps3 - healthyDeps0;6        String route→ primary = "primary";
  2. route ← fallback

    8if (healthyDeps0 < totalDeps3) {9    route→ fallback = "fallback";10}
  3. route ← cache

    10}11if (healthyDeps0 == 0) {12    route→ cache = "cache";13}
  4. System.out.println("healthy=" + healthyDeps + " degraded=" + degraded …

    15    System.out.println("healthy=" + healthyDeps0 + " degraded=" + degraded3 + " route=" + routecache);16}
    outputhealthy=0 degraded=3 route=cache
  1. healthyDeps ← 1, totalDeps ← 3, degraded ← 2, route ← primary

    1public class DependencyFallbackRemediationReport {2    public static void main(String[] args) {3        int healthyDeps→ 1 = 1;4        int totalDeps→ 3 = 3;5        int degraded→ 2 = totalDeps3 - healthyDeps1;6        String route→ primary = "primary";
  2. route ← fallback

    8if (healthyDeps1 < totalDeps3) {9    route→ fallback = "fallback";10}
  3. System.out.println("healthy=" + healthyDeps + " degraded=" + degraded …

    15    System.out.println("healthy=" + healthyDeps1 + " degraded=" + degraded2 + " route=" + routefallback);16}
    outputhealthy=1 degraded=2 route=fallback