You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2014/07/17 11:08:00 UTC

[1/4] git commit: Fix SshFeedIntegrationTest.testDynamicEnvAndCommandSupplier

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 458763390 -> 9e7b23730


Fix SshFeedIntegrationTest.testDynamicEnvAndCommandSupplier


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

Branch: refs/heads/master
Commit: 12141c762452b35bbe10bfb451fb70262835e929
Parents: 18f633f
Author: Aled Sage <al...@gmail.com>
Authored: Wed Jul 16 15:35:59 2014 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Jul 16 16:22:49 2014 +0100

----------------------------------------------------------------------
 .../test/java/brooklyn/event/feed/ssh/SshFeedIntegrationTest.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/12141c76/core/src/test/java/brooklyn/event/feed/ssh/SshFeedIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/event/feed/ssh/SshFeedIntegrationTest.java b/core/src/test/java/brooklyn/event/feed/ssh/SshFeedIntegrationTest.java
index b781197..b5370ce 100644
--- a/core/src/test/java/brooklyn/event/feed/ssh/SshFeedIntegrationTest.java
+++ b/core/src/test/java/brooklyn/event/feed/ssh/SshFeedIntegrationTest.java
@@ -218,7 +218,7 @@ public class SshFeedIntegrationTest extends BrooklynAppUnitTestSupport {
                         .onSuccess(SshValueFunctions.stdout()))
                 .build();
         
-        EntityTestUtils.assertAttributeEventuallyNonNull(entity, SENSOR_STRING);        
+        EntityTestUtils.assertAttributeEventuallyNonNull(entity2, SENSOR_STRING);        
         final String val1 = assertDifferentOneInOutput(entity2);
         
         EntityTestUtils.assertAttributeEventually(entity2, SENSOR_STRING, Predicates.not(Predicates.equalTo(val1)));        


[4/4] git commit: This closes #73

Posted by al...@apache.org.
This closes #73


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

Branch: refs/heads/master
Commit: 9e7b237309fcce563354cd92406a78d6429aef2a
Parents: 4587633 12141c7
Author: Aled Sage <al...@gmail.com>
Authored: Thu Jul 17 10:07:38 2014 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Jul 17 10:07:38 2014 +0100

----------------------------------------------------------------------
 .../group/AbstractMembershipTrackingPolicy.java | 36 +++++++++-----------
 .../internal/AbstractManagementContext.java     |  2 +-
 .../util/task/BasicExecutionManager.java        |  4 +--
 .../group/MembershipTrackingPolicyTest.java     | 25 +++++++++++---
 .../event/feed/ssh/SshFeedIntegrationTest.java  |  2 +-
 .../brooklyn/entity/pool/ServerPoolImpl.java    |  3 +-
 .../entity/proxy/AbstractControllerImpl.java    |  3 +-
 7 files changed, 43 insertions(+), 32 deletions(-)
----------------------------------------------------------------------



[3/4] git commit: MembershipTrackingPolicy: default to not notifying of duplicates

Posted by al...@apache.org.
MembershipTrackingPolicy: default to not notifying of duplicates


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

Branch: refs/heads/master
Commit: e832afb3959f7f7e0226a128bf0a26ade0d8cff7
Parents: 6325e50
Author: Aled Sage <al...@gmail.com>
Authored: Wed Jul 16 15:34:03 2014 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Jul 16 16:22:49 2014 +0100

----------------------------------------------------------------------
 .../group/AbstractMembershipTrackingPolicy.java | 36 +++++++++-----------
 .../group/MembershipTrackingPolicyTest.java     | 25 +++++++++++---
 .../brooklyn/entity/pool/ServerPoolImpl.java    |  3 +-
 .../entity/proxy/AbstractControllerImpl.java    |  3 +-
 4 files changed, 39 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e832afb3/core/src/main/java/brooklyn/entity/group/AbstractMembershipTrackingPolicy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/group/AbstractMembershipTrackingPolicy.java b/core/src/main/java/brooklyn/entity/group/AbstractMembershipTrackingPolicy.java
index e4508fd..e3f0dce 100644
--- a/core/src/main/java/brooklyn/entity/group/AbstractMembershipTrackingPolicy.java
+++ b/core/src/main/java/brooklyn/entity/group/AbstractMembershipTrackingPolicy.java
@@ -33,7 +33,6 @@ import brooklyn.entity.basic.Attributes;
 import brooklyn.entity.basic.ConfigKeys;
 import brooklyn.entity.basic.DynamicGroup;
 import brooklyn.entity.basic.EntityLocal;
-import brooklyn.entity.trait.Startable;
 import brooklyn.event.Sensor;
 import brooklyn.event.SensorEvent;
 import brooklyn.event.SensorEventListener;
@@ -60,7 +59,7 @@ public abstract class AbstractMembershipTrackingPolicy extends AbstractPolicy {
 
     public static final ConfigKey<Boolean> NOTIFY_ON_DUPLICATES = ConfigKeys.newBooleanConfigKey("notifyOnDuplicates",
             "Whether to notify listeners when a sensor is published with the same value as last time",
-            true);
+            false);
 
     public static final ConfigKey<Group> GROUP = ConfigKeys.newConfigKey(Group.class, "group");
 
@@ -175,28 +174,25 @@ public abstract class AbstractMembershipTrackingPolicy extends AbstractPolicy {
 
         for (Sensor<?> sensor : getSensorsToTrack()) {
             subscribeToMembers(group, sensor, new SensorEventListener<Object>() {
-                boolean hasWarnedOfServiceUp = false;
-                
                 @Override public void onEvent(SensorEvent<Object> event) {
                     boolean notifyOnDuplicates = getRequiredConfig(NOTIFY_ON_DUPLICATES);
-                    if (Startable.SERVICE_UP.equals(event.getSensor()) && notifyOnDuplicates && !hasWarnedOfServiceUp) {
-                        LOG.warn("Deprecated behaviour: not notifying of duplicate value for service-up in {}, group {}", AbstractMembershipTrackingPolicy.this, group);
-                        hasWarnedOfServiceUp = true;
-                        notifyOnDuplicates = false;
-                    }
-                    
                     String entityId = event.getSource().getId();
 
-                    Map<Sensor<Object>, Object> newMap = MutableMap.<Sensor<Object>, Object>of();
-                    // NOTE: putIfAbsent returns null if the key is not present, or the *previous* value if present
-                    Map<Sensor<Object>, Object> sensorCache = entitySensorCache.putIfAbsent(entityId, newMap);
-                    if (sensorCache == null) {
-                        sensorCache = newMap;
-                    }
-                    
-                    if (!notifyOnDuplicates && Objects.equal(event.getValue(), sensorCache.put(event.getSensor(), event.getValue()))) {
-                        // ignore if value has not changed
-                        return;
+                    if (!notifyOnDuplicates) {
+                        Map<Sensor<Object>, Object> newMap = MutableMap.<Sensor<Object>, Object>of();
+                        // NOTE: putIfAbsent returns null if the key is not present, or the *previous* value if present
+                        Map<Sensor<Object>, Object> sensorCache = entitySensorCache.putIfAbsent(entityId, newMap);
+                        if (sensorCache == null) {
+                            sensorCache = newMap;
+                        }
+                        
+                        boolean oldExists = sensorCache.containsKey(event.getSensor());
+                        Object oldVal = sensorCache.put(event.getSensor(), event.getValue());
+                        
+                        if (oldExists && Objects.equal(event.getValue(), oldVal)) {
+                            // ignore if value has not changed
+                            return;
+                        }
                     }
 
                     onEntityEvent(EventType.ENTITY_CHANGE, event.getSource());

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e832afb3/core/src/test/java/brooklyn/entity/group/MembershipTrackingPolicyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/group/MembershipTrackingPolicyTest.java b/core/src/test/java/brooklyn/entity/group/MembershipTrackingPolicyTest.java
index 86a5eb9..8fe0e19 100644
--- a/core/src/test/java/brooklyn/entity/group/MembershipTrackingPolicyTest.java
+++ b/core/src/test/java/brooklyn/entity/group/MembershipTrackingPolicyTest.java
@@ -35,6 +35,7 @@ import brooklyn.entity.basic.Entities;
 import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.entity.trait.Startable;
 import brooklyn.event.Sensor;
+import brooklyn.location.LocationSpec;
 import brooklyn.location.basic.SimulatedLocation;
 import brooklyn.management.EntityManager;
 import brooklyn.policy.PolicySpec;
@@ -60,7 +61,7 @@ public class MembershipTrackingPolicyTest extends BrooklynAppUnitTestSupport {
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        loc = new SimulatedLocation();
+        loc = mgmt.getLocationManager().createLocation(LocationSpec.create(SimulatedLocation.class));
         entityManager = app.getManagementContext().getEntityManager();
         
         group = app.createAndManageChild(EntitySpec.create(BasicGroup.class)
@@ -169,25 +170,41 @@ public class MembershipTrackingPolicyTest extends BrooklynAppUnitTestSupport {
                 .configure(AbstractMembershipTrackingPolicy.GROUP, group));
 
         e1.setAttribute(TestEntity.NAME, "myname");
-
         assertRecordsEventually(nonDuplicateTrackingPolicy, Record.newAdded(e1), Record.newChanged(e1));
         
         e1.setAttribute(TestEntity.NAME, "myname");
-        
         assertRecordsContinually(nonDuplicateTrackingPolicy, Record.newAdded(e1), Record.newChanged(e1));
         
         e1.setAttribute(TestEntity.NAME, "mynewname");
+        assertRecordsEventually(nonDuplicateTrackingPolicy, Record.newAdded(e1), Record.newChanged(e1), Record.newChanged(e1));
+    }
+
+    // NOTIFY_ON_DUPLICATES==false is default
+    @Test
+    public void testDefaultNotNotifiedOfExtraTrackedSensorsIfDuplicate() throws Exception {
+        TestEntity e1 = createAndManageChildOf(group);
+        
+        RecordingMembershipTrackingPolicy nonDuplicateTrackingPolicy = app.addPolicy(PolicySpec.create(RecordingMembershipTrackingPolicy.class)
+                .configure(AbstractMembershipTrackingPolicy.SENSORS_TO_TRACK, ImmutableSet.<Sensor<?>>of(TestEntity.NAME))
+                .configure(AbstractMembershipTrackingPolicy.GROUP, group));
+
+        e1.setAttribute(TestEntity.NAME, "myname");
+        assertRecordsEventually(nonDuplicateTrackingPolicy, Record.newAdded(e1), Record.newChanged(e1));
         
+        e1.setAttribute(TestEntity.NAME, "myname");
+        assertRecordsContinually(nonDuplicateTrackingPolicy, Record.newAdded(e1), Record.newChanged(e1));
+        
+        e1.setAttribute(TestEntity.NAME, "mynewname");
         assertRecordsEventually(nonDuplicateTrackingPolicy, Record.newAdded(e1), Record.newChanged(e1), Record.newChanged(e1));
     }
 
-    // NOTIFY_ON_DUPLICATES==true is default
     @Test
     public void testNotifiedOfExtraTrackedSensorsIfDuplicate() throws Exception {
         TestEntity e1 = createAndManageChildOf(group);
         
         RecordingMembershipTrackingPolicy nonDuplicateTrackingPolicy = app.addPolicy(PolicySpec.create(RecordingMembershipTrackingPolicy.class)
                 .configure(AbstractMembershipTrackingPolicy.SENSORS_TO_TRACK, ImmutableSet.<Sensor<?>>of(TestEntity.NAME))
+                .configure(AbstractMembershipTrackingPolicy.NOTIFY_ON_DUPLICATES, true)
                 .configure(AbstractMembershipTrackingPolicy.GROUP, group));
 
         e1.setAttribute(TestEntity.NAME, "myname");

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e832afb3/software/base/src/main/java/brooklyn/entity/pool/ServerPoolImpl.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/pool/ServerPoolImpl.java b/software/base/src/main/java/brooklyn/entity/pool/ServerPoolImpl.java
index b05a4dc..5ca8646 100644
--- a/software/base/src/main/java/brooklyn/entity/pool/ServerPoolImpl.java
+++ b/software/base/src/main/java/brooklyn/entity/pool/ServerPoolImpl.java
@@ -118,8 +118,7 @@ public class ServerPoolImpl extends DynamicClusterImpl implements ServerPool {
     private void addMembershipTrackerPolicy() {
         membershipTracker = addPolicy(PolicySpec.create(MemberTrackingPolicy.class)
                 .displayName(getDisplayName() + " membership tracker")
-                .configure("group", this)
-                .configure("notifyOnDuplicates", false));
+                .configure("group", this));
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e832afb3/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractControllerImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractControllerImpl.java b/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractControllerImpl.java
index 2e0c0bd..9542b88 100644
--- a/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractControllerImpl.java
+++ b/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractControllerImpl.java
@@ -124,8 +124,7 @@ public abstract class AbstractControllerImpl extends SoftwareProcessImpl impleme
         serverPoolMemberTrackerPolicy = addPolicy(PolicySpec.create(ServerPoolMemberTrackerPolicy.class)
                 .displayName("Controller targets tracker")
                 .configure("group", serverPool)
-                .configure("sensorsToTrack", sensorsToTrack)
-                .configure(ServerPoolMemberTrackerPolicy.NOTIFY_ON_DUPLICATES, false));
+                .configure("sensorsToTrack", sensorsToTrack));
 
         LOG.info("Added policy {} to {}", serverPoolMemberTrackerPolicy, this);
         


[2/4] git commit: White space tidies

Posted by al...@apache.org.
White space tidies


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

Branch: refs/heads/master
Commit: 18f633f3921b92754663bf5c5f8cf34ec1911ac9
Parents: e832afb
Author: Aled Sage <al...@gmail.com>
Authored: Wed Jul 16 15:35:36 2014 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Jul 16 16:22:49 2014 +0100

----------------------------------------------------------------------
 .../brooklyn/management/internal/AbstractManagementContext.java  | 2 +-
 core/src/main/java/brooklyn/util/task/BasicExecutionManager.java | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/18f633f3/core/src/main/java/brooklyn/management/internal/AbstractManagementContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/AbstractManagementContext.java b/core/src/main/java/brooklyn/management/internal/AbstractManagementContext.java
index 860e5d4..2eb695a 100644
--- a/core/src/main/java/brooklyn/management/internal/AbstractManagementContext.java
+++ b/core/src/main/java/brooklyn/management/internal/AbstractManagementContext.java
@@ -81,7 +81,7 @@ import com.google.common.base.Throwables;
 public abstract class AbstractManagementContext implements ManagementContextInternal {
     private static final Logger log = LoggerFactory.getLogger(AbstractManagementContext.class);
 
-    private static DataGridFactory loadDataGridFactory(BrooklynProperties properties){
+    private static DataGridFactory loadDataGridFactory(BrooklynProperties properties) {
         String clazzName = properties.getFirst(DataGridFactory.class.getName());
         if(clazzName == null){
             clazzName = InMemoryDataGridFactory.class.getName();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/18f633f3/core/src/main/java/brooklyn/util/task/BasicExecutionManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/task/BasicExecutionManager.java b/core/src/main/java/brooklyn/util/task/BasicExecutionManager.java
index a36124e..a9d6a46 100644
--- a/core/src/main/java/brooklyn/util/task/BasicExecutionManager.java
+++ b/core/src/main/java/brooklyn/util/task/BasicExecutionManager.java
@@ -124,7 +124,7 @@ public class BasicExecutionManager implements ExecutionManager {
                 .build();
                 
         // use Executors.newCachedThreadPool(daemonThreadFactory), but timeout of 1s rather than 60s for better shutdown!
-        runner = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 1L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), 
+        runner = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 10L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), 
                 daemonThreadFactory);
             
         delayedRunner = new ScheduledThreadPoolExecutor(1, daemonThreadFactory);
@@ -138,7 +138,7 @@ public class BasicExecutionManager implements ExecutionManager {
 	protected ThreadFactory newThreadFactory(String contextid) {
 	    return new ThreadFactoryBuilder()
         	    .setNameFormat("brooklyn-execmanager-"+contextid+"-%d")
-        	    .setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler(){
+        	    .setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
                         @Override
                         public void uncaughtException(Thread t, Throwable e) {
                             log.error("Uncaught exception in thread "+t.getName(), e);