brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [03/10] brooklyn-server git commit: fix CompositeEffector logic
Date Wed, 15 Feb 2017 18:57:26 GMT
fix CompositeEffector logic


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/119ba5a4
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/119ba5a4
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/119ba5a4

Branch: refs/heads/master
Commit: 119ba5a47b4a5198ae99927511e35107d2ebce89
Parents: eadec9a
Author: Andrea Turli <andrea.turli@gmail.com>
Authored: Mon Jan 23 17:12:14 2017 +0100
Committer: Andrea Turli <andrea.turli@gmail.com>
Committed: Mon Feb 13 15:09:31 2017 +0100

----------------------------------------------------------------------
 .../core/effector/CompositeEffector.java         | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/119ba5a4/core/src/main/java/org/apache/brooklyn/core/effector/CompositeEffector.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/effector/CompositeEffector.java b/core/src/main/java/org/apache/brooklyn/core/effector/CompositeEffector.java
index 88cd92c..ca627bb 100644
--- a/core/src/main/java/org/apache/brooklyn/core/effector/CompositeEffector.java
+++ b/core/src/main/java/org/apache/brooklyn/core/effector/CompositeEffector.java
@@ -36,9 +36,9 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.annotations.Beta;
+import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Predicate;
-import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
@@ -95,19 +95,22 @@ public class CompositeEffector extends AddEffector {
 
             List <Object> results = Lists.newArrayList();
             if (!override) {
-                List<Effector<?>> originalEffectors = FluentIterable.from(entity().getEntityType().getEffectors())
-                        .filter(new Predicate<Effector<?>>() {
+                Optional<Effector<?>> effectorOptional = Iterables.tryFind(entity().getEntityType().getEffectors(),
new Predicate<Effector<?>>() {
                             @Override
                             public boolean apply(@Nullable Effector<?> input) {
                                 return input.getName().equals("original-" + effector.getName());
                             }
-                        })
-                        .toList();
-
-                for (Effector<?> originalEffector : originalEffectors) {
-                    results.add(invokeEffectorNamed(originalEffector.getName(), params));
+                        });
+                // if it is a stop effector, it has to be executed as last effector
+                if (effectorOptional.isPresent()) {
+                    if (effectorOptional.get().getName().endsWith("-stop")) {
+                        effectorNames.add(effectorOptional.get().getName());
+                    } else {
+                        effectorNames.add(0, effectorOptional.get().getName());
+                    }
                 }
             }
+            
             for (String eff : effectorNames) {
                 results.add(invokeEffectorNamed(eff, params));
             }


Mime
View raw message