Github user neykov commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/617#discussion_r30801647
  
    --- 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()) {
    --- End diff --
    
    After discussion - clarify "official" as being first master rebind OR (in 
non-rebind mode) the load triggered by CLI
    Then, feels like the cases should be
    ```
    if (catalog persistence enabled) {
      if (!hasBeenMaster) {
        if (reset || isEmpty) {
           don't use persistence catalog items
           init initial catalog
        }
        init add'tl catalog
      }
    } else {//catalog persistence disabled
      if (didn't initialize the catalog) {
           init initial catalog
           init add'tl catalog
      }
    }
    ```


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to