Repository: brooklyn-library Updated Branches: refs/heads/master 4d231bf3a -> 2420536d6
Always use EnricherSpec to create enrichers Project: http://git-wip-us.apache.org/repos/asf/brooklyn-library/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-library/commit/e099df27 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-library/tree/e099df27 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-library/diff/e099df27 Branch: refs/heads/master Commit: e099df27bd08142127bd2dcc1c2cd63ef8acefd0 Parents: f7268b7 Author: Aled Sage <[email protected]> Authored: Mon Jun 19 13:14:20 2017 +0100 Committer: Aled Sage <[email protected]> Committed: Mon Jun 19 13:14:20 2017 +0100 ---------------------------------------------------------------------- .../brooklyn/qa/load/SimulatedTheeTierApp.java | 2 +- .../webcluster/SinusoidalLoadGenerator.java | 8 ------ .../qa/longevity/webcluster/WebClusterApp.java | 2 +- .../nosql/cassandra/CassandraNodeImpl.java | 30 ++++++++++++++------ .../entity/webapp/WebAppServiceMethods.java | 29 ++++++++++++++----- .../webapp/TomcatAutoScalerPolicyTest.java | 5 ++-- 6 files changed, 47 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/e099df27/qa/src/main/java/org/apache/brooklyn/qa/load/SimulatedTheeTierApp.java ---------------------------------------------------------------------- diff --git a/qa/src/main/java/org/apache/brooklyn/qa/load/SimulatedTheeTierApp.java b/qa/src/main/java/org/apache/brooklyn/qa/load/SimulatedTheeTierApp.java index b0178e5..5e2e566 100644 --- a/qa/src/main/java/org/apache/brooklyn/qa/load/SimulatedTheeTierApp.java +++ b/qa/src/main/java/org/apache/brooklyn/qa/load/SimulatedTheeTierApp.java @@ -105,7 +105,7 @@ public class SimulatedTheeTierApp extends AbstractApplication { metric(DynamicWebAppCluster.REQUESTS_PER_SECOND_IN_WINDOW_PER_NODE). metricRange(10, 100). sizeRange(2, 5). - build()); + buildSpec()); enrichers().add(Enrichers.builder() .propagating(Attributes.MAIN_URI, WebAppServiceConstants.ROOT_URL, http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/e099df27/qa/src/test/java/org/apache/brooklyn/qa/longevity/webcluster/SinusoidalLoadGenerator.java ---------------------------------------------------------------------- diff --git a/qa/src/test/java/org/apache/brooklyn/qa/longevity/webcluster/SinusoidalLoadGenerator.java b/qa/src/test/java/org/apache/brooklyn/qa/longevity/webcluster/SinusoidalLoadGenerator.java index a8dd8da..40f6b49 100644 --- a/qa/src/test/java/org/apache/brooklyn/qa/longevity/webcluster/SinusoidalLoadGenerator.java +++ b/qa/src/test/java/org/apache/brooklyn/qa/longevity/webcluster/SinusoidalLoadGenerator.java @@ -55,14 +55,6 @@ public class SinusoidalLoadGenerator extends AbstractEnricher { this.executor = Executors.newSingleThreadScheduledExecutor(); } - public SinusoidalLoadGenerator(AttributeSensor<Double> target, long publishPeriodMs, long sinPeriodMs, double sinAmplitude) { - config().set(TARGET, target); - config().set(PUBLISH_PERIOD_MS, publishPeriodMs); - config().set(SIN_PERIOD_MS, sinPeriodMs); - config().set(SIN_AMPLITUDE, sinAmplitude); - this.executor = Executors.newSingleThreadScheduledExecutor(); - } - @Override public void setEntity(final EntityLocal entity) { super.setEntity(entity); http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/e099df27/qa/src/test/java/org/apache/brooklyn/qa/longevity/webcluster/WebClusterApp.java ---------------------------------------------------------------------- diff --git a/qa/src/test/java/org/apache/brooklyn/qa/longevity/webcluster/WebClusterApp.java b/qa/src/test/java/org/apache/brooklyn/qa/longevity/webcluster/WebClusterApp.java index 7c11803..3b25212 100644 --- a/qa/src/test/java/org/apache/brooklyn/qa/longevity/webcluster/WebClusterApp.java +++ b/qa/src/test/java/org/apache/brooklyn/qa/longevity/webcluster/WebClusterApp.java @@ -82,7 +82,7 @@ public class WebClusterApp extends AbstractApplication { .metric(averageLoad) .sizeRange(1, 3) .metricRange(0.3, 0.7) - .build()); + .buildSpec()); } public static void main(String[] argv) { http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/e099df27/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeImpl.java ---------------------------------------------------------------------- diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeImpl.java b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeImpl.java index 488f0e9..6917e62 100644 --- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeImpl.java +++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeImpl.java @@ -35,7 +35,7 @@ import javax.management.ObjectName; import org.apache.brooklyn.api.entity.Entity; import org.apache.brooklyn.api.location.MachineLocation; import org.apache.brooklyn.api.location.MachineProvisioningLocation; -import org.apache.brooklyn.api.sensor.AttributeSensor; +import org.apache.brooklyn.api.sensor.EnricherSpec; import org.apache.brooklyn.core.effector.EffectorBody; import org.apache.brooklyn.core.entity.Attributes; import org.apache.brooklyn.core.entity.Entities; @@ -525,16 +525,28 @@ public class CassandraNodeImpl extends SoftwareProcessImpl implements CassandraN protected void connectEnrichers(Duration windowPeriod) { JavaAppUtils.connectJavaAppServerPolicies(this); - enrichers().add(TimeWeightedDeltaEnricher.<Long>getPerSecondDeltaEnricher(this, READ_COMPLETED, READS_PER_SECOND_LAST)); - enrichers().add(TimeWeightedDeltaEnricher.<Long>getPerSecondDeltaEnricher(this, WRITE_COMPLETED, WRITES_PER_SECOND_LAST)); + enrichers().add(EnricherSpec.create(TimeWeightedDeltaEnricher.class) + .configure("producer", this) + .configure("source", READ_COMPLETED) + .configure("target", READS_PER_SECOND_LAST) + .configure("unitMillis", 1000)); if (windowPeriod!=null) { - enrichers().add(new RollingTimeWindowMeanEnricher<Long>(this, THRIFT_PORT_LATENCY, - THRIFT_PORT_LATENCY_IN_WINDOW, windowPeriod)); - enrichers().add(new RollingTimeWindowMeanEnricher<Double>(this, READS_PER_SECOND_LAST, - READS_PER_SECOND_IN_WINDOW, windowPeriod)); - enrichers().add(new RollingTimeWindowMeanEnricher<Double>(this, WRITES_PER_SECOND_LAST, - WRITES_PER_SECOND_IN_WINDOW, windowPeriod)); + enrichers().add(EnricherSpec.create(RollingTimeWindowMeanEnricher.class) + .configure("producer", this) + .configure("source", THRIFT_PORT_LATENCY) + .configure("target", THRIFT_PORT_LATENCY_IN_WINDOW) + .configure("timePeriod", windowPeriod)); + enrichers().add(EnricherSpec.create(RollingTimeWindowMeanEnricher.class) + .configure("producer", this) + .configure("source", READS_PER_SECOND_LAST) + .configure("target", READS_PER_SECOND_IN_WINDOW) + .configure("timePeriod", windowPeriod)); + enrichers().add(EnricherSpec.create(RollingTimeWindowMeanEnricher.class) + .configure("producer", this) + .configure("source", WRITES_PER_SECOND_LAST) + .configure("target", WRITES_PER_SECOND_IN_WINDOW) + .configure("timePeriod", windowPeriod)); } // service-up checks http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/e099df27/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/WebAppServiceMethods.java ---------------------------------------------------------------------- diff --git a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/WebAppServiceMethods.java b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/WebAppServiceMethods.java index a25b4f7..6c2d874 100644 --- a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/WebAppServiceMethods.java +++ b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/WebAppServiceMethods.java @@ -24,7 +24,9 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import org.apache.brooklyn.api.entity.Entity; +import org.apache.brooklyn.api.sensor.EnricherSpec; import org.apache.brooklyn.core.location.access.BrooklynAccessUtils; +import org.apache.brooklyn.entity.java.UsesJavaMXBeans; import org.apache.brooklyn.policy.enricher.RollingTimeWindowMeanEnricher; import org.apache.brooklyn.policy.enricher.TimeFractionDeltaEnricher; import org.apache.brooklyn.policy.enricher.TimeWeightedDeltaEnricher; @@ -41,20 +43,33 @@ public class WebAppServiceMethods implements WebAppServiceConstants { } public static void connectWebAppServerPolicies(Entity entity, Duration windowPeriod) { - entity.enrichers().add(TimeWeightedDeltaEnricher.<Integer>getPerSecondDeltaEnricher(entity, REQUEST_COUNT, REQUESTS_PER_SECOND_LAST)); + entity.enrichers().add(EnricherSpec.create(TimeWeightedDeltaEnricher.class) + .configure("producer", entity) + .configure("source", REQUEST_COUNT) + .configure("target", REQUESTS_PER_SECOND_LAST) + .configure("unitMillis", 1000)); if (windowPeriod!=null) { - entity.enrichers().add(new RollingTimeWindowMeanEnricher<Double>(entity, REQUESTS_PER_SECOND_LAST, - REQUESTS_PER_SECOND_IN_WINDOW, windowPeriod)); + entity.enrichers().add(EnricherSpec.create(RollingTimeWindowMeanEnricher.class) + .configure("producer", entity) + .configure("source", REQUESTS_PER_SECOND_LAST) + .configure("target", REQUESTS_PER_SECOND_IN_WINDOW) + .configure("timePeriod", windowPeriod)); } - entity.enrichers().add(new TimeFractionDeltaEnricher<Integer>(entity, TOTAL_PROCESSING_TIME, PROCESSING_TIME_FRACTION_LAST, TimeUnit.MILLISECONDS)); + entity.enrichers().add(EnricherSpec.create(TimeFractionDeltaEnricher.class) + .configure("producer", entity) + .configure("source", TOTAL_PROCESSING_TIME) + .configure("target", PROCESSING_TIME_FRACTION_LAST) + .configure("durationPerOrigUnit", Duration.millis(1))); if (windowPeriod!=null) { - entity.enrichers().add(new RollingTimeWindowMeanEnricher<Double>(entity, PROCESSING_TIME_FRACTION_LAST, - PROCESSING_TIME_FRACTION_IN_WINDOW, windowPeriod)); + entity.enrichers().add(EnricherSpec.create(RollingTimeWindowMeanEnricher.class) + .configure("producer", entity) + .configure("source", PROCESSING_TIME_FRACTION_LAST) + .configure("target", PROCESSING_TIME_FRACTION_IN_WINDOW) + .configure("timePeriod", windowPeriod)); } - } public static Set<String> getEnabledProtocols(Entity entity) { http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/e099df27/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/TomcatAutoScalerPolicyTest.java ---------------------------------------------------------------------- diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/TomcatAutoScalerPolicyTest.java b/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/TomcatAutoScalerPolicyTest.java index 7ffed3e..bd3faa4 100644 --- a/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/TomcatAutoScalerPolicyTest.java +++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/TomcatAutoScalerPolicyTest.java @@ -86,12 +86,11 @@ public class TomcatAutoScalerPolicyTest { .configure(DynamicWebAppCluster.INITIAL_SIZE, 1) .configure(DynamicWebAppCluster.MEMBER_SPEC, EntitySpec.create(TomcatServer.class))); - final AutoScalerPolicy policy = AutoScalerPolicy.builder() + final AutoScalerPolicy policy = cluster.policies().add(AutoScalerPolicy.builder() .metric(DynamicWebAppCluster.REQUEST_COUNT_PER_NODE) .metricRange(0, 1) .minPoolSize(1) - .build(); - cluster.policies().add(policy); + .buildSpec()); app.start(ImmutableList.of(loc));
