You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2021/10/05 09:44:07 UTC

[brooklyn-server] branch master updated (e5da763 -> 868bfdd)

This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git.


    from e5da763  Merge branch 'misc-updates'
     new 6c7a22f  another transforming convenience for the MutableMap
     new 0c7f314  logging when a non-preferred resolver is activated
     new 868bfdd  Merge branch 'resolvers-logging'

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../core/typereg/BrooklynCatalogBundleResolvers.java     | 16 +++++++++++++++-
 .../org/apache/brooklyn/util/collections/MutableMap.java | 10 ++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

[brooklyn-server] 03/03: Merge branch 'resolvers-logging'

Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git

commit 868bfdd2c990d60e8c064099fbdf044a32eb6bd2
Merge: 6c7a22f 0c7f314
Author: Alex Heneveld <al...@cloudsoftcorp.com>
AuthorDate: Tue Oct 5 10:43:55 2021 +0100

    Merge branch 'resolvers-logging'

 .../core/typereg/BrooklynCatalogBundleResolvers.java     | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

[brooklyn-server] 01/03: another transforming convenience for the MutableMap

Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git

commit 6c7a22f149fbfd9273c58e3e0b5c027377cb5aa6
Author: Alex Heneveld <al...@cloudsoftcorp.com>
AuthorDate: Tue Oct 5 10:36:24 2021 +0100

    another transforming convenience for the MutableMap
---
 .../java/org/apache/brooklyn/util/collections/MutableMap.java  | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/collections/MutableMap.java b/utils/common/src/main/java/org/apache/brooklyn/util/collections/MutableMap.java
index 280caa2..f6ae6b4 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/collections/MutableMap.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/collections/MutableMap.java
@@ -24,6 +24,7 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import java.util.function.BiFunction;
 import java.util.function.Function;
 import javax.annotation.Nullable;
 
@@ -125,6 +126,15 @@ public class MutableMap<K,V> extends LinkedHashMap<K,V> {
         return result;
     }
 
+    /** creates a copy of a map, transforming the values */
+    public static <K,V1,V2> MutableMap<K,V2> copyOf(@Nullable Map<? extends K, ? extends V1> orig, BiFunction<K,V1,V2> transform) {
+        MutableMap<K,V2> result = new MutableMap<>();
+        if (orig!=null) {
+            orig.forEach( (k,v) -> result.put(k, transform.apply(k, v)) );
+        }
+        return result;
+    }
+
     public MutableMap() {}
     @SuppressWarnings("unchecked")
     public MutableMap(@SuppressWarnings("rawtypes") Map source) { super(source); }

[brooklyn-server] 02/03: logging when a non-preferred resolver is activated

Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git

commit 0c7f314eb7a9b6f3a0cb0438f160ea0e45c3b28b
Author: Alex Heneveld <al...@cloudsoftcorp.com>
AuthorDate: Tue Oct 5 10:42:53 2021 +0100

    logging when a non-preferred resolver is activated
---
 .../core/typereg/BrooklynCatalogBundleResolvers.java     | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/brooklyn/core/typereg/BrooklynCatalogBundleResolvers.java b/core/src/main/java/org/apache/brooklyn/core/typereg/BrooklynCatalogBundleResolvers.java
index 5632bca..6e9843a 100644
--- a/core/src/main/java/org/apache/brooklyn/core/typereg/BrooklynCatalogBundleResolvers.java
+++ b/core/src/main/java/org/apache/brooklyn/core/typereg/BrooklynCatalogBundleResolvers.java
@@ -141,7 +141,9 @@ public class BrooklynCatalogBundleResolvers {
             Map<BrooklynCatalogBundleResolver, Double> resolvers = forBundleWithScore(mgmt, input, options);
             Collection<String> resolversWhoDontSupport = new ArrayList<String>();
             Map<BrooklynCatalogBundleResolver, Exception> failuresFromResolvers = MutableMap.of();
-            for (BrooklynCatalogBundleResolver t : resolvers.keySet()) {
+            Double highestFailedScore = null;
+            for (Entry<BrooklynCatalogBundleResolver,Double> ti : resolvers.entrySet()) {
+                BrooklynCatalogBundleResolver t = ti.getKey();
                 try {
                     ReferenceWithError<OsgiBundleInstallationResult> result = t.install(input, options);
                     if (result == null) {
@@ -154,6 +156,17 @@ public class BrooklynCatalogBundleResolvers {
                     }
                     result.get();  // assert there is no error
                     LOG.debug("Installed bundle {} / {} for {}: {}: {}", input, (options==null ? null : options.knownBundleMetadata), Entitlements.getEntitlementContextUser(), result.get().getCode(), result.get().getMessage());
+                    if (highestFailedScore!=null) {
+                        if (highestFailedScore > 0.9 && (ti.getValue() == null || highestFailedScore > ti.getValue() + 0.1)) {
+                            // if there was an error from a high scoring resolver and a lower-scoring resolver accepted it, log a warning
+                            LOG.warn("Bundle {} was installed by fallback resolver {} because preferred resolver(s) reported issues: {} / {} (scores {})",
+                                    t, result.get().getMetadata(), resolversWhoDontSupport, failuresFromResolvers, resolvers);
+                        } else {
+                            // if there was an error from a high scoring resolver and a lower-scoring resolver accepted it, log a warning
+                            LOG.debug("Bundle {} was installed by resolver {} after other resolver(s) reported issues: {} / {} (scores {})",
+                                    t, result.get().getMetadata(), resolversWhoDontSupport, failuresFromResolvers, resolvers);
+                        }
+                    }
                     return result;
                 } catch (@SuppressWarnings("deprecation") UnsupportedCatalogBundleException e) {
                     resolversWhoDontSupport.add(t.getFormatCode() +
@@ -167,6 +180,7 @@ public class BrooklynCatalogBundleResolvers {
                             (t.getFormatCode() + " bundle installation error") + ": " +
                                     Exceptions.collapseText(e), e));
                 }
+                if (highestFailedScore==null) highestFailedScore = ti.getValue();
             }
 
             if (LOG.isDebugEnabled()) {