You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sj...@apache.org on 2016/01/13 11:42:47 UTC

[1/8] incubator-brooklyn git commit: Fix LocalhostExternalIpLoader blocking - BROOKLYN-213

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master d05815810 -> 58337c4e4


Fix LocalhostExternalIpLoader blocking - BROOKLYN-213

Lookups will now block until the first successful resolve attempt or all services have been tried.


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

Branch: refs/heads/master
Commit: 71f11ea1d2cd03d69cb96b2264b3502899f19f03
Parents: 7bcb392
Author: Matt Champion <ma...@gmail.com>
Authored: Fri Jan 8 10:56:16 2016 +0000
Committer: Matt Champion <ma...@gmail.com>
Committed: Fri Jan 8 11:48:46 2016 +0000

----------------------------------------------------------------------
 .../location/geo/LocalhostExternalIpLoader.java | 73 ++++++++++++++------
 1 file changed, 52 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/71f11ea1/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/location/geo/LocalhostExternalIpLoader.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/location/geo/LocalhostExternalIpLoader.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/location/geo/LocalhostExternalIpLoader.java
index fd95585..f6623fc 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/location/geo/LocalhostExternalIpLoader.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/location/geo/LocalhostExternalIpLoader.java
@@ -44,8 +44,21 @@ public class LocalhostExternalIpLoader {
 
     public static final Logger LOG = LoggerFactory.getLogger(LocalhostExternalIpLoader.class);
 
-    private static final AtomicBoolean retrievingLocalExternalIp = new AtomicBoolean(false);
-    private static final CountDownLatch triedLocalExternalIp = new CountDownLatch(1);
+    /**
+     * Mutex to guard access to retrievingLocalExternalIp.
+     */
+    private static final Object mutex = new Object();
+    /**
+     * When null there is no ongoing attempt to load the external IP address. Either no attempt has been made or the
+     * last attempt has been completed.
+     * When set there is an ongoing attempt to load the external IP address. New attempts to lookup the external IP
+     * address should wait on this latch instead of making another attempt to load the IP address.
+     */
+    private static CountDownLatch retrievingLocalExternalIp;
+    /**
+     * Cached external IP address of localhost. Null if either no attempt has been made to resolve the address or the
+     * last attempt failed.
+     */
     private static volatile String localExternalIp;
 
     private static class IpLoader implements Callable<String> {
@@ -120,57 +133,75 @@ public class LocalhostExternalIpLoader {
     }
 
     /**
-     * Requests URLs returned by {@link #getIpAddressWebsites()} until one returns an IP address.
+     * Requests URLs returned by {@link #getIpAddressWebsites()} until one returns an IP address or all URLs have been tried.
      * The address is assumed to be the external IP address of localhost.
      * @param blockFor The maximum duration to wait for the IP address to be resolved.
      *                 An indefinite way if null.
      * @return A string in IPv4 format, or null if no such address could be ascertained.
      */
     private static String doLoad(Duration blockFor) {
-        if (localExternalIp != null) {
-            return localExternalIp;
+        // Check for a cached external IP address
+        final String resolvedIp = localExternalIp;
+        if (resolvedIp != null) {
+            return resolvedIp;
         }
 
-        final List<String> candidateUrls = getIpAddressWebsites();
-        if (candidateUrls.isEmpty()) {
-            LOG.debug("No candidate URLs to use to determine external IP of localhost");
-            return null;
+        // Check for an ongoing attempt to load an external IP address
+        final boolean startAttemptToLoadIp;
+        final CountDownLatch attemptToRetrieveLocalExternalIp;
+        synchronized (mutex) {
+            if (retrievingLocalExternalIp == null) {
+                retrievingLocalExternalIp = new CountDownLatch(1);
+                startAttemptToLoadIp = true;
+            }
+            else {
+                startAttemptToLoadIp = false;
+            }
+            attemptToRetrieveLocalExternalIp = retrievingLocalExternalIp;
         }
 
-        // do in private thread, otherwise blocks for 30s+ on dodgy network!
+        // Attempt to load the external IP address in private thread, otherwise blocks for 30s+ on dodgy network!
         // (we can skip it if someone else is doing it, we have synch lock so we'll get notified)
-        if (retrievingLocalExternalIp.compareAndSet(false, true)) {
+        if (startAttemptToLoadIp) {
+            final List<String> candidateUrls = getIpAddressWebsites();
+            if (candidateUrls.isEmpty()) {
+                LOG.debug("No candidate URLs to use to determine external IP of localhost");
+                return null;
+            }
+
             new Thread() {
                 public void run() {
                     for (String url : candidateUrls) {
                         try {
                             LOG.debug("Looking up external IP of this host from {} in private thread {}", url, Thread.currentThread());
-                            localExternalIp = new IpLoader(url).call();
-                            LOG.debug("Finished looking up external IP of this host from {} in private thread, result {}", url, localExternalIp);
+                            final String loadedIp = new IpLoader(url).call();
+                            localExternalIp = loadedIp;
+                            LOG.debug("Finished looking up external IP of this host from {} in private thread, result {}", url, loadedIp);
                             break;
                         } catch (Throwable t) {
                             LOG.debug("Unable to look up external IP of this host from {}, probably offline {})", url, t);
-                        } finally {
-                            retrievingLocalExternalIp.set(false);
-                            triedLocalExternalIp.countDown();
                         }
                     }
+
+                    attemptToRetrieveLocalExternalIp.countDown();
+
+                    synchronized (mutex) {
+                        retrievingLocalExternalIp = null;
+                    }
                 }
             }.start();
         }
 
         try {
             if (blockFor!=null) {
-                Durations.await(triedLocalExternalIp, blockFor);
+                Durations.await(attemptToRetrieveLocalExternalIp, blockFor);
             } else {
-                triedLocalExternalIp.await();
+                attemptToRetrieveLocalExternalIp.await();
             }
         } catch (InterruptedException e) {
             throw Exceptions.propagate(e);
         }
-        if (localExternalIp == null) {
-            return null;
-        }
+
         return localExternalIp;
     }
 


[2/8] incubator-brooklyn git commit: Remove discontinued IP lookup service - BROOKLYN-213

Posted by sj...@apache.org.
Remove discontinued IP lookup service - BROOKLYN-213

The IP lookup service http://www.telize.com/ip was discontinued on the 15th of November 2015.


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

Branch: refs/heads/master
Commit: d4565b89f3a89658851a6053db7177ff4a64debb
Parents: 71f11ea
Author: Matt Champion <ma...@gmail.com>
Authored: Fri Jan 8 10:58:01 2016 +0000
Committer: Matt Champion <ma...@gmail.com>
Committed: Fri Jan 8 11:51:23 2016 +0000

----------------------------------------------------------------------
 .../apache/brooklyn/location/geo/external-ip-address-resolvers.txt  | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d4565b89/brooklyn-server/core/src/main/resources/org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/resources/org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt b/brooklyn-server/core/src/main/resources/org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt
index bc3c26e..693114a 100644
--- a/brooklyn-server/core/src/main/resources/org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt
+++ b/brooklyn-server/core/src/main/resources/org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt
@@ -18,7 +18,6 @@
 http://jsonip.com/
 http://myip.dnsomatic.com/
 http://checkip.dyndns.org/
-http://www.telize.com/ip
 http://wtfismyip.com/text
 http://whatismyip.akamai.com/
 http://myip.wampdeveloper.com/


[5/8] incubator-brooklyn git commit: [BROOKLYN-183] Remove dangling file

Posted by sj...@apache.org.
[BROOKLYN-183] Remove dangling file

The real stuff is karaf/src/feature/feature.xml


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

Branch: refs/heads/master
Commit: 41e9231c44d6572de70269e5317e16ea1ae66df6
Parents: 966b714
Author: Ciprian Ciubotariu <ch...@gmx.net>
Authored: Tue Jan 12 19:46:41 2016 +0200
Committer: Ciprian Ciubotariu <ch...@gmx.net>
Committed: Tue Jan 12 19:46:41 2016 +0200

----------------------------------------------------------------------
 brooklyn-server/karaf/feature.xml | 51 ----------------------------------
 1 file changed, 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/41e9231c/brooklyn-server/karaf/feature.xml
----------------------------------------------------------------------
diff --git a/brooklyn-server/karaf/feature.xml b/brooklyn-server/karaf/feature.xml
deleted file mode 100644
index fdb959d..0000000
--- a/brooklyn-server/karaf/feature.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
--->
-<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="org.apache.brooklyn-${project.version}">
-
-    <repository>mvn:org.apache.karaf.features/standard/${karaf.version}/xml/features</repository>
-    <repository>mvn:org.apache.karaf.features/enterprise/${karaf.version}/xml/features</repository>
-    <repository>mvn:org.apache.karaf.features/spring/${karaf.version}/xml/features</repository>
-  
-    <!-- TODO: complete the features set -->
-    <feature name="brooklyn-core" version="${project.version}" description="Brooklyn Core">
-        <bundle>mvn:org.apache.brooklyn/brooklyn-core/${project.version}</bundle>
-        <bundle>mvn:org.apache.brooklyn/brooklyn-api/${project.version}</bundle>
-        <bundle>mvn:org.apache.brooklyn/brooklyn-utils-common/${project.version}</bundle>
-        <bundle>mvn:org.apache.brooklyn/brooklyn-utils-groovy/${project.version}</bundle>
-        <bundle>mvn:org.apache.brooklyn/brooklyn-logback-includes/${project.version}</bundle>
-    
-        <!-- TODO: via geoip -->
-        <bundle dependency="true">wrap:mvn:com.google.http-client/google-http-client/1.18.0-rc</bundle>
-        <!-- TODO: why it does not come automagically? -->
-        <bundle dependency="true">mvn:com.google.guava/guava/${guava.version}</bundle>
-        <bundle dependency="true">mvn:com.google.code.gson/gson/${gson.version}</bundle>
-        <bundle dependency="true">mvn:com.jayway.jsonpath/json-path/${jsonPath.version}</bundle>
-        <bundle dependency="true">mvn:com.fasterxml.jackson.core/jackson-core/${fasterxml.jackson.version}</bundle>
-        <bundle dependency="true">mvn:com.fasterxml.jackson.core/jackson-databind/${fasterxml.jackson.version}</bundle>
-        <bundle dependency="true">mvn:com.fasterxml.jackson.core/jackson-annotations/${fasterxml.jackson.version}</bundle>
-        <bundle dependency="true">mvn:net.minidev/json-smart/${jsonSmart.version}</bundle>
-        <bundle dependency="true">mvn:net.minidev/asm/${minidev.asm.version}</bundle>
-    </feature>
-  
-    <feature name="brooklyn-commands"  version="${project.version}"  description="Brooklyn Shell Commands">
-        <bundle>mvn:org.apache.brooklyn/brooklyn-commands/${project.version}</bundle>
-        <!--<feature version="${project.version}">brooklyn-core</feature>-->
-    </feature>
-  
-</features>


[3/8] incubator-brooklyn git commit: BROOKLYN-214: fix cancelling of AttributeWhenReady task

Posted by sj...@apache.org.
BROOKLYN-214: fix cancelling of AttributeWhenReady task

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

Branch: refs/heads/master
Commit: d5c072257250e1b54e08efe2ac31b4b1ff03a6e0
Parents: d058158
Author: Aled Sage <al...@gmail.com>
Authored: Tue Jan 12 13:24:43 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Jan 12 13:24:43 2016 +0000

----------------------------------------------------------------------
 .../spi/dsl/BrooklynDslDeferredSupplier.java    |  40 ++++++-
 .../DependentConfigPollingYamlTest.java         | 117 +++++++++++++++++++
 2 files changed, 155 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5c07225/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/BrooklynDslDeferredSupplier.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/BrooklynDslDeferredSupplier.java b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/BrooklynDslDeferredSupplier.java
index 65bf561..a417e32 100644
--- a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/BrooklynDslDeferredSupplier.java
+++ b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/BrooklynDslDeferredSupplier.java
@@ -18,7 +18,10 @@
  */
 package org.apache.brooklyn.camp.brooklyn.spi.dsl;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
 import java.io.Serializable;
+import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.mgmt.ExecutionContext;
@@ -55,6 +58,11 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  * and should not accessed until after the components / entities are created 
  * and are being started.
  * (TODO the precise semantics of this are under development.)
+ * 
+ * The threading model is that only one thread can call {@link #get()} at a time. An interruptible
+ * lock is obtained using {@link #lock} for the duration of that method. It is important to not
+ * use {@code synchronized} because that is not interruptible - if someone tries to get the value
+ * and interrupts after a short wait, then we must release the lock immediately and return.
  * <p>
  **/
 public abstract class BrooklynDslDeferredSupplier<T> implements DeferredSupplier<T>, TaskFactory<Task<T>>, Serializable {
@@ -63,6 +71,15 @@ public abstract class BrooklynDslDeferredSupplier<T> implements DeferredSupplier
 
     private static final Logger log = LoggerFactory.getLogger(BrooklynDslDeferredSupplier.class);
 
+    /**
+     * Lock to be used, rather than {@code synchronized} blocks, for anything long-running.
+     * Use {@link #getLock()} rather than this field directly, to ensure it is reinitialised 
+     * after rebinding.
+     * 
+     * @see https://issues.apache.org/jira/browse/BROOKLYN-214
+     */
+    private transient ReentrantLock lock;
+    
     // TODO json of this object should *be* this, not wrapped this ($brooklyn:literal is a bit of a hack, though it might work!)
     @JsonInclude
     @JsonProperty(value="$brooklyn:literal")
@@ -72,8 +89,9 @@ public abstract class BrooklynDslDeferredSupplier<T> implements DeferredSupplier
     public BrooklynDslDeferredSupplier() {
         PlanInterpretationNode sourceNode = BrooklynDslInterpreter.currentNode();
         dsl = sourceNode!=null ? sourceNode.getOriginalValue() : null;
+        lock = new ReentrantLock();
     }
-
+    
     /** returns the current entity; for use in implementations of {@link #get()} */
     protected final static EntityInternal entity() {
         return (EntityInternal) BrooklynTaskTags.getTargetOrContextEntity(Tasks.current());
@@ -88,7 +106,13 @@ public abstract class BrooklynDslDeferredSupplier<T> implements DeferredSupplier
     }
 
     @Override
-    public final synchronized T get() {
+    public final T get() {
+        try {
+            getLock().lockInterruptibly();
+        } catch (InterruptedException e) {
+            throw Exceptions.propagate(e);
+        }
+        
         try {
             if (log.isDebugEnabled())
                 log.debug("Queuing task to resolve "+dsl);
@@ -110,7 +134,19 @@ public abstract class BrooklynDslDeferredSupplier<T> implements DeferredSupplier
 
         } catch (Exception e) {
             throw Exceptions.propagate(e);
+        } finally {
+            getLock().unlock();
+        }
+    }
+
+    // Use this method, rather than the direct field, to ensure it is initialised after rebinding.
+    protected ReentrantLock getLock() {
+        synchronized (this) {
+            if (lock == null) {
+                lock = new ReentrantLock();
+            }
         }
+        return lock;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5c07225/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/DependentConfigPollingYamlTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/DependentConfigPollingYamlTest.java b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/DependentConfigPollingYamlTest.java
new file mode 100644
index 0000000..10df5f0
--- /dev/null
+++ b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/DependentConfigPollingYamlTest.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.camp.brooklyn;
+
+import static org.testng.Assert.assertTrue;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.test.Asserts;
+import org.apache.brooklyn.util.core.task.Tasks;
+import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.Iterables;
+
+@Test
+public class DependentConfigPollingYamlTest extends AbstractYamlTest {
+    private static final Logger log = LoggerFactory.getLogger(DependentConfigPollingYamlTest.class);
+    
+    private ExecutorService executor;
+
+    @BeforeMethod(alwaysRun = true)
+    @Override
+    public void setUp() {
+        super.setUp();
+        executor = Executors.newCachedThreadPool();
+    }
+            
+    @AfterMethod(alwaysRun = true)
+    @Override
+    public void tearDown() {
+        if (executor != null) executor.shutdownNow();
+        super.tearDown();
+    }
+            
+    // Test for BROOKLYN-214. Previously, the brief Tasks.resolving would cause a thread to be
+    // leaked. This was because it would call into BrooklynDslDeferredSupplier.get, which would
+    // wait on a synchronized block and thus not be interruptible - the thread would be consumed
+    // forever, until the attributeWhenReady returned true!
+    //
+    // Integration test, because takes several seconds.
+    @Test(groups="Integration")
+    public void testResolveAttributeWhenReadyWithTimeoutDoesNotLeaveThreadRunning() throws Exception {
+        String yaml = Joiner.on("\n").join(
+                "services:",
+                "- type: org.apache.brooklyn.core.test.entity.TestEntity",
+                "  id: myentity",
+                "  brooklyn.config:",
+                "    test.confName: $brooklyn:entity(\"myentity\").attributeWhenReady(\"mysensor\")");
+        
+        final Entity app = createAndStartApplication(yaml);
+        final TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
+
+        // Cause a thread to block, getting the config - previousy (before fixing 214) this would be in
+        // the synchronized block if BrooklynDslDeferredSupplier.get().
+        // The sleep is to ensure we really did get into the locking code.
+        executor.submit(new Callable<Object>() {
+            public Object call() {
+                return entity.config().get(TestEntity.CONF_NAME);
+            }});
+        Thread.sleep(100);
+        
+        // Try to resolve the value many times, each in its own task, but with a short timeout for each.
+        final int numIterations = 20;
+        final int preNumThreads = Thread.activeCount();
+        
+        for (int i = 0; i < numIterations; i++) {
+            // Same as RestValueResolver.getImmediateValue
+            Tasks.resolving(entity.config().getRaw(TestEntity.CONF_NAME).get())
+                    .as(Object.class)
+                    .defaultValue("UNRESOLVED")
+                    .timeout(Duration.millis(100))
+                    .context(entity)
+                    .swallowExceptions()
+                    .get();
+        }
+
+        // Confirm we haven't left threads behind.
+        Asserts.succeedsEventually(new Runnable() {
+            public void run() {
+                int postNumThreads = Thread.activeCount();
+                String msg = "pre="+preNumThreads+"; post="+postNumThreads+"; iterations="+numIterations;
+                log.info(msg);
+                assertTrue(postNumThreads < preNumThreads + (numIterations / 2), msg);
+            }});
+    }
+
+    @Override
+    protected Logger getLogger() {
+        return log;
+    }
+}


[8/8] incubator-brooklyn git commit: This closes #1139

Posted by sj...@apache.org.
This closes #1139

Remove karaf-features auto-generated dependencies.xml


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

Branch: refs/heads/master
Commit: 58337c4e40a1e7e7389d7ee96faa7fc0819704bb
Parents: 38a225f 41e9231
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Wed Jan 13 10:40:59 2016 +0000
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Wed Jan 13 10:40:59 2016 +0000

----------------------------------------------------------------------
 brooklyn-server/karaf/feature.xml               |  51 ---------
 brooklyn-server/karaf/features/pom.xml          |   4 -
 .../features/src/main/history/dependencies.xml  | 103 -------------------
 3 files changed, 158 deletions(-)
----------------------------------------------------------------------



[6/8] incubator-brooklyn git commit: This closes #1133

Posted by sj...@apache.org.
This closes #1133

BROOKLYN-213 Fix localhost external IP loader


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

Branch: refs/heads/master
Commit: 2916fff534a8135c9faeb9e731371f90a91c51d4
Parents: d058158 d4565b8
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Wed Jan 13 10:19:22 2016 +0000
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Wed Jan 13 10:19:22 2016 +0000

----------------------------------------------------------------------
 .../location/geo/LocalhostExternalIpLoader.java | 73 ++++++++++++++------
 .../geo/external-ip-address-resolvers.txt       |  1 -
 2 files changed, 52 insertions(+), 22 deletions(-)
----------------------------------------------------------------------



[7/8] incubator-brooklyn git commit: This closes #1137

Posted by sj...@apache.org.
This closes #1137

BROOKLYN-214: fix cancelling of AttributeWhenReady task


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

Branch: refs/heads/master
Commit: 38a225f7848fd5a6b0cce5ec4db6d0f184c12d6b
Parents: 2916fff d5c0722
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Wed Jan 13 10:31:12 2016 +0000
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Wed Jan 13 10:31:12 2016 +0000

----------------------------------------------------------------------
 .../spi/dsl/BrooklynDslDeferredSupplier.java    |  40 ++++++-
 .../DependentConfigPollingYamlTest.java         | 117 +++++++++++++++++++
 2 files changed, 155 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[4/8] incubator-brooklyn git commit: [BROOKLYN-183] Remove karaf dependencies.xml from git

Posted by sj...@apache.org.
[BROOKLYN-183] Remove karaf dependencies.xml from git

The dependencies.xml file can be used to track dependency changes for
karaf features. For this reason it has to be added to the git repository
so such changes can be detected between commits.

However, developers complained about having this file on git, since it
confusingly keeps showing up in commits. Also, at this stage this
tracking is unnecessary.


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

Branch: refs/heads/master
Commit: 966b714eefe2a3d5233959f121fe80f6f9e3f426
Parents: d058158
Author: Ciprian Ciubotariu <ch...@gmx.net>
Authored: Tue Jan 12 19:35:51 2016 +0200
Committer: Ciprian Ciubotariu <ch...@gmx.net>
Committed: Tue Jan 12 19:44:05 2016 +0200

----------------------------------------------------------------------
 brooklyn-server/karaf/features/pom.xml          |   4 -
 .../features/src/main/history/dependencies.xml  | 103 -------------------
 2 files changed, 107 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/966b714e/brooklyn-server/karaf/features/pom.xml
----------------------------------------------------------------------
diff --git a/brooklyn-server/karaf/features/pom.xml b/brooklyn-server/karaf/features/pom.xml
index 03cd932..c7bb6b4 100755
--- a/brooklyn-server/karaf/features/pom.xml
+++ b/brooklyn-server/karaf/features/pom.xml
@@ -51,10 +51,6 @@
                     <startLevel>50</startLevel>
                     <aggregateFeatures>true</aggregateFeatures>
                     <resolver>(obr)</resolver>
-                    <checkDependencyChange>true</checkDependencyChange>
-                    <failOnDependencyChange>false</failOnDependencyChange>
-                    <logDependencyChanges>true</logDependencyChanges>
-                    <overwriteChangedDependencies>true</overwriteChangedDependencies>
                 </configuration>
             </plugin>
         </plugins>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/966b714e/brooklyn-server/karaf/features/src/main/history/dependencies.xml
----------------------------------------------------------------------
diff --git a/brooklyn-server/karaf/features/src/main/history/dependencies.xml b/brooklyn-server/karaf/features/src/main/history/dependencies.xml
deleted file mode 100644
index 2bcbdca..0000000
--- a/brooklyn-server/karaf/features/src/main/history/dependencies.xml
+++ /dev/null
@@ -1,103 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<features xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" name="org.apache.brooklyn-0.9.0-SNAPSHOT">  <!-- BROOKLYN_VERSION -->
-    <feature version="0.0.0">
-        <feature prerequisite="false" dependency="false">brooklyn-api</feature>
-        <feature prerequisite="false" dependency="false">brooklyn-api</feature>
-        <feature prerequisite="false" dependency="false">brooklyn-camp-base</feature>
-        <feature prerequisite="false" dependency="false">brooklyn-camp-base</feature>
-        <feature prerequisite="false" dependency="false">brooklyn-camp-base</feature>
-        <feature prerequisite="false" dependency="false">brooklyn-camp-brooklyn</feature>
-        <feature prerequisite="false" dependency="false">brooklyn-core</feature>
-        <feature prerequisite="false" dependency="false">brooklyn-core</feature>
-        <feature prerequisite="false" dependency="false">brooklyn-rest-api</feature>
-        <feature prerequisite="false" dependency="false">brooklyn-utils-common</feature>
-        <feature prerequisite="false" dependency="false">brooklyn-utils-common</feature>
-        <feature prerequisite="false" dependency="false">brooklyn-utils-common</feature>
-        <feature prerequisite="false" dependency="false">brooklyn-utils-common</feature>
-        <feature prerequisite="false" dependency="false">brooklyn-utils-rest-swagger</feature>
-        <feature prerequisite="false" dependency="false">brooklyn-utils-rest-swagger</feature>
-        <feature prerequisite="false" dependency="false">jetty</feature>
-        <feature prerequisite="false" dependency="false">swagger-crippled</feature>
-        <feature prerequisite="false" dependency="false">war</feature>
-        <feature prerequisite="false" dependency="false">war</feature>
-        <bundle>mvn:ch.qos.logback/logback-classic/1.0.7</bundle>
-        <bundle>mvn:ch.qos.logback/logback-core/1.0.7</bundle>
-        <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/2.4.5</bundle>
-        <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/2.4.5</bundle>
-        <bundle>mvn:com.fasterxml.jackson.core/jackson-core/2.4.5</bundle>
-        <bundle>mvn:com.fasterxml.jackson.core/jackson-core/2.4.5</bundle>
-        <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/2.4.5</bundle>
-        <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/2.4.5</bundle>
-        <bundle>mvn:com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.4.5</bundle>
-        <bundle>mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-base/2.4.5</bundle>
-        <bundle>mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider/2.4.5</bundle>
-        <bundle>mvn:com.google.code.gson/gson/2.3</bundle>
-        <bundle>mvn:com.google.guava/guava/17.0</bundle>
-        <bundle>mvn:com.jayway.jsonpath/json-path/2.0.0</bundle>
-        <bundle>mvn:com.sun.jersey.contribs/jersey-multipart/1.19</bundle>
-        <bundle>mvn:com.sun.jersey/jersey-core/1.19</bundle>
-        <bundle>mvn:com.sun.jersey/jersey-core/1.19</bundle>
-        <bundle>mvn:com.sun.jersey/jersey-server/1.19</bundle>
-        <bundle>mvn:com.sun.jersey/jersey-server/1.19</bundle>
-        <bundle>mvn:com.sun.jersey/jersey-servlet/1.19</bundle>
-        <bundle>mvn:com.sun.jersey/jersey-servlet/1.19</bundle>
-        <bundle>mvn:com.sun.jersey/jersey-servlet/1.19</bundle>
-        <bundle>mvn:com.thoughtworks.xstream/xstream/1.4.7</bundle>
-        <bundle>mvn:commons-beanutils/commons-beanutils/1.9.1</bundle>
-        <bundle>mvn:commons-codec/commons-codec/1.9</bundle>
-        <bundle>mvn:commons-codec/commons-codec/1.9</bundle>
-        <bundle>mvn:commons-collections/commons-collections/3.2.1</bundle>
-        <bundle>mvn:commons-io/commons-io/2.4</bundle>
-        <bundle>mvn:commons-lang/commons-lang/2.4</bundle>
-        <bundle>mvn:io.swagger/swagger-annotations/1.5.3</bundle>
-        <bundle>mvn:io.swagger/swagger-models/1.5.3</bundle>
-        <bundle>mvn:javax.servlet/javax.servlet-api/3.1.0</bundle>
-        <bundle>mvn:javax.servlet/javax.servlet-api/3.1.0</bundle>
-        <bundle>mvn:javax.ws.rs/jsr311-api/1.1.1</bundle>
-        <bundle>mvn:net.minidev/asm/1.0.2</bundle>
-        <bundle>mvn:net.minidev/json-smart/2.1.1</bundle>
-        <bundle>mvn:net.schmizz/sshj/0.8.1</bundle>
-        <bundle>mvn:org.apache.brooklyn.camp/camp-base/0.9.0-SNAPSHOT</bundle>  <!-- BROOKLYN_VERSION -->
-        <bundle>mvn:org.apache.brooklyn.camp/camp-server/0.9.0-SNAPSHOT</bundle>  <!-- BROOKLYN_VERSION -->
-        <bundle>mvn:org.apache.brooklyn/brooklyn-api/0.9.0-SNAPSHOT</bundle>  <!-- BROOKLYN_VERSION -->
-        <bundle>mvn:org.apache.brooklyn/brooklyn-camp/0.9.0-SNAPSHOT</bundle>  <!-- BROOKLYN_VERSION -->
-        <bundle>mvn:org.apache.brooklyn/brooklyn-commands/0.9.0-SNAPSHOT</bundle>  <!-- BROOKLYN_VERSION -->
-        <bundle>mvn:org.apache.brooklyn/brooklyn-core/0.9.0-SNAPSHOT</bundle>  <!-- BROOKLYN_VERSION -->
-        <bundle>mvn:org.apache.brooklyn/brooklyn-jsgui/0.9.0-SNAPSHOT/war</bundle>  <!-- BROOKLYN_VERSION -->
-        <bundle>mvn:org.apache.brooklyn/brooklyn-logback-includes/0.9.0-SNAPSHOT</bundle>  <!-- BROOKLYN_VERSION -->
-        <bundle>mvn:org.apache.brooklyn/brooklyn-rest-api/0.9.0-SNAPSHOT</bundle>  <!-- BROOKLYN_VERSION -->
-        <bundle>mvn:org.apache.brooklyn/brooklyn-rest-server/0.9.0-SNAPSHOT</bundle>  <!-- BROOKLYN_VERSION -->
-        <bundle>mvn:org.apache.brooklyn/brooklyn-rt-osgi/0.9.0-SNAPSHOT</bundle>  <!-- BROOKLYN_VERSION -->
-        <bundle>mvn:org.apache.brooklyn/brooklyn-utils-common/0.9.0-SNAPSHOT</bundle>  <!-- BROOKLYN_VERSION -->
-        <bundle>mvn:org.apache.brooklyn/brooklyn-utils-common/0.9.0-SNAPSHOT</bundle>  <!-- BROOKLYN_VERSION -->
-        <bundle>mvn:org.apache.brooklyn/brooklyn-utils-groovy/0.9.0-SNAPSHOT</bundle>  <!-- BROOKLYN_VERSION -->
-        <bundle>mvn:org.apache.brooklyn/brooklyn-utils-rest-swagger/0.9.0-SNAPSHOT</bundle>  <!-- BROOKLYN_VERSION -->
-        <bundle>mvn:org.apache.commons/commons-compress/1.4</bundle>
-        <bundle>mvn:org.apache.commons/commons-lang3/3.1</bundle>
-        <bundle>mvn:org.apache.commons/commons-lang3/3.1</bundle>
-        <bundle>mvn:org.apache.commons/commons-lang3/3.1</bundle>
-        <bundle>mvn:org.apache.commons/commons-lang3/3.1</bundle>
-        <bundle>mvn:org.apache.httpcomponents/httpclient-osgi/4.4.1</bundle>
-        <bundle>mvn:org.apache.httpcomponents/httpcore-osgi/4.4.1</bundle>
-        <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jzlib/1.1.3_2</bundle>
-        <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.reflections/0.9.9_1</bundle>
-        <bundle>mvn:org.bouncycastle/bcpkix-jdk15on/1.49</bundle>
-        <bundle>mvn:org.bouncycastle/bcprov-ext-jdk15on/1.49</bundle>
-        <bundle>mvn:org.codehaus.groovy/groovy-all/2.3.7</bundle>
-        <bundle>mvn:org.codehaus.jackson/jackson-core-asl/1.9.13</bundle>
-        <bundle>mvn:org.codehaus.jackson/jackson-core-asl/1.9.13</bundle>
-        <bundle>mvn:org.codehaus.jackson/jackson-core-asl/1.9.13</bundle>
-        <bundle>mvn:org.codehaus.jackson/jackson-jaxrs/1.9.13</bundle>
-        <bundle>mvn:org.codehaus.jackson/jackson-mapper-asl/1.9.13</bundle>
-        <bundle>mvn:org.codehaus.jackson/jackson-mapper-asl/1.9.13</bundle>
-        <bundle>mvn:org.freemarker/freemarker/2.3.22</bundle>
-        <bundle>mvn:org.jvnet.mimepull/mimepull/1.9.3</bundle>
-        <bundle>mvn:org.slf4j/jul-to-slf4j/1.6.6</bundle>
-        <bundle>mvn:org.yaml/snakeyaml/1.11</bundle>
-        <bundle>wrap:mvn:com.google.http-client/google-http-client/1.18.0-rc</bundle>
-        <bundle>wrap:mvn:com.maxmind.geoip2/geoip2/0.8.1</bundle>
-        <bundle>wrap:mvn:javax.validation/validation-api/1.1.0.Final</bundle>
-        <bundle>wrap:mvn:org.tukaani/xz/1.4</bundle>
-        <bundle>wrap:mvn:xpp3/xpp3_min/1.1.4c</bundle>
-    </feature>
-</features>