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 2016/04/01 16:22:19 UTC

[1/4] brooklyn-server git commit: BROOKLYN-245: improve synchronization in entity

Repository: brooklyn-server
Updated Branches:
  refs/heads/master 797ed8f26 -> 9720743a2


BROOKLYN-245: improve synchronization in entity

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

Branch: refs/heads/master
Commit: 24aa5dddd87e5b20ed7e43f817be9355d0b198bd
Parents: cf305e2
Author: Aled Sage <al...@gmail.com>
Authored: Thu Mar 31 20:46:58 2016 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Mar 31 20:46:58 2016 +0100

----------------------------------------------------------------------
 .../org/apache/brooklyn/core/entity/AbstractEntity.java   | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/24aa5ddd/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
index 1406855..09834af 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
@@ -1484,9 +1484,11 @@ public abstract class AbstractEntity extends AbstractBrooklynObject implements E
         }
         
         protected SubscriptionContext getSubscriptionContext() {
-            synchronized (AbstractEntity.this) {
-                return getManagementSupport().getSubscriptionContext();
-            }
+            // Rely on synchronization in EntityManagementSupport; synchronizing on AbstractEntity.this
+            // is dangerous because user's entity code might synchronize on that and call getAttribute.
+            // Given that getSubscriptionContext is called by AttributeMap.update (via emitInternal),
+            // that risks deadlock!
+            return getManagementSupport().getSubscriptionContext();
         }
 
         protected SubscriptionTracker getSubscriptionTracker() {
@@ -1548,7 +1550,7 @@ public abstract class AbstractEntity extends AbstractBrooklynObject implements E
      * @deprecated since 0.9.0; for internal use only
      */
     @Deprecated
-    protected synchronized SubscriptionTracker getSubscriptionTracker() {
+    protected SubscriptionTracker getSubscriptionTracker() {
         return subscriptions().getSubscriptionTracker();
     }
     


[2/4] brooklyn-server git commit: Entity.getSubscriptionTracker synchronization

Posted by he...@apache.org.
Entity.getSubscriptionTracker synchronization

Avoid calling getSubscriptionContext() while holding lock on 
AbstractEntity.this. See discussion in https://github.com/apache/brooklyn-server/pull/96


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

Branch: refs/heads/master
Commit: 01c67b667d7062804259f9b66e3a18977f7b8fbb
Parents: 24aa5dd
Author: Aled Sage <al...@gmail.com>
Authored: Fri Apr 1 12:32:39 2016 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Apr 1 12:32:39 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/brooklyn/core/entity/AbstractEntity.java   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/01c67b66/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
index 09834af..58767e4 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
@@ -1492,9 +1492,13 @@ public abstract class AbstractEntity extends AbstractBrooklynObject implements E
         }
 
         protected SubscriptionTracker getSubscriptionTracker() {
+            // TODO Would be nice to simplify concurrent model, and not synchronize on
+            // AbstractEntity.this; perhaps could get rid of lazy-initialisation, but then
+            // would need to first ensure `managementSupport` is definitely initialised.
+            SubscriptionContext subscriptionContext = getSubscriptionContext();
             synchronized (AbstractEntity.this) {
                 if (_subscriptionTracker == null) {
-                    _subscriptionTracker = new SubscriptionTracker(getSubscriptionContext());
+                    _subscriptionTracker = new SubscriptionTracker(subscriptionContext);
                 }
                 return _subscriptionTracker;
             }


[3/4] brooklyn-server git commit: This closes #96

Posted by he...@apache.org.
This closes #96


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

Branch: refs/heads/master
Commit: 6e3945a509becd8bf409040f967ce2ab8a0de06e
Parents: 797ed8f 01c67b6
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Fri Apr 1 15:20:00 2016 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Fri Apr 1 15:20:00 2016 +0100

----------------------------------------------------------------------
 .../apache/brooklyn/core/entity/AbstractEntity.java | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------



[4/4] brooklyn-server git commit: small tweak to optimise subscription tracker access

Posted by he...@apache.org.
small tweak to optimise subscription tracker access


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

Branch: refs/heads/master
Commit: 9720743a23b816914e66fb37ed4d783837ecca36
Parents: 6e3945a
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Fri Apr 1 15:21:30 2016 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Fri Apr 1 15:21:30 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/brooklyn/core/entity/AbstractEntity.java    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9720743a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
index 58767e4..738ce86 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
@@ -264,7 +264,7 @@ public abstract class AbstractEntity extends AbstractBrooklynObject implements E
     @Deprecated
     protected final Map<String,Object> tempWorkings = Maps.newLinkedHashMap();
 
-    protected transient SubscriptionTracker _subscriptionTracker;
+    protected transient volatile SubscriptionTracker _subscriptionTracker;
     
     public AbstractEntity() {
         this(Maps.newLinkedHashMap(), null);
@@ -1492,6 +1492,9 @@ public abstract class AbstractEntity extends AbstractBrooklynObject implements E
         }
 
         protected SubscriptionTracker getSubscriptionTracker() {
+            if (_subscriptionTracker != null) {
+                return _subscriptionTracker;
+            }
             // TODO Would be nice to simplify concurrent model, and not synchronize on
             // AbstractEntity.this; perhaps could get rid of lazy-initialisation, but then
             // would need to first ensure `managementSupport` is definitely initialised.