Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1D52C200CF3 for ; Wed, 19 Jul 2017 18:25:37 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1BE8216952A; Wed, 19 Jul 2017 16:25:37 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 47EC2169529 for ; Wed, 19 Jul 2017 18:25:36 +0200 (CEST) Received: (qmail 35547 invoked by uid 500); 19 Jul 2017 16:25:35 -0000 Mailing-List: contact commits-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list commits@brooklyn.apache.org Received: (qmail 35185 invoked by uid 99); 19 Jul 2017 16:25:34 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Jul 2017 16:25:34 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D87A3E5E44; Wed, 19 Jul 2017 16:25:32 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: geomacy@apache.org To: commits@brooklyn.apache.org Date: Wed, 19 Jul 2017 16:26:02 -0000 Message-Id: <28361aa5886840dfb7b011e3a94940c2@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [32/39] brooklyn-server git commit: remove more of the legacy bom-scanning support archived-at: Wed, 19 Jul 2017 16:25:37 -0000 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 Authored: Mon Jul 17 11:26:26 2017 +0100 Committer: Alex Heneveld 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 applicationsPermitted; private ManagementContext managementContext; - public CatalogBundleLoader(Predicate 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> 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> 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> loadCatalogBomLegacy(Bundle bundle) { - return loadCatalogBomLegacy(bundle, false); - } - - @Beta // as above - public List> 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> loadCatalogBomInternal(ManagementContext mgmt, Bundle bundle, boolean force, boolean validate, boolean legacy) { + private static Iterable> loadCatalogBomInternal(ManagementContext mgmt, Bundle bundle, boolean force, boolean validate) { Iterable> catalogItems = MutableList.of(); try { - final Predicate applicationsPermitted = Predicates.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