brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geom...@apache.org
Subject [32/39] brooklyn-server git commit: remove more of the legacy bom-scanning support
Date Wed, 19 Jul 2017 16:26:02 GMT
remove more of the legacy bom-scanning support


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

Branch: refs/heads/master
Commit: a9e770f3df019e30b8d7feaab7d54e435ea9e0ad
Parents: 5868124
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Mon Jul 17 11:26:26 2017 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Mon Jul 17 11:26:26 2017 +0100

----------------------------------------------------------------------
 .../catalog/internal/CatalogBundleLoader.java   | 39 +++-----------------
 .../brooklyn/core/mgmt/ha/OsgiManager.java      | 33 +++--------------
 2 files changed, 11 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a9e770f3/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogBundleLoader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogBundleLoader.java
b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogBundleLoader.java
index e55617a..339280e 100644
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogBundleLoader.java
+++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogBundleLoader.java
@@ -31,7 +31,6 @@ import java.util.Map;
 import org.apache.brooklyn.api.catalog.CatalogItem;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.api.typereg.ManagedBundle;
-import org.apache.brooklyn.api.typereg.OsgiBundleWithUrl;
 import org.apache.brooklyn.api.typereg.RegisteredType;
 import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
 import org.apache.brooklyn.core.typereg.RegisteredTypePredicates;
@@ -45,7 +44,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.annotations.Beta;
-import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 
 @Beta
@@ -54,30 +52,20 @@ public class CatalogBundleLoader {
     private static final Logger LOG = LoggerFactory.getLogger(CatalogBundleLoader.class);
     private static final String CATALOG_BOM_URL = "catalog.bom";
 
-    private Predicate<Bundle> applicationsPermitted;
     private ManagementContext managementContext;
 
-    public CatalogBundleLoader(Predicate<Bundle> applicationsPermitted, ManagementContext
managementContext) {
-        this.applicationsPermitted = applicationsPermitted;
+    public CatalogBundleLoader(ManagementContext managementContext) {
         this.managementContext = managementContext;
     }
 
     public void scanForCatalog(Bundle bundle, boolean force, boolean validate) {
         scanForCatalogInternal(bundle, force, validate, false);
     }
-    
-    /**
-     * Scan the given bundle for a catalog.bom and adds it to the catalog.
-     *
-     * @param bundle The bundle to add
-     * @return A list of items added to the catalog
-     * @throws RuntimeException if the catalog items failed to be added to the catalog
-     */
-    public Iterable<? extends CatalogItem<?, ?>> scanForCatalogLegacy(Bundle
bundle) {
-        return scanForCatalogLegacy(bundle, false);
-    }
-    
+
+    /** @deprecated since 0.12.0 */
+    @Deprecated // scans a bundle which is installed but Brooklyn isn't managing (will probably
remove)
     public Iterable<? extends CatalogItem<?, ?>> scanForCatalogLegacy(Bundle
bundle, boolean force) {
+        LOG.warn("Bundle "+bundle+" being loaded with deprecated legacy loader");
         return scanForCatalogInternal(bundle, force, true, true);
     }
     
@@ -119,26 +107,9 @@ public class CatalogBundleLoader {
             LOG.debug("No BOM found in {} {} {}", CatalogUtils.bundleIds(bundle));
         }
 
-        if (!applicationsPermitted.apply(bundle)) {
-            if (legacy) {
-                catalogItems = removeApplications(catalogItems);
-            } else {
-                removeApplications(mb);
-            }
-        }
-
         return catalogItems;
     }
 
-    private void removeApplications(ManagedBundle mb) {
-        for (RegisteredType t: managementContext.getTypeRegistry().getMatching(RegisteredTypePredicates.containingBundle(mb.getVersionedName())))
{
-            // TODO support templates, and remove them here
-//            if (t.getKind() == RegisteredTypeKind.TEMPLATE) {
-//                ((BasicBrooklynTypeRegistry) managementContext.getTypeRegistry()).delete(t);
-//            }
-        }
-    }
-
     /**
      * Remove the given items from the catalog.
      *

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a9e770f3/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
index 9d6587c..98c962e 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
@@ -73,8 +73,6 @@ import org.slf4j.LoggerFactory;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterables;
@@ -371,39 +369,20 @@ public class OsgiManager {
         }
     }
 
-    @Beta
-    // TODO this is designed to work if the FEATURE_LOAD_BUNDLE_CATALOG_BOM is disabled,
the default, but unintuitive here
-    // it probably works even if that is true, but we should consider what to do;
-    // possibly remove that other capability, so that bundles with BOMs _have_ to be installed
via this method.
-    // (load order gets confusing with auto-scanning...)
-    public List<? extends CatalogItem<?,?>> loadCatalogBomLegacy(Bundle bundle)
{
-        return loadCatalogBomLegacy(bundle, false);
-    }
-    
-    @Beta  // as above
-    public List<? extends CatalogItem<?,?>> loadCatalogBomLegacy(Bundle bundle,
boolean force) {
-        return MutableList.copyOf(loadCatalogBomInternal(mgmt, bundle, force, true, true));
-    }
-    
     // since 0.12.0 no longer returns items; it installs non-persisted RegisteredTypes to
the type registry instead 
     @Beta
     public void loadCatalogBom(Bundle bundle, boolean force, boolean validate) {
-        loadCatalogBomInternal(mgmt, bundle, force, validate, false);
+        loadCatalogBomInternal(mgmt, bundle, force, validate);
     }
     
-    private static Iterable<? extends CatalogItem<?, ?>> loadCatalogBomInternal(ManagementContext
mgmt, Bundle bundle, boolean force, boolean validate, boolean legacy) {
+    private static Iterable<? extends CatalogItem<?, ?>> loadCatalogBomInternal(ManagementContext
mgmt, Bundle bundle, boolean force, boolean validate) {
         Iterable<? extends CatalogItem<?, ?>> catalogItems = MutableList.of();
 
         try {
-            final Predicate<Bundle> applicationsPermitted = Predicates.<Bundle>alwaysTrue();
-
-            CatalogBundleLoader cl = new CatalogBundleLoader(applicationsPermitted, mgmt);
-            if (legacy) {
-                catalogItems = cl.scanForCatalogLegacy(bundle, force);
-            } else {
-                cl.scanForCatalog(bundle, force, validate);
-                catalogItems = null;
-            }
+            CatalogBundleLoader cl = new CatalogBundleLoader(mgmt);
+            cl.scanForCatalog(bundle, force, validate);
+            catalogItems = null;
+            
         } catch (RuntimeException ex) {
             // TODO confirm -- as of May 2017 we no longer uninstall the bundle if install
of catalog items fails;
             // caller needs to upgrade, or uninstall then reinstall


Mime
View raw message