brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [6/6] git commit: add back error handling, and misc minor code review comments.
Date Thu, 03 Jul 2014 09:42:16 GMT
add back error handling, and misc minor code review comments.

This closes #34. And this closes #35.


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

Branch: refs/heads/master
Commit: abf21bdc49088d2df8d1f4cd34735a983f2ac7c0
Parents: fdbacdf
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Thu Jul 3 10:18:05 2014 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Thu Jul 3 10:41:43 2014 +0100

----------------------------------------------------------------------
 .../entity/rebind/BasicEntityRebindSupport.java | 12 ++++++--
 .../BrooklynMementoPersisterToObjectStore.java  |  1 -
 .../internal/BrooklynFeatureEnablement.java     |  6 ++--
 .../entity/rebind/RebindTestFixture.java        | 31 +++++++-------------
 4 files changed, 23 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/abf21bdc/core/src/main/java/brooklyn/entity/rebind/BasicEntityRebindSupport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/BasicEntityRebindSupport.java b/core/src/main/java/brooklyn/entity/rebind/BasicEntityRebindSupport.java
index 50fc396..f154474 100644
--- a/core/src/main/java/brooklyn/entity/rebind/BasicEntityRebindSupport.java
+++ b/core/src/main/java/brooklyn/entity/rebind/BasicEntityRebindSupport.java
@@ -101,7 +101,11 @@ public class BasicEntityRebindSupport implements RebindSupport<EntityMemento>
{
         for (String policyId : memento.getPolicies()) {
             AbstractPolicy policy = (AbstractPolicy) rebindContext.getPolicy(policyId);
             if (policy != null) {
-                entity.addPolicy(policy);
+                try {
+                    entity.addPolicy(policy);
+                } catch (Exception e) {
+                    rebindContext.getExceptionHandler().onAddPolicyFailed(entity, policy,
e);
+                }
             } else {
                 LOG.warn("Policy not found; discarding policy {} of entity {}({})",
                         new Object[] {policyId, memento.getType(), memento.getId()});
@@ -114,7 +118,11 @@ public class BasicEntityRebindSupport implements RebindSupport<EntityMemento>
{
         for (String enricherId : memento.getEnrichers()) {
             AbstractEnricher enricher = (AbstractEnricher) rebindContext.getEnricher(enricherId);
             if (enricher != null) {
-                entity.addEnricher(enricher);
+                try {
+                    entity.addEnricher(enricher);
+                } catch (Exception e) {
+                    rebindContext.getExceptionHandler().onAddEnricherFailed(entity, enricher,
e);
+                }
             } else {
                 LOG.warn("Enricher not found; discarding enricher {} of entity {}({})",
                         new Object[] {enricherId, memento.getType(), memento.getId()});

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/abf21bdc/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
index 8a2b549..8746cc0 100644
--- a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
+++ b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
@@ -50,7 +50,6 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
     private volatile boolean running = true;
 
 
-    // FIXME Delete
     public BrooklynMementoPersisterToObjectStore(PersistenceObjectStore objectStore, ClassLoader
classLoader) {
         this.objectStore = checkNotNull(objectStore, "objectStore");
         MementoSerializer<Object> rawSerializer = new XmlMementoSerializer<Object>(classLoader);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/abf21bdc/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java b/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
index a0a520d..8838b46 100644
--- a/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
+++ b/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
@@ -24,9 +24,9 @@ public class BrooklynFeatureEnablement {
     
     static {
         // Idea is here one can put experimental features that are *enabled* by default,
but 
-        // that can be turned off via system properties. One might want to do that because
-        // the feature is deemed risky!
-        //   e.g. setDefault(ENABLE_POLICY_PERSISTENCE_PROPERTY, true);
+        // that can be turned off via system properties, or vice versa.
+        // Typically this is useful where a feature is deemed risky!
+        
         setDefault(FEATURE_POLICY_PERSISTENCE_PROPERTY, true);
         setDefault(FEATURE_ENRICHER_PERSISTENCE_PROPERTY, true);
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/abf21bdc/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java b/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java
index 89ac7a1..3b1992d 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java
@@ -35,14 +35,8 @@ public abstract class RebindTestFixture<T extends StartableApplication>
{
     protected T newApp;
     protected ManagementContext newManagementContext;
 
-    private boolean origPolicyPersistenceEnabled;
-    private boolean origEnricherPersistenceEnabled;
-    
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
-        origPolicyPersistenceEnabled = BrooklynFeatureEnablement.enable(BrooklynFeatureEnablement.FEATURE_POLICY_PERSISTENCE_PROPERTY);
-        origEnricherPersistenceEnabled = BrooklynFeatureEnablement.enable(BrooklynFeatureEnablement.FEATURE_ENRICHER_PERSISTENCE_PROPERTY);
-        
         mementoDir = Os.newTempDir(getClass());
         origManagementContext = RebindTestUtils.newPersistingManagementContext(mementoDir,
classLoader, getPersistPeriodMillis());
         origApp = createApp();
@@ -59,21 +53,16 @@ public abstract class RebindTestFixture<T extends StartableApplication>
{
 
     @AfterMethod(alwaysRun=true)
     public void tearDown() throws Exception {
-        try {
-            if (origApp != null) Entities.destroyAll(origApp.getManagementContext());
-            if (newApp != null) Entities.destroyAll(newApp.getManagementContext());
-            if (newManagementContext != null) Entities.destroyAll(newManagementContext);
-            origApp = null;
-            newApp = null;
-            newManagementContext = null;
-    
-            if (origManagementContext != null) Entities.destroyAll(origManagementContext);
-            if (mementoDir != null) FileBasedObjectStore.deleteCompletely(mementoDir);
-            origManagementContext = null;
-        } finally {
-            BrooklynFeatureEnablement.setEnablement(BrooklynFeatureEnablement.FEATURE_POLICY_PERSISTENCE_PROPERTY,
origPolicyPersistenceEnabled);
-            BrooklynFeatureEnablement.setEnablement(BrooklynFeatureEnablement.FEATURE_ENRICHER_PERSISTENCE_PROPERTY,
origEnricherPersistenceEnabled);
-        }
+        if (origApp != null) Entities.destroyAll(origApp.getManagementContext());
+        if (newApp != null) Entities.destroyAll(newApp.getManagementContext());
+        if (newManagementContext != null) Entities.destroyAll(newManagementContext);
+        origApp = null;
+        newApp = null;
+        newManagementContext = null;
+
+        if (origManagementContext != null) Entities.destroyAll(origManagementContext);
+        if (mementoDir != null) FileBasedObjectStore.deleteCompletely(mementoDir);
+        origManagementContext = null;
     }
 
     /** rebinds, and sets newApp */


Mime
View raw message