Return-Path: X-Original-To: apmail-brooklyn-commits-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A269C117FD for ; Wed, 3 Sep 2014 16:15:51 +0000 (UTC) Received: (qmail 78956 invoked by uid 500); 3 Sep 2014 16:15:51 -0000 Delivered-To: apmail-brooklyn-commits-archive@brooklyn.apache.org Received: (qmail 78926 invoked by uid 500); 3 Sep 2014 16:15:51 -0000 Mailing-List: contact commits-help@brooklyn.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.incubator.apache.org Delivered-To: mailing list commits@brooklyn.incubator.apache.org Received: (qmail 78916 invoked by uid 99); 3 Sep 2014 16:15:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Sep 2014 16:15:51 +0000 X-ASF-Spam-Status: No, hits=-2001.7 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 03 Sep 2014 16:15:49 +0000 Received: (qmail 78356 invoked by uid 99); 3 Sep 2014 16:15:29 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Sep 2014 16:15:29 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9CD33A064CF; Wed, 3 Sep 2014 16:15:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: heneveld@apache.org To: commits@brooklyn.incubator.apache.org Date: Wed, 03 Sep 2014 16:15:31 -0000 Message-Id: <85ace71d55d343b58c66566aa852eff3@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [04/11] git commit: add maxmind v2 (now ASL licensed) in preference to Utrace, but with fallback to Utrace if maxmind not installed X-Virus-Checked: Checked by ClamAV on apache.org 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 Authored: Tue Sep 2 21:03:27 2014 +0100 Committer: Alex Heneveld 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 @@ com.google.code.findbugs jsr305 + + com.maxmind.geoip2 + geoip2 + org.testng 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 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 @@ 1.6.6 1.4.7 1.9.13 - 2.2.0 + 2.4.2 1.12 1.0.1 0.4.4 @@ -186,6 +186,7 @@ 2.4 1.1 1.1.1 + 0.8.1 Integration,Acceptance,Live,WIP @@ -600,6 +601,11 @@ json-path ${jsonPath.version} + + com.maxmind.geoip2 + geoip2 + ${maxmind.version} + 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(); }