brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [11/19] brooklyn-server git commit: tweak self-ref check strategy to make idempotent
Date Thu, 02 Mar 2017 17:01:55 GMT
tweak self-ref check strategy to make idempotent


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

Branch: refs/heads/master
Commit: b0733494ce0ef307235ff055bfb0f4815736e876
Parents: 7476d3b
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Sat Feb 18 11:53:11 2017 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Sat Feb 18 11:53:11 2017 +0000

----------------------------------------------------------------------
 .../brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b0733494/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
----------------------------------------------------------------------
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 7d9a951..bc93c05 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
@@ -553,7 +553,6 @@ public class DslComponent extends BrooklynDslDeferredSupplier<Entity>
implements
             if (targetEntityMaybe.isAbsent()) return Maybe.<Object>cast(targetEntityMaybe);
             EntityInternal targetEntity = (EntityInternal) targetEntityMaybe.get();
             checkAndTagForRecursiveReference(targetEntity);
-
             String keyNameS = resolveKeyName(true);
             ConfigKey<?> key = targetEntity.getEntityType().getConfigKey(keyNameS);
             Maybe<?> result = targetEntity.config().getNonBlocking(key != null ? key
: ConfigKeys.newConfigKey(Object.class, keyNameS));
@@ -582,6 +581,13 @@ public class DslComponent extends BrooklynDslDeferredSupplier<Entity>
implements
         private void checkAndTagForRecursiveReference(Entity targetEntity) {
             String tag = "DSL:entity('"+targetEntity.getId()+"').config('"+keyName+"')";
             Task<?> ancestor = Tasks.current();
+            if (ancestor!=null) {
+                // don't check on ourself; only look higher in hierarchy;
+                // this assumes impls always spawn new tasks (which they do, just maybe not
always in new threads)
+                // but it means it does not rely on tag removal to prevent weird errors,

+                // and more importantly it makes the strategy idempotent
+                ancestor = ancestor.getSubmittedByTask();
+            }
             while (ancestor!=null) {
                 if (TaskTags.hasTag(ancestor, tag)) {
                     throw new IllegalStateException("Recursive config reference "+tag); 


Mime
View raw message