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

2016-01-13 Thread sjcorbett
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 
Authored: Fri Jan 8 10:58:01 2016 +
Committer: Matt Champion 
Committed: Fri Jan 8 11:51:23 2016 +

--
 .../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/



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

2016-01-13 Thread sjcorbett
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 
Authored: Fri Jan 8 10:56:16 2016 +
Committer: Matt Champion 
Committed: Fri Jan 8 11:48:46 2016 +

--
 .../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 {
@@ -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 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 

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

2016-01-13 Thread sjcorbett
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 
Authored: Tue Jan 12 13:24:43 2016 +
Committer: Aled Sage 
Committed: Tue Jan 12 13:24:43 2016 +

--
 .../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.
  * 
  **/
 public abstract class BrooklynDslDeferredSupplier implements 
DeferredSupplier, TaskFactory, Serializable {
@@ -63,6 +71,15 @@ public abstract class BrooklynDslDeferredSupplier 
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 
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 
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 
implements DeferredSupplier
 
 } catch (Exception e) {
 throw Exceptions.propagate(e);
+} finally {
+getLock().unlock();
+}
+}
+
+// Use this method, rather than the direct field, 

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

2016-01-13 Thread sjcorbett
[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 
Authored: Tue Jan 12 19:46:41 2016 +0200
Committer: Ciprian Ciubotariu 
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..000
--- a/brooklyn-server/karaf/feature.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-http://karaf.apache.org/xmlns/features/v1.2.0; 
name="org.apache.brooklyn-${project.version}">
-
-
mvn:org.apache.karaf.features/standard/${karaf.version}/xml/features
-
mvn:org.apache.karaf.features/enterprise/${karaf.version}/xml/features
-
mvn:org.apache.karaf.features/spring/${karaf.version}/xml/features
-  
-
-
-
mvn:org.apache.brooklyn/brooklyn-core/${project.version}
-
mvn:org.apache.brooklyn/brooklyn-api/${project.version}
-
mvn:org.apache.brooklyn/brooklyn-utils-common/${project.version}
-
mvn:org.apache.brooklyn/brooklyn-utils-groovy/${project.version}
-
mvn:org.apache.brooklyn/brooklyn-logback-includes/${project.version}
-
-
-wrap:mvn:com.google.http-client/google-http-client/1.18.0-rc
-
-mvn:com.google.guava/guava/${guava.version}
-mvn:com.google.code.gson/gson/${gson.version}
-mvn:com.jayway.jsonpath/json-path/${jsonPath.version}
-mvn:com.fasterxml.jackson.core/jackson-core/${fasterxml.jackson.version}
-mvn:com.fasterxml.jackson.core/jackson-databind/${fasterxml.jackson.version}
-mvn:com.fasterxml.jackson.core/jackson-annotations/${fasterxml.jackson.version}
-mvn:net.minidev/json-smart/${jsonSmart.version}
-mvn:net.minidev/asm/${minidev.asm.version}
-
-  
-
-
mvn:org.apache.brooklyn/brooklyn-commands/${project.version}
-
-
-  
-



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

2016-01-13 Thread sjcorbett
[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 
Authored: Tue Jan 12 19:35:51 2016 +0200
Committer: Ciprian Ciubotariu 
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 @@
 50
 true
 (obr)
-true
-false
-true
-
true
 
 
 

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..000
--- a/brooklyn-server/karaf/features/src/main/history/dependencies.xml
+++ /dev/null
@@ -1,103 +0,0 @@
-
-http://karaf.apache.org/xmlns/features/v1.3.0; 
name="org.apache.brooklyn-0.9.0-SNAPSHOT">  
-
-brooklyn-api
-brooklyn-api
-brooklyn-camp-base
-brooklyn-camp-base
-brooklyn-camp-base
-brooklyn-camp-brooklyn
-brooklyn-core
-brooklyn-core
-brooklyn-rest-api
-brooklyn-utils-common
-brooklyn-utils-common
-brooklyn-utils-common
-brooklyn-utils-common
-brooklyn-utils-rest-swagger
-brooklyn-utils-rest-swagger
-jetty
-swagger-crippled
-war
-war
-mvn:ch.qos.logback/logback-classic/1.0.7
-mvn:ch.qos.logback/logback-core/1.0.7
-
mvn:com.fasterxml.jackson.core/jackson-annotations/2.4.5
-
mvn:com.fasterxml.jackson.core/jackson-annotations/2.4.5
-mvn:com.fasterxml.jackson.core/jackson-core/2.4.5
-mvn:com.fasterxml.jackson.core/jackson-core/2.4.5
-mvn:com.fasterxml.jackson.core/jackson-databind/2.4.5
-mvn:com.fasterxml.jackson.core/jackson-databind/2.4.5
-
mvn:com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.4.5
-
mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-base/2.4.5
-
mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider/2.4.5
-mvn:com.google.code.gson/gson/2.3
-mvn:com.google.guava/guava/17.0
-mvn:com.jayway.jsonpath/json-path/2.0.0
-mvn:com.sun.jersey.contribs/jersey-multipart/1.19
-mvn:com.sun.jersey/jersey-core/1.19
-mvn:com.sun.jersey/jersey-core/1.19
-mvn:com.sun.jersey/jersey-server/1.19
-mvn:com.sun.jersey/jersey-server/1.19
-mvn:com.sun.jersey/jersey-servlet/1.19
-mvn:com.sun.jersey/jersey-servlet/1.19
-mvn:com.sun.jersey/jersey-servlet/1.19
-mvn:com.thoughtworks.xstream/xstream/1.4.7
-mvn:commons-beanutils/commons-beanutils/1.9.1
-mvn:commons-codec/commons-codec/1.9
-mvn:commons-codec/commons-codec/1.9
-mvn:commons-collections/commons-collections/3.2.1
-mvn:commons-io/commons-io/2.4
-mvn:commons-lang/commons-lang/2.4
-mvn:io.swagger/swagger-annotations/1.5.3
-mvn:io.swagger/swagger-models/1.5.3
-mvn:javax.servlet/javax.servlet-api/3.1.0
-mvn:javax.servlet/javax.servlet-api/3.1.0
-mvn:javax.ws.rs/jsr311-api/1.1.1
-mvn:net.minidev/asm/1.0.2
-mvn:net.minidev/json-smart/2.1.1
-mvn:net.schmizz/sshj/0.8.1
-