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 2022/07/14 23:24:54 UTC
[brooklyn-server] branch master updated: allow groups change policy to invoke things when a member joins
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
The following commit(s) were added to refs/heads/master by this push:
new ac8a5b28c6 allow groups change policy to invoke things when a member joins
ac8a5b28c6 is described below
commit ac8a5b28c6af7200ccb60cf7b20a11d2c9910c3c
Author: Alex Heneveld <al...@cloudsoft.io>
AuthorDate: Fri Jul 15 00:24:36 2022 +0100
allow groups change policy to invoke things when a member joins
---
.../apache/brooklyn/entity/group/GroupsChangePolicy.java | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/core/src/main/java/org/apache/brooklyn/entity/group/GroupsChangePolicy.java b/core/src/main/java/org/apache/brooklyn/entity/group/GroupsChangePolicy.java
index ab6adfd17e..10412f08d8 100644
--- a/core/src/main/java/org/apache/brooklyn/entity/group/GroupsChangePolicy.java
+++ b/core/src/main/java/org/apache/brooklyn/entity/group/GroupsChangePolicy.java
@@ -44,6 +44,7 @@ import org.apache.brooklyn.core.resolve.jackson.BeanWithTypeUtils;
import org.apache.brooklyn.core.typereg.AbstractTypePlanTransformer;
import org.apache.brooklyn.core.typereg.RegisteredTypeLoadingContexts;
import org.apache.brooklyn.core.typereg.RegisteredTypes;
+import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.core.config.ConfigBag;
import org.apache.brooklyn.util.core.flags.BrooklynTypeNameResolution;
import org.apache.brooklyn.util.exceptions.Exceptions;
@@ -105,22 +106,31 @@ public class GroupsChangePolicy extends AbstractMembershipTrackingPolicy {
public static final ConfigKey<List<Map<String, Object>>> LOCATIONS = ConfigKeys.builder(new TypeToken<List<Map<String, Object>>>() {})
.name("member.locations")
+ .description("Locations to add to any joining member when it joins")
.defaultValue(ImmutableList.of())
.build();
public static final ConfigKey<List<Map<String, Object>>> POLICIES = ConfigKeys.builder(new TypeToken<List<Map<String, Object>>>() {})
.name("member.policies")
- .description("List of policies of the form [{type: policyType, brooklyn.config: {configKey: configValue}}]")
+ .description("Policies to add to any joining member when it joins, of the form [{type: policyType, brooklyn.config: {configKey: configValue}}]")
.defaultValue(ImmutableList.of())
.build();
public static final ConfigKey<List<Map<String, Object>>> INITIALIZERS = ConfigKeys.builder(new TypeToken<List<Map<String, Object>>>(){})
.name("member.initializers")
+ .description("Initializers to run on any joining member when it joins")
.defaultValue(ImmutableList.of())
.build();
public static final ConfigKey<List<Map<String, Object>>> ENRICHERS = ConfigKeys.builder(new TypeToken<List<Map<String, Object>>>(){})
.name("member.enrichers")
+ .description("Enrichers to add to any joining member when it joins")
+ .defaultValue(ImmutableList.of())
+ .build();
+
+ public static final ConfigKey<List<String>> INVOKE = ConfigKeys.builder(new TypeToken<List<String>>(){})
+ .name("member.invoke")
+ .description("Effectors to invoke on any joining member when it joins (run in parallel asynchronously, after initializers so they can add new effectors)")
.defaultValue(ImmutableList.of())
.build();
@@ -223,6 +233,10 @@ public class GroupsChangePolicy extends AbstractMembershipTrackingPolicy {
member.enrichers().add(enricherSpec);
}
);
+
+ config().get(INVOKE).forEach(effName -> {
+ member.invoke( ((EntityInternal)member).getEffector(effName), MutableMap.of() );
+ });
}
@SuppressWarnings("unchecked")