brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahgittin <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: CLI commands for manipulating cat...
Date Mon, 25 May 2015 10:44:38 GMT
Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/617#discussion_r30973941
  
    --- Diff: core/src/main/java/brooklyn/entity/rebind/RebindIteration.java ---
    @@ -341,38 +340,64 @@ protected void rebuildCatalog() {
                     }
                 }
             }
    +
    +        // See notes in CatalogInitialization
             
    -        // Register catalogue items with the management context. Loads the bundles in
the OSGi framework.
    -        CatalogLoadMode catalogLoadMode = managementContext.getConfig().getConfig(BrooklynServerConfig.CATALOG_LOAD_MODE);
    +        Collection<CatalogItem<?, ?>> catalogItems = rebindContext.getCatalogItems();
    +        CatalogInitialization catInit = ((ManagementContextInternal)managementContext).getCatalogInitialization();
    +        catInit.applyCatalogLoadMode();
    +        Collection<CatalogItem<?,?>> itemsForResettingCatalog = null;
    +        boolean needsInitialCatalog;
             if (rebindManager.persistCatalogItemsEnabled) {
    -            boolean shouldResetCatalog = catalogLoadMode == CatalogLoadMode.LOAD_PERSISTED_STATE
    -                    || (!isEmpty && catalogLoadMode == CatalogLoadMode.LOAD_BROOKLYN_CATALOG_URL_IF_NO_PERSISTED_STATE);
    -            boolean shouldLoadDefaultCatalog = catalogLoadMode == CatalogLoadMode.LOAD_BROOKLYN_CATALOG_URL
    -                    || (isEmpty && catalogLoadMode == CatalogLoadMode.LOAD_BROOKLYN_CATALOG_URL_IF_NO_PERSISTED_STATE);
    -            if (shouldResetCatalog) {
    -                // Reset catalog with previously persisted state
    -                logRebindingDebug("RebindManager resetting management context catalog
to previously persisted state");
    -                managementContext.getCatalog().reset(rebindContext.getCatalogItems());
    -            } else if (shouldLoadDefaultCatalog) {
    -                // Load catalogue as normal
    -                // TODO in read-only mode, should do this less frequently than entities
etc
    -                logRebindingDebug("RebindManager loading default catalog");
    -                ((BasicBrooklynCatalog) managementContext.getCatalog()).resetCatalogToContentsAtConfiguredUrl();
    +            if (!catInit.hasRunOfficial() && catInit.isInitialResetRequested())
{
    +                String message = "RebindManager resetting catalog on first run (catalog
persistence enabled, but reset explicitly specified). ";
    +                if (catalogItems.isEmpty()) {
    +                    message += "Catalog was empty anyway.";
    +                } else {
    +                    message += "Deleting "+catalogItems.size()+" persisted catalog item"+Strings.s(catalogItems)+":
"+catalogItems;
    +                    if (shouldLogRebinding()) {
    +                        LOG.info(message);
    +                    }
    +                }
    +                logRebindingDebug(message);
    +
    +                itemsForResettingCatalog = MutableList.<CatalogItem<?,?>>of();
    --- End diff --
    
    agree with your synopsis. have added comments:
    
                    // we will have unnecessarily tried to load the catalog item manifests
earlier in this iteration,
                    // and problems there could fail a rebind even when we are resetting;
                    // it might be cleaner to check earlier whether a reset is happening and
not load those items at all,
                    // but that would be a significant new code path (to remove a directory
in the persistent store, essentially),
                    // and as it stands we don't do much with those manifests (e.g. we won't
register them or fail on missing types)
                    // so we think it's only really corrupted XML or CatalogItem schema changes
which would cause such problems.
                    // in extremis someone might need to wipe their store but for most purposes
i don't think there will be any issue
                    // with loading the catalog item manifests before wiping all those files.



---
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