brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [2/3] git commit: Move RebindFailureMode enum into RebindManager i/f
Date Tue, 03 Jun 2014 21:55:14 GMT
Move RebindFailureMode enum into RebindManager i/f


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

Branch: refs/heads/master
Commit: 443bea776b867f31b99be77d71a57796d4e8a676
Parents: 9a468e2
Author: Richard Downer <richard.downer@cloudsoftcorp.com>
Authored: Tue Jun 3 17:40:19 2014 +0200
Committer: Richard Downer <richard.downer@cloudsoftcorp.com>
Committed: Tue Jun 3 23:33:10 2014 +0200

----------------------------------------------------------------------
 .../brooklyn/entity/rebind/RebindManager.java   |  6 +++++
 .../rebind/RebindExceptionHandlerImpl.java      | 26 ++++++++------------
 .../entity/rebind/RebindManagerImpl.java        |  1 -
 .../BrooklynMementoPersisterInMemory.java       |  4 +--
 .../entity/rebind/RebindFailuresTest.java       | 18 +++++++-------
 .../entity/rebind/RebindTestFixture.java        |  3 +--
 .../rebind/RecordingRebindExceptionHandler.java |  2 +-
 7 files changed, 29 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/443bea77/api/src/main/java/brooklyn/entity/rebind/RebindManager.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/rebind/RebindManager.java b/api/src/main/java/brooklyn/entity/rebind/RebindManager.java
index 10b8311..309dedf 100644
--- a/api/src/main/java/brooklyn/entity/rebind/RebindManager.java
+++ b/api/src/main/java/brooklyn/entity/rebind/RebindManager.java
@@ -24,6 +24,12 @@ public interface RebindManager {
     //
     // Or is that a risky API because you could call it on a non-empty managementContext?
     
+    public enum RebindFailureMode {
+        FAIL_FAST,
+        FAIL_AT_END,
+        CONTINUE;
+    }
+    
     public void setPersister(BrooklynMementoPersister persister);
 
     @VisibleForTesting

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/443bea77/core/src/main/java/brooklyn/entity/rebind/RebindExceptionHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/RebindExceptionHandlerImpl.java b/core/src/main/java/brooklyn/entity/rebind/RebindExceptionHandlerImpl.java
index 4dc2b54..475a0e4 100644
--- a/core/src/main/java/brooklyn/entity/rebind/RebindExceptionHandlerImpl.java
+++ b/core/src/main/java/brooklyn/entity/rebind/RebindExceptionHandlerImpl.java
@@ -25,14 +25,8 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler
{
     
     private static final Logger LOG = LoggerFactory.getLogger(RebindExceptionHandlerImpl.class);
 
-    public enum RebindFailureMode {
-        FAIL_FAST,
-        FAIL_AT_END,
-        CONTINUE;
-    }
-    
-    protected final RebindFailureMode danglingRefFailureMode;
-    protected final RebindFailureMode rebindFailureMode;
+    protected final RebindManager.RebindFailureMode danglingRefFailureMode;
+    protected final RebindManager.RebindFailureMode rebindFailureMode;
 
     protected final Set<String> missingEntities = Sets.newLinkedHashSet();
     protected final Set<String> missingLocations = Sets.newLinkedHashSet();
@@ -43,7 +37,7 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler
{
     protected final Set<String> creationFailedPolicies = Sets.newLinkedHashSet();
     protected final List<Exception> exceptions = Lists.newArrayList();
     
-    public RebindExceptionHandlerImpl(RebindFailureMode danglingRefFailureMode, RebindFailureMode
rebindFailureMode) {
+    public RebindExceptionHandlerImpl(RebindManager.RebindFailureMode danglingRefFailureMode,
RebindManager.RebindFailureMode rebindFailureMode) {
         this.danglingRefFailureMode = checkNotNull(danglingRefFailureMode, "danglingRefFailureMode");
         this.rebindFailureMode = checkNotNull(rebindFailureMode, "rebindFailureMode");
     }
@@ -78,7 +72,7 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler
{
     @Override
     public Entity onDanglingEntityRef(String id) {
         missingEntities.add(id);
-        if (danglingRefFailureMode == RebindFailureMode.FAIL_FAST) {
+        if (danglingRefFailureMode == RebindManager.RebindFailureMode.FAIL_FAST) {
             throw new IllegalStateException("No entity found with id "+id);
         } else {
             LOG.warn("No entity found with id "+id+"; returning null");
@@ -89,7 +83,7 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler
{
     @Override
     public Location onDanglingLocationRef(String id) {
         missingLocations.add(id);
-        if (danglingRefFailureMode == RebindFailureMode.FAIL_FAST) {
+        if (danglingRefFailureMode == RebindManager.RebindFailureMode.FAIL_FAST) {
             throw new IllegalStateException("No location found with id "+id);
         } else {
             LOG.warn("No location found with id "+id+"; returning null");
@@ -100,7 +94,7 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler
{
     @Override
     public Policy onDanglingPolicyRef(String id) {
         missingPolicies.add(id);
-        if (danglingRefFailureMode == RebindFailureMode.FAIL_FAST) {
+        if (danglingRefFailureMode == RebindManager.RebindFailureMode.FAIL_FAST) {
             throw new IllegalStateException("No policy found with id "+id);
         } else {
             LOG.warn("No policy found with id "+id+"; returning null");
@@ -111,7 +105,7 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler
{
     @Override
     public Enricher onDanglingEnricherRef(String id) {
         missingEnrichers.add(id);
-        if (danglingRefFailureMode == RebindFailureMode.FAIL_FAST) {
+        if (danglingRefFailureMode == RebindManager.RebindFailureMode.FAIL_FAST) {
             throw new IllegalStateException("No enricher found with id "+id);
         } else {
             LOG.warn("No enricher found with id "+id+"; returning null");
@@ -230,7 +224,7 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler
{
     }
     
     protected void onErrorImpl(String errmsg, Exception e) {
-        if (rebindFailureMode == RebindFailureMode.FAIL_FAST) {
+        if (rebindFailureMode == RebindManager.RebindFailureMode.FAIL_FAST) {
             throw new IllegalStateException("Rebind: aborting due to "+errmsg, e);
         } else {
             LOG.warn("Rebind: continuing after "+errmsg, e);
@@ -256,7 +250,7 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler
{
         if (e != null) {
             allExceptions.add(e);
         }
-        if (danglingRefFailureMode != RebindFailureMode.CONTINUE) {
+        if (danglingRefFailureMode != RebindManager.RebindFailureMode.CONTINUE) {
             if (missingEntities.size() > 0) {
                 allExceptions.add(new IllegalStateException("Missing referenced entit"+(missingEntities.size()
== 1 ? "y" : "ies")+": "+missingEntities));
             }
@@ -270,7 +264,7 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler
{
                 allExceptions.add(new IllegalStateException("Missing referenced enricher"+(missingEnrichers.size()
== 1 ? "" : "s")+": "+missingEnrichers));
             }
         }
-        if (rebindFailureMode != RebindFailureMode.CONTINUE) {
+        if (rebindFailureMode != RebindManager.RebindFailureMode.CONTINUE) {
             allExceptions.addAll(exceptions);
         }
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/443bea77/core/src/main/java/brooklyn/entity/rebind/RebindManagerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/RebindManagerImpl.java b/core/src/main/java/brooklyn/entity/rebind/RebindManagerImpl.java
index d6491a4..aa30927 100644
--- a/core/src/main/java/brooklyn/entity/rebind/RebindManagerImpl.java
+++ b/core/src/main/java/brooklyn/entity/rebind/RebindManagerImpl.java
@@ -22,7 +22,6 @@ import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.entity.proxying.InternalEntityFactory;
 import brooklyn.entity.proxying.InternalLocationFactory;
 import brooklyn.entity.proxying.InternalPolicyFactory;
-import brooklyn.entity.rebind.RebindExceptionHandlerImpl.RebindFailureMode;
 import brooklyn.internal.BrooklynFeatureEnablement;
 import brooklyn.location.Location;
 import brooklyn.location.basic.AbstractLocation;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/443bea77/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterInMemory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterInMemory.java
b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterInMemory.java
index 3f9fcf6..f1fda50 100644
--- a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterInMemory.java
+++ b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterInMemory.java
@@ -15,7 +15,7 @@ import brooklyn.entity.basic.EntityInternal;
 import brooklyn.entity.proxying.EntityProxy;
 import brooklyn.entity.rebind.RebindExceptionHandler;
 import brooklyn.entity.rebind.RebindExceptionHandlerImpl;
-import brooklyn.entity.rebind.RebindExceptionHandlerImpl.RebindFailureMode;
+import brooklyn.entity.rebind.RebindManager;
 import brooklyn.location.Location;
 import brooklyn.location.basic.LocationInternal;
 import brooklyn.mementos.BrooklynMemento;
@@ -113,7 +113,7 @@ public class BrooklynMementoPersisterInMemory extends AbstractBrooklynMementoPer
                 };
 
                 // Not actually reconstituting, because need to use a real lookupContext
to reconstitute all the entities
-                RebindExceptionHandler exceptionHandler = new RebindExceptionHandlerImpl(RebindFailureMode.FAIL_AT_END,
RebindFailureMode.FAIL_AT_END);
+                RebindExceptionHandler exceptionHandler = new RebindExceptionHandlerImpl(RebindManager.RebindFailureMode.FAIL_AT_END,
RebindManager.RebindFailureMode.FAIL_AT_END);
                 persister.loadMemento(dummyLookupContext, exceptionHandler);
             } finally {
                 Os.tryDeleteDirectory(tempDir.getAbsolutePath());

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/443bea77/core/src/test/java/brooklyn/entity/rebind/RebindFailuresTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindFailuresTest.java b/core/src/test/java/brooklyn/entity/rebind/RebindFailuresTest.java
index f4b84d7..db9a4c7 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindFailuresTest.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindFailuresTest.java
@@ -19,7 +19,7 @@ import brooklyn.entity.basic.EntityPredicates;
 import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.entity.rebind.RebindEntityTest.MyEntity;
 import brooklyn.entity.rebind.RebindEntityTest.MyEntityImpl;
-import brooklyn.entity.rebind.RebindExceptionHandlerImpl.RebindFailureMode;
+import brooklyn.entity.rebind.RebindManager.RebindFailureMode;
 import brooklyn.event.AttributeSensor;
 import brooklyn.management.EntityManager;
 import brooklyn.management.internal.LocalManagementContext;
@@ -57,8 +57,8 @@ public class RebindFailuresTest extends RebindTestFixtureWithApp {
 
     @Test
     public void testFailureRebindingEntityWhenFailAtEnd() throws Exception {
-        RebindFailureMode danglingRefFailureMode = RebindFailureMode.CONTINUE;
-        RebindFailureMode rebindFailureMode = RebindFailureMode.FAIL_AT_END;
+        RebindFailureMode danglingRefFailureMode = RebindManager.RebindFailureMode.CONTINUE;
+        RebindFailureMode rebindFailureMode = RebindManager.RebindFailureMode.FAIL_AT_END;
         
         MyEntity origFailingE = origApp.createAndManageChild(EntitySpec.create(MyEntity.class)
                 .impl(MyEntityFailingImpl.class)
@@ -83,8 +83,8 @@ public class RebindFailuresTest extends RebindTestFixtureWithApp {
     
     @Test
     public void testFailureRebindingEntityWhenFailFast() throws Exception {
-        RebindFailureMode danglingRefFailureMode = RebindFailureMode.CONTINUE;
-        RebindFailureMode rebindFailureMode = RebindFailureMode.FAIL_FAST;
+        RebindFailureMode danglingRefFailureMode = RebindManager.RebindFailureMode.CONTINUE;
+        RebindFailureMode rebindFailureMode = RebindManager.RebindFailureMode.FAIL_FAST;
         
         MyEntity origFailingE = origApp.createAndManageChild(EntitySpec.create(MyEntity.class)
                 .impl(MyEntityFailingImpl.class)
@@ -109,8 +109,8 @@ public class RebindFailuresTest extends RebindTestFixtureWithApp {
     
     @Test
     public void testFailureRebindingEntityWhenContinue() throws Exception {
-        RebindFailureMode danglingRefFailureMode = RebindFailureMode.CONTINUE;
-        RebindFailureMode rebindFailureMode = RebindFailureMode.CONTINUE;
+        RebindFailureMode danglingRefFailureMode = RebindManager.RebindFailureMode.CONTINUE;
+        RebindFailureMode rebindFailureMode = RebindManager.RebindFailureMode.CONTINUE;
         
         MyEntity origFailingE = origApp.createAndManageChild(EntitySpec.create(MyEntity.class)
                 .impl(MyEntityFailingImpl.class)
@@ -130,8 +130,8 @@ public class RebindFailuresTest extends RebindTestFixtureWithApp {
     
     @Test
     public void testFailureRebindingBecauseDirectoryCorrupt() throws Exception {
-        RebindFailureMode danglingRefFailureMode = RebindFailureMode.CONTINUE;
-        RebindFailureMode rebindFailureMode = RebindFailureMode.FAIL_AT_END;
+        RebindFailureMode danglingRefFailureMode = RebindManager.RebindFailureMode.CONTINUE;
+        RebindFailureMode rebindFailureMode = RebindManager.RebindFailureMode.FAIL_AT_END;
         
         origManagementContext.getRebindManager().stop();
         if (mementoDir != null) RebindTestUtils.deleteMementoDir(mementoDir);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/443bea77/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 d315d75..fdd0a0f 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java
@@ -7,7 +7,6 @@ import org.testng.annotations.BeforeMethod;
 
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.basic.StartableApplication;
-import brooklyn.entity.rebind.RebindExceptionHandlerImpl.RebindFailureMode;
 import brooklyn.entity.rebind.persister.BrooklynMementoPersisterToMultiFile;
 import brooklyn.internal.BrooklynFeatureEnablement;
 import brooklyn.management.ManagementContext;
@@ -102,7 +101,7 @@ public abstract class RebindTestFixture<T extends StartableApplication>
{
     
     protected BrooklynMementoManifest loadMementoManifest() throws Exception {
         BrooklynMementoPersisterToMultiFile persister = new BrooklynMementoPersisterToMultiFile(mementoDir,
classLoader);
-        RebindExceptionHandler exceptionHandler = new RecordingRebindExceptionHandler(RebindFailureMode.FAIL_AT_END,
RebindFailureMode.FAIL_AT_END);
+        RebindExceptionHandler exceptionHandler = new RecordingRebindExceptionHandler(RebindManager.RebindFailureMode.FAIL_AT_END,
RebindManager.RebindFailureMode.FAIL_AT_END);
         BrooklynMementoManifest mementoManifest = persister.loadMementoManifest(exceptionHandler);
         persister.stop();
         return mementoManifest;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/443bea77/core/src/test/java/brooklyn/entity/rebind/RecordingRebindExceptionHandler.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RecordingRebindExceptionHandler.java
b/core/src/test/java/brooklyn/entity/rebind/RecordingRebindExceptionHandler.java
index d3fc0be..9b72543 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RecordingRebindExceptionHandler.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RecordingRebindExceptionHandler.java
@@ -26,7 +26,7 @@ public class RecordingRebindExceptionHandler extends RebindExceptionHandlerImpl
     protected final Map<String, Exception> policyNotFoundFailures = Maps.newLinkedHashMap();
     protected Exception failed;
     
-    public RecordingRebindExceptionHandler(RebindFailureMode danglingRefFailureMode, RebindFailureMode
rebindFailureMode) {
+    public RecordingRebindExceptionHandler(RebindManager.RebindFailureMode danglingRefFailureMode,
RebindManager.RebindFailureMode rebindFailureMode) {
         super(danglingRefFailureMode, rebindFailureMode);
     }
 


Mime
View raw message