brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [2/3] brooklyn-server git commit: PR #148: auto-unmanaged locations incorporate comments
Date Sat, 28 May 2016 11:53:44 GMT
PR #148: auto-unmanaged locations incorporate comments

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

Branch: refs/heads/master
Commit: 73895e5eaa9ed3d07ee540e541d3f8b4ed3cab5f
Parents: 4070cbd
Author: Aled Sage <aled.sage@gmail.com>
Authored: Fri May 27 15:47:32 2016 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Fri May 27 15:47:32 2016 +0100

----------------------------------------------------------------------
 .../brooklyn/core/entity/AbstractEntity.java    |  7 ++++---
 .../apache/brooklyn/core/mgmt/BrooklynTags.java |  1 -
 .../core/mgmt/internal/LocalEntityManager.java  |  6 +++---
 .../BrooklynMementoPersisterTestFixture.java    | 21 +++++++++++++++-----
 .../SoftwareProcessLocationUnmanageTest.java    |  8 +++++++-
 5 files changed, 30 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/73895e5e/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 cb22c14..bde505c 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
@@ -886,9 +886,10 @@ public abstract class AbstractEntity extends AbstractBrooklynObject implements
E
                 if (!getId().equals(ownerEntityTag.getContents())) {
                     // A location is "owned" if it was created as part of the EntitySpec
of an entity (by Brooklyn).
                     // To share a location between entities create it yourself and pass it
to any entities that needs it.
-                    LOG.warn("Adding location {} to entity {} which is already owner by another
entity {}. " +
-                            "Locations which are owned by a specific entity should not be
shared with other entities as they " +
-                            "will be unmanaged together with their owner, regardless of other
references to them.",
+                    LOG.info("Adding location {} to entity {}, which is already owned by
another entity {}. " +
+                            "Locations owned by a specific entity will be unmanaged together
with their owner, " +
+                            "regardless of other references to them. Therefore care should
be taken if sharing " +
+                            "the location with other entities.",
                             new Object[] {loc, this, ownerEntityTag.getContents()});
                 }
             }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/73895e5e/core/src/main/java/org/apache/brooklyn/core/mgmt/BrooklynTags.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/BrooklynTags.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/BrooklynTags.java
index 3187665..20b42ac 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/BrooklynTags.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/BrooklynTags.java
@@ -22,7 +22,6 @@ import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.util.collections.MutableList;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/73895e5e/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalEntityManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalEntityManager.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalEntityManager.java
index b30089d..6edecfc 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalEntityManager.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalEntityManager.java
@@ -758,9 +758,9 @@ public class LocalEntityManager implements EntityManagerInternal {
                 } else {
                     // A location is "owned" if it was created as part of the EntitySpec
of an entity (by Brooklyn).
                     // To share a location between entities create it yourself and pass it
to any entities that needs it.
-                    log.warn("Unmanaging entity {} which contains a location {} owned by
another entity {}. " +
-                            "Locations which are owned by a specific entity should not be
shared with other entities as they " +
-                            "will be unmanaged together with their owner, regardless of other
references to them.",
+                    log.debug("Unmanaging entity {}, which contains a location {} owned by
another entity {}. " +
+                            "Not automatically unmanaging the location (it will be unmanaged
when its owning " +
+                            "entity is unmanaged).",
                             new Object[] {e, loc, ownerEntityTag.getContents()});
                 }
             }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/73895e5e/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterTestFixture.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterTestFixture.java
b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterTestFixture.java
index 4c8aac0..6f6d363 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterTestFixture.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterTestFixture.java
@@ -34,6 +34,7 @@ import org.apache.brooklyn.api.mgmt.rebind.mementos.BrooklynMemento;
 import org.apache.brooklyn.api.mgmt.rebind.mementos.BrooklynMementoPersister;
 import org.apache.brooklyn.api.mgmt.rebind.mementos.BrooklynMementoRawData;
 import org.apache.brooklyn.api.policy.Policy;
+import org.apache.brooklyn.api.policy.PolicySpec;
 import org.apache.brooklyn.api.sensor.Enricher;
 import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.factory.ApplicationBuilder;
@@ -80,12 +81,13 @@ public abstract class BrooklynMementoPersisterTestFixture {
         if (objectStore==null && persister instanceof BrooklynMementoPersisterToObjectStore)
{
             objectStore = ((BrooklynMementoPersisterToObjectStore)persister).getObjectStore();
         }
-        app = ApplicationBuilder.newManagedApp(EntitySpec.create(TestApplication.class),
localManagementContext);
-        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(
-            LocationSpec.create(SshMachineLocation.class).configure("address", "localhost")));
-        location = Iterables.getOnlyElement( entity.getLocations() );
+        EntitySpec<TestApplication> appSpec = EntitySpec.create(TestApplication.class)
+                .location(LocationSpec.create(SshMachineLocation.class).configure("address",
"localhost"));
+        app = ApplicationBuilder.newManagedApp(appSpec, localManagementContext);
+        location = Iterables.getOnlyElement( app.getLocations() );
+        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class));
         enricher = app.enrichers().add(Enrichers.builder().propagatingAll().from(entity).build());
-        app.policies().add(policy = new TestPolicy());
+        policy = app.policies().add(PolicySpec.create(TestPolicy.class));
     }
 
     protected abstract ManagementContext newPersistingManagementContext();
@@ -141,6 +143,15 @@ public abstract class BrooklynMementoPersisterTestFixture {
         assertNotNull(reloadedMemento);
         assertFalse(Iterables.contains(reloadedMemento.getEntityIds(), entity.getId()));
         assertEquals(Iterables.getOnlyElement(reloadedMemento.getLocationIds()), location.getId());
+        
+        // Destroying the app should also unmanage its owned location, and adjuncts
+        Entities.destroy(app);
+        reloadedMemento = loadMemento();
+        
+        assertFalse(Iterables.contains(reloadedMemento.getEntityIds(), entity.getId()));
+        assertFalse(Iterables.contains(reloadedMemento.getPolicyIds(), policy.getId()));
+        assertFalse(Iterables.contains(reloadedMemento.getEnricherIds(), enricher.getId()));
+        assertFalse(Iterables.contains(reloadedMemento.getLocationIds(), location.getId()));
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/73895e5e/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/location/SoftwareProcessLocationUnmanageTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/location/SoftwareProcessLocationUnmanageTest.java
b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/location/SoftwareProcessLocationUnmanageTest.java
index 342ec69..d8d9fd1 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/location/SoftwareProcessLocationUnmanageTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/location/SoftwareProcessLocationUnmanageTest.java
@@ -46,7 +46,13 @@ public class SoftwareProcessLocationUnmanageTest extends BrooklynAppUnitTestSupp
         testLocationUnmanagedOnStop(locationSpec);
     }
 
-    @Test(groups="Live")
+    /**
+     * This is a convenience for manually testing against a Docker endpoint (hence it being

+     * marked "WIP", so not in any jenkins builds). Before running, manually change the endpoint,
+     * identity and credential. The Docker host (or Swarm endpoint) needs to be configured
+     * with TLS, and have "ubuntu:14:04" already pulled on the server.
+     */
+    @Test(groups={"Live", "WIP"})
     public void testDockerLocationUnmanagedOnStop() {
         LocationSpec<? extends Location> locationSpec = LocationSpec.create(JcloudsLocation.class)
                 .configure(JcloudsLocation.CLOUD_PROVIDER, "docker")


Mime
View raw message