@Test(groups="Integration") public void testResizeDownStabilizationDelayResizesAfterDelay() throws Exception { final long resizeDownStabilizationDelay = 1000L; Duration minPeriodBetweenExecs = Duration.ZERO; resizable.policies().remove(policy); policy = AutoScalerPolicy.builder() .resizeDownStabilizationDelay(Duration.of(resizeDownStabilizationDelay, TimeUnit.MILLISECONDS)) .minPeriodBetweenExecs(minPeriodBetweenExecs) .build(); resizable.policies().add(policy); resizable.resize(2); final long emitTime = System.currentTimeMillis(); final Map<String, Object> needJust1 = message(2, 1L, 2*10L, 2*20L); resizable.sensors().emit(AutoScalerPolicy.DEFAULT_POOL_COLD_SENSOR, needJust1); final AtomicInteger emitCount = new AtomicInteger(0); Asserts.succeedsEventually(MutableMap.of("timeout", TIMEOUT_MS), new Runnable() { public void run() { if (System.currentTimeMillis() - emitTime > (2+emitCount.get())*resizeDownStabilizationDelay) { resizable.sensors().emit(AutoScalerPolicy.DEFAULT_POOL_COLD_SENSOR, needJust1); emitCount.incrementAndGet(); } assertEquals(resizable.getCurrentSize(), (Integer)1); }}); long resizeDelay = System.currentTimeMillis() - emitTime; assertTrue(resizeDelay >= (resizeDownStabilizationDelay-EARLY_RETURN_MS), "resizeDelay="+resizeDelay); }
public static Builder builder() { return new Builder(); }
AutoScalerPolicy extends AbstractPolicy { public static Builder builder() { return new Builder(); } }
AutoScalerPolicy extends AbstractPolicy { public static Builder builder() { return new Builder(); } AutoScalerPolicy();  AutoScalerPolicy(Map<String,?> props); }
AutoScalerPolicy extends AbstractPolicy { public static Builder builder() { return new Builder(); } AutoScalerPolicy();  AutoScalerPolicy(Map<String,?> props); static Builder builder(); @Override void init(); @Override void rebind(); void setMetricLowerBound(Number val); void setMetricUpperBound(Number val); int getResizeUpIterationIncrement(); void setResizeUpIterationIncrement(Integer val); int getResizeDownIterationIncrement(); void setResizeDownIterationIncrement(Integer val); int getResizeUpIterationMax(); void setResizeUpIterationMax(Integer val); int getResizeDownIterationMax(); void setResizeDownIterationMax(Integer val); void setMinPeriodBetweenExecs(Duration val); void setResizeUpStabilizationDelay(Duration val); void setResizeDownStabilizationDelay(Duration val); void setMinPoolSize(int val); void setMaxPoolSize(int val); @Override void suspend(); @Override void resume(); @Override void setEntity(EntityLocal entity); @Override String toString(); }
AutoScalerPolicy extends AbstractPolicy { public static Builder builder() { return new Builder(); } AutoScalerPolicy();  AutoScalerPolicy(Map<String,?> props); static Builder builder(); @Override void init(); @Override void rebind(); void setMetricLowerBound(Number val); void setMetricUpperBound(Number val); int getResizeUpIterationIncrement(); void setResizeUpIterationIncrement(Integer val); int getResizeDownIterationIncrement(); void setResizeDownIterationIncrement(Integer val); int getResizeUpIterationMax(); void setResizeUpIterationMax(Integer val); int getResizeDownIterationMax(); void setResizeDownIterationMax(Integer val); void setMinPeriodBetweenExecs(Duration val); void setResizeUpStabilizationDelay(Duration val); void setResizeDownStabilizationDelay(Duration val); void setMinPoolSize(int val); void setMaxPoolSize(int val); @Override void suspend(); @Override void resume(); @Override void setEntity(EntityLocal entity); @Override String toString(); static BasicNotificationSensor<Map> DEFAULT_POOL_HOT_SENSOR; static BasicNotificationSensor<Map> DEFAULT_POOL_COLD_SENSOR; static BasicNotificationSensor<Map> DEFAULT_POOL_OK_SENSOR; static BasicNotificationSensor<MaxPoolSizeReachedEvent> DEFAULT_MAX_SIZE_REACHED_SENSOR; static final String POOL_CURRENT_SIZE_KEY; static final String POOL_HIGH_THRESHOLD_KEY; static final String POOL_LOW_THRESHOLD_KEY; static final String POOL_CURRENT_WORKRATE_KEY; @SuppressWarnings("serial")
    @SetFromFlag("metric")
    static final ConfigKey<AttributeSensor<? extends Number>> METRIC; @SetFromFlag("entityWithMetric")
    static final ConfigKey<Entity> ENTITY_WITH_METRIC; @SetFromFlag("metricLowerBound")
    static final ConfigKey<Number> METRIC_LOWER_BOUND; @SetFromFlag("metricUpperBound")
    static final ConfigKey<Number> METRIC_UPPER_BOUND; @SetFromFlag("resizeUpIterationIncrement")
    static final ConfigKey<Integer> RESIZE_UP_ITERATION_INCREMENT; @SetFromFlag("resizeUpIterationMax")
    static final ConfigKey<Integer> RESIZE_UP_ITERATION_MAX; @SetFromFlag("resizeDownIterationIncrement")
    static final ConfigKey<Integer> RESIZE_DOWN_ITERATION_INCREMENT; @SetFromFlag("resizeDownIterationMax")
    static final ConfigKey<Integer> RESIZE_DOWN_ITERATION_MAX; @SetFromFlag("minPeriodBetweenExecs")
    static final ConfigKey<Duration> MIN_PERIOD_BETWEEN_EXECS; @SetFromFlag("resizeUpStabilizationDelay")
    static final ConfigKey<Duration> RESIZE_UP_STABILIZATION_DELAY; @SetFromFlag("resizeDownStabilizationDelay")
    static final ConfigKey<Duration> RESIZE_DOWN_STABILIZATION_DELAY; @SetFromFlag("minPoolSize")
    static final ConfigKey<Integer> MIN_POOL_SIZE; @SetFromFlag("maxPoolSize")
    static final ConfigKey<Integer> MAX_POOL_SIZE; static final ConfigKey<Integer> INSUFFICIENT_CAPACITY_HIGH_WATER_MARK; @SetFromFlag("resizeOperator")
    static final ConfigKey<ResizeOperator> RESIZE_OPERATOR; @SuppressWarnings("serial")
    @SetFromFlag("currentSizeOperator")
    static final ConfigKey<Function<Entity,Integer>> CURRENT_SIZE_OPERATOR; @SuppressWarnings("serial")
    @SetFromFlag("poolHotSensor")
    static final ConfigKey<BasicNotificationSensor<? extends Map>> POOL_HOT_SENSOR; @SuppressWarnings("serial")
    @SetFromFlag("poolColdSensor")
    static final ConfigKey<BasicNotificationSensor<? extends Map>> POOL_COLD_SENSOR; @SuppressWarnings("serial")
    @SetFromFlag("poolOkSensor")
    static final ConfigKey<BasicNotificationSensor<? extends Map>> POOL_OK_SENSOR; @SuppressWarnings("serial")
    @SetFromFlag("maxSizeReachedSensor")
    static final ConfigKey<BasicNotificationSensor<? super MaxPoolSizeReachedEvent>> MAX_SIZE_REACHED_SENSOR; @SetFromFlag("maxReachedNotificationDelay")
    static final ConfigKey<Duration> MAX_REACHED_NOTIFICATION_DELAY; }