This is an automated email from the ASF dual-hosted git repository. heneveld pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
commit aef8b330e6a3874bf77dfe458ce46e7c6a77624a Author: Alex Heneveld <g...@alex.heneveld.org> AuthorDate: Wed Jul 17 15:48:12 2024 +0100 expose an attributeWhenReadyAllowingOnFire --- .../brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java | 4 ++++ .../brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java | 8 ++++++++ .../org/apache/brooklyn/core/sensor/DependentConfiguration.java | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java index b22207cb67..bd6790450a 100644 --- a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java +++ b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java @@ -330,6 +330,10 @@ public class BrooklynDslCommon { return attributeWhenReady(sensorName, null); } @DslAccessible + public BrooklynDslDeferredSupplier<?> attributeWhenReadyAllowingOnFire(final Object sensorName) { + return attributeWhenReady(sensorName, DependentConfiguration.AttributeWhenReadyOptions.allowingOnFireMap()); + } + @DslAccessible public static BrooklynDslDeferredSupplier<?> attributeWhenReady(final Object sensorName, Map options) { return new DslComponent(Scope.THIS, "").attributeWhenReady(sensorName, options); } diff --git a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java index cb0e14c382..7d3ef9f0c1 100644 --- a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java +++ b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java @@ -657,6 +657,10 @@ public class DslComponent extends BrooklynDslDeferredSupplier<Entity> implements return new AttributeWhenReady(this, sensorNameOrSupplier); } @DslAccessible + public BrooklynDslDeferredSupplier<?> attributeWhenReadyAllowingOnFire(final Object sensorNameOrSupplier) { + return new AttributeWhenReady(this, sensorNameOrSupplier, DependentConfiguration.AttributeWhenReadyOptions.allowingOnFireMap()); + } + @DslAccessible public BrooklynDslDeferredSupplier<?> attributeWhenReady(final Object sensorNameOrSupplier, Map options) { return new AttributeWhenReady(this, sensorNameOrSupplier, options); } @@ -747,6 +751,10 @@ public class DslComponent extends BrooklynDslDeferredSupplier<Entity> implements } @Override public String toDslString(boolean yamlAllowed) { + if (options!=null && DependentConfiguration.AttributeWhenReadyOptions.allowingOnFireMap().equals(options)) { + return DslToStringHelpers.chainFunctionOnComponent1(yamlAllowed, component, + "attributeWhenReadyAllowingOnFire", sensorName); + } return DslToStringHelpers.chainFunctionOnComponent(yamlAllowed, component, "attributeWhenReady", MutableList.of(sensorName).appendIfNotNull(options)); } diff --git a/core/src/main/java/org/apache/brooklyn/core/sensor/DependentConfiguration.java b/core/src/main/java/org/apache/brooklyn/core/sensor/DependentConfiguration.java index eef904bb22..39567f8116 100644 --- a/core/src/main/java/org/apache/brooklyn/core/sensor/DependentConfiguration.java +++ b/core/src/main/java/org/apache/brooklyn/core/sensor/DependentConfiguration.java @@ -169,6 +169,10 @@ public class DependentConfiguration { result.timeoutIfDown = Duration.ONE_MINUTE; return result; } + + public static Map allowingOnFireMap() { + return MutableMap.of("timeout", "forever"); + } } public static <T> Task<T> attributeWhenReady(final Entity source, final AttributeSensor<T> sensor, AttributeWhenReadyOptions options) {