brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (BROOKLYN-49) Catalogue should be persisted and used when rebinding
Date Fri, 19 Sep 2014 14:42:33 GMT

    [ https://issues.apache.org/jira/browse/BROOKLYN-49?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14140662#comment-14140662
] 

ASF GitHub Bot commented on BROOKLYN-49:
----------------------------------------

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!


> Catalogue should be persisted and used when rebinding
> -----------------------------------------------------
>
>                 Key: BROOKLYN-49
>                 URL: https://issues.apache.org/jira/browse/BROOKLYN-49
>             Project: Brooklyn
>          Issue Type: Improvement
>            Reporter: Sam Corbett
>            Assignee: Sam Corbett
>
> Proposal:
> The catalogue, consisting of application templates, entities, policies and 'configuration'
(whose purpose is unknown to me and is unused in general), will be persisted to a `catalog`
directory alongside enrichers, entities, locations, nodes, plane and policies. Location definitions
(that are conceptually linked but are unrelated in code) will be stored too.
> Modes of operation:
> * If persistence if disabled load the default catalogue;
> * If persistence is enabled but there is no persisted catalogue (i.e. the server is running
for the first time) then load the default catalogue;
> * Otherwise load the persisted catalogue. Do _not_ load the default catalogue. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message