Calculate capacity reserve and label whether the reserve is stable, watched, or tight.

reserve report Fixed capacity and demand values can produce a replay-friendly reserve label before any scheduler acts on it.

Capacity Reserve Reliability Report

demand
CapacityReserveReliabilityReport.java
Replay: real traced execution (multi-file project)
public class CapacityReserveReliabilityReport {
    public static void main(String[] args) {
        int demand = 72;
        int capacity = 100;
        int reserve = capacity - demand;
        String reserveStatus = "tight";

        if (reserve >= 20) {
            reserveStatus = "stable";
        } else if (reserve >= 10) {
            reserveStatus = "watch";
        }

        System.out.println("demand=" + demand + " reserve=" + reserve + " status=" + reserveStatus);
    }
}
public class CapacityReserveReliabilityReport {
    public static void main(String[] args) {
        int demand = 88;
        int capacity = 100;
        int reserve = capacity - demand;
        String reserveStatus = "tight";

        if (reserve >= 20) {
            reserveStatus = "stable";
        } else if (reserve >= 10) {
            reserveStatus = "watch";
        }

        System.out.println("demand=" + demand + " reserve=" + reserve + " status=" + reserveStatus);
    }
}
public class CapacityReserveReliabilityReport {
    public static void main(String[] args) {
        int demand = 95;
        int capacity = 100;
        int reserve = capacity - demand;
        String reserveStatus = "tight";

        if (reserve >= 20) {
            reserveStatus = "stable";
        } else if (reserve >= 10) {
            reserveStatus = "watch";
        }

        System.out.println("demand=" + demand + " reserve=" + reserve + " status=" + reserveStatus);
    }
}
  1. demand ← 72, capacity ← 100, reserve ← 28, reserveStatus ← tight

    1public class CapacityReserveReliabilityReport {2    public static void main(String[] args) {3        int demand→ 72 = 72;  //@demand=88, 954        int capacity→ 100 = 100;5        int reserve→ 28 = capacity100 - demand72;6        String reserveStatus→ tight = "tight";
  2. reserveStatus ← stable

    8if (reserve28 >= 20) {9    reserveStatus→ stable = "stable";10} else if (reserve >= 10) {
  3. System.out.println("demand=" + demand + " reserve=" + reserve + " stat…

    14    System.out.println("demand=" + demand72 + " reserve=" + reserve28 + " status=" + reserveStatusstable);15}
    outputdemand=72 reserve=28 status=stable
  1. demand ← 88, capacity ← 100, reserve ← 12, reserveStatus ← tight

    1public class CapacityReserveReliabilityReport {2    public static void main(String[] args) {3        int demand→ 88 = 88;4        int capacity→ 100 = 100;5        int reserve→ 12 = capacity100 - demand88;6        String reserveStatus→ tight = "tight";
  2. reserveStatus ← watch

    9    reserveStatus = "stable";10} else if (reserve12 >= 10) {11    reserveStatus→ watch = "watch";12}
  3. System.out.println("demand=" + demand + " reserve=" + reserve + " stat…

    14    System.out.println("demand=" + demand88 + " reserve=" + reserve12 + " status=" + reserveStatuswatch);15}
    outputdemand=88 reserve=12 status=watch
  1. demand ← 95, capacity ← 100, reserve ← 5, reserveStatus ← tight

    1public class CapacityReserveReliabilityReport {2    public static void main(String[] args) {3        int demand→ 95 = 95;4        int capacity→ 100 = 100;5        int reserve→ 5 = capacity100 - demand95;6        String reserveStatus→ tight = "tight";78        if (reserve >= 20) {9            reserveStatus = "stable";10        } else if (reserve >= 10) {11            reserveStatus = "watch";12        }1314        System.out.println("demand=" + demand95 + " reserve=" + reserve5 + " status=" + reserveStatustight);15    }
    outputdemand=95 reserve=5 status=tight