brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [29/50] [abbrv] brooklyn-server git commit: Prevents Location Events being reported to metering for temporary locations
Date Mon, 01 Feb 2016 17:50:26 GMT
Prevents Location Events being reported to metering for temporary locations


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

Branch: refs/heads/0.7.0-incubating
Commit: 392d2bc62f0900994735569a233cf0d7cf661034
Parents: 83797a2
Author: Martin Harris <github@nakomis.com>
Authored: Thu Jun 25 15:44:51 2015 +0100
Committer: Martin Harris <github@nakomis.com>
Committed: Thu Jun 25 15:46:03 2015 +0100

----------------------------------------------------------------------
 .../main/java/brooklyn/location/basic/AbstractLocation.java   | 7 ++++++-
 .../brooklyn/management/internal/LocalLocationManager.java    | 2 +-
 .../java/brooklyn/management/internal/LocalUsageManager.java  | 6 ++++++
 .../main/java/brooklyn/location/jclouds/JcloudsLocation.java  | 4 +++-
 4 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/392d2bc6/core/src/main/java/brooklyn/location/basic/AbstractLocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/basic/AbstractLocation.java b/core/src/main/java/brooklyn/location/basic/AbstractLocation.java
index 8696378..80aa804 100644
--- a/core/src/main/java/brooklyn/location/basic/AbstractLocation.java
+++ b/core/src/main/java/brooklyn/location/basic/AbstractLocation.java
@@ -36,6 +36,7 @@ import brooklyn.basic.AbstractBrooklynObject;
 import brooklyn.config.ConfigInheritance;
 import brooklyn.config.ConfigKey;
 import brooklyn.config.ConfigKey.HasConfigKey;
+import brooklyn.entity.basic.ConfigKeys;
 import brooklyn.entity.rebind.BasicLocationRebindSupport;
 import brooklyn.entity.rebind.RebindSupport;
 import brooklyn.entity.trait.Configurable;
@@ -86,7 +87,11 @@ public abstract class AbstractLocation extends AbstractBrooklynObject implements
     public static final Logger LOG = LoggerFactory.getLogger(AbstractLocation.class);
 
     public static final ConfigKey<Location> PARENT_LOCATION = new BasicConfigKey<Location>(Location.class,
"parentLocation");
-    
+
+    public static final ConfigKey<Boolean> TEMPORARY_LOCATION = ConfigKeys.newBooleanConfigKey("temporaryLocation",
+            "Indicates that the location is a temporary location that has been created to
test connectivity, and that" +
+            "the location's events should not be recorded by usage listeners", false);
+
     private final AtomicBoolean configured = new AtomicBoolean();
     
     private Reference<Long> creationTimeUtc = new BasicReference<Long>(System.currentTimeMillis());

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/392d2bc6/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 2f75120..7d179b6 100644
--- a/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java
+++ b/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java
@@ -98,7 +98,7 @@ public class LocalLocationManager implements LocationManagerInternal {
             if (createUnmanaged) {
                 spec.removeConfig(CREATE_UNMANAGED);
             }
-            
+
             T loc = locationFactory.createLocation(spec);
             if (!createUnmanaged) {
                 manage(loc);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/392d2bc6/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 68f5088..305266f 100644
--- a/core/src/main/java/brooklyn/management/internal/LocalUsageManager.java
+++ b/core/src/main/java/brooklyn/management/internal/LocalUsageManager.java
@@ -41,6 +41,7 @@ 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 brooklyn.management.ManagementContextInjectable;
@@ -284,6 +285,10 @@ public class LocalUsageManager implements UsageManager {
         // but no strong enough feelings yet...
         
         checkNotNull(loc, "location");
+        if (loc.getConfig(AbstractLocation.TEMPORARY_LOCATION)) {
+            log.info("Ignoring location lifecycle usage event for {} (state {}), because
location is a temporary location", loc, state);
+            return;
+        }
         checkNotNull(state, "state of location %s", loc);
         if (loc.getId() == null) {
             log.error("Ignoring location lifecycle usage event for {} (state {}), because
location has no id", loc, state);
@@ -302,6 +307,7 @@ public class LocalUsageManager implements UsageManager {
             Entity caller = (Entity) callerContext;
             String entityTypeName = caller.getEntityType().getName();
             String appId = caller.getApplicationId();
+
             final LocationUsage.LocationEvent event = new LocationUsage.LocationEvent(state,
caller.getId(), entityTypeName, appId, getUser());
             
             ConcurrentMap<String, LocationUsage> usageMap = managementContext.getStorage().<String,
LocationUsage>getMap(LOCATION_USAGE_KEY);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/392d2bc6/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
index 02b7dde..214f946 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
@@ -27,6 +27,7 @@ import static org.jclouds.compute.options.RunScriptOptions.Builder.overrideLogin
 import static org.jclouds.scriptbuilder.domain.Statements.exec;
 
 import brooklyn.util.flags.MethodCoercions;
+import brooklyn.location.basic.AbstractLocation;
 import io.cloudsoft.winrm4j.pywinrm.Session;
 import io.cloudsoft.winrm4j.pywinrm.WinRMFactory;
 
@@ -35,7 +36,6 @@ import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.lang.reflect.Type;
 import java.security.KeyPair;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -1479,6 +1479,7 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation
im
         sshProps.put("user", initialUser);
         sshProps.put("address", hostAndPort.getHostText());
         sshProps.put("port", hostAndPort.getPort());
+        sshProps.put(AbstractLocation.TEMPORARY_LOCATION.getName(), true);
         if (initialPassword.isPresent()) sshProps.put("password", initialPassword.get());
         if (initialPrivateKey.isPresent()) sshProps.put("privateKeyData", initialPrivateKey.get());
         if (initialPrivateKey.isPresent()) sshProps.put("privateKeyData", initialPrivateKey.get());
@@ -1548,6 +1549,7 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation
im
                 SshMachineLocation sshLoc = null;
                 try {
                     if (isManaged()) {
+                        sshProps.put(AbstractLocation.TEMPORARY_LOCATION.getName(), true);
                         sshLoc = getManagementContext().getLocationManager().createLocation(sshProps,
SshMachineLocation.class);
                     } else {
                         sshLoc = new SshMachineLocation(sshProps);


Mime
View raw message