You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:50:13 UTC
[16/50] [abbrv] brooklyn-server git commit: set AutoScalerPolicy to
have min size default of 1 not 0
set AutoScalerPolicy to have min size default of 1 not 0
else it might scale to 0 if the metric hits 0, and then it won't usually scale back out as nothing is generating load!
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/53656bd8
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/53656bd8
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/53656bd8
Branch: refs/heads/0.7.0-incubating
Commit: 53656bd8528af6a44e08e514ec709143bb821b3b
Parents: 2cc241c
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Mon Jun 22 23:11:09 2015 -0700
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Wed Jun 24 00:40:34 2015 -0700
----------------------------------------------------------------------
.../policy/autoscaling/AutoScalerPolicy.java | 24 ++++++++++++++++----
1 file changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/53656bd8/policy/src/main/java/brooklyn/policy/autoscaling/AutoScalerPolicy.java
----------------------------------------------------------------------
diff --git a/policy/src/main/java/brooklyn/policy/autoscaling/AutoScalerPolicy.java b/policy/src/main/java/brooklyn/policy/autoscaling/AutoScalerPolicy.java
index b693955..f453aa5 100644
--- a/policy/src/main/java/brooklyn/policy/autoscaling/AutoScalerPolicy.java
+++ b/policy/src/main/java/brooklyn/policy/autoscaling/AutoScalerPolicy.java
@@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import groovy.lang.Closure;
import java.util.Map;
+import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
@@ -35,6 +36,8 @@ import org.slf4j.LoggerFactory;
import brooklyn.catalog.Catalog;
import brooklyn.config.ConfigKey;
import brooklyn.entity.Entity;
+import brooklyn.entity.basic.BrooklynTaskTags;
+import brooklyn.entity.basic.Entities;
import brooklyn.entity.basic.EntityLocal;
import brooklyn.entity.trait.Resizable;
import brooklyn.entity.trait.Startable;
@@ -51,6 +54,7 @@ import brooklyn.policy.loadbalancing.LoadBalancingPolicy;
import brooklyn.util.collections.MutableMap;
import brooklyn.util.flags.SetFromFlag;
import brooklyn.util.flags.TypeCoercions;
+import brooklyn.util.task.Tasks;
import brooklyn.util.time.Duration;
import com.google.common.base.Function;
@@ -88,7 +92,7 @@ public class AutoScalerPolicy extends AbstractPolicy {
private Entity entityWithMetric;
private Number metricUpperBound;
private Number metricLowerBound;
- private int minPoolSize = 0;
+ private int minPoolSize = 1;
private int maxPoolSize = Integer.MAX_VALUE;
private Integer resizeDownIterationIncrement;
private Integer resizeDownIterationMax;
@@ -357,7 +361,7 @@ public class AutoScalerPolicy extends AbstractPolicy {
@SetFromFlag("minPoolSize")
public static final ConfigKey<Integer> MIN_POOL_SIZE = BasicConfigKey.builder(Integer.class)
.name("autoscaler.minPoolSize")
- .defaultValue(0)
+ .defaultValue(1)
.reconfigurable(true)
.build();
@@ -1034,7 +1038,7 @@ public class AutoScalerPolicy extends AbstractPolicy {
private void resizeNow() {
long currentPoolSize = getCurrentSizeOperator().apply(poolEntity);
CalculatedDesiredPoolSize calculatedDesiredPoolSize = calculateDesiredPoolSize(currentPoolSize);
- long desiredPoolSize = calculatedDesiredPoolSize.size;
+ final long desiredPoolSize = calculatedDesiredPoolSize.size;
boolean stable = calculatedDesiredPoolSize.stable;
if (!stable) {
@@ -1054,8 +1058,18 @@ public class AutoScalerPolicy extends AbstractPolicy {
if (LOG.isDebugEnabled()) LOG.debug("{} requesting resize to {}; current {}, min {}, max {}",
new Object[] {this, desiredPoolSize, currentPoolSize, getMinPoolSize(), getMaxPoolSize()});
- // TODO Should we use int throughout, rather than casting here?
- getResizeOperator().resize(poolEntity, (int) desiredPoolSize);
+ Entities.submit(entity, Tasks.<Void>builder().name("Auto-scaler")
+ .description("Auto-scaler recommending resize from "+currentPoolSize+" to "+desiredPoolSize)
+ .tag(BrooklynTaskTags.NON_TRANSIENT_TASK_TAG)
+ .body(new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ // TODO Should we use int throughout, rather than casting here?
+ getResizeOperator().resize(poolEntity, (int) desiredPoolSize);
+ return null;
+ }
+ }).build())
+ .blockUntilEnded();
}
/**