public int getBoundedRecommendation()

in src/main/java/com/google/cloud/run/kafkascaler/ScalingStabilizer.java [164:198]


  public int getBoundedRecommendation(
      Behavior behavior, Instant time, int currentInstanceCount, int recommendedInstances) {
    BoundsDebugInfo bounds = new BoundsDebugInfo();
    int boundedRecommendation = recommendedInstances;
    if (recommendedInstances > currentInstanceCount) {
      boundedRecommendation =
          getBoundedRecommendationForScaleUp(
              behavior, time, currentInstanceCount, recommendedInstances, bounds);
      if (boundedRecommendation < recommendedInstances) {
        logger.atInfo().log(
            "ScalingStabilizer: scale up is bounded down to %d from the recommendation of %d",
            boundedRecommendation, recommendedInstances);
      }
    } else if (recommendedInstances < currentInstanceCount) {
      boundedRecommendation =
          getBoundedRecommendationForScaleDown(
              behavior, time, currentInstanceCount, recommendedInstances, bounds);
      if (boundedRecommendation > recommendedInstances) {
        logger.atInfo().log(
            "ScalingStabilizer: scale down is bounded up to %d from the recommendation of %d",
            boundedRecommendation, recommendedInstances);
      }
    }

    // Always record the recommendation, even if it's unchanged.
    recommendations.add(new DataPoint(time, recommendedInstances));

    if (recommendedInstances > currentInstanceCount) {
      logger.atInfo().log("%s", bounds.toScaleUpBoundDebugString());
    } else if (recommendedInstances < currentInstanceCount) {
      logger.atInfo().log("%s", bounds.toScaleDownBoundDebugString());
    }

    return boundedRecommendation;
  }