brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [04/11] git commit: add maxmind v2 (now ASL licensed) in preference to Utrace, but with fallback to Utrace if maxmind not installed
Date Wed, 03 Sep 2014 16:15:31 GMT
add maxmind v2 (now ASL licensed) in preference to Utrace, but with fallback to Utrace if maxmind
not installed


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

Branch: refs/heads/master
Commit: a64e2835bb676cb71e33604e1a1423e66fe385a4
Parents: c1ab0be
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Tue Sep 2 21:03:27 2014 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Wed Sep 3 13:24:58 2014 +0100

----------------------------------------------------------------------
 core/pom.xml                                    |   4 +
 .../java/brooklyn/location/geo/HostGeoInfo.java |  26 ++++-
 .../location/geo/MaxMind2HostGeoLookup.java     | 115 +++++++++++++++++++
 .../location/geo/HostGeoInfoTest.groovy         |  69 -----------
 .../brooklyn/location/geo/HostGeoInfoTest.java  |  52 +++++++++
 .../geo/HostGeoLookupIntegrationTest.java       |  20 +++-
 docs/use/examples/global-web-fabric/index.md    |   4 +-
 pom.xml                                         |   8 +-
 .../geoscaling/GeoscalingIntegrationTest.java   |   6 +-
 9 files changed, 223 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a64e2835/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 51a05d9..4d33e60 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -164,6 +164,10 @@
             <groupId>com.google.code.findbugs</groupId>
             <artifactId>jsr305</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.maxmind.geoip2</groupId>
+            <artifactId>geoip2</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>org.testng</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a64e2835/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java b/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java
index c1ff026..2dfa5d8 100644
--- a/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java
+++ b/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java
@@ -21,6 +21,8 @@ package brooklyn.location.geo;
 import java.io.Serializable;
 import java.net.InetAddress;
 
+import javax.annotation.Nullable;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -31,6 +33,7 @@ import brooklyn.location.basic.AbstractLocation;
 import brooklyn.location.basic.LocationConfigKeys;
 import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.flags.TypeCoercions;
+import brooklyn.util.guava.Maybe;
 import brooklyn.util.internal.BrooklynSystemProperties;
 
 import com.google.common.base.Objects;
@@ -51,6 +54,8 @@ public class HostGeoInfo implements Serializable {
     
     public final double latitude;
     public final double longitude;
+    
+    private static Maybe<HostGeoLookup> cachedLookup = null;
 
     public static HostGeoInfo create(String address, String displayName, double latitude,
double longitude) {
         return new HostGeoInfo(address, displayName, latitude, longitude);
@@ -58,16 +63,23 @@ public class HostGeoInfo implements Serializable {
     
     public static HostGeoInfo fromIpAddress(InetAddress address) {
         try {
-            HostGeoLookup lookup = findHostGeoLookupImpl();
-            if (lookup!=null) {
+            HostGeoLookup lookup = getDefaultLookup();
+            if (lookup!=null)
                 return lookup.getHostGeoInfo(address);
-            }
         } catch (Exception e) {
             if (log.isDebugEnabled())
                 log.debug("unable to look up geo DNS info for "+address, e);
         }
         return null;
     }
+
+    @Nullable
+    public static HostGeoLookup getDefaultLookup() throws InstantiationException, IllegalAccessException,
ClassNotFoundException {
+        if (cachedLookup==null) {
+            cachedLookup = Maybe.of(findHostGeoLookupImpl());
+        }                
+        return cachedLookup.get();
+    }
     
     /** returns null if cannot be set */
     public static HostGeoInfo fromLocation(Location l) {
@@ -129,7 +141,13 @@ public class HostGeoInfo implements Serializable {
     private static HostGeoLookup findHostGeoLookupImpl() throws InstantiationException, IllegalAccessException,
ClassNotFoundException {
         String type = BrooklynSystemProperties.HOST_GEO_LOOKUP_IMPL.getValue();
         //like utrace because it seems more accurate than geobytes and gives a report of
how many tokens are left
-        if (type==null) return new UtraceHostGeoLookup();
+        //but maxmind free is even better
+        if (type==null) {
+            if (MaxMind2HostGeoLookup.getDatabaseReader()!=null)
+                return new MaxMind2HostGeoLookup();
+            log.debug("Using Utrace remote for geo lookup because MaxMind2 is not available");
+            return new UtraceHostGeoLookup();
+        }
         if (type.isEmpty()) return null;
         return (HostGeoLookup) Class.forName(type).newInstance();
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a64e2835/core/src/main/java/brooklyn/location/geo/MaxMind2HostGeoLookup.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/geo/MaxMind2HostGeoLookup.java b/core/src/main/java/brooklyn/location/geo/MaxMind2HostGeoLookup.java
new file mode 100644
index 0000000..da79c29
--- /dev/null
+++ b/core/src/main/java/brooklyn/location/geo/MaxMind2HostGeoLookup.java
@@ -0,0 +1,115 @@
+/*
+ * 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 brooklyn.location.geo;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.MalformedURLException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import brooklyn.util.internal.BrooklynSystemProperties;
+import brooklyn.util.net.Networking;
+import brooklyn.util.text.Strings;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.Lists;
+import com.maxmind.geoip2.DatabaseReader;
+import com.maxmind.geoip2.model.CityResponse;
+import com.maxmind.geoip2.record.Subdivision;
+
+public class MaxMind2HostGeoLookup implements HostGeoLookup {
+
+    public static final Logger log = LoggerFactory.getLogger(MaxMind2HostGeoLookup.class);
+    
+    static final String MAXMIND_DB_URL = "http://dev.maxmind.com/geoip/geoip2/geolite2/#Downloads";
+    // TODO this should be configurable from system property or brooklyn.properties
+    // TODO and should use properties BrooklynServerConfig.MGMT_BASE_DIR (but hard to get
mgmt properties here!)
+    static final String MAXMIND_DB_PATH = System.getProperty("user.home")+"/"+".brooklyn/"+"GeoLite2-City.mmdb";
+    
+    static boolean lookupFailed = false;
+    static DatabaseReader databaseReader = null;
+    
+    public static synchronized DatabaseReader getDatabaseReader() {
+        if (databaseReader!=null) return databaseReader;
+        try {
+            File f = new File(MAXMIND_DB_PATH);
+            databaseReader = new DatabaseReader.Builder(f).build();
+        } catch (IOException e) {
+            lookupFailed = true;
+            log.debug("MaxMind geo lookup unavailable; either download and unpack the latest
"+
+                    "binary from "+MAXMIND_DB_URL+" into "+MAXMIND_DB_PATH+", "+
+                    "or specify a different HostGeoLookup implementation with the key "+
+                    BrooklynSystemProperties.HOST_GEO_LOOKUP_IMPL.getPropertyName()+" (error
trying to read: "+e+")");
+        }
+        return databaseReader;
+    }
+    
+    public HostGeoInfo getHostGeoInfo(InetAddress address) throws MalformedURLException,
IOException {
+        if (lookupFailed) return null;
+        
+        DatabaseReader ll = getDatabaseReader();
+        if (ll==null) return null;
+        
+        InetAddress extAddress = address;
+        if (Networking.isPrivateSubnet(extAddress)) extAddress = InetAddress.getByName(LocalhostExternalIpLoader.getLocalhostIpQuicklyOrDefault());
+        
+        try {
+            CityResponse l = ll.city(extAddress);
+            if (l==null) {
+                if (log.isDebugEnabled()) log.debug("Geo info failed to find location for
address {}, using {}", extAddress, ll);
+                return null;
+            }
+            
+            StringBuilder name = new StringBuilder();
+            
+            if (l.getCity()!=null && l.getCity().getName()!=null) name.append(l.getCity().getName());
+            
+            if (l.getSubdivisions()!=null) {
+                for (Subdivision subd: Lists.reverse(l.getSubdivisions())) {
+                    if (name.length()>0) name.append(", ");
+                    // prefer e.g. USA state codes over state names
+                    if (!Strings.isBlank(subd.getIsoCode())) 
+                        name.append(subd.getIsoCode());
+                    else
+                        name.append(subd.getName());
+                }
+            }
+            
+            if (l.getCountry()!=null) {
+                if (name.length()==0) {
+                    name.append(l.getCountry().getName());
+                } else {
+                    name.append(" ("); name.append(l.getCountry().getIsoCode()); name.append(")");
+                }
+            }
+
+            
+            HostGeoInfo geo = new HostGeoInfo(address.getHostName(), name.toString(), l.getLocation().getLatitude(),
l.getLocation().getLongitude());
+            log.debug("Geo info lookup (MaxMind DB) for "+address+" returned: "+geo);
+            return geo;
+        } catch (Exception e) {
+            if (log.isDebugEnabled())
+                log.debug("Geo info lookup failed: "+e);
+            throw Throwables.propagate(e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a64e2835/core/src/test/java/brooklyn/location/geo/HostGeoInfoTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/geo/HostGeoInfoTest.groovy b/core/src/test/java/brooklyn/location/geo/HostGeoInfoTest.groovy
deleted file mode 100644
index 9945e7d..0000000
--- a/core/src/test/java/brooklyn/location/geo/HostGeoInfoTest.groovy
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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 brooklyn.location.geo;
-
-import static org.testng.AssertJUnit.*
-
-import org.testng.annotations.Test
-
-import brooklyn.location.Location
-import brooklyn.location.basic.SimulatedLocation
-import brooklyn.location.basic.SshMachineLocation
-
-public class HostGeoInfoTest {
-    private static final String IP = "192.168.0.1";
-    
-    private static final Location DOUBLE_LOCATION = new SimulatedLocation(name: "doubles",
latitude: 50.0d, longitude: 0.0d);
-    private static final Location BIGDECIMAL_LOCATION = new SimulatedLocation( name: "bigdecimals",
latitude: 50.0, longitude: 0.0);
-    private static final Location MIXED_LOCATION = new SimulatedLocation(name: "mixed", latitude:
50.0d, longitude: 0.0);
-    
-    private static final Location DOUBLE_CHILD = new SshMachineLocation(name: "double-child",
address: IP, parentLocation: DOUBLE_LOCATION);
-    private static final Location BIGDECIMAL_CHILD = new SshMachineLocation(name: "bigdecimal-child",
address: IP, parentLocation: BIGDECIMAL_LOCATION);
-    private static final Location MIXED_CHILD = new SshMachineLocation(name: "mixed-child",
address: IP, parentLocation: MIXED_LOCATION);
-
-        
-    @Test
-    public void testDoubleCoordinates() {
-        HostGeoInfo hgi = HostGeoInfo.fromLocation(DOUBLE_CHILD);
-        assertNotNull(hgi);
-        assertEquals(50.0d, hgi.latitude);
-        assertEquals(0.0d, hgi.longitude);
-    }
-    
-    @Test
-    public void testBigdecimalCoordinates() {
-        HostGeoInfo hgi = HostGeoInfo.fromLocation(BIGDECIMAL_CHILD);
-        assertNotNull(hgi);
-        assertEquals(50.0d, hgi.latitude);
-        assertEquals(0.0d, hgi.longitude);
-    }
-    
-    @Test
-    public void testMixedCoordinates() {
-        HostGeoInfo hgi = HostGeoInfo.fromLocation(MIXED_CHILD);
-        assertNotNull(hgi);
-        assertEquals(50.0d, hgi.latitude);
-        assertEquals(0.0d, hgi.longitude);
-    }
-    
-    @Test
-    public void testMissingCoordinates() {
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a64e2835/core/src/test/java/brooklyn/location/geo/HostGeoInfoTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/geo/HostGeoInfoTest.java b/core/src/test/java/brooklyn/location/geo/HostGeoInfoTest.java
new file mode 100644
index 0000000..1f82275
--- /dev/null
+++ b/core/src/test/java/brooklyn/location/geo/HostGeoInfoTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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 brooklyn.location.geo;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
+
+import org.testng.annotations.Test;
+
+import brooklyn.location.Location;
+import brooklyn.location.basic.SimulatedLocation;
+import brooklyn.util.collections.MutableMap;
+
+public class HostGeoInfoTest {
+    private static final String IP = "192.168.0.1";
+    
+    private static final Location CUSTOM_LOCATION = new SimulatedLocation(MutableMap.of("name",
"custom", "latitude", 50d, "longitude", 0d));
+    private static final Location CUSTOM_LOCATION_CHILD = new SimulatedLocation(MutableMap.of("name",
"custom-child", "address", IP, "parentLocation", CUSTOM_LOCATION));
+        
+    @Test
+    public void testCustomLocationCoordinates() {
+        HostGeoInfo hgi = HostGeoInfo.fromLocation(CUSTOM_LOCATION);
+        assertNotNull(hgi);
+        assertEquals(50.0d, hgi.latitude);
+        assertEquals(0.0d, hgi.longitude);
+    }
+    
+    @Test
+    public void testCustomLocationChildCoordinates() {
+        HostGeoInfo hgi = HostGeoInfo.fromLocation(CUSTOM_LOCATION_CHILD);
+        assertNotNull(hgi);
+        assertEquals(50.0d, hgi.latitude);
+        assertEquals(0.0d, hgi.longitude);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a64e2835/core/src/test/java/brooklyn/location/geo/HostGeoLookupIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/geo/HostGeoLookupIntegrationTest.java b/core/src/test/java/brooklyn/location/geo/HostGeoLookupIntegrationTest.java
index ced1cc8..aeaf960 100644
--- a/core/src/test/java/brooklyn/location/geo/HostGeoLookupIntegrationTest.java
+++ b/core/src/test/java/brooklyn/location/geo/HostGeoLookupIntegrationTest.java
@@ -28,6 +28,8 @@ import org.testng.annotations.Test;
 import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
 import brooklyn.location.basic.SshMachineLocation;
 
+import com.google.common.base.Objects;
+
 public class HostGeoLookupIntegrationTest {
 
     public static final Logger log = LoggerFactory.getLogger(HostGeoLookupIntegrationTest.class);
@@ -37,7 +39,7 @@ public class HostGeoLookupIntegrationTest {
         SshMachineLocation l = new LocalhostMachineProvisioningLocation().obtain();
         HostGeoInfo geo = HostGeoInfo.fromLocation(l);
         log.info("localhost is in "+geo);
-        Assert.assertNotNull(geo, "couldn't load data; must be online and with credit with
the HostGeoLookup impl (e.g. GeoBytes)");
+        Assert.assertNotNull(geo, "couldn't load data; must have a valid HostGeoLookup impl
(e.g. MaxMind installed, or online and with Utrace credit)");
         Assert.assertTrue(-90 <= geo.latitude && geo.latitude <= 90); 
     }
 
@@ -56,4 +58,20 @@ public class HostGeoLookupIntegrationTest {
         Assert.assertEquals(geo.latitude, 51, 2);
         Assert.assertEquals(geo.longitude, 9, 5);
     }
+
+    @Test(groups = "Integration")
+    public void testMaxmindLookup() throws Exception {
+        HostGeoInfo geo = new MaxMind2HostGeoLookup().getHostGeoInfo(InetAddress.getByName("maxmind.com"));
+        log.info("maxmind.com at "+geo);
+        
+        // used to be Washington; now lDalas - in case this is temporary failover will accept
either!
+        // Also saw variation in lat/lon reported, so happy to within one degree now.
+//      Assert.assertEquals(geo.displayName, "Washington, DC (US)");
+//      Assert.assertEquals(geo.latitude, 38.90, 0.1);
+//      Assert.assertEquals(geo.longitude, -77.02, 0.1);
+        
+        Assert.assertTrue(Objects.equal(geo.displayName, "Washington, DC (US)") || Objects.equal(geo.displayName,
"Dallas, TX (US)"), "name="+geo.displayName);
+        Assert.assertTrue(Math.abs(geo.latitude - 38.90) <= 1 || Math.abs(geo.latitude
- 32.78) <= 1, "lat="+geo.latitude);
+        Assert.assertTrue(Math.abs(geo.longitude - -77.02) <= 1 || Math.abs(geo.longitude
- -96.82) <= 1, "lon="+geo.longitude);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a64e2835/docs/use/examples/global-web-fabric/index.md
----------------------------------------------------------------------
diff --git a/docs/use/examples/global-web-fabric/index.md b/docs/use/examples/global-web-fabric/index.md
index 5866618..8664f84 100644
--- a/docs/use/examples/global-web-fabric/index.md
+++ b/docs/use/examples/global-web-fabric/index.md
@@ -67,8 +67,8 @@ In order to generate the "closest-IP" script,
 Brooklyn needs a way to find out the latitude and longitude of the
 servers you are using.
 The simplest way to do this is do download the free GeoCityLite binary flatfile 
-from [MaxMind](http://www.maxmind.com/app/geolitecity),
-unpack it, and copy it to `~/.brooklyn/MaxMind-GeoLiteCity.dat`.
+from [MaxMind](http://dev.maxmind.com/geoip/geoip2/geolite2/#Downloads),
+unpack it, and copy it to `~/.brooklyn/GeoLite2-City.mmdb`.
 
 This will be picked up automatically if it is installed.
 You can instead specify to use an online lookup service, such as 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a64e2835/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 51eb785..db4af47 100644
--- a/pom.xml
+++ b/pom.xml
@@ -119,7 +119,7 @@
         <slf4j.version>1.6.6</slf4j.version>  <!-- used for java.util.logging
jul-to-slf4j interception -->
         <xstream.version>1.4.7</xstream.version>
         <jackson.version>1.9.13</jackson.version>  <!-- codehaus jackson,
used by brooklyn rest server -->
-        <fasterxml.jackson.version>2.2.0</fasterxml.jackson.version>  <!--
fasterxml (newer) jackson, used by camp -->
+        <fasterxml.jackson.version>2.4.2</fasterxml.jackson.version>
         <jersey.version>1.12</jersey.version> <!-- NB: 1.17 requires changes
to how we hanlde multipart in CatalogApi -->
         <swagger.version>1.0.1</swagger.version>
         <dropwizard.version>0.4.4</dropwizard.version>
@@ -186,6 +186,7 @@
         <commons-lang.version>2.4</commons-lang.version>
         <hamcrest.version>1.1</hamcrest.version>
         <jsr311-api.version>1.1.1</jsr311-api.version>
+        <maxmind.version>0.8.1</maxmind.version>
 
         <includedTestGroups />
         <excludedTestGroups>Integration,Acceptance,Live,WIP</excludedTestGroups>
@@ -600,6 +601,11 @@
                 <artifactId>json-path</artifactId>
                 <version>${jsonPath.version}</version>
             </dependency>
+            <dependency>
+                <groupId>com.maxmind.geoip2</groupId>
+                <artifactId>geoip2</artifactId>
+                <version>${maxmind.version}</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a64e2835/software/webapp/src/test/java/brooklyn/entity/dns/geoscaling/GeoscalingIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/dns/geoscaling/GeoscalingIntegrationTest.java
b/software/webapp/src/test/java/brooklyn/entity/dns/geoscaling/GeoscalingIntegrationTest.java
index 8af53fb..6729ef5 100644
--- a/software/webapp/src/test/java/brooklyn/entity/dns/geoscaling/GeoscalingIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/dns/geoscaling/GeoscalingIntegrationTest.java
@@ -28,7 +28,6 @@ import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import brooklyn.entity.basic.ApplicationBuilder;
 import brooklyn.entity.basic.Attributes;
 import brooklyn.entity.basic.DynamicGroup;
 import brooklyn.entity.basic.Entities;
@@ -37,7 +36,6 @@ import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.location.basic.SshMachineLocation;
 import brooklyn.location.geo.HostGeoInfo;
 import brooklyn.location.geo.HostGeoLookup;
-import brooklyn.location.geo.UtraceHostGeoLookup;
 import brooklyn.test.Asserts;
 import brooklyn.test.entity.TestApplication;
 import brooklyn.test.entity.TestEntity;
@@ -83,7 +81,7 @@ public class GeoscalingIntegrationTest {
     public void setUp() throws Exception {
         geoLookupImpl = BrooklynSystemProperties.HOST_GEO_LOOKUP_IMPL.getValue();
         
-        app = ApplicationBuilder.newManagedApp(TestApplication.class);
+        app = TestApplication.Factory.newManagedInstanceForTests();
         target = app.createAndManageChild(EntitySpec.create(TestEntity.class));
         
         group = app.createAndManageChild(EntitySpec.create(DynamicGroup.class)
@@ -167,7 +165,7 @@ public class GeoscalingIntegrationTest {
         
         public StubHostGeoLookup(String delegateImpl) throws Exception {
             if (delegateImpl == null) {
-                delegate = new UtraceHostGeoLookup();
+                delegate = HostGeoInfo.getDefaultLookup();
             } else {
                 delegate = (HostGeoLookup) Class.forName(delegateImpl).newInstance();
             }


Mime
View raw message