brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [21/50] [abbrv] brooklyn-server git commit: code review for #705, minor but important
Date Mon, 01 Feb 2016 17:50:18 GMT
code review for #705, minor but important


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

Branch: refs/heads/0.7.0-incubating
Commit: 08d9b7cf569ca65f972a5c42d025bb64b1be2a19
Parents: e26c9e3
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Wed Jun 24 13:52:51 2015 -0700
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Wed Jun 24 13:52:51 2015 -0700

----------------------------------------------------------------------
 .../brooklyn/entity/basic/BrooklynTaskTags.java   |  2 +-
 .../java/brooklyn/util/flags/TypeCoercions.java   | 18 ++++++------------
 .../brooklyn/util/task/BasicExecutionContext.java |  3 ++-
 .../enricher/RollingTimeWindowMeanEnricher.java   |  6 ++++++
 .../enricher/TimeWeightedDeltaEnricher.java       |  5 +++++
 .../rest/transform/CatalogTransformer.java        |  9 ++++++++-
 6 files changed, 28 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/08d9b7cf/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java b/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
index e90a014..901191a 100644
--- a/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
+++ b/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
@@ -269,7 +269,7 @@ public class BrooklynTaskTags extends TaskTags {
     public static void setTransient(Task<?> task) { addTagDynamically(task, TRANSIENT_TASK_TAG);
}
     public static boolean isTransient(Task<?> task) { 
         if (hasTag(task, TRANSIENT_TASK_TAG)) return true;
-        if (hasTag(task, NON_TRANSIENT_TASK_TAG)) return true;
+        if (hasTag(task, NON_TRANSIENT_TASK_TAG)) return false;
         if (task.getSubmittedByTask()!=null) return isTransient(task.getSubmittedByTask());
         return false;
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/08d9b7cf/core/src/main/java/brooklyn/util/flags/TypeCoercions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/flags/TypeCoercions.java b/core/src/main/java/brooklyn/util/flags/TypeCoercions.java
index c2876bd..3b4ec3d 100644
--- a/core/src/main/java/brooklyn/util/flags/TypeCoercions.java
+++ b/core/src/main/java/brooklyn/util/flags/TypeCoercions.java
@@ -729,12 +729,9 @@ public class TypeCoercions {
             public AttributeSensor apply(final String input) {
                 Entity entity = BrooklynTaskTags.getContextEntity(Tasks.current());
                 if (entity!=null) {
-                    Sensor<?> result = null;
-                    if (entity!=null) {
-                        result = entity.getEntityType().getSensor(input);
-                        if (result instanceof AttributeSensor) 
-                            return (AttributeSensor) result;
-                    }
+                    Sensor<?> result = entity.getEntityType().getSensor(input);
+                    if (result instanceof AttributeSensor) 
+                        return (AttributeSensor) result;
                 }
                 return Sensors.newSensor(Object.class, input);
             }
@@ -744,12 +741,9 @@ public class TypeCoercions {
             public AttributeSensor apply(final String input) {
                 Entity entity = BrooklynTaskTags.getContextEntity(Tasks.current());
                 if (entity!=null) {
-                    Sensor<?> result = null;
-                    if (entity!=null) {
-                        result = entity.getEntityType().getSensor(input);
-                        if (result != null) 
-                            return (AttributeSensor) result;
-                    }
+                    Sensor<?> result = entity.getEntityType().getSensor(input);
+                    if (result != null) 
+                        return (AttributeSensor) result;
                 }
                 return Sensors.newSensor(Object.class, input);
             }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/08d9b7cf/core/src/main/java/brooklyn/util/task/BasicExecutionContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/task/BasicExecutionContext.java b/core/src/main/java/brooklyn/util/task/BasicExecutionContext.java
index 6346ecd..2e75d35 100644
--- a/core/src/main/java/brooklyn/util/task/BasicExecutionContext.java
+++ b/core/src/main/java/brooklyn/util/task/BasicExecutionContext.java
@@ -169,7 +169,8 @@ public class BasicExecutionContext extends AbstractExecutionContext {
 
         taskTags.addAll(tags);
         
-        if (Tasks.current()!=null && BrooklynTaskTags.isTransient(Tasks.current())
&& !taskTags.contains(BrooklynTaskTags.NON_TRANSIENT_TASK_TAG)) {
+        if (Tasks.current()!=null && BrooklynTaskTags.isTransient(Tasks.current())

+                && !taskTags.contains(BrooklynTaskTags.NON_TRANSIENT_TASK_TAG) &&
!taskTags.contains(BrooklynTaskTags.TRANSIENT_TASK_TAG)) {
             // tag as transient if submitter is transient, unless explicitly tagged as non-transient
             taskTags.add(BrooklynTaskTags.TRANSIENT_TASK_TAG);
         }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/08d9b7cf/policy/src/main/java/brooklyn/enricher/RollingTimeWindowMeanEnricher.java
----------------------------------------------------------------------
diff --git a/policy/src/main/java/brooklyn/enricher/RollingTimeWindowMeanEnricher.java b/policy/src/main/java/brooklyn/enricher/RollingTimeWindowMeanEnricher.java
index 7c55a81..a2148e7 100644
--- a/policy/src/main/java/brooklyn/enricher/RollingTimeWindowMeanEnricher.java
+++ b/policy/src/main/java/brooklyn/enricher/RollingTimeWindowMeanEnricher.java
@@ -23,6 +23,7 @@ import java.util.LinkedList;
 
 import brooklyn.config.ConfigKey;
 import brooklyn.enricher.basic.AbstractTypeTransformingEnricher;
+import brooklyn.enricher.basic.YamlRollingTimeWindowMeanEnricher;
 import brooklyn.entity.Entity;
 import brooklyn.entity.basic.ConfigKeys;
 import brooklyn.event.AttributeSensor;
@@ -32,6 +33,7 @@ import brooklyn.util.flags.SetFromFlag;
 import brooklyn.util.javalang.JavaClassNames;
 import brooklyn.util.time.Duration;
 
+import com.google.common.annotations.Beta;
 import com.google.common.base.Preconditions;
 
 /**
@@ -56,7 +58,11 @@ import com.google.common.base.Preconditions;
  * the average is no longer meaningful.
  * <p>
  * The default average when no data has been received is 0, with a confidence of 0
+ * <p>
+ * TODO this may end up being deprecated in favour of near-duplicate code in YAML-friendly
{@link YamlRollingTimeWindowMeanEnricher},
+ * marking as @Beta in 0.7.0 timeframe 
  */
+@Beta
 //@Catalog(name="Rolling Mean in Time Window", description="Transforms a sensor's data into
a rolling average "
 //        + "based on a time window.")
 public class RollingTimeWindowMeanEnricher<T extends Number> extends AbstractTypeTransformingEnricher<T,Double>
{

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/08d9b7cf/policy/src/main/java/brooklyn/enricher/TimeWeightedDeltaEnricher.java
----------------------------------------------------------------------
diff --git a/policy/src/main/java/brooklyn/enricher/TimeWeightedDeltaEnricher.java b/policy/src/main/java/brooklyn/enricher/TimeWeightedDeltaEnricher.java
index 42e418f..608c6eb 100644
--- a/policy/src/main/java/brooklyn/enricher/TimeWeightedDeltaEnricher.java
+++ b/policy/src/main/java/brooklyn/enricher/TimeWeightedDeltaEnricher.java
@@ -34,6 +34,7 @@ import brooklyn.util.flags.SetFromFlag;
 import brooklyn.util.javalang.JavaClassNames;
 import brooklyn.util.time.Duration;
 
+import com.google.common.annotations.Beta;
 import com.google.common.base.Function;
 import com.google.common.base.Functions;
 
@@ -44,7 +45,11 @@ import com.google.common.base.Functions;
  * NB for time (e.g. "total milliseconds consumed") use {@link TimeFractionDeltaEnricher}
  * <p>
  * See also {@link YamlTimeWeightedDeltaEnricher} designed for use from YAML.
+ * <p>
+ * TODO this may end up being deprecated in favour of near-duplicate code in YAML-friendly
{@link YamlTimeWeightedDeltaEnricher},
+ * marking as @Beta in 0.7.0 timeframe 
  */
+@Beta
 //@Catalog(name="Time-weighted Delta", description="Converts an absolute sensor into a delta
sensor "
 //        + "(i.e. the diff between the current and previous value), presented as a units/timeUnit
"
 //        + "based on the event timing.")

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/08d9b7cf/usage/rest-server/src/main/java/brooklyn/rest/transform/CatalogTransformer.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/transform/CatalogTransformer.java
b/usage/rest-server/src/main/java/brooklyn/rest/transform/CatalogTransformer.java
index a9f9baf..00e5144 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/transform/CatalogTransformer.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/transform/CatalogTransformer.java
@@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
 
 import brooklyn.basic.BrooklynTypes;
 import brooklyn.catalog.CatalogItem;
+import brooklyn.catalog.CatalogItem.CatalogItemType;
 import brooklyn.config.ConfigKey;
 import brooklyn.entity.Effector;
 import brooklyn.entity.Entity;
@@ -76,9 +77,15 @@ public class CatalogTransformer {
                 effectors.add(EffectorTransformer.effectorSummaryForCatalog(x));
             
         } catch (Exception e) {
+            Exceptions.propagateIfFatal(e);
+            
             // templates with multiple entities can't have spec created in the manner above;
just ignore
-            if (log.isTraceEnabled())
+            if (item.getCatalogItemType()==CatalogItemType.ENTITY) {
+                log.warn("Unable to create spec for "+item+": "+e, e);
+            }
+            if (log.isTraceEnabled()) {
                 log.trace("Unable to create spec for "+item+": "+e, e);
+            }
         }
         
         return new CatalogEntitySummary(item.getSymbolicName(), item.getVersion(), item.getDisplayName(),


Mime
View raw message