You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ha...@apache.org on 2015/08/14 05:43:06 UTC
[37/54] incubator-brooklyn git commit: [BROOKLYN-162] Renaming
package brooklyn.location
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java b/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java
deleted file mode 100644
index 66c6065..0000000
--- a/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java
+++ /dev/null
@@ -1,116 +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.cloud;
-
-import java.util.Collection;
-
-import com.google.common.annotations.Beta;
-import com.google.common.reflect.TypeToken;
-
-import brooklyn.config.ConfigKey;
-import brooklyn.entity.basic.ConfigKeys;
-import brooklyn.event.basic.BasicConfigKey;
-import brooklyn.location.MachineLocationCustomizer;
-import brooklyn.location.basic.LocationConfigKeys;
-import brooklyn.util.flags.SetFromFlag;
-
-public interface CloudLocationConfig {
-
- public static final ConfigKey<String> CLOUD_ENDPOINT = LocationConfigKeys.CLOUD_ENDPOINT;
- public static final ConfigKey<String> CLOUD_REGION_ID = LocationConfigKeys.CLOUD_REGION_ID;
- public static final ConfigKey<String> CLOUD_AVAILABILITY_ZONE_ID = LocationConfigKeys.CLOUD_AVAILABILITY_ZONE_ID;
-
- @SetFromFlag("identity")
- public static final ConfigKey<String> ACCESS_IDENTITY = LocationConfigKeys.ACCESS_IDENTITY;
- @SetFromFlag("credential")
- public static final ConfigKey<String> ACCESS_CREDENTIAL = LocationConfigKeys.ACCESS_CREDENTIAL;
-
- public static final ConfigKey<String> USER = LocationConfigKeys.USER;
-
- public static final ConfigKey<String> PASSWORD = LocationConfigKeys.PASSWORD;
- public static final ConfigKey<String> PUBLIC_KEY_FILE = LocationConfigKeys.PUBLIC_KEY_FILE;
- public static final ConfigKey<String> PUBLIC_KEY_DATA = LocationConfigKeys.PUBLIC_KEY_DATA;
- public static final ConfigKey<String> PRIVATE_KEY_FILE = LocationConfigKeys.PRIVATE_KEY_FILE;
- public static final ConfigKey<String> PRIVATE_KEY_DATA = LocationConfigKeys.PRIVATE_KEY_DATA;
- public static final ConfigKey<String> PRIVATE_KEY_PASSPHRASE = LocationConfigKeys.PRIVATE_KEY_PASSPHRASE;
-
- /** @deprecated since 0.6.0; included here so it gets picked up in auto-detect routines */ @Deprecated
- public static final ConfigKey<String> LEGACY_PUBLIC_KEY_FILE = LocationConfigKeys.LEGACY_PUBLIC_KEY_FILE;
- /** @deprecated since 0.6.0; included here so it gets picked up in auto-detect routines */ @Deprecated
- public static final ConfigKey<String> LEGACY_PUBLIC_KEY_DATA = LocationConfigKeys.LEGACY_PUBLIC_KEY_DATA;
- /** @deprecated since 0.6.0; included here so it gets picked up in auto-detect routines */ @Deprecated
- public static final ConfigKey<String> LEGACY_PRIVATE_KEY_FILE = LocationConfigKeys.LEGACY_PRIVATE_KEY_FILE;
- /** @deprecated since 0.6.0; included here so it gets picked up in auto-detect routines */ @Deprecated
- public static final ConfigKey<String> LEGACY_PRIVATE_KEY_DATA = LocationConfigKeys.LEGACY_PRIVATE_KEY_DATA;
- /** @deprecated since 0.6.0; included here so it gets picked up in auto-detect routines */ @Deprecated
- public static final ConfigKey<String> LEGACY_PRIVATE_KEY_PASSPHRASE = LocationConfigKeys.LEGACY_PRIVATE_KEY_PASSPHRASE;
-
- // default is just shy of common 64-char boundary, leaving 4 chars plus our salt allowance (default 4+1) which allows up to -12345678 by jclouds
- public static final ConfigKey<Integer> VM_NAME_MAX_LENGTH = ConfigKeys.newIntegerConfigKey(
- "vmNameMaxLength", "Maximum length of VM name", 60);
-
- public static final ConfigKey<Integer> VM_NAME_SALT_LENGTH = ConfigKeys.newIntegerConfigKey(
- "vmNameSaltLength", "Number of characters to use for a random identifier inserted in hostname "
- + "to uniquely identify machines", 4);
-
- public static final ConfigKey<String> WAIT_FOR_SSHABLE = ConfigKeys.newStringConfigKey("waitForSshable",
- "Whether and how long to wait for a newly provisioned VM to be accessible via ssh; " +
- "if 'false', won't check; if 'true' uses default duration; otherwise accepts a time string e.g. '5m' (the default) or a number of milliseconds", "5m");
-
- public static final ConfigKey<String> WAIT_FOR_WINRM_AVAILABLE = ConfigKeys.newStringConfigKey("waitForWinRmAvailable",
- "Whether and how long to wait for a newly provisioned VM to be accessible via WinRm; " +
- "if 'false', won't check; if 'true' uses default duration; otherwise accepts a time string e.g. '30m' (the default) or a number of milliseconds", "30m");
-
- public static final ConfigKey<Boolean> LOG_CREDENTIALS = ConfigKeys.newBooleanConfigKey(
- "logCredentials",
- "Whether to log credentials of a new VM - strongly recommended never be used in production, as it is a big security hole!",
- false);
-
- public static final ConfigKey<Object> CALLER_CONTEXT = LocationConfigKeys.CALLER_CONTEXT;
-
- public static final ConfigKey<Boolean> DESTROY_ON_FAILURE = ConfigKeys.newBooleanConfigKey("destroyOnFailure", "Whether to destroy the VM if provisioningLocation.obtain() fails", true);
-
- public static final ConfigKey<Object> INBOUND_PORTS = new BasicConfigKey<Object>(Object.class, "inboundPorts",
- "Inbound ports to be applied when creating a VM, on supported clouds " +
- "(either a single port as a String, or an Iterable<Integer> or Integer[])", null);
- @Beta
- public static final ConfigKey<Object> ADDITIONAL_INBOUND_PORTS = new BasicConfigKey<Object>(Object.class, "required.ports",
- "Required additional ports to be applied when creating a VM, on supported clouds " +
- "(either a single port as an Integer, or an Iterable<Integer> or Integer[])", null);
-
- public static final ConfigKey<Boolean> OS_64_BIT = ConfigKeys.newBooleanConfigKey("os64Bit",
- "Whether to require 64-bit OS images (true), 32-bit images (false), or either (null)");
-
- public static final ConfigKey<Object> MIN_RAM = new BasicConfigKey<Object>(Object.class, "minRam",
- "Minimum amount of RAM, either as string (4gb) or number of MB (4096), for use in selecting the machine/hardware profile", null);
-
- public static final ConfigKey<Integer> MIN_CORES = new BasicConfigKey<Integer>(Integer.class, "minCores",
- "Minimum number of cores, for use in selecting the machine/hardware profile", null);
-
- public static final ConfigKey<Object> MIN_DISK = new BasicConfigKey<Object>(Object.class, "minDisk",
- "Minimum size of disk, either as string (100gb) or number of GB (100), for use in selecting the machine/hardware profile", null);
-
- public static final ConfigKey<String> DOMAIN_NAME = new BasicConfigKey<String>(String.class, "domainName",
- "DNS domain where the host should be created, e.g. yourdomain.com (selected clouds only)", null);
-
- @SuppressWarnings("serial")
- public static final ConfigKey<Collection<MachineLocationCustomizer>> MACHINE_LOCATION_CUSTOMIZERS = ConfigKeys.newConfigKey(
- new TypeToken<Collection<MachineLocationCustomizer>>() {},
- "machineCustomizers", "Optional machine customizers");
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/location/cloud/names/AbstractCloudMachineNamer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/cloud/names/AbstractCloudMachineNamer.java b/core/src/main/java/brooklyn/location/cloud/names/AbstractCloudMachineNamer.java
deleted file mode 100644
index d165fe1..0000000
--- a/core/src/main/java/brooklyn/location/cloud/names/AbstractCloudMachineNamer.java
+++ /dev/null
@@ -1,151 +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.cloud.names;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.trait.HasShortName;
-
-import brooklyn.location.cloud.CloudLocationConfig;
-import brooklyn.util.config.ConfigBag;
-import brooklyn.util.text.Identifiers;
-import brooklyn.util.text.Strings;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.CharMatcher;
-
-/**
- * Implements <b>most</b> of {@link CloudMachineNamer},
- * leaving just one method -- {@link #generateNewIdOfLength(int)} --
- * for subclasses to provide.
- * <p>
- * {@link CloudLocationConfig#VM_NAME_MAX_LENGTH} is used to find the VM length,
- * unless {@link #getCustomMaxNameLength(ConfigBag)} is overridden or
- * {@link #setDefaultMachineNameMaxLength(int)} invoked on the instance supplied.
- */
-public abstract class AbstractCloudMachineNamer implements CloudMachineNamer {
-
- int defaultMachineNameMaxLength = CloudLocationConfig.VM_NAME_MAX_LENGTH.getDefaultValue();
- int defaultMachineNameSaltLength = CloudLocationConfig.VM_NAME_SALT_LENGTH.getDefaultValue();
- protected String separator = "-";
-
- public String generateNewMachineUniqueName(ConfigBag setup) {
- return generateNewIdReservingLength(setup, 0);
- }
-
- public String generateNewMachineUniqueNameFromGroupId(ConfigBag setup, String groupId) {
- int availSaltLength = getMaxNameLength(setup) - (groupId.length() + separator.length());
- int requestedSaltLength = getLengthForMachineUniqueNameSalt(setup, false);
- if (availSaltLength <= 0 || requestedSaltLength <= 0) {
- return groupId;
- }
-
- return sanitize(groupId + separator + Identifiers.makeRandomId(Math.min(requestedSaltLength, availSaltLength))).toLowerCase();
- }
-
- public String generateNewGroupId(ConfigBag setup) {
- return sanitize(generateNewIdReservingLength(setup, getLengthForMachineUniqueNameSalt(setup, true))).toLowerCase();
- }
-
- protected String generateNewIdReservingLength(ConfigBag setup, int lengthToReserve) {
- int len = getMaxNameLength(setup);
- // decrement by e.g. 9 chars because jclouds adds that (dash plus 8 for hex id)
- len -= lengthToReserve;
- if (len<=0) return "";
- return Strings.maxlen(generateNewIdOfLength(setup, len), len);
- }
-
- /** Method for subclasses to provide to construct the context-specific part of an identifier,
- * for use in {@link #generateNewGroupId()} and {@link #generateNewMachineUniqueName()}.
- *
- * @param maxLengthHint an indication of the maximum length permitted for the ID generated,
- * supplied for implementations which wish to use this information to decide what to truncate.
- * (This class will truncate any return values longer than this.)
- */
- protected abstract String generateNewIdOfLength(ConfigBag setup, int maxLengthHint);
-
- /** Returns the max length of a VM name for the cloud specified in setup;
- * this value is typically decremented by 9 to make room for jclouds labels;
- * delegates to {@link #getCustomMaxNameLength()} when
- * {@link CloudLocationConfig#VM_NAME_MAX_LENGTH} is not set */
- public int getMaxNameLength(ConfigBag setup) {
- if (setup.containsKey(CloudLocationConfig.VM_NAME_MAX_LENGTH)) {
- // if a length is set explicitly, use that (but intercept default behaviour)
- return setup.get(CloudLocationConfig.VM_NAME_MAX_LENGTH);
- }
-
- Integer custom = getCustomMaxNameLength(setup);
- if (custom!=null) return custom;
-
- // return the default
- return defaultMachineNameMaxLength;
- }
-
- // sometimes we create salt string, sometimes jclouds does
- public int getLengthForMachineUniqueNameSalt(ConfigBag setup, boolean includeSeparator) {
- int saltLen;
- if (setup.containsKey(CloudLocationConfig.VM_NAME_SALT_LENGTH)) {
- saltLen = setup.get(CloudLocationConfig.VM_NAME_SALT_LENGTH);
- } else {
- // default value comes from key, but custom default can be set
- saltLen = defaultMachineNameSaltLength;
- }
-
- if (saltLen>0 && includeSeparator)
- saltLen += separator.length();
-
- return saltLen;
- }
-
- public AbstractCloudMachineNamer setDefaultMachineNameMaxLength(int defaultMaxLength) {
- this.defaultMachineNameMaxLength = defaultMaxLength;
- return this;
- }
-
- /** Number of chars to use or reserve for the machine identifier when constructing a group identifier;
- * jclouds for instance uses "-" plus 8 */
- public AbstractCloudMachineNamer setDefaultMachineNameSeparatorAndSaltLength(String separator, int defaultMachineUniqueNameSaltLength) {
- this.separator = separator;
- this.defaultMachineNameSaltLength = defaultMachineUniqueNameSaltLength;
- return this;
- }
-
- /** Method for overriding to provide custom logic when an explicit config key is not set for the machine length. */
- public Integer getCustomMaxNameLength(ConfigBag setup) {
- return null;
- }
-
- protected static String shortName(Object x) {
- if (x instanceof HasShortName) {
- return ((HasShortName)x).getShortName();
- }
- if (x instanceof Entity) {
- return ((Entity)x).getDisplayName();
- }
- return x.toString();
- }
-
- @Beta //probably won't live here long-term
- public static String sanitize(String s) {
- return CharMatcher.inRange('A', 'Z')
- .or(CharMatcher.inRange('a', 'z'))
- .or(CharMatcher.inRange('0', '9'))
- .negate()
- .trimAndCollapseFrom(s, '-');
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/location/cloud/names/BasicCloudMachineNamer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/cloud/names/BasicCloudMachineNamer.java b/core/src/main/java/brooklyn/location/cloud/names/BasicCloudMachineNamer.java
deleted file mode 100644
index 0b014f2..0000000
--- a/core/src/main/java/brooklyn/location/cloud/names/BasicCloudMachineNamer.java
+++ /dev/null
@@ -1,92 +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.cloud.names;
-
-import org.apache.brooklyn.api.entity.Application;
-import org.apache.brooklyn.api.entity.Entity;
-
-import brooklyn.location.cloud.CloudLocationConfig;
-import brooklyn.util.config.ConfigBag;
-import brooklyn.util.text.Identifiers;
-import brooklyn.util.text.StringShortener;
-import brooklyn.util.text.Strings;
-
-/**
- * Standard implementation of {@link CloudMachineNamer},
- * which looks at several of the properties of the context (entity)
- * and is clever about abbreviating them. */
-public class BasicCloudMachineNamer extends AbstractCloudMachineNamer {
-
- @Override
- protected String generateNewIdOfLength(ConfigBag setup, int len) {
- Object context = setup.peek(CloudLocationConfig.CALLER_CONTEXT);
- Entity entity = null;
- if (context instanceof Entity) entity = (Entity) context;
-
- StringShortener shortener = Strings.shortener().separator("-");
- shortener.append("system", "brooklyn");
-
- // randId often not necessary, as an 8-char hex identifier is added later (in jclouds? can we override?)
- // however it can be useful to have this early in the string, to prevent collisions in places where it is abbreviated
- shortener.append("randId", Identifiers.makeRandomId(4));
-
- String user = System.getProperty("user.name");
- if (!"brooklyn".equals(user))
- // include user; unless the user is 'brooklyn', as 'brooklyn-brooklyn-' is just silly!
- shortener.append("user", user);
-
- if (entity!=null) {
- Application app = entity.getApplication();
- if (app!=null) {
- shortener.append("app", shortName(app))
- .append("appId", app.getId());
- }
- shortener.append("entity", shortName(entity))
- .append("entityId", entity.getId());
- } else if (context!=null) {
- shortener.append("context", context.toString());
- }
-
- shortener.truncate("user", 12)
- .truncate("app", 16)
- .truncate("entity", 16)
- .truncate("appId", 4)
- .truncate("entityId", 4)
- .truncate("context", 12);
-
- shortener.canTruncate("user", 8)
- .canTruncate("app", 5)
- .canTruncate("entity", 5)
- .canTruncate("system", 2)
- .canTruncate("app", 3)
- .canTruncate("entity", 3)
- .canRemove("app")
- .canTruncate("user", 4)
- .canRemove("entity")
- .canTruncate("context", 4)
- .canTruncate("randId", 2)
- .canRemove("user")
- .canTruncate("appId", 2)
- .canRemove("appId");
-
- String s = shortener.getStringOfMaxLength(len);
- return sanitize(s).toLowerCase();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/location/cloud/names/CloudMachineNamer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/cloud/names/CloudMachineNamer.java b/core/src/main/java/brooklyn/location/cloud/names/CloudMachineNamer.java
deleted file mode 100644
index 23dd31b..0000000
--- a/core/src/main/java/brooklyn/location/cloud/names/CloudMachineNamer.java
+++ /dev/null
@@ -1,62 +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.cloud.names;
-
-import org.apache.brooklyn.api.entity.Entity;
-
-import brooklyn.location.Location;
-import brooklyn.location.cloud.CloudLocationConfig;
-import brooklyn.util.config.ConfigBag;
-
-/**
- * Interface used to construct names for individual cloud machines and for groups of machines.
- * <p>
- * Implementations <b>must</b> provide a constructor which takes a single argument,
- * being the {@link ConfigBag} for the context where the machine is being created
- * (usually a {@link Location}).
- * <p>
- * With that bag, the config key {@link CloudLocationConfig#CALLER_CONTEXT}
- * typically contains the {@link Entity} for which the machine is being created.
- */
-public interface CloudMachineNamer {
-
- /**
- * Generate a name for a new machine, based on context.
- * <p>
- * The name should normally be unique, as a context might produce multiple machines,
- * for example basing it partially on information from the context but also including some random salt.
- */
- public String generateNewMachineUniqueName(ConfigBag setup);
- /**
- * Generate a name stem for a group of machines, based on context.
- * <p>
- * The name does not need to be unique, as uniqueness will be applied by {@link #generateNewMachineUniqueNameFromGroupId(String)}.
- */
- public String generateNewGroupId(ConfigBag setup);
-
- /**
- * Generate a unique name from the given name stem.
- * <p>
- * The name stem is normally based on context information so the usual
- * function of this method is to apply a suffix which helps to uniquely distinguish between machines
- * in cases where the same name stem ({@link #generateNewGroupId()}) is used for multiple machines.
- */
- public String generateNewMachineUniqueNameFromGroupId(ConfigBag setup, String groupId);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/location/cloud/names/CustomMachineNamer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/cloud/names/CustomMachineNamer.java b/core/src/main/java/brooklyn/location/cloud/names/CustomMachineNamer.java
deleted file mode 100644
index e5dabe3..0000000
--- a/core/src/main/java/brooklyn/location/cloud/names/CustomMachineNamer.java
+++ /dev/null
@@ -1,73 +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.cloud.names;
-
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.Entity;
-
-import brooklyn.config.ConfigKey;
-import brooklyn.entity.basic.ConfigKeys;
-import brooklyn.entity.basic.EntityInternal;
-import brooklyn.location.cloud.CloudLocationConfig;
-import brooklyn.util.config.ConfigBag;
-import brooklyn.util.text.Strings;
-import brooklyn.util.text.TemplateProcessor;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.reflect.TypeToken;
-
-/** Provides a machine namer which looks at a location config key {@link #MACHINE_NAME_TEMPLATE}
- * to construct the hostname.
- * For instance, setting this to <code>${config.entity_hostname}</code>
- * will take the hostname from an <code>entity_hostname</code> key passed as entity <code>brooklyn.config</code>.
- * <p>
- * Note that this is not jclouds aware, so jclouds-specific cloud max lengths are not observed with this class.
- */
-public class CustomMachineNamer extends BasicCloudMachineNamer {
-
- public static final ConfigKey<String> MACHINE_NAME_TEMPLATE = ConfigKeys.newStringConfigKey("custom.machine.namer.machine",
- "Freemarker template format for custom machine name", "${entity.displayName}");
- @SuppressWarnings("serial")
- public static final ConfigKey<Map<String, ?>> EXTRA_SUBSTITUTIONS = ConfigKeys.newConfigKey(new TypeToken<Map<String, ?>>() {},
- "custom.machine.namer.substitutions", "Additional substitutions to be used in the template", ImmutableMap.<String, Object>of());
-
- @Override
- protected String generateNewIdOfLength(ConfigBag setup, int len) {
- Object context = setup.peek(CloudLocationConfig.CALLER_CONTEXT);
- Entity entity = null;
- if (context instanceof Entity) {
- entity = (Entity) context;
- }
-
- String template = setup.get(MACHINE_NAME_TEMPLATE);
-
- String processed;
- if (entity == null) {
- processed = TemplateProcessor.processTemplateContents(template, setup.get(EXTRA_SUBSTITUTIONS));
- } else {
- processed = TemplateProcessor.processTemplateContents(template, (EntityInternal)entity, setup.get(EXTRA_SUBSTITUTIONS));
- }
-
- processed = Strings.removeFromStart(processed, "#ftl\n");
-
- return sanitize(processed);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/location/dynamic/DynamicLocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/dynamic/DynamicLocation.java b/core/src/main/java/brooklyn/location/dynamic/DynamicLocation.java
deleted file mode 100644
index d85d40d..0000000
--- a/core/src/main/java/brooklyn/location/dynamic/DynamicLocation.java
+++ /dev/null
@@ -1,51 +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.dynamic;
-
-import org.apache.brooklyn.api.entity.Entity;
-
-import com.google.common.annotations.Beta;
-
-import brooklyn.config.ConfigKey;
-import brooklyn.entity.basic.ConfigKeys;
-import brooklyn.location.Location;
-import brooklyn.util.flags.SetFromFlag;
-
-/**
- * A location that is created and owned by an entity at runtime.
- * <p>
- * The lifecycle of the location is managed by the owning entity.
- *
- * @param E the entity type
- * @param L the location type
- */
-@Beta
-public interface DynamicLocation<E extends Entity & LocationOwner<L, E>, L extends Location & DynamicLocation<E, L>> {
-
- @SetFromFlag("owner")
- ConfigKey<Entity> OWNER =
- ConfigKeys.newConfigKey(Entity.class, "owner", "The entity owning this location");
-
- @SetFromFlag("maxLocations")
- ConfigKey<Integer> MAX_SUB_LOCATIONS =
- ConfigKeys.newIntegerConfigKey("maxLocations", "The maximum number of sub-locations that can be created; 0 for unlimited", 0);
-
- E getOwner();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/location/dynamic/LocationOwner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/dynamic/LocationOwner.java b/core/src/main/java/brooklyn/location/dynamic/LocationOwner.java
deleted file mode 100644
index b001023..0000000
--- a/core/src/main/java/brooklyn/location/dynamic/LocationOwner.java
+++ /dev/null
@@ -1,86 +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.dynamic;
-
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.event.AttributeSensor;
-
-import brooklyn.config.ConfigKey;
-import brooklyn.entity.basic.ConfigKeys;
-import brooklyn.event.basic.BasicAttributeSensorAndConfigKey;
-import brooklyn.event.basic.Sensors;
-import brooklyn.location.Location;
-import brooklyn.location.LocationDefinition;
-import brooklyn.util.flags.SetFromFlag;
-
-import com.google.common.annotations.Beta;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.reflect.TypeToken;
-
-/**
- * An entity that owns a particular location.
- * <p>
- * The entity should be able to dynamically create an instance of the required type of location, and will manage
- * the lifecycle of the location in parallel with its own.
- *
- * @param L the location type
- * @param E the entity type
- */
-@Beta
-public interface LocationOwner<L extends Location & DynamicLocation<E, L>, E extends Entity & LocationOwner<L, E>> {
-
- @SetFromFlag("locationPrefix")
- ConfigKey<String> LOCATION_NAME_PREFIX = ConfigKeys.newStringConfigKey(
- "entity.dynamicLocation.prefix", "The name prefix for the location owned by this entity", "dynamic");
-
- @SetFromFlag("locationSuffix")
- ConfigKey<String> LOCATION_NAME_SUFFIX = ConfigKeys.newStringConfigKey(
- "entity.dynamicLocation.suffix", "The name suffix for the location owned by this entity");
-
- @SetFromFlag("locationName")
- BasicAttributeSensorAndConfigKey<String> LOCATION_NAME = new BasicAttributeSensorAndConfigKey<String>(String.class,
- "entity.dynamicLocation.name", "The name of the location owned by this entity (default is auto-generated using prefix and suffix keys)");
-
- ConfigKey<Map<String, Object>> LOCATION_FLAGS = ConfigKeys.newConfigKey(new TypeToken<Map<String, Object>>() { },
- "entity.dynamicLocation.flags", "Extra creation flags for the Location owned by this entity",
- ImmutableMap.<String, Object>of());
-
- AttributeSensor<Location> DYNAMIC_LOCATION = Sensors.newSensor(Location.class,
- "entity.dynamicLocation", "The location owned by this entity");
-
- AttributeSensor<String> LOCATION_SPEC = Sensors.newStringSensor(
- "entity.dynamicLocation.spec", "The specification string for the location owned by this entity");
-
- AttributeSensor<Boolean> DYNAMIC_LOCATION_STATUS = Sensors.newBooleanSensor(
- "entity.dynamicLocation.status", "The status of the location owned by this entity");
-
- AttributeSensor<LocationDefinition> LOCATION_DEFINITION = Sensors.newSensor(
- LocationDefinition.class, "entity.dynamicLocation.definition", "The location definition for the location owned by this entity");
-
- L getDynamicLocation();
-
- L createLocation(Map<String, ?> flags);
-
- boolean isLocationAvailable();
-
- void deleteLocation();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/location/geo/GeoBytesHostGeoLookup.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/geo/GeoBytesHostGeoLookup.java b/core/src/main/java/brooklyn/location/geo/GeoBytesHostGeoLookup.java
deleted file mode 100644
index 1c68000..0000000
--- a/core/src/main/java/brooklyn/location/geo/GeoBytesHostGeoLookup.java
+++ /dev/null
@@ -1,105 +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 java.io.IOException;
-import java.net.InetAddress;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Properties;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.util.net.Networking;
-
-/** @deprecated Mar 2015 - the API has changed; GetLocation now discouraged for free access, and valuepairs.txt not supported */
-@Deprecated
-public class GeoBytesHostGeoLookup implements HostGeoLookup {
-
- public static final Logger log = LoggerFactory.getLogger(GeoBytesHostGeoLookup.class);
-
- /*
- curl "http://www.geobytes.com/IpLocator.htm?GetLocation&template=valuepairs.txt&IpAddress=geobytes.com"
- known=1
- countryid=254
- country=United States
- fips104=US
- iso2=US
- iso3=USA
- ison=840
- internet=US
- comment=
- regionid=142
- region=Maryland
- code=MD
- adm1code=
- cityid=8909
- city=Baltimore
- latitude=39.2894
- longitude=-76.6384
- timezone=-05:00
- dmaid=512
- dma=512
- market=Baltimore
- certainty=78
- isproxy=false
- mapbytesremaining=Free
- */
-
- public String getPropertiesLookupUrlForPublicIp(String ip) {
- return "http://www.geobytes.com/IpLocator.htm?GetLocation&template=valuepairs.txt&IpAddress="+ip.trim();
- }
-
- public String getPropertiesLookupUrlForLocalhost() {
- return "http://www.geobytes.com/IpLocator.htm?GetLocation&template=valuepairs.txt";
- }
-
- /** returns URL to get properties for the given address (assuming localhost if address is on a subnet) */
- public String getPropertiesLookupUrlFor(InetAddress address) {
- if (Networking.isPrivateSubnet(address)) return getPropertiesLookupUrlForLocalhost();
- return getPropertiesLookupUrlForPublicIp(address.getHostAddress());
- }
-
- private static boolean LOGGED_GEO_LOOKUP_UNAVAILABLE = false;
-
- public HostGeoInfo getHostGeoInfo(InetAddress address) throws MalformedURLException, IOException {
- String url = getPropertiesLookupUrlFor(address);
- if (log.isDebugEnabled())
- log.debug("Geo info lookup for "+address+" at "+url);
- Properties props = new Properties();
- try {
- props.load( new URL(url).openStream() );
- HostGeoInfo geo = new HostGeoInfo(address.getHostName(), props.getProperty("city")+" ("+props.getProperty("iso2")+")",
- Double.parseDouble(props.getProperty("latitude")), Double.parseDouble(props.getProperty("longitude")));
- log.info("Geo info lookup for "+address+" returned: "+geo);
- return geo;
- } catch (Exception e) {
- // may be web not available, or gateway giving us funny crap
- if (log.isDebugEnabled())
- log.debug("Geo info lookup for "+address+" failed: "+e);
- if (!LOGGED_GEO_LOOKUP_UNAVAILABLE) {
- LOGGED_GEO_LOOKUP_UNAVAILABLE = true;
- log.info("Geo info lookup unavailable (for "+address+"; cause "+e+")");
- }
- return null;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/location/geo/HasHostGeoInfo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/geo/HasHostGeoInfo.java b/core/src/main/java/brooklyn/location/geo/HasHostGeoInfo.java
deleted file mode 100644
index 86920e8..0000000
--- a/core/src/main/java/brooklyn/location/geo/HasHostGeoInfo.java
+++ /dev/null
@@ -1,25 +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;
-
-public interface HasHostGeoInfo {
-
- HostGeoInfo getHostGeoInfo();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/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
deleted file mode 100644
index 43ee4ad..0000000
--- a/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java
+++ /dev/null
@@ -1,206 +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 java.io.Serializable;
-import java.net.InetAddress;
-
-import javax.annotation.Nullable;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.location.AddressableLocation;
-import brooklyn.location.Location;
-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;
-
-/**
- * Encapsulates geo-IP information for a given host.
- */
-public class HostGeoInfo implements Serializable {
-
- private static final long serialVersionUID = -5866759901535266181L;
-
- public static final Logger log = LoggerFactory.getLogger(HostGeoInfo.class);
-
- /** the IP address */
- public final String address;
-
- public final String displayName;
-
- 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);
- }
-
- public static HostGeoInfo fromIpAddress(InetAddress address) {
- try {
- 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();
- }
-
- public static void clearCachedLookup() {
- cachedLookup = null;
- }
-
- /** returns null if cannot be set */
- public static HostGeoInfo fromLocation(Location l) {
- if (l==null) return null;
-
- Location la = l;
- HostGeoInfo resultFromLocation = null;
- while (la!=null) {
- if (la instanceof HasHostGeoInfo) {
- resultFromLocation = ((HasHostGeoInfo)l).getHostGeoInfo();
- if (resultFromLocation!=null) break;
- }
- la = la.getParent();
- }
- if (resultFromLocation!=null && l==la) {
- // from the location
- return resultFromLocation;
- }
- // resultFromLocation may be inherited, in which case we will copy it later
-
- InetAddress address = findIpAddress(l);
- Object latitude = l.getConfig(LocationConfigKeys.LATITUDE);
- Object longitude = l.getConfig(LocationConfigKeys.LONGITUDE);
-
- if (resultFromLocation!=null && (latitude == null || longitude == null)) {
- latitude = resultFromLocation.latitude;
- longitude = resultFromLocation.longitude;
- }
- if (address!=null && (latitude == null || longitude == null)) {
- HostGeoInfo geo = fromIpAddress(address);
- if (geo==null) return null;
- latitude = geo.latitude;
- longitude = geo.longitude;
- }
-
- if (latitude==null || longitude==null)
- return null;
-
- Exception error=null;
- try {
- latitude = TypeCoercions.castPrimitive(latitude, Double.class);
- longitude = TypeCoercions.castPrimitive(longitude, Double.class);
- } catch (Exception e) {
- Exceptions.propagateIfFatal(e);
- error = e;
- }
- if (error!=null || !(latitude instanceof Double) || !(longitude instanceof Double))
- throw new IllegalArgumentException("Location "+l+" specifies invalid type of lat/long: " +
- "lat="+latitude+" (type "+(latitude==null ? null : latitude.getClass())+"); " +
- "lon="+longitude+" (type "+(longitude==null ? null : longitude.getClass())+")", error);
-
- HostGeoInfo result = new HostGeoInfo(address!=null ? address.getHostAddress() : null, l.getDisplayName(), (Double) latitude, (Double) longitude);
- if (l instanceof AbstractLocation) {
- ((AbstractLocation)l).setHostGeoInfo(result);
- }
- return result;
- }
-
- private static HostGeoLookup findHostGeoLookupImpl() throws InstantiationException, IllegalAccessException, ClassNotFoundException {
- String type = BrooklynSystemProperties.HOST_GEO_LOOKUP_IMPL.getValue();
- /* utrace seems more accurate than geobytes, and it gives a report of how many tokens are left;
- * but maxmind if it's installed locally is even better (does not require remote lookup),
- * so use it if available */
- 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();
- }
-
- public static HostGeoInfo fromEntity(Entity e) {
- for (Location l : e.getLocations()) {
- HostGeoInfo hgi = fromLocation(l);
- if (hgi != null)
- return hgi;
- }
- return null;
- }
-
- public static InetAddress findIpAddress(Location l) {
- if (l == null)
- return null;
- if (l instanceof AddressableLocation)
- return ((AddressableLocation) l).getAddress();
- return findIpAddress(l.getParent());
- }
-
- public HostGeoInfo(String address, String displayName, double latitude, double longitude) {
- this.address = address;
- this.displayName = displayName==null ? "" : displayName;
- this.latitude = latitude;
- this.longitude = longitude;
- }
-
- public String getAddress() {
- return address;
- }
-
- @Override
- public String toString() {
- return "HostGeoInfo["+displayName+": "+(address!=null ? address : "(no-address)")+" at ("+latitude+","+longitude+")]";
- }
-
- @Override
- public boolean equals(Object o) {
- // Slight cheat: only includes the address + displayName field (displayName to allow overloading localhost etc)
- return (o instanceof HostGeoInfo) && Objects.equal(address, ((HostGeoInfo) o).address)
- && Objects.equal(displayName, ((HostGeoInfo) o).displayName);
- }
-
- @Override
- public int hashCode() {
- // Slight cheat: only includes the address + displayName field (displayName to allow overloading localhost etc)
- return Objects.hashCode(address, displayName);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/location/geo/HostGeoLookup.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/geo/HostGeoLookup.java b/core/src/main/java/brooklyn/location/geo/HostGeoLookup.java
deleted file mode 100644
index ef9d043..0000000
--- a/core/src/main/java/brooklyn/location/geo/HostGeoLookup.java
+++ /dev/null
@@ -1,27 +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 java.net.InetAddress;
-
-public interface HostGeoLookup {
-
- public HostGeoInfo getHostGeoInfo(InetAddress address) throws Exception;
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/location/geo/LocalhostExternalIpLoader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/geo/LocalhostExternalIpLoader.java b/core/src/main/java/brooklyn/location/geo/LocalhostExternalIpLoader.java
deleted file mode 100644
index 74056bc..0000000
--- a/core/src/main/java/brooklyn/location/geo/LocalhostExternalIpLoader.java
+++ /dev/null
@@ -1,179 +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 java.util.Collections;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.util.ResourceUtils;
-import brooklyn.util.exceptions.Exceptions;
-import brooklyn.util.text.StringPredicates;
-import brooklyn.util.time.Duration;
-import brooklyn.util.time.Durations;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Predicates;
-import com.google.common.base.Splitter;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-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);
- private static volatile String localExternalIp;
-
- private static class IpLoader implements Callable<String> {
- private static final Pattern ipPattern = Pattern.compile(
- "\\b((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\\b");
- final String url;
-
- protected IpLoader(String url) {
- this.url = url;
- }
-
- @Override
- public String call() {
- String response = ResourceUtils.create(LocalhostExternalIpLoader.class)
- .getResourceAsString(url).trim();
- return postProcessResponse(response);
- }
-
- String postProcessResponse(String response) {
- Matcher matcher = ipPattern.matcher(response);
- boolean matched = matcher.find();
- if (!matched) {
- LOG.error("No IP address matched in output from {}: {}", url, response);
- return null;
- } else {
- return matcher.group();
- }
- }
- }
-
- @VisibleForTesting
- static List<String> getIpAddressWebsites() {
- String file = new ResourceUtils(LocalhostExternalIpLoader.class)
- .getResourceAsString("classpath://brooklyn/location/geo/external-ip-address-resolvers.txt");
- Iterable<String> lines = Splitter.on('\n')
- .omitEmptyStrings()
- .trimResults()
- .split(file);
- List<String> urls = Lists.newArrayList(Iterables.filter(lines, Predicates.not(StringPredicates.startsWith("#"))));
- Collections.shuffle(urls);
- return urls;
- }
-
- @VisibleForTesting
- static String getIpAddressFrom(String url) {
- return new IpLoader(url).call();
- }
-
- /** As {@link #getLocalhostIpWithin(Duration)} but returning 127.0.0.1 if not accessible */
- public static String getLocalhostIpQuicklyOrDefault() {
- String result = doLoad(Duration.seconds(2));
- if (result==null) return "127.0.0.1";
- return result;
- }
-
- /** As {@link #getLocalhostIpWithin(Duration)} but without the time limit cut-off, failing if the load gives an error. */
- public static String getLocalhostIpWaiting() {
- return getLocalhostIpWithin(null);
- }
-
- /**
- * Attempts to load the public IP address of localhost, failing if the load
- * does not complete within the given duration.
- * @return The public IP address of localhost
- */
- public static String getLocalhostIpWithin(Duration timeout) {
- String result = doLoad(timeout);
- if (result == null) {
- throw new IllegalStateException("Unable to retrieve external IP for localhost; network may be down or slow or remote service otherwise not responding");
- }
- return result;
- }
-
- /**
- * Requests URLs returned by {@link #getIpAddressWebsites()} until one returns an IP address.
- * 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;
- }
-
- final List<String> candidateUrls = getIpAddressWebsites();
- if (candidateUrls.isEmpty()) {
- LOG.debug("No candidate URLs to use to determine external IP of localhost");
- return null;
- }
-
- // do 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)) {
- 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);
- 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();
- }
- }
- }
- }.start();
- }
-
- try {
- if (blockFor!=null) {
- Durations.await(triedLocalExternalIp, blockFor);
- } else {
- triedLocalExternalIp.await();
- }
- } catch (InterruptedException e) {
- throw Exceptions.propagate(e);
- }
- if (localExternalIp == null) {
- return null;
- }
- return localExternalIp;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/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
deleted file mode 100644
index da79c29..0000000
--- a/core/src/main/java/brooklyn/location/geo/MaxMind2HostGeoLookup.java
+++ /dev/null
@@ -1,115 +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 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/e2c57058/core/src/main/java/brooklyn/location/geo/UtraceHostGeoLookup.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/geo/UtraceHostGeoLookup.java b/core/src/main/java/brooklyn/location/geo/UtraceHostGeoLookup.java
deleted file mode 100644
index 10b21df..0000000
--- a/core/src/main/java/brooklyn/location/geo/UtraceHostGeoLookup.java
+++ /dev/null
@@ -1,210 +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 groovy.util.Node;
-import groovy.util.NodeList;
-import groovy.util.XmlParser;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.MalformedURLException;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.util.exceptions.Exceptions;
-import brooklyn.util.javalang.JavaClassNames;
-import brooklyn.util.net.Networking;
-import brooklyn.util.time.Duration;
-import brooklyn.util.time.Durations;
-
-import com.google.common.base.Throwables;
-
-public class UtraceHostGeoLookup implements HostGeoLookup {
-
-
- /*
- *
-http://xml.utrace.de/?query=88.198.156.18
-(IP address or hostname)
-
-The XML result is as follows:
-
-<?xml version="1.0" encoding="iso-8869-1"?>
-<results>
-<result>
-<ip>88.198.156.18</ip>
-<host>utrace.de</host>
-<isp>Hetzner Online AG</isp>
-<org>Pagedesign GmbH</org>
-<region>Hamburg</region>
-<countrycode>DE</countrycode>
-<latitude>53.5499992371</latitude>
-<longitude>10</longitude>
-<queries>10</queries>
-</result>
-</results>
-
-Note the queries count field -- you are permitted 100 per day.
-Beyond this you get blacklisted and requests may time out, or return none.
-(This may last for several days once blacklisting, not sure how long.)
- */
-
- /** after failures, subsequent retries within this time interval are blocked */
- private static final Duration RETRY_INTERVAL = Duration.FIVE_MINUTES;
- /** requests taking longer than this period are deemed to have timed out and failed;
- * set reasonably low so that if we are blacklisted for making too many requests,
- * the call to get geo info does not take very long */
- private static final Duration REQUEST_TIMEOUT = Duration.seconds(3);
-
- public static final Logger log = LoggerFactory.getLogger(UtraceHostGeoLookup.class);
-
- public String getLookupUrlForPublicIp(String ip) {
- return "http://xml.utrace.de/?query="+ip.trim();
- }
-
- /**
- * @deprecated since 0.7.0. Use {@link brooklyn.location.geo.LocalhostExternalIpLoader} instead.
- */
- @Deprecated
- public static String getLocalhostExternalIp() {
- return LocalhostExternalIpLoader.getLocalhostIpWithin(Duration.seconds(2));
- }
-
- /**
- * @deprecated since 0.7.0. Use {@link brooklyn.location.geo.LocalhostExternalIpLoader} instead.
- */
- @Deprecated
- public static String getLocalhostExternalIpImpl() {
- return LocalhostExternalIpLoader.getLocalhostIpWithin(Duration.seconds(2));
- }
-
- public String getLookupUrlForLocalhost() {
- return getLookupUrlForPublicIp(LocalhostExternalIpLoader.getLocalhostIpQuicklyOrDefault());
- }
-
- /** returns URL to get properties for the given address (assuming localhost if address is on a subnet) */
- public String getLookupUrlFor(InetAddress address) {
- if (Networking.isPrivateSubnet(address)) return getLookupUrlForLocalhost();
- return getLookupUrlForPublicIp(address.getHostAddress());
- }
-
- private static boolean LOGGED_GEO_LOOKUP_UNAVAILABLE = false;
- private static long LAST_FAILURE_UTC = -1;
-
- /** does the {@link #retrieveHostGeoInfo(InetAddress)}, but in the background with a default timeout */
- public HostGeoInfo getHostGeoInfo(InetAddress address) throws MalformedURLException, IOException {
- if (Duration.sinceUtc(LAST_FAILURE_UTC).compareTo(RETRY_INTERVAL) < 0) {
- // wait at least 60s since a failure
- return null;
- }
- return getHostGeoInfo(address, REQUEST_TIMEOUT);
- }
-
- /** does a {@link #retrieveHostGeoInfo(InetAddress)} with a timeout (returning null, interrupting, and setting failure time) */
- public HostGeoInfo getHostGeoInfo(final InetAddress address, Duration timeout) throws MalformedURLException, IOException {
- final AtomicReference<HostGeoInfo> result = new AtomicReference<HostGeoInfo>();
- Thread lt = new Thread() {
- public void run() {
- try {
- result.set(retrieveHostGeoInfo(address));
- } catch (Exception e) {
- log.warn("Error computing geo info for "+address+"; internet issues or too many requests to (free) servers for "+JavaClassNames.simpleClassName(UtraceHostGeoLookup.this)+": "+e);
- log.debug("Detail of host geo error: "+e, e);
- }
- }
- };
- lt.start();
-
- try {
- Durations.join(lt, timeout);
- } catch (InterruptedException e) {
- throw Exceptions.propagate(e);
- }
-
- if (lt.isAlive()) {
- // interrupt and set the failure time so that subsequent attempts do not face this timeout
- lt.interrupt();
- LAST_FAILURE_UTC = System.currentTimeMillis();
- log.debug("Geo info lookup for "+address+" timed out after "+timeout);
- }
-
- return result.get();
- }
-
- public HostGeoInfo retrieveHostGeoInfo(InetAddress address) throws MalformedURLException, IOException {
- String url = getLookupUrlFor(address);
- if (log.isDebugEnabled())
- log.debug("Geo info lookup for "+address+" at "+url);
- Node xml;
- try {
- xml = new XmlParser().parse(getLookupUrlFor(address));
- } catch (Exception e) {
- LAST_FAILURE_UTC = System.currentTimeMillis();
- if (log.isDebugEnabled())
- log.debug("Geo info lookup for "+address+" failed: "+e);
- if (!LOGGED_GEO_LOOKUP_UNAVAILABLE) {
- LOGGED_GEO_LOOKUP_UNAVAILABLE = true;
- log.info("Geo info lookup unavailable (for "+address+"; cause "+e+")");
- }
- return null;
- }
- try {
- String org = getXmlResultsField(xml, "org").trim();
- if (org.isEmpty()) org = getXmlResultsField(xml, "isp").trim();
- String region = getXmlResultsField(xml, "region").trim();
- if (!org.isEmpty()) {
- if (!region.isEmpty()) region = org+", "+region;
- else region = org;
- }
- if (region.isEmpty()) region = getXmlResultsField(xml, "isp").trim();
- if (region.isEmpty()) region = address.toString();
- HostGeoInfo geo = new HostGeoInfo(address.getHostName(),
- region+
- " ("+getXmlResultsField(xml, "countrycode")+")",
- Double.parseDouble(""+getXmlResultsField(xml, "latitude")),
- Double.parseDouble(""+getXmlResultsField(xml, "longitude")));
- log.info("Geo info lookup for "+address+" returned: "+geo);
- return geo;
- } catch (Exception e) {
- if (log.isDebugEnabled())
- log.debug("Geo info lookup failed, for "+address+" at "+url+", due to "+e+"; response is "+xml);
- throw Throwables.propagate(e);
- }
- }
-
- @Nullable
- private static Node getFirstChild(Node xml, String field) {
- if (xml==null) return null;
- NodeList nl = (NodeList)xml.get(field);
- if (nl==null || nl.isEmpty()) return null;
- return (Node)nl.get(0);
- }
- @Nonnull
- private static String getXmlResultsField(Node xml, String field) {
- Node f1 = getFirstChild(getFirstChild(xml, "result"), field);
- if (f1==null) return "";
- return f1.text();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/location/paas/PaasLocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/paas/PaasLocation.java b/core/src/main/java/brooklyn/location/paas/PaasLocation.java
deleted file mode 100644
index 6165e04..0000000
--- a/core/src/main/java/brooklyn/location/paas/PaasLocation.java
+++ /dev/null
@@ -1,30 +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.paas;
-
-import brooklyn.location.Location;
-
-/**
- * {@link Location} representing an application container on a PaaS provider.
- */
-public interface PaasLocation extends Location {
-
- String getPaasProviderName();
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java b/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
index 8481e6e..b933e6b 100644
--- a/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
+++ b/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
@@ -60,7 +60,7 @@ import brooklyn.entity.rebind.plane.dto.BasicManagementNodeSyncRecord;
import brooklyn.entity.rebind.plane.dto.ManagementPlaneSyncRecordImpl;
import brooklyn.entity.rebind.plane.dto.ManagementPlaneSyncRecordImpl.Builder;
import brooklyn.internal.BrooklynFeatureEnablement;
-import brooklyn.location.Location;
+import org.apache.brooklyn.location.Location;
import brooklyn.management.ha.BasicMasterChooser.AlphabeticMasterChooser;
import brooklyn.management.internal.BrooklynObjectManagementMode;
import brooklyn.management.internal.LocalEntityManager;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/management/internal/AbstractManagementContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/AbstractManagementContext.java b/core/src/main/java/brooklyn/management/internal/AbstractManagementContext.java
index b85e133..4c790b6 100644
--- a/core/src/main/java/brooklyn/management/internal/AbstractManagementContext.java
+++ b/core/src/main/java/brooklyn/management/internal/AbstractManagementContext.java
@@ -66,8 +66,8 @@ import brooklyn.internal.storage.DataGrid;
import brooklyn.internal.storage.DataGridFactory;
import brooklyn.internal.storage.impl.BrooklynStorageImpl;
import brooklyn.internal.storage.impl.inmemory.InMemoryDataGridFactory;
-import brooklyn.location.LocationRegistry;
-import brooklyn.location.basic.BasicLocationRegistry;
+import org.apache.brooklyn.location.LocationRegistry;
+import org.apache.brooklyn.location.basic.BasicLocationRegistry;
import brooklyn.management.classloading.JavaBrooklynClassLoadingContext;
import brooklyn.management.entitlement.Entitlements;
import brooklyn.management.ha.HighAvailabilityManagerImpl;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java b/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
index fdf2803..5bb6eac 100644
--- a/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
+++ b/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
@@ -49,7 +49,7 @@ import brooklyn.entity.basic.BrooklynTaskTags.WrappedStream;
import brooklyn.entity.basic.ConfigKeys;
import brooklyn.entity.basic.Entities;
import brooklyn.internal.storage.BrooklynStorage;
-import brooklyn.location.Location;
+import org.apache.brooklyn.location.Location;
import brooklyn.util.collections.MutableList;
import brooklyn.util.collections.MutableMap;
import brooklyn.util.collections.MutableSet;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/management/internal/LocalAccessManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/LocalAccessManager.java b/core/src/main/java/brooklyn/management/internal/LocalAccessManager.java
index d169e33..3874d3d 100644
--- a/core/src/main/java/brooklyn/management/internal/LocalAccessManager.java
+++ b/core/src/main/java/brooklyn/management/internal/LocalAccessManager.java
@@ -23,7 +23,7 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.api.management.AccessController;
-import brooklyn.location.Location;
+import org.apache.brooklyn.location.Location;
import com.google.common.annotations.Beta;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java b/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java
index cb9a7e2..3d6acfd 100644
--- a/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java
+++ b/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java
@@ -36,11 +36,11 @@ import brooklyn.entity.basic.ConfigKeys;
import brooklyn.entity.basic.Lifecycle;
import brooklyn.entity.proxying.InternalLocationFactory;
import brooklyn.internal.storage.BrooklynStorage;
-import brooklyn.location.Location;
-import brooklyn.location.LocationSpec;
-import brooklyn.location.ProvisioningLocation;
-import brooklyn.location.basic.AbstractLocation;
-import brooklyn.location.basic.LocationInternal;
+import org.apache.brooklyn.location.Location;
+import org.apache.brooklyn.location.LocationSpec;
+import org.apache.brooklyn.location.ProvisioningLocation;
+import org.apache.brooklyn.location.basic.AbstractLocation;
+import org.apache.brooklyn.location.basic.LocationInternal;
import brooklyn.management.entitlement.Entitlements;
import brooklyn.util.config.ConfigBag;
import brooklyn.util.exceptions.Exceptions;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/management/internal/LocalManagementContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/LocalManagementContext.java b/core/src/main/java/brooklyn/management/internal/LocalManagementContext.java
index beb568f..73a362f 100644
--- a/core/src/main/java/brooklyn/management/internal/LocalManagementContext.java
+++ b/core/src/main/java/brooklyn/management/internal/LocalManagementContext.java
@@ -53,7 +53,7 @@ import brooklyn.entity.proxying.InternalLocationFactory;
import brooklyn.entity.proxying.InternalPolicyFactory;
import brooklyn.internal.BrooklynFeatureEnablement;
import brooklyn.internal.storage.DataGridFactory;
-import brooklyn.location.Location;
+import org.apache.brooklyn.location.Location;
import brooklyn.management.entitlement.Entitlements;
import brooklyn.management.ha.OsgiManager;
import brooklyn.util.exceptions.Exceptions;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/management/internal/LocalUsageManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/LocalUsageManager.java b/core/src/main/java/brooklyn/management/internal/LocalUsageManager.java
index 9ae12f5..31084a4 100644
--- a/core/src/main/java/brooklyn/management/internal/LocalUsageManager.java
+++ b/core/src/main/java/brooklyn/management/internal/LocalUsageManager.java
@@ -41,10 +41,10 @@ import brooklyn.entity.basic.Entities;
import brooklyn.entity.basic.EntityInternal;
import brooklyn.entity.basic.Lifecycle;
import brooklyn.internal.storage.BrooklynStorage;
-import brooklyn.location.Location;
-import brooklyn.location.basic.AbstractLocation;
-import brooklyn.location.basic.LocationConfigKeys;
-import brooklyn.location.basic.LocationInternal;
+import org.apache.brooklyn.location.Location;
+import org.apache.brooklyn.location.basic.AbstractLocation;
+import org.apache.brooklyn.location.basic.LocationConfigKeys;
+import org.apache.brooklyn.location.basic.LocationInternal;
import brooklyn.management.ManagementContextInjectable;
import brooklyn.management.entitlement.Entitlements;
import brooklyn.management.usage.ApplicationUsage;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/management/internal/LocationManagerInternal.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/LocationManagerInternal.java b/core/src/main/java/brooklyn/management/internal/LocationManagerInternal.java
index f36f5df..2d126bc 100644
--- a/core/src/main/java/brooklyn/management/internal/LocationManagerInternal.java
+++ b/core/src/main/java/brooklyn/management/internal/LocationManagerInternal.java
@@ -20,7 +20,7 @@ package brooklyn.management.internal;
import org.apache.brooklyn.api.management.LocationManager;
-import brooklyn.location.Location;
+import org.apache.brooklyn.location.Location;
public interface LocationManagerInternal extends LocationManager, BrooklynObjectManagerInternal<Location> {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/management/internal/ManagementContextInternal.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/ManagementContextInternal.java b/core/src/main/java/brooklyn/management/internal/ManagementContextInternal.java
index 46bdbf8..699b34f 100644
--- a/core/src/main/java/brooklyn/management/internal/ManagementContextInternal.java
+++ b/core/src/main/java/brooklyn/management/internal/ManagementContextInternal.java
@@ -36,7 +36,7 @@ import brooklyn.entity.proxying.InternalEntityFactory;
import brooklyn.entity.proxying.InternalLocationFactory;
import brooklyn.entity.proxying.InternalPolicyFactory;
import brooklyn.internal.storage.BrooklynStorage;
-import brooklyn.location.Location;
+import org.apache.brooklyn.location.Location;
import brooklyn.management.ha.OsgiManager;
import brooklyn.util.guava.Maybe;
import brooklyn.util.task.TaskTags;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/management/internal/NonDeploymentLocationManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/NonDeploymentLocationManager.java b/core/src/main/java/brooklyn/management/internal/NonDeploymentLocationManager.java
index 97c10c7..eaad030 100644
--- a/core/src/main/java/brooklyn/management/internal/NonDeploymentLocationManager.java
+++ b/core/src/main/java/brooklyn/management/internal/NonDeploymentLocationManager.java
@@ -24,8 +24,8 @@ import java.util.Map;
import org.apache.brooklyn.api.management.ManagementContext;
-import brooklyn.location.Location;
-import brooklyn.location.LocationSpec;
+import org.apache.brooklyn.location.Location;
+import org.apache.brooklyn.location.LocationSpec;
public class NonDeploymentLocationManager implements LocationManagerInternal {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java b/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
index cb0e9ef..eff0417 100644
--- a/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
+++ b/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
@@ -66,8 +66,8 @@ import brooklyn.entity.proxying.InternalEntityFactory;
import brooklyn.entity.proxying.InternalLocationFactory;
import brooklyn.entity.proxying.InternalPolicyFactory;
import brooklyn.internal.storage.BrooklynStorage;
-import brooklyn.location.Location;
-import brooklyn.location.LocationRegistry;
+import org.apache.brooklyn.location.Location;
+import org.apache.brooklyn.location.LocationRegistry;
import brooklyn.management.entitlement.Entitlements;
import brooklyn.management.ha.OsgiManager;
import brooklyn.util.guava.Maybe;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/management/internal/NonDeploymentUsageManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/NonDeploymentUsageManager.java b/core/src/main/java/brooklyn/management/internal/NonDeploymentUsageManager.java
index c8508a1..55577d4 100644
--- a/core/src/main/java/brooklyn/management/internal/NonDeploymentUsageManager.java
+++ b/core/src/main/java/brooklyn/management/internal/NonDeploymentUsageManager.java
@@ -23,7 +23,7 @@ import java.util.Set;
import org.apache.brooklyn.api.entity.Application;
import brooklyn.entity.basic.Lifecycle;
-import brooklyn.location.Location;
+import org.apache.brooklyn.location.Location;
import brooklyn.management.usage.ApplicationUsage;
import brooklyn.management.usage.LocationUsage;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/management/internal/UsageListener.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/UsageListener.java b/core/src/main/java/brooklyn/management/internal/UsageListener.java
index 44c5e67..3914802 100644
--- a/core/src/main/java/brooklyn/management/internal/UsageListener.java
+++ b/core/src/main/java/brooklyn/management/internal/UsageListener.java
@@ -22,7 +22,7 @@ import java.util.Map;
import org.apache.brooklyn.api.entity.Application;
-import brooklyn.location.Location;
+import org.apache.brooklyn.location.Location;
import brooklyn.management.usage.ApplicationUsage.ApplicationEvent;
import brooklyn.management.usage.LocationUsage.LocationEvent;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/management/internal/UsageManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/UsageManager.java b/core/src/main/java/brooklyn/management/internal/UsageManager.java
index 2263691..bc4dfe5 100644
--- a/core/src/main/java/brooklyn/management/internal/UsageManager.java
+++ b/core/src/main/java/brooklyn/management/internal/UsageManager.java
@@ -29,7 +29,7 @@ import org.apache.brooklyn.api.entity.Application;
import brooklyn.config.ConfigKey;
import brooklyn.entity.basic.ConfigKeys;
import brooklyn.entity.basic.Lifecycle;
-import brooklyn.location.Location;
+import org.apache.brooklyn.location.Location;
import brooklyn.management.usage.ApplicationUsage;
import brooklyn.management.usage.ApplicationUsage.ApplicationEvent;
import brooklyn.management.usage.LocationUsage;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/main/java/brooklyn/util/BrooklynNetworkUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/BrooklynNetworkUtils.java b/core/src/main/java/brooklyn/util/BrooklynNetworkUtils.java
index 86bf827..0c1d39d 100644
--- a/core/src/main/java/brooklyn/util/BrooklynNetworkUtils.java
+++ b/core/src/main/java/brooklyn/util/BrooklynNetworkUtils.java
@@ -21,7 +21,7 @@ package brooklyn.util;
import java.net.InetAddress;
import brooklyn.config.BrooklynServiceAttributes;
-import brooklyn.location.geo.LocalhostExternalIpLoader;
+import org.apache.brooklyn.location.geo.LocalhostExternalIpLoader;
import brooklyn.util.flags.TypeCoercions;
import brooklyn.util.net.Networking;