brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geomacy <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request: Support removal of catalog entries f...
Date Wed, 06 Apr 2016 15:44:56 GMT
Github user geomacy commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/100#discussion_r58729416
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogBomScanner.java
---
    @@ -100,54 +103,82 @@ public ManagementContext getManagementContext() {
                 return managementContext;
             }
     
    +        /**
    +         * Scans the bundle being added for a catalog.bom file and adds any entries in
it to the catalog.
    +         *
    +         * @param bundle The bundle being added to the bundle context.
    +         * @param bundleEvent The event of the addition.
    +         *
    +         * @return The items added to the catalog; these will be tracked by the {@link
BundleTracker} mechanism
    +         *         and supplied to the {@link #removedBundle(Bundle, BundleEvent, Iterable)}
method.
    +         */
             @Override
    -        public Long addingBundle(Bundle bundle, BundleEvent bundleEvent) {
    +        public Iterable<? extends CatalogItem<?, ?>> addingBundle(Bundle
bundle, BundleEvent bundleEvent) {
    +            return scanForCatalog(bundle);
    +        }
     
    -            final BundleContext bundleContext = FrameworkUtil.getBundle(CatalogBomScanner.class).getBundleContext();
    -            if (bundleContext == null) {
    -                LOG.info("Bundle context not yet established for bundle {} {} {}", bundleIds(bundle));
    -                return null;
    -            }
     
    -            scanForCatalog(bundle);
    +        @Override
    +        public void removedBundle(Bundle bundle, BundleEvent bundleEvent, Iterable<?
extends CatalogItem<?, ?>> items) {
    +            if (!items.iterator().hasNext()) {
    +                return;
    +            }
    +            LOG.debug("Unloading catalog BOM entries from {} {} {}", bundleIds(bundle));
    +            List<Exception> exceptions = MutableList.of();
    +            final BrooklynCatalog catalog = getManagementContext().getCatalog();
    +            for (CatalogItem<?, ?> item : items) {
    +                LOG.debug("Unloading {} {} from catalog", item.getSymbolicName(), item.getVersion());
    +
    +                try {
    +                    catalog.deleteCatalogItem(item.getSymbolicName(), item.getVersion());
    +                } catch (Exception e) {
    +                    LOG.warn("Caught {} unloading {} {} from catalog", new String []
{
    +                        e.getMessage(), item.getSymbolicName(), item.getVersion()
    +                    });
    +                    exceptions.add(e);
    +                }
    +            }
     
    -            return bundle.getBundleId();
    +            if (0 < exceptions.size()) {
    +                throw new CompoundRuntimeException(
    --- End diff --
    
    Hm, I guess I have been assuming that this will just result in a message being logged
by Karaf as opposed to it causing a failure - I will have to test that out.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message