brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: BROOKLYN-49: Catalogue persistenc...
Date Fri, 19 Sep 2014 14:42:24 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/175#discussion_r17788280
  
    --- Diff: core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java ---
    @@ -103,26 +113,70 @@ public boolean blockIfNotLoaded(Duration timeout) {
         }
         
         public void reset(CatalogDto dto) {
    +        // Unregister all existing persisted items.
    +        for (CatalogItem toRemove : getCatalogItems()) {
    +            if (log.isTraceEnabled()) {
    +                log.trace("Scheduling item for persistence removal: {}", toRemove.getId());
    +            }
    +            mgmt.getRebindManager().getChangeListener().onUnmanaged(toRemove);
    +        }
             CatalogDo catalog = new CatalogDo(mgmt, dto);
             log.debug("Resetting "+this+" catalog to "+dto);
             catalog.load(mgmt, null);
             log.debug("Reloaded catalog for "+this+", now switching");
             this.catalog = catalog;
    +
    +        // Inject management context into and persist all the new entries.
    +        for (CatalogItem<?, ?> entry : getCatalogItems()) {
    +            boolean setManagementContext = false;
    +            if (entry instanceof CatalogItemDo) {
    +                CatalogItemDo cid = CatalogItemDo.class.cast(entry);
    +                if (cid.getDto() instanceof CatalogItemDtoAbstract) {
    +                    CatalogItemDtoAbstract cdto = CatalogItemDtoAbstract.class.cast(cid.getDto());
    +                    if (cdto.getManagementContext() == null) {
    +                        cdto.setManagementContext((ManagementContextInternal) mgmt);
    +                    }
    +                    setManagementContext = true;
    +                }
    +            }
    +            if (!setManagementContext) {
    +                log.warn("Can't set management context on entry with unexpected type
in catalog. type={}, " +
    --- End diff --
    
    Ah, this is effectively your else block! I should have read on in the code!


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