brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [11/12] This closes 108.
Date Thu, 25 Sep 2014 22:49:35 GMT
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/fbd4e309/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
index a931229..0b95e47 100644
--- a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
+++ b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
@@ -122,11 +122,8 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
         objectStore.createSubPath("locations");
         objectStore.createSubPath("policies");
         objectStore.createSubPath("enrichers");
-<<<<<<< HEAD
-        objectStore.createSubPath("catalog");
-=======
         objectStore.createSubPath("feeds");
->>>>>>> apache-gh/pr/108
+        objectStore.createSubPath("catalog");
 
         // FIXME does it belong here or to ManagementPlaneSyncRecordPersisterToObjectStore
?
         objectStore.createSubPath("plane");
@@ -192,6 +189,9 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
                     case ENRICHER:
                         builder.enricher((String) XmlUtil.xpath(contents, "/enricher/id"),
contents);
                         break;
+                    case FEED:
+                        builder.feed((String) XmlUtil.xpath(contents, "/feed/id"), contents);
+                        break;
                     case CATALOG_ITEM:
                         builder.catalogItem((String) XmlUtil.xpath(contents, "/catalogItem/id"),
contents);
                         break;
@@ -208,9 +208,10 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
         BrooklynMementoRawData result = builder.build();
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Loaded memento manifest; took {}; {} entities, {} locations, {} policies,
{} enrichers, from {}", new Object[]{
+            LOG.debug("Loaded memento manifest; took {}; {} entities, {} locations, {} policies,
{} enrichers, {} feeds, {} catalog items, from {}", new Object[]{
                      Time.makeTimeStringRounded(stopwatch.elapsed(TimeUnit.MILLISECONDS)),
result.getEntities().size(), 
                      result.getLocations().size(), result.getPolicies().size(), result.getEnrichers().size(),
+                     result.getFeeds().size(), result.getCatalogItems().size(),
                      objectStore.getSummaryName() });
         }
 
@@ -245,6 +246,11 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
                         objType = (String) XmlUtil.xpath(contents, "/enricher/type");
                         builder.enricher(id, objType);
                         break;
+                    case FEED:
+                        id = (String) XmlUtil.xpath(contents, "/feed/id");
+                        objType = (String) XmlUtil.xpath(contents, "/feed/type");
+                        builder.feed(id, objType);
+                        break;
                     case CATALOG_ITEM:
                         id = (String) XmlUtil.xpath(contents, "/catalogItem/id");
                         objType = (String) XmlUtil.xpath(contents, "/catalogItem/type");
@@ -263,9 +269,10 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
         BrooklynMementoManifest result = builder.build();
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Loaded memento manifest; took {}; {} entities, {} locations, {} policies,
{} enrichers, {} catalog items, from {}", new Object[]{
+            LOG.debug("Loaded memento manifest; took {}; {} entities, {} locations, {} policies,
{} enrichers, {} feeds, {} catalog items, from {}", new Object[]{
                      Time.makeTimeStringRounded(stopwatch.elapsed(TimeUnit.MILLISECONDS)),
result.getEntityIdToType().size(), 
-                     result.getLocationIdToType().size(), result.getPolicyIdToType().size(),
result.getEnricherIdToType().size(), result.getCatalogItemIdToType().size(),
+                     result.getLocationIdToType().size(), result.getPolicyIdToType().size(),
result.getEnricherIdToType().size(), 
+                     result.getFeedIdToType().size(), result.getCatalogItemIdToType().size(),
                      objectStore.getSummaryName() });
         }
 
@@ -304,9 +311,10 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
         BrooklynMemento result = builder.build();
         
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Loaded memento; took {}; {} entities, {} locations, {} policies, {}
enrichers, {} catalog items, from {}", new Object[]{
+            LOG.debug("Loaded memento; took {}; {} entities, {} locations, {} policies, {}
enrichers, {} feeds, {} catalog items, from {}", new Object[]{
                       Time.makeTimeStringRounded(stopwatch.elapsed(TimeUnit.MILLISECONDS)),
result.getEntityIds().size(), 
-                      result.getLocationIds().size(), result.getPolicyIds().size(), result.getEnricherIds().size(),
result.getCatalogItemIds().size(),
+                      result.getLocationIds().size(), result.getPolicyIds().size(), result.getEnricherIds().size(),

+                      result.getFeedIds().size(), result.getCatalogItemIds().size(),
                       objectStore.getSummaryName() });
         }
         
@@ -325,38 +333,26 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
         List<String> locationSubPathList;
         List<String> policySubPathList;
         List<String> enricherSubPathList;
-<<<<<<< HEAD
-        List<String> catalogSubPathList;
-=======
         List<String> feedSubPathList;
->>>>>>> apache-gh/pr/108
+        List<String> catalogSubPathList;
+        
         try {
             entitySubPathList = objectStore.listContentsWithSubPath("entities");
             locationSubPathList = objectStore.listContentsWithSubPath("locations");
             policySubPathList = objectStore.listContentsWithSubPath("policies");
             enricherSubPathList = objectStore.listContentsWithSubPath("enrichers");
-<<<<<<< HEAD
-            catalogSubPathList = objectStore.listContentsWithSubPath("catalog");
-=======
             feedSubPathList = objectStore.listContentsWithSubPath("feeds");
->>>>>>> apache-gh/pr/108
+            catalogSubPathList = objectStore.listContentsWithSubPath("catalog");
         } catch (Exception e) {
             Exceptions.propagateIfFatal(e);
             exceptionHandler.onLoadMementoFailed(BrooklynObjectType.UNKNOWN, "Failed to list
files", e);
             throw new IllegalStateException("Failed to list memento files in "+objectStore,
e);
         }
 
-<<<<<<< HEAD
-        LOG.debug("Scanning persisted state: {} entities, {} locations, {} policies, {} enrichers,
{} catalog items from {}", new Object[]{
-            entitySubPathList.size(), locationSubPathList.size(), policySubPathList.size(),
enricherSubPathList.size(), catalogSubPathList.size(),
+        LOG.debug("Scanning persisted state: {} entities, {} locations, {} policies, {} enrichers,
{} feeds, {} catalog items from {}", new Object[]{
+            entitySubPathList.size(), locationSubPathList.size(), policySubPathList.size(),
enricherSubPathList.size(), 
+            feedSubPathList.size(), catalogSubPathList.size(),
             objectStore.getSummaryName() });
-=======
-        Stopwatch stopwatch = Stopwatch.createStarted();
-
-        LOG.debug("Scanning persisted state: {} entities, {} locations, {} policies, {} enrichers,
{} feeds from {}", new Object[]{
-            entitySubPathList.size(), locationSubPathList.size(), policySubPathList.size(),
enricherSubPathList.size(),
-            feedSubPathList.size(), objectStore.getSummaryName() });
->>>>>>> apache-gh/pr/108
 
         List<ListenableFuture<?>> futures = Lists.newArrayList();
         
@@ -390,28 +386,13 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
         for (final String subPath : enricherSubPathList) {
             futures.add(executor.submit(new VisitorWrapper(subPath, BrooklynObjectType.ENRICHER)));
         }
-<<<<<<< HEAD
+        for (final String subPath : feedSubPathList) {
+            futures.add(executor.submit(new VisitorWrapper(subPath, BrooklynObjectType.FEED)));
+        }
         for (final String subPath : catalogSubPathList) {
             futures.add(executor.submit(new VisitorWrapper(subPath, BrooklynObjectType.CATALOG_ITEM)));
         }
 
-=======
-        for (final String subPath : feedSubPathList) {
-            futures.add(executor.submit(new Runnable() {
-                public void run() {
-                    try {
-                        String contents = read(subPath);
-                        String id = (String) XmlUtil.xpath(contents, "/feed/id");
-                        String type = (String) XmlUtil.xpath(contents, "/feed/type");
-                        builder.feed(id, type);
-                    } catch (Exception e) {
-                        Exceptions.propagateIfFatal(e);
-                        exceptionHandler.onLoadMementoFailed(BrooklynObjectType.FEED, "Memento
"+subPath, e);
-                    }
-                }}));
-        }
->>>>>>> apache-gh/pr/108
-
         try {
             // Wait for all, failing fast if any exceptions.
             Futures.allAsList(futures).get();
@@ -440,24 +421,6 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
                 throw new CompoundRuntimeException("Problem loading mementos", exceptions);
             }
         }
-<<<<<<< HEAD
-=======
-
-        BrooklynMementoManifest result = builder.build();
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Loaded memento manifest; took {}; {} entities, {} locations, {} policies,
{} enrichers, {} feeds, from {}", new Object[]{
-                     Time.makeTimeStringRounded(stopwatch.elapsed(TimeUnit.MILLISECONDS)),
result.getEntityIdToType().size(), 
-                     result.getLocationIdToType().size(), result.getPolicyIdToType().size(),
result.getEnricherIdToType().size(),
-                     result.getFeedIdToType().size(), objectStore.getSummaryName() });
-        }
-
-        if (result.getEntityIdToType().size() != entitySubPathList.size()) {
-            LOG.error("Lost an entity?!");
-        }
-        
-        return result;
->>>>>>> apache-gh/pr/108
     }
 
     @Beta
@@ -466,7 +429,6 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
             if (LOG.isDebugEnabled()) LOG.debug("Ignoring checkpointing entire memento, because
not running");
             return;
         }
-<<<<<<< HEAD
         
         try {
             lock.writeLock().lockInterruptibly();
@@ -474,57 +436,6 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
             throw Exceptions.propagate(e);
         }
         
-=======
-        Stopwatch stopwatch = Stopwatch.createStarted();
-
-        List<String> entitySubPathList;
-        List<String> locationSubPathList;
-        List<String> policySubPathList;
-        List<String> enricherSubPathList;
-        List<String> feedSubPathList;
-        try {
-            entitySubPathList = objectStore.listContentsWithSubPath("entities");
-            locationSubPathList = objectStore.listContentsWithSubPath("locations");
-            policySubPathList = objectStore.listContentsWithSubPath("policies");
-            enricherSubPathList = objectStore.listContentsWithSubPath("enrichers");
-            feedSubPathList = objectStore.listContentsWithSubPath("feeds");
-        } catch (Exception e) {
-            Exceptions.propagateIfFatal(e);
-            exceptionHandler.onLoadMementoFailed(BrooklynObjectType.UNKNOWN, "Failed to list
files", e);
-            throw new IllegalStateException("Failed to list memento files in "+objectStore+":
"+e, e);
-        }
-        
-        LOG.debug("Loading persisted state: {} entities, {} locations, {} policies, {} enrichers,
{} feeds, from {}", new Object[]{
-            entitySubPathList.size(), locationSubPathList.size(), policySubPathList.size(),
enricherSubPathList.size(),
-            feedSubPathList.size(), objectStore.getSummaryName() });
-
-        final BrooklynMementoImpl.Builder builder = BrooklynMementoImpl.builder();
-        serializer.setLookupContext(lookupContext);
-        
-        List<ListenableFuture<?>> futures = Lists.newArrayList();
-
-        class MementoLoader implements Runnable {
-            private final String subPath;
-            private final BrooklynObjectType type;
-            public MementoLoader(String subPath, BrooklynObjectType type) {
-                this.subPath = subPath;
-                this.type = type;
-            }
-            public void run() {
-                try {
-                    Memento memento = (Memento) serializer.fromString(read(subPath));
-                    if (memento == null) {
-                        LOG.warn("No "+type.toString().toLowerCase()+"-memento deserialized
from " + subPath + "; ignoring and continuing");
-                    } else {
-                        builder.memento(memento);
-                    }
-                } catch (Exception e) {
-                    exceptionHandler.onLoadMementoFailed(type, "Memento "+subPath, e);
-                }
-            }
-        }
-
->>>>>>> apache-gh/pr/108
         try {
             objectStore.prepareForMasterUse();
             
@@ -543,17 +454,13 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
             for (Map.Entry<String, String> entry : newMemento.getEnrichers().entrySet())
{
                 futures.add(asyncPersist("enrichers", BrooklynObjectType.ENRICHER, entry.getKey(),
entry.getValue(), exceptionHandler));
             }
-<<<<<<< HEAD
+            for (Map.Entry<String, String> entry : newMemento.getFeeds().entrySet())
{
+                futures.add(asyncPersist("feeds", BrooklynObjectType.FEED, entry.getKey(),
entry.getValue(), exceptionHandler));
+            }
             for (Map.Entry<String, String> entry : newMemento.getCatalogItems().entrySet())
{
                 futures.add(asyncPersist("catalog", BrooklynObjectType.CATALOG_ITEM, entry.getKey(),
entry.getValue(), exceptionHandler));
             }
-
-=======
-            for (final String subPath : feedSubPathList) {
-                futures.add(executor.submit(new MementoLoader(subPath, BrooklynObjectType.FEED)));
-            }
             
->>>>>>> apache-gh/pr/108
             try {
                 // Wait for all the tasks to complete or fail, rather than aborting on the
first failure.
                 // But then propagate failure if any fail. (hence the two calls).
@@ -566,20 +473,7 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
             
             if (LOG.isDebugEnabled()) LOG.debug("Checkpointed entire memento in {}", Time.makeTimeStringRounded(stopwatch));
         } finally {
-<<<<<<< HEAD
             lock.writeLock().unlock();
-=======
-            serializer.unsetLookupContext();
-        }
-
-        BrooklynMemento result = builder.build();
-        
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Loaded memento; took {}; {} entities, {} locations, {} policies, {}
enrichers, {} feeds, from {}", new Object[]{
-                      Time.makeTimeStringRounded(stopwatch.elapsed(TimeUnit.MILLISECONDS)),
result.getEntityIds().size(), 
-                      result.getLocationIds().size(), result.getPolicyIds().size(), result.getEnricherIds().size(),
-                      result.getFeedIds().size(), objectStore.getSummaryName() });
->>>>>>> apache-gh/pr/108
         }
     }
 
@@ -596,11 +490,8 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
                 .locations(newMemento.getLocationMementos().values())
                 .policies(newMemento.getPolicyMementos().values())
                 .enrichers(newMemento.getEnricherMementos().values())
-<<<<<<< HEAD
-                .catalogItems(newMemento.getCatalogItemMementos().values())
-=======
                 .feeds(newMemento.getFeedMementos().values())
->>>>>>> apache-gh/pr/108
+                .catalogItems(newMemento.getCatalogItemMementos().values())
                 .build();
         Stopwatch stopwatch = deltaImpl(delta, exceptionHandler);
         
@@ -655,17 +546,13 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
             for (EnricherMemento enricher : delta.enrichers()) {
                 futures.add(asyncPersist("enrichers", enricher, exceptionHandler));
             }
-<<<<<<< HEAD
-            for (CatalogItemMemento catalogItem : delta.catalogItems()) {
-                futures.add(asyncPersist("catalog", catalogItem, exceptionHandler));
-            }
-
-=======
             for (FeedMemento feed : delta.feeds()) {
                 futures.add(asyncPersist("feeds", feed, exceptionHandler));
             }
+            for (CatalogItemMemento catalogItem : delta.catalogItems()) {
+                futures.add(asyncPersist("catalog", catalogItem, exceptionHandler));
+            }
             
->>>>>>> apache-gh/pr/108
             for (String id : delta.removedEntityIds()) {
                 futures.add(asyncDelete("entities", id, exceptionHandler));
             }
@@ -678,13 +565,11 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
             for (String id : delta.removedEnricherIds()) {
                 futures.add(asyncDelete("enrichers", id, exceptionHandler));
             }
-<<<<<<< HEAD
-            for (String id : delta.removedCatalogItemIds()) {
-                futures.add(asyncDelete("catalog", id, exceptionHandler));
-=======
             for (String id : delta.removedFeedIds()) {
                 futures.add(asyncDelete("feeds", id, exceptionHandler));
->>>>>>> apache-gh/pr/108
+            }
+            for (String id : delta.removedCatalogItemIds()) {
+                futures.add(asyncDelete("catalog", id, exceptionHandler));
             }
             
             try {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/fbd4e309/core/src/main/java/brooklyn/entity/rebind/persister/XmlMementoSerializer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/persister/XmlMementoSerializer.java
b/core/src/main/java/brooklyn/entity/rebind/persister/XmlMementoSerializer.java
index 0969886..881f101 100644
--- a/core/src/main/java/brooklyn/entity/rebind/persister/XmlMementoSerializer.java
+++ b/core/src/main/java/brooklyn/entity/rebind/persister/XmlMementoSerializer.java
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
 import brooklyn.catalog.CatalogItem;
 import brooklyn.entity.Effector;
 import brooklyn.entity.Entity;
+import brooklyn.entity.Feed;
 import brooklyn.entity.basic.BasicParameterType;
 import brooklyn.entity.effector.EffectorAndBody;
 import brooklyn.entity.effector.EffectorTasks.EffectorBodyTaskFactory;
@@ -78,7 +79,7 @@ public class XmlMementoSerializer<T> extends XmlSerializer<T>
implements Memento
     public XmlMementoSerializer(ClassLoader classLoader) {
         this.classLoader = checkNotNull(classLoader, "classLoader");
         
-        // old (deprecated in 070? or earlier) single-file persistence uses this keyword;
TODO remove soon
+        // old (deprecated in 070? or earlier) single-file persistence uses this keyword;
TODO remove soon in 080 ?
         xstream.alias("brooklyn", MutableBrooklynMemento.class);
         
         xstream.alias("entity", BasicEntityMemento.class);
@@ -103,6 +104,7 @@ public class XmlMementoSerializer<T> extends XmlSerializer<T>
implements Memento
         xstream.registerConverter(new PolicyConverter());
         xstream.registerConverter(new EnricherConverter());
         xstream.registerConverter(new EntityConverter());
+        xstream.registerConverter(new FeedConverter());
         xstream.registerConverter(new CatalogItemConverter());
 
         xstream.registerConverter(new ManagementContextConverter());
@@ -235,6 +237,16 @@ public class XmlMementoSerializer<T> extends XmlSerializer<T>
implements Memento
         }
     }
     
+    public class FeedConverter extends IdentifiableConverter<Feed> {
+        FeedConverter() {
+            super(Feed.class);
+        }
+        @Override
+        protected Feed lookup(String id) {
+            return lookupContext.lookupFeed(id);
+        }
+    }
+    
     public class EntityConverter extends IdentifiableConverter<Entity> {
         EntityConverter() {
             super(Entity.class);
@@ -245,12 +257,13 @@ public class XmlMementoSerializer<T> extends XmlSerializer<T>
implements Memento
         }
     }
 
+    @SuppressWarnings("rawtypes")
     public class CatalogItemConverter extends IdentifiableConverter<CatalogItem> {
         CatalogItemConverter() {
             super(CatalogItem.class);
         }
         @Override
-        protected CatalogItem lookup(String id) {
+        protected CatalogItem<?,?> lookup(String id) {
             return lookupContext.lookupCatalogItem(id);
         }
     }
@@ -267,6 +280,7 @@ public class XmlMementoSerializer<T> extends XmlSerializer<T>
implements Memento
         public boolean canConvert(@SuppressWarnings("rawtypes") Class type) {
             return Task.class.isAssignableFrom(type);
         }
+        @SuppressWarnings("deprecation")
         @Override
         public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext
context) {
             if (source == null) return;
@@ -312,15 +326,7 @@ public class XmlMementoSerializer<T> extends XmlSerializer<T>
implements Memento
         }
         @Override
         public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext
context) {
-            // we write nothing, and always insert the current mgmt context
-            
-            // if we want to explore this further, see #1422; but in short, mgmt is a common
part of DSL resolution
-//            if (!loggedMgmtContextWarning) {
-//                LOG.warn("Intercepting request to serialize management context"
-//                    + (context instanceof ReferencingMarshallingContext ? " at "+((ReferencingMarshallingContext)context).currentPath()
: "")+
-//                    " (only logging this once): "+source);
-//                loggedMgmtContextWarning = true;
-//            }
+            // write nothing, and always insert the current mgmt context
         }
         @Override
         public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
{

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/fbd4e309/core/src/main/java/brooklyn/entity/rebind/transformer/CompoundTransformer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/transformer/CompoundTransformer.java
b/core/src/main/java/brooklyn/entity/rebind/transformer/CompoundTransformer.java
index f146162..eb7e289 100644
--- a/core/src/main/java/brooklyn/entity/rebind/transformer/CompoundTransformer.java
+++ b/core/src/main/java/brooklyn/entity/rebind/transformer/CompoundTransformer.java
@@ -130,6 +130,7 @@ public class CompoundTransformer {
         Map<String, String> locations = MutableMap.copyOf(rawData.getLocations());
         Map<String, String> policies = MutableMap.copyOf(rawData.getPolicies());
         Map<String, String> enrichers = MutableMap.copyOf(rawData.getEnrichers());
+        Map<String, String> feeds = MutableMap.copyOf(rawData.getFeeds());
         Map<String, String> catalogItems = MutableMap.copyOf(rawData.getCatalogItems());
 
         // TODO @neykov asks whether transformers should be run in registration order,
@@ -160,6 +161,11 @@ public class CompoundTransformer {
                             entry.setValue(transformer.transform(entry.getValue()));
                         }
                         break;
+                    case FEED:
+                        for (Map.Entry<String, String> entry : feeds.entrySet()) {
+                            entry.setValue(transformer.transform(entry.getValue()));
+                        }
+                        break;
                     case CATALOG_ITEM:
                         for (Map.Entry<String, String> entry : catalogItems.entrySet())
{
                             entry.setValue(transformer.transform(entry.getValue()));
@@ -178,6 +184,8 @@ public class CompoundTransformer {
                 .locations(locations)
                 .policies(policies)
                 .enrichers(enrichers)
+                .feeds(feeds)
+                .catalogItems(catalogItems)
                 .build();
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/fbd4e309/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java b/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
index 002f13a..d5ec2ba 100644
--- a/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
+++ b/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
@@ -40,15 +40,11 @@ public class BrooklynFeatureEnablement {
     public static final String FEATURE_POLICY_PERSISTENCE_PROPERTY = "brooklyn.experimental.feature.policyPersistence";
     
     public static final String FEATURE_ENRICHER_PERSISTENCE_PROPERTY = "brooklyn.experimental.feature.enricherPersistence";
-<<<<<<< HEAD
+
+    public static final String FEATURE_FEED_PERSISTENCE_PROPERTY = "brooklyn.experimental.feature.feedPersistence";
 
     public static final String FEATURE_CATALOG_PERSISTENCE_PROPERTY = "brooklyn.experimental.feature.catalogPersistence";
 
-=======
-    
-    public static final String FEATURE_FEED_PERSISTENCE_PROPERTY = "brooklyn.experimental.feature.feedPersistence";
-    
->>>>>>> apache-gh/pr/108
     private static final Map<String, Boolean> FEATURE_ENABLEMENTS = Maps.newLinkedHashMap();
 
     private static final Object MUTEX = new Object();
@@ -60,11 +56,8 @@ public class BrooklynFeatureEnablement {
         
         setDefault(FEATURE_POLICY_PERSISTENCE_PROPERTY, true);
         setDefault(FEATURE_ENRICHER_PERSISTENCE_PROPERTY, true);
-<<<<<<< HEAD
-        setDefault(FEATURE_CATALOG_PERSISTENCE_PROPERTY, true);
-=======
         setDefault(FEATURE_FEED_PERSISTENCE_PROPERTY, true);
->>>>>>> apache-gh/pr/108
+        setDefault(FEATURE_CATALOG_PERSISTENCE_PROPERTY, true);
     }
     
     static {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/fbd4e309/core/src/test/java/brooklyn/entity/rebind/persister/XmlMementoSerializerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/persister/XmlMementoSerializerTest.java
b/core/src/test/java/brooklyn/entity/rebind/persister/XmlMementoSerializerTest.java
index 2f2ee4c..ebcd0e3 100644
--- a/core/src/test/java/brooklyn/entity/rebind/persister/XmlMementoSerializerTest.java
+++ b/core/src/test/java/brooklyn/entity/rebind/persister/XmlMementoSerializerTest.java
@@ -37,6 +37,7 @@ import brooklyn.catalog.CatalogItem;
 import brooklyn.catalog.internal.CatalogItemBuilder;
 import brooklyn.catalog.internal.CatalogLibrariesDto;
 import brooklyn.entity.Entity;
+import brooklyn.entity.Feed;
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.location.Location;
@@ -132,7 +133,7 @@ public class XmlMementoSerializerTest {
         try {
             serializer.setLookupContext(new LookupContextImpl(managementContext,
                     ImmutableList.of(app), ImmutableList.<Location>of(), ImmutableList.<Policy>of(),
-                    ImmutableList.<Enricher>of(), ImmutableList.<CatalogItem<?,
?>>of(), true));
+                    ImmutableList.<Enricher>of(), ImmutableList.<Feed>of(), ImmutableList.<CatalogItem<?,
?>>of(), true));
             assertSerializeAndDeserialize(app);
         } finally {
             Entities.destroyAll(managementContext);
@@ -148,7 +149,7 @@ public class XmlMementoSerializerTest {
             final Location loc = managementContext.getLocationManager().createLocation(LocationSpec.create(brooklyn.location.basic.SimulatedLocation.class));
             serializer.setLookupContext(new LookupContextImpl(managementContext,
                     ImmutableList.<Entity>of(), ImmutableList.of(loc), ImmutableList.<Policy>of(),
-                    ImmutableList.<Enricher>of(), ImmutableList.<CatalogItem<?,
?>>of(), true));
+                    ImmutableList.<Enricher>of(), ImmutableList.<Feed>of(), ImmutableList.<CatalogItem<?,
?>>of(), true));
             assertSerializeAndDeserialize(loc);
         } finally {
             Entities.destroyAll(managementContext);
@@ -161,7 +162,7 @@ public class XmlMementoSerializerTest {
         ManagementContext managementContext = app.getManagementContext();
         try {
             CatalogItem<?, ?> catalogItem = CatalogItemBuilder.newEntity("registeredtypename")
-                    .name("test catalog item")
+                    .displayName("test catalog item")
                     .description("description")
                     .plan("yaml plan")
                     .iconUrl("iconUrl")
@@ -169,7 +170,7 @@ public class XmlMementoSerializerTest {
                     .build();
             serializer.setLookupContext(new LookupContextImpl(managementContext,
                     ImmutableList.<Entity>of(), ImmutableList.<Location>of(),
ImmutableList.<Policy>of(),
-                    ImmutableList.<Enricher>of(), ImmutableList.of(catalogItem), true));
+                    ImmutableList.<Enricher>of(), ImmutableList.<Feed>of(), ImmutableList.of(catalogItem),
true));
             assertSerializeAndDeserialize(catalogItem);
         } finally {
             Entities.destroyAll(managementContext);
@@ -187,7 +188,7 @@ public class XmlMementoSerializerTest {
         try {
             serializer.setLookupContext(new LookupContextImpl(managementContext,
                     ImmutableList.of(app), ImmutableList.<Location>of(), ImmutableList.<Policy>of(),
-                    ImmutableList.<Enricher>of(), ImmutableList.<CatalogItem<?,
?>>of(), false));
+                    ImmutableList.<Enricher>of(), ImmutableList.<Feed>of(), ImmutableList.<CatalogItem<?,
?>>of(), false));
             
             List<?> resultList = serializeAndDeserialize(ImmutableList.of(app, entity));
             assertEquals(resultList, ImmutableList.of(app));
@@ -211,7 +212,7 @@ public class XmlMementoSerializerTest {
         try {
             serializer.setLookupContext(new LookupContextImpl(managementContext,
                     ImmutableList.of(app), ImmutableList.<Location>of(), ImmutableList.<Policy>of(),
-                    ImmutableList.<Enricher>of(), ImmutableList.<CatalogItem<?,
?>>of(), true));
+                    ImmutableList.<Enricher>of(), ImmutableList.<Feed>of(), ImmutableList.<CatalogItem<?,
?>>of(), true));
             ReffingEntity reffer2 = assertSerializeAndDeserialize(reffer);
             assertEquals(reffer2.entity, app);
         } finally {
@@ -227,7 +228,7 @@ public class XmlMementoSerializerTest {
         try {
             serializer.setLookupContext(new LookupContextImpl(managementContext,
                     ImmutableList.of(app), ImmutableList.<Location>of(), ImmutableList.<Policy>of(),
-                    ImmutableList.<Enricher>of(), ImmutableList.<CatalogItem<?,
?>>of(), true));
+                    ImmutableList.<Enricher>of(), ImmutableList.<Feed>of(), ImmutableList.<CatalogItem<?,
?>>of(), true));
             ReffingEntity reffer2 = assertSerializeAndDeserialize(reffer);
             assertEquals(reffer2.obj, app);
         } finally {
@@ -276,33 +277,37 @@ public class XmlMementoSerializerTest {
         private final Map<String, Location> locations;
         private final Map<String, Policy> policies;
         private final Map<String, Enricher> enrichers;
+        private final Map<String, Feed> feeds;
         private final Map<String, CatalogItem<?, ?>> catalogItems;
         private final boolean failOnDangling;
 
         LookupContextImpl(ManagementContext mgmt, Iterable<? extends Entity> entities,
Iterable<? extends Location> locations,
-                Iterable<? extends Policy> policies, Iterable<? extends Enricher>
enrichers,
+                Iterable<? extends Policy> policies, Iterable<? extends Enricher>
enrichers, Iterable<? extends Feed> feeds,
                 Iterable<? extends CatalogItem<?, ?>> catalogItems, boolean failOnDangling)
{
             this.mgmt = mgmt;
             this.entities = Maps.newLinkedHashMap();
             this.locations = Maps.newLinkedHashMap();
             this.policies = Maps.newLinkedHashMap();
             this.enrichers = Maps.newLinkedHashMap();
+            this.feeds = Maps.newLinkedHashMap();
             this.catalogItems = Maps.newLinkedHashMap();
             for (Entity entity : entities) this.entities.put(entity.getId(), entity);
             for (Location location : locations) this.locations.put(location.getId(), location);
             for (Policy policy : policies) this.policies.put(policy.getId(), policy);
             for (Enricher enricher : enrichers) this.enrichers.put(enricher.getId(), enricher);
+            for (Feed feed : feeds) this.feeds.put(feed.getId(), feed);
             for (CatalogItem<?, ?> catalogItem : catalogItems) this.catalogItems.put(catalogItem.getId(),
catalogItem);
             this.failOnDangling = failOnDangling;
         }
         LookupContextImpl(ManagementContext mgmt, Map<String,? extends Entity> entities,
Map<String,? extends Location> locations,
-                Map<String,? extends Policy> policies, Map<String,? extends Enricher>
enrichers,
+                Map<String,? extends Policy> policies, Map<String,? extends Enricher>
enrichers, Map<String,? extends Feed> feeds,
                 Map<String, ? extends CatalogItem<?, ?>> catalogItems, boolean
failOnDangling) {
             this.mgmt = mgmt;
             this.entities = ImmutableMap.copyOf(entities);
             this.locations = ImmutableMap.copyOf(locations);
             this.policies = ImmutableMap.copyOf(policies);
             this.enrichers = ImmutableMap.copyOf(enrichers);
+            this.feeds = ImmutableMap.copyOf(feeds);
             this.catalogItems = ImmutableMap.copyOf(catalogItems);
             this.failOnDangling = failOnDangling;
         }
@@ -345,6 +350,15 @@ public class XmlMementoSerializerTest {
             }
             return null;
         }
+        @Override public Feed lookupFeed(String id) {
+            if (feeds.containsKey(id)) {
+                return feeds.get(id);
+            }
+            if (failOnDangling) {
+                throw new NoSuchElementException("no feed with id "+id+"; contenders are
"+feeds.keySet());
+            }
+            return null;
+        }
         @Override public CatalogItem<?, ?> lookupCatalogItem(String id) {
             if (catalogItems.containsKey(id)) {
                 return catalogItems.get(id);


Mime
View raw message