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:58:33 GMT

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

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_r17789160
  
    --- Diff: core/src/main/java/brooklyn/catalog/internal/CatalogDo.java ---
    @@ -185,42 +204,59 @@ CatalogDo loadCatalog(CatalogDto child) {
                 for (CatalogItemDtoAbstract<?,?> entry: entriesReversed)
                     cache.put(entry.getId(), new CatalogItemDo(this, entry));
             }
    -        
    +        Map<String, CatalogItemDo<?, ?>> typeNameCache = Maps.newHashMap();
    +        for (CatalogItemDo<?, ?> entry : cache.values()) {
    +            typeNameCache.put(entry.getRegisteredTypeName(), entry);
    +        }
             this.cache = cache;
    +        this.registeredTypeNameCache = typeNameCache;
             return cache;
         }
         
         protected synchronized void clearCache(boolean deep) {
             this.cache = null;
    -        if (deep) 
    -            for (CatalogDo child: childrenCatalogs) child.clearCache(true); 
    +        this.registeredTypeNameCache = null;
    +        if (deep) {
    +            for (CatalogDo child : childrenCatalogs) {
    +                child.clearCache(true);
    +            }
    +        }
         }
         
    -    /** adds the given entry to the catalog, with no enrichment;
    -     * callers may prefer {@link CatalogClasspathDo#addCatalogEntry(CatalogItemDtoAbstract,
Class)}
    +    /**
    +     * Adds the given entry to the catalog, with no enrichment.
    +     * Callers may prefer {@link CatalogClasspathDo#addCatalogEntry(CatalogItemDtoAbstract,
Class)}
          */
         @SuppressWarnings({ "unchecked", "rawtypes" })
         public synchronized void addEntry(CatalogItemDtoAbstract<?,?> entry) {
             if (dto.entries==null) 
                 dto.entries = new ArrayList<CatalogItemDtoAbstract<?,?>>();
             dto.entries.add(entry);
    -        if (cache!=null)
    -            cache.put(entry.getId(), new CatalogItemDo(this, entry));
    -    }
    +        if (cache!=null) {
    +            CatalogItemDo<?, ?> cdo = new CatalogItemDo(this, entry);
    +            cache.put(entry.getId(), cdo);
    +            registeredTypeNameCache.put(entry.getRegisteredTypeName(), cdo);
    +        }
    +        if (mgmt != null) {
    +            mgmt.getRebindManager().getChangeListener().onManaged(entry);
    +        }
    +   }
     
    +    /**
    +     * Removes the given entry from the catalog.
    +     */
         public synchronized void deleteEntry(CatalogItemDtoAbstract<?, ?> entry) {
             if (dto.entries != null)
                 dto.entries.remove(entry);
    -        if (cache!=null)
    -            cache.remove(entry.getId());
    -    }
    -
    -    /** removes the given entry from the catalog;
    -     */
    -    public synchronized void removeEntry(CatalogItemDtoAbstract<?,?> entry) {
    -        dto.entries.remove(entry);
    -        if (cache!=null)
    +        if (cache!=null) {
                 cache.remove(entry.getId());
    +            registeredTypeNameCache.remove(entry.getRegisteredTypeName());
    +        }
    +        if (mgmt != null) {
    +            // Can the entry be in more than one catalogue? The management context has
no notion of
    --- End diff --
    
    Include a `TODO` at the start of this comment.
    The original `catalog.xml` (and catalog structure) allowed for nesting of catalogs. I
don't think anyone has ever used that. We should probably simplify the code until requirements
for that kind of thing become apparent. 


> 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