You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2014/09/26 00:49:34 UTC
[10/12] git commit: Merge remote-tracking branch 'apache-gh/pr/108'
into pr/108
Merge remote-tracking branch 'apache-gh/pr/108' into pr/108
Conflicts - to be resolved in subsequent commit
api/src/main/java/brooklyn/entity/rebind/BrooklynObjectType.java
api/src/main/java/brooklyn/entity/rebind/RebindContext.java
api/src/main/java/brooklyn/mementos/BrooklynMemento.java
api/src/main/java/brooklyn/mementos/BrooklynMementoManifest.java
api/src/main/java/brooklyn/mementos/BrooklynMementoPersister.java
core/src/main/java/brooklyn/entity/rebind/PeriodicDeltaChangeListener.java
core/src/main/java/brooklyn/entity/rebind/PersisterDeltaImpl.java
core/src/main/java/brooklyn/entity/rebind/RebindContextImpl.java
core/src/main/java/brooklyn/entity/rebind/RebindManagerImpl.java
core/src/main/java/brooklyn/entity/rebind/dto/BrooklynMementoImpl.java
core/src/main/java/brooklyn/entity/rebind/dto/BrooklynMementoManifestImpl.java
core/src/main/java/brooklyn/entity/rebind/dto/MementosGenerators.java
core/src/main/java/brooklyn/entity/rebind/dto/MutableBrooklynMemento.java
core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/a361cc50
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/a361cc50
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/a361cc50
Branch: refs/heads/master
Commit: a361cc50e9dd5acc5614ee3db55758aa24cd693e
Parents: 320c1c7 435734c
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu Sep 25 20:46:24 2014 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu Sep 25 20:46:24 2014 +0100
----------------------------------------------------------------------
api/src/main/java/brooklyn/entity/Entity.java | 5 +
api/src/main/java/brooklyn/entity/Feed.java | 74 ++++++++
.../entity/rebind/BrooklynObjectType.java | 4 +
.../brooklyn/entity/rebind/RebindContext.java | 5 +
.../entity/rebind/RebindExceptionHandler.java | 3 +
.../brooklyn/entity/rebind/RebindSupport.java | 2 +
.../java/brooklyn/mementos/BrooklynMemento.java | 14 ++
.../mementos/BrooklynMementoManifest.java | 4 +
.../mementos/BrooklynMementoPersister.java | 8 +
.../java/brooklyn/mementos/EntityMemento.java | 6 +
.../java/brooklyn/mementos/FeedMemento.java | 33 ++++
.../brooklyn/entity/basic/AbstractEntity.java | 60 ++++++
.../brooklyn/entity/basic/DataEntityImpl.java | 2 +-
.../brooklyn/entity/basic/EntityFunctions.java | 20 ++
.../brooklyn/entity/basic/EntityInternal.java | 25 +++
.../brooklyn/entity/basic/EntitySuppliers.java | 47 +++++
.../entity/proxying/InternalPolicyFactory.java | 8 +
.../AbstractBrooklynObjectRebindSupport.java | 6 +
.../entity/rebind/BasicEntityRebindSupport.java | 29 +++
.../entity/rebind/BasicFeedRebindSupport.java | 48 +++++
.../rebind/BasicLocationRebindSupport.java | 5 +
.../rebind/PeriodicDeltaChangeListener.java | 28 +++
.../entity/rebind/PersisterDeltaImpl.java | 28 +++
.../entity/rebind/RebindContextImpl.java | 23 +++
.../rebind/RebindExceptionHandlerImpl.java | 22 +++
.../entity/rebind/RebindManagerImpl.java | 91 +++++++++
.../entity/rebind/dto/BasicEnricherMemento.java | 2 +-
.../entity/rebind/dto/BasicEntityMemento.java | 10 +
.../entity/rebind/dto/BasicFeedMemento.java | 89 +++++++++
.../entity/rebind/dto/BasicPolicyMemento.java | 2 +-
.../entity/rebind/dto/BrooklynMementoImpl.java | 46 +++++
.../rebind/dto/BrooklynMementoManifestImpl.java | 28 +++
.../entity/rebind/dto/MementosGenerators.java | 51 ++++-
.../rebind/dto/MutableBrooklynMemento.java | 47 +++++
.../BrooklynMementoPersisterToObjectStore.java | 146 +++++++++++++-
.../java/brooklyn/event/feed/AbstractFeed.java | 97 ++++++++--
.../main/java/brooklyn/event/feed/Poller.java | 4 +-
.../event/feed/function/FunctionFeed.java | 27 ++-
.../event/feed/function/FunctionPollConfig.java | 33 +++-
.../java/brooklyn/event/feed/http/HttpFeed.java | 25 ++-
.../event/feed/http/HttpPollConfig.java | 16 +-
.../brooklyn/event/feed/shell/ShellFeed.java | 30 ++-
.../java/brooklyn/event/feed/ssh/SshFeed.java | 83 +++++---
.../windows/WindowsPerformanceCounterFeed.java | 103 ++++++----
.../WindowsPerformanceCounterPollConfig.java | 54 ++++++
.../internal/BrooklynFeatureEnablement.java | 10 +
.../internal/EntityChangeListener.java | 7 +
.../internal/EntityManagementSupport.java | 11 ++
.../entity/basic/EntityFunctionsTest.java | 12 ++
.../entity/basic/EntitySuppliersTest.java | 70 +++++++
.../brooklyn/entity/rebind/RebindFeedTest.java | 190 +++++++++++++++++++
.../event/feed/function/FunctionFeedTest.java | 25 +++
.../WindowsPerformanceCounterFeedLiveTest.java | 32 +---
.../WindowsPerformanceCounterFeedTest.java | 4 +-
.../entity/monitoring/zabbix/ZabbixFeed.java | 79 +++++---
.../brooklyn/entity/chef/ChefAttributeFeed.java | 107 +++++++----
.../entity/chef/ChefAttributePollConfig.java | 54 ++++++
.../java/brooklyn/event/feed/jmx/JmxFeed.java | 112 ++++++++---
.../java/brooklyn/event/feed/jmx/JmxHelper.java | 10 +-
.../event/feed/jmx/RebindJmxFeedTest.java | 146 ++++++++++++++
.../guava/IllegalStateExceptionSupplier.java | 2 +
.../main/java/brooklyn/util/guava/Maybe.java | 2 +-
62 files changed, 2113 insertions(+), 253 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/api/src/main/java/brooklyn/entity/Entity.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/api/src/main/java/brooklyn/entity/rebind/BrooklynObjectType.java
----------------------------------------------------------------------
diff --cc api/src/main/java/brooklyn/entity/rebind/BrooklynObjectType.java
index 5342145,4530e66..ee84d5e
--- a/api/src/main/java/brooklyn/entity/rebind/BrooklynObjectType.java
+++ b/api/src/main/java/brooklyn/entity/rebind/BrooklynObjectType.java
@@@ -26,6 -26,6 +26,10 @@@ public enum BrooklynObjectType
LOCATION,
POLICY,
ENRICHER,
++<<<<<<< HEAD
+ CATALOG_ITEM,
++=======
+ FEED,
++>>>>>>> apache-gh/pr/108
UNKNOWN;
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/api/src/main/java/brooklyn/entity/rebind/RebindContext.java
----------------------------------------------------------------------
diff --cc api/src/main/java/brooklyn/entity/rebind/RebindContext.java
index c67734e,7ac0aa2..4204ea2
--- a/api/src/main/java/brooklyn/entity/rebind/RebindContext.java
+++ b/api/src/main/java/brooklyn/entity/rebind/RebindContext.java
@@@ -18,8 -18,8 +18,9 @@@
*/
package brooklyn.entity.rebind;
+import brooklyn.catalog.CatalogItem;
import brooklyn.entity.Entity;
+ import brooklyn.entity.Feed;
import brooklyn.location.Location;
import brooklyn.policy.Enricher;
import brooklyn.policy.Policy;
@@@ -43,7 -43,7 +44,11 @@@ public interface RebindContext
Enricher getEnricher(String id);
++<<<<<<< HEAD
+ CatalogItem<?, ?> getCatalogItem(String id);
++=======
+ Feed getFeed(String id);
++>>>>>>> apache-gh/pr/108
Class<?> loadClass(String typeName) throws ClassNotFoundException;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/api/src/main/java/brooklyn/entity/rebind/RebindExceptionHandler.java
----------------------------------------------------------------------
diff --cc api/src/main/java/brooklyn/entity/rebind/RebindExceptionHandler.java
index 26afde1,d6518ac..2cca2f3
--- a/api/src/main/java/brooklyn/entity/rebind/RebindExceptionHandler.java
+++ b/api/src/main/java/brooklyn/entity/rebind/RebindExceptionHandler.java
@@@ -19,8 -19,8 +19,9 @@@
package brooklyn.entity.rebind;
import brooklyn.basic.BrooklynObject;
+import brooklyn.catalog.CatalogItem;
import brooklyn.entity.Entity;
+ import brooklyn.entity.Feed;
import brooklyn.entity.basic.EntityLocal;
import brooklyn.location.Location;
import brooklyn.policy.Enricher;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/api/src/main/java/brooklyn/mementos/BrooklynMemento.java
----------------------------------------------------------------------
diff --cc api/src/main/java/brooklyn/mementos/BrooklynMemento.java
index 5a6a1bc,fa63d46..797d609
--- a/api/src/main/java/brooklyn/mementos/BrooklynMemento.java
+++ b/api/src/main/java/brooklyn/mementos/BrooklynMemento.java
@@@ -44,8 -44,8 +44,13 @@@ public interface BrooklynMemento extend
public PolicyMemento getPolicyMemento(String id);
public EnricherMemento getEnricherMemento(String id);
++<<<<<<< HEAD
+
+ public CatalogItemMemento getCatalogItemMemento(String id);
++=======
+
+ public FeedMemento getFeedMemento(String id);
++>>>>>>> apache-gh/pr/108
public Collection<String> getApplicationIds();
@@@ -59,7 -59,7 +64,11 @@@
public Collection<String> getEnricherIds();
++<<<<<<< HEAD
+ public Collection<String> getCatalogItemIds();
++=======
+ public Collection<String> getFeedIds();
++>>>>>>> apache-gh/pr/108
public Map<String, EntityMemento> getEntityMementos();
@@@ -68,7 -68,6 +77,12 @@@
public Map<String, PolicyMemento> getPolicyMementos();
public Map<String, EnricherMemento> getEnricherMementos();
++<<<<<<< HEAD
+
+ public Map<String, CatalogItemMemento> getCatalogItemMementos();
+
++=======
+
+ public Map<String, FeedMemento> getFeedMementos();
++>>>>>>> apache-gh/pr/108
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/api/src/main/java/brooklyn/mementos/BrooklynMementoManifest.java
----------------------------------------------------------------------
diff --cc api/src/main/java/brooklyn/mementos/BrooklynMementoManifest.java
index 843e800,1c4f0b5..6e37c81
--- a/api/src/main/java/brooklyn/mementos/BrooklynMementoManifest.java
+++ b/api/src/main/java/brooklyn/mementos/BrooklynMementoManifest.java
@@@ -36,7 -36,7 +36,11 @@@ public interface BrooklynMementoManifes
public Map<String, String> getEnricherIdToType();
++<<<<<<< HEAD
+ public Map<String, String> getCatalogItemIdToType();
++=======
+ public Map<String, String> getFeedIdToType();
++>>>>>>> apache-gh/pr/108
public boolean isEmpty();
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/api/src/main/java/brooklyn/mementos/BrooklynMementoPersister.java
----------------------------------------------------------------------
diff --cc api/src/main/java/brooklyn/mementos/BrooklynMementoPersister.java
index f7487e6,46afbb5..e391828
--- a/api/src/main/java/brooklyn/mementos/BrooklynMementoPersister.java
+++ b/api/src/main/java/brooklyn/mementos/BrooklynMementoPersister.java
@@@ -80,12 -78,12 +80,20 @@@ public interface BrooklynMementoPersist
Collection<EntityMemento> entities();
Collection<PolicyMemento> policies();
Collection<EnricherMemento> enrichers();
++<<<<<<< HEAD
+ Collection<CatalogItemMemento> catalogItems();
++=======
+ Collection<FeedMemento> feeds();
++>>>>>>> apache-gh/pr/108
Collection<String> removedLocationIds();
Collection<String> removedEntityIds();
Collection<String> removedPolicyIds();
Collection<String> removedEnricherIds();
++<<<<<<< HEAD
+ Collection<String> removedCatalogItemIds();
++=======
+ Collection<String> removedFeedIds();
++>>>>>>> apache-gh/pr/108
}
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/core/src/main/java/brooklyn/entity/rebind/PeriodicDeltaChangeListener.java
----------------------------------------------------------------------
diff --cc core/src/main/java/brooklyn/entity/rebind/PeriodicDeltaChangeListener.java
index 76e10ae,6831704..9fb4b4a
--- a/core/src/main/java/brooklyn/entity/rebind/PeriodicDeltaChangeListener.java
+++ b/core/src/main/java/brooklyn/entity/rebind/PeriodicDeltaChangeListener.java
@@@ -30,8 -29,8 +30,9 @@@ import org.slf4j.Logger
import org.slf4j.LoggerFactory;
import brooklyn.basic.BrooklynObject;
+import brooklyn.catalog.CatalogItem;
import brooklyn.entity.Entity;
+ import brooklyn.entity.Feed;
import brooklyn.entity.basic.EntityInternal;
import brooklyn.internal.BrooklynFeatureEnablement;
import brooklyn.location.Location;
@@@ -73,18 -72,18 +74,32 @@@ public class PeriodicDeltaChangeListene
Set<Entity> entities = Sets.newLinkedHashSet();
Set<Policy> policies = Sets.newLinkedHashSet();
Set<Enricher> enrichers = Sets.newLinkedHashSet();
++<<<<<<< HEAD
+ Set<CatalogItem<?, ?>> catalogItems = Sets.newLinkedHashSet();
++=======
+ Set<Feed> feeds = Sets.newLinkedHashSet();
++>>>>>>> apache-gh/pr/108
Set<String> removedLocationIds = Sets.newLinkedHashSet();
Set<String> removedEntityIds = Sets.newLinkedHashSet();
Set<String> removedPolicyIds = Sets.newLinkedHashSet();
Set<String> removedEnricherIds = Sets.newLinkedHashSet();
++<<<<<<< HEAD
+ Set<String> removedCatalogItemIds = Sets.newLinkedHashSet();
+
+ public boolean isEmpty() {
+ return locations.isEmpty() && entities.isEmpty() && policies.isEmpty() &&
+ enrichers.isEmpty() && catalogItems.isEmpty() &&
+ removedEntityIds.isEmpty() && removedLocationIds.isEmpty() && removedPolicyIds.isEmpty() &&
+ removedEnricherIds.isEmpty() && removedCatalogItemIds.isEmpty();
++=======
+ Set<String> removedFeedIds = Sets.newLinkedHashSet();
+
+ public boolean isEmpty() {
+ return locations.isEmpty() && entities.isEmpty() && policies.isEmpty() &&
+ enrichers.isEmpty() && feeds.isEmpty() &&
+ removedEntityIds.isEmpty() && removedLocationIds.isEmpty() && removedPolicyIds.isEmpty() &&
+ removedEnricherIds.isEmpty() && removedFeedIds.isEmpty();
++>>>>>>> apache-gh/pr/108
}
}
@@@ -293,11 -255,11 +308,19 @@@
exceptionHandler.onGenerateMementoFailed(BrooklynObjectType.ENRICHER, enricher, e);
}
}
++<<<<<<< HEAD
+ for (CatalogItem<?, ?> catalogItem : prevDeltaCollector.catalogItems) {
+ try {
+ persisterDelta.catalogItems.add(catalogItem.getRebindSupport().getMemento());
+ } catch (Exception e) {
+ exceptionHandler.onGenerateMementoFailed(BrooklynObjectType.CATALOG_ITEM, catalogItem, e);
++=======
+ for (Feed feed : prevDeltaCollector.feeds) {
+ try {
+ persisterDelta.feeds.add(feed.getRebindSupport().getMemento());
+ } catch (Exception e) {
+ exceptionHandler.onGenerateMementoFailed(BrooklynObjectType.FEED, feed, e);
++>>>>>>> apache-gh/pr/108
}
}
persisterDelta.removedLocationIds = prevDeltaCollector.removedLocationIds;
@@@ -384,8 -358,8 +407,13 @@@
deltaCollector.policies.add((Policy) instance);
} else if (instance instanceof Enricher) {
deltaCollector.enrichers.add((Enricher) instance);
++<<<<<<< HEAD
+ } else if (instance instanceof CatalogItem) {
+ deltaCollector.catalogItems.add((CatalogItem) instance);
++=======
+ } else if (instance instanceof Feed) {
+ deltaCollector.feeds.add((Feed) instance);
++>>>>>>> apache-gh/pr/108
} else {
throw new IllegalStateException("Unexpected brooklyn type: "+instance);
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/core/src/main/java/brooklyn/entity/rebind/PersisterDeltaImpl.java
----------------------------------------------------------------------
diff --cc core/src/main/java/brooklyn/entity/rebind/PersisterDeltaImpl.java
index 5c56879,53ec906..c70e96b
--- a/core/src/main/java/brooklyn/entity/rebind/PersisterDeltaImpl.java
+++ b/core/src/main/java/brooklyn/entity/rebind/PersisterDeltaImpl.java
@@@ -21,9 -21,9 +21,10 @@@ package brooklyn.entity.rebind
import java.util.Collection;
import brooklyn.mementos.BrooklynMementoPersister.Delta;
+import brooklyn.mementos.CatalogItemMemento;
import brooklyn.mementos.EnricherMemento;
import brooklyn.mementos.EntityMemento;
+ import brooklyn.mementos.FeedMemento;
import brooklyn.mementos.LocationMemento;
import brooklyn.mementos.PolicyMemento;
@@@ -54,8 -54,8 +55,13 @@@ public class PersisterDeltaImpl impleme
delta.enrichers.addAll(vals);
return this;
}
++<<<<<<< HEAD
+ public Builder catalogItems(Collection<? extends CatalogItemMemento> vals) {
+ delta.catalogItems.addAll(vals);
++=======
+ public Builder feeds(Collection<? extends FeedMemento> vals) {
+ delta.feeds.addAll(vals);
++>>>>>>> apache-gh/pr/108
return this;
}
public Builder removedLocationIds(Collection<String> vals) {
@@@ -87,13 -83,13 +93,23 @@@
Collection<EntityMemento> entities = Sets.newLinkedHashSet();
Collection<PolicyMemento> policies = Sets.newLinkedHashSet();
Collection<EnricherMemento> enrichers = Sets.newLinkedHashSet();
++<<<<<<< HEAD
+ Collection<CatalogItemMemento> catalogItems = Sets.newLinkedHashSet();
+ Collection<String> removedLocationIds = Sets.newLinkedHashSet();
+ Collection<String> removedEntityIds = Sets.newLinkedHashSet();
+ Collection<String> removedPolicyIds = Sets.newLinkedHashSet();
+ Collection<String> removedEnricherIds = Sets.newLinkedHashSet();
+ Collection<String> removedCatalogItemIds = Sets.newLinkedHashSet();
+
++=======
+ Collection<FeedMemento> feeds = Sets.newLinkedHashSet();
+ Collection <String> removedLocationIds = Sets.newLinkedHashSet();
+ Collection <String> removedEntityIds = Sets.newLinkedHashSet();
+ Collection <String> removedPolicyIds = Sets.newLinkedHashSet();
+ Collection <String> removedEnricherIds = Sets.newLinkedHashSet();
+ Collection <String> removedFeedIds = Sets.newLinkedHashSet();
+
++>>>>>>> apache-gh/pr/108
@Override
public Collection<LocationMemento> locations() {
return locations;
@@@ -115,8 -111,8 +131,13 @@@
}
@Override
++<<<<<<< HEAD
+ public Collection<CatalogItemMemento> catalogItems() {
+ return catalogItems;
++=======
+ public Collection<FeedMemento> feeds() {
+ return feeds;
++>>>>>>> apache-gh/pr/108
}
@Override
@@@ -138,9 -134,9 +159,16 @@@
public Collection<String> removedEnricherIds() {
return removedEnricherIds;
}
++<<<<<<< HEAD
+
+ @Override
+ public Collection<String> removedCatalogItemIds() {
+ return removedCatalogItemIds;
++=======
+
+ @Override
+ public Collection<String> removedFeedIds() {
+ return removedFeedIds;
++>>>>>>> apache-gh/pr/108
}
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/core/src/main/java/brooklyn/entity/rebind/RebindContextImpl.java
----------------------------------------------------------------------
diff --cc core/src/main/java/brooklyn/entity/rebind/RebindContextImpl.java
index f087c13,ab077b7..f66730a
--- a/core/src/main/java/brooklyn/entity/rebind/RebindContextImpl.java
+++ b/core/src/main/java/brooklyn/entity/rebind/RebindContextImpl.java
@@@ -23,8 -23,8 +23,9 @@@ import static com.google.common.base.Pr
import java.util.Collection;
import java.util.Map;
+import brooklyn.catalog.CatalogItem;
import brooklyn.entity.Entity;
+ import brooklyn.entity.Feed;
import brooklyn.location.Location;
import brooklyn.policy.Enricher;
import brooklyn.policy.Policy;
@@@ -37,7 -37,7 +38,11 @@@ public class RebindContextImpl implemen
private final Map<String, Location> locations = Maps.newLinkedHashMap();
private final Map<String, Policy> policies = Maps.newLinkedHashMap();
private final Map<String, Enricher> enrichers = Maps.newLinkedHashMap();
++<<<<<<< HEAD
+ private final Map<String, CatalogItem<?, ?>> catalogItems = Maps.newLinkedHashMap();
++=======
+ private final Map<String, Feed> feeds = Maps.newLinkedHashMap();
++>>>>>>> apache-gh/pr/108
private final ClassLoader classLoader;
private final RebindExceptionHandler exceptionHandler;
@@@ -61,11 -61,11 +66,15 @@@
public void registerEnricher(String id, Enricher enricher) {
enrichers.put(id, enricher);
}
+
+ public void registerCatalogItem(String id, CatalogItem<?, ?> catalogItem) {
+ catalogItems.put(id, catalogItem);
+ }
+ public void registerFeed(String id, Feed feed) {
+ feeds.put(id, feed);
+ }
+
public void unregisterPolicy(Policy policy) {
policies.remove(policy.getId());
}
@@@ -93,13 -97,13 +106,18 @@@
public Enricher getEnricher(String id) {
return enrichers.get(id);
}
-
+
+ @Override
+ public CatalogItem<?, ?> getCatalogItem(String id) {
+ return catalogItems.get(id);
+ }
+
@Override
+ public Feed getFeed(String id) {
+ return feeds.get(id);
+ }
+
+ @Override
public Class<?> loadClass(String className) throws ClassNotFoundException {
return classLoader.loadClass(className);
}
@@@ -125,7 -129,7 +143,12 @@@
return enrichers.values();
}
++<<<<<<< HEAD
+ protected Collection<CatalogItem<?, ?>> getCatalogItems() {
+ return catalogItems.values();
++=======
+ protected Collection<Feed> getFeeds() {
+ return feeds.values();
++>>>>>>> apache-gh/pr/108
}
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/core/src/main/java/brooklyn/entity/rebind/RebindExceptionHandlerImpl.java
----------------------------------------------------------------------
diff --cc core/src/main/java/brooklyn/entity/rebind/RebindExceptionHandlerImpl.java
index abea001,cdb8e22..47736b9
--- a/core/src/main/java/brooklyn/entity/rebind/RebindExceptionHandlerImpl.java
+++ b/core/src/main/java/brooklyn/entity/rebind/RebindExceptionHandlerImpl.java
@@@ -28,8 -28,8 +28,9 @@@ import org.slf4j.Logger
import org.slf4j.LoggerFactory;
import brooklyn.basic.BrooklynObject;
+import brooklyn.catalog.CatalogItem;
import brooklyn.entity.Entity;
+ import brooklyn.entity.Feed;
import brooklyn.entity.basic.EntityLocal;
import brooklyn.entity.rebind.RebindManager.RebindFailureMode;
import brooklyn.location.Location;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/core/src/main/java/brooklyn/entity/rebind/RebindManagerImpl.java
----------------------------------------------------------------------
diff --cc core/src/main/java/brooklyn/entity/rebind/RebindManagerImpl.java
index 65e0524,4e517a1..d33a300
--- a/core/src/main/java/brooklyn/entity/rebind/RebindManagerImpl.java
+++ b/core/src/main/java/brooklyn/entity/rebind/RebindManagerImpl.java
@@@ -50,7 -45,7 +51,11 @@@ import brooklyn.entity.proxying.Interna
import brooklyn.entity.proxying.InternalFactory;
import brooklyn.entity.proxying.InternalLocationFactory;
import brooklyn.entity.proxying.InternalPolicyFactory;
++<<<<<<< HEAD
+import brooklyn.entity.rebind.persister.BrooklynMementoPersisterToObjectStore;
++=======
+ import brooklyn.event.feed.AbstractFeed;
++>>>>>>> apache-gh/pr/108
import brooklyn.internal.BrooklynFeatureEnablement;
import brooklyn.location.Location;
import brooklyn.location.basic.AbstractLocation;
@@@ -61,10 -56,9 +66,11 @@@ import brooklyn.mementos.BrooklynMement
import brooklyn.mementos.BrooklynMementoManifest;
import brooklyn.mementos.BrooklynMementoPersister;
import brooklyn.mementos.BrooklynMementoPersister.LookupContext;
+import brooklyn.mementos.BrooklynMementoRawData;
+import brooklyn.mementos.CatalogItemMemento;
import brooklyn.mementos.EnricherMemento;
import brooklyn.mementos.EntityMemento;
+ import brooklyn.mementos.FeedMemento;
import brooklyn.mementos.LocationMemento;
import brooklyn.mementos.PolicyMemento;
import brooklyn.mementos.TreeNode;
@@@ -124,7 -118,7 +130,11 @@@ public class RebindManagerImpl implemen
private final boolean persistPoliciesEnabled;
private final boolean persistEnrichersEnabled;
++<<<<<<< HEAD
+ private final boolean persistCatalogItemsEnabled;
++=======
+ private final boolean persistFeedsEnabled;
++>>>>>>> apache-gh/pr/108
private RebindFailureMode danglingRefFailureMode;
private RebindFailureMode rebindFailureMode;
private RebindFailureMode addPolicyFailureMode;
@@@ -159,7 -153,7 +169,11 @@@
this.persistPoliciesEnabled = BrooklynFeatureEnablement.isEnabled(BrooklynFeatureEnablement.FEATURE_POLICY_PERSISTENCE_PROPERTY);
this.persistEnrichersEnabled = BrooklynFeatureEnablement.isEnabled(BrooklynFeatureEnablement.FEATURE_ENRICHER_PERSISTENCE_PROPERTY);
++<<<<<<< HEAD
+ this.persistCatalogItemsEnabled = BrooklynFeatureEnablement.isEnabled(BrooklynFeatureEnablement.FEATURE_CATALOG_PERSISTENCE_PROPERTY);
++=======
+ this.persistFeedsEnabled = BrooklynFeatureEnablement.isEnabled(BrooklynFeatureEnablement.FEATURE_FEED_PERSISTENCE_PROPERTY);
++>>>>>>> apache-gh/pr/108
danglingRefFailureMode = managementContext.getConfig().getConfig(DANGLING_REFERENCE_FAILURE_MODE);
rebindFailureMode = managementContext.getConfig().getConfig(REBIND_FAILURE_MODE);
@@@ -432,24 -434,25 +446,44 @@@
LOG.debug("Not rebinding enrichers; feature disabled: {}", memento.getEnricherIds());
}
++<<<<<<< HEAD
+ // Instantiate catalog items
+ if (persistCatalogItemsEnabled) {
+ LOG.debug("RebindManager instantiating catalog items: {}", memento.getCatalogItemIds());
+ for (CatalogItemMemento catalogItemMemento : memento.getCatalogItemMementos().values()) {
+ if (LOG.isDebugEnabled()) LOG.debug("RebindManager instantiating catalog item {}", catalogItemMemento);
+ try {
+ CatalogItem<?, ?> catalogItem = newCatalogItem(catalogItemMemento, reflections);
+ rebindContext.registerCatalogItem(catalogItemMemento.getId(), catalogItem);
+ } catch (Exception e) {
+ exceptionHandler.onCreateFailed(BrooklynObjectType.CATALOG_ITEM, catalogItemMemento.getId(), catalogItemMemento.getType(), e);
+ }
+ }
+ } else {
+ LOG.debug("Not rebinding catalog; feature disabled: {}", memento.getCatalogItemIds());
+ }
+
++=======
+ // Instantiate feeds
+ if (persistFeedsEnabled) {
+ LOG.debug("RebindManager instantiating feeds: {}", memento.getFeedIds());
+ for (FeedMemento feedMemento : memento.getFeedMementos().values()) {
+ if (LOG.isDebugEnabled()) LOG.debug("RebindManager instantiating feed {}", feedMemento);
+
+ try {
+ Feed feed = newFeed(feedMemento, reflections);
+ rebindContext.registerFeed(feedMemento.getId(), feed);
+ } catch (Exception e) {
+ exceptionHandler.onCreateFailed(BrooklynObjectType.FEED, feedMemento.getId(), feedMemento.getType(), e);
+ }
+ }
+ } else {
+ LOG.debug("Not rebinding feeds; feature disabled: {}", memento.getFeedIds());
+ }
+
++>>>>>>> apache-gh/pr/108
//
- // PHASE THREE
+ // PHASE FIVE
//
// Reconstruct locations
@@@ -508,9 -511,32 +542,35 @@@
rebindContext.unregisterEnricher(enricher);
}
}
-
}
}
++<<<<<<< HEAD
++
++=======
+
+ // Reconstruct feeds
+ if (persistFeedsEnabled) {
+ LOG.debug("RebindManager reconstructing feeds");
+ for (FeedMemento feedMemento : memento.getFeedMementos().values()) {
+ Feed feed = rebindContext.getFeed(feedMemento.getId());
+ if (LOG.isDebugEnabled()) LOG.debug("RebindManager reconstructing feed {}", feedMemento);
+
+ if (feed == null) {
+ // usually because of creation-failure, when not using fail-fast
+ exceptionHandler.onNotFound(BrooklynObjectType.FEED, feedMemento.getId());
+ } else {
+ try {
+ feed.getRebindSupport().reconstruct(rebindContext, feedMemento);
+ } catch (Exception e) {
+ exceptionHandler.onRebindFailed(BrooklynObjectType.FEED, feed, e);
+ rebindContext.unregisterFeed(feed);
+ }
+ }
+ }
+ }
+
++>>>>>>> apache-gh/pr/108
// Reconstruct entities
LOG.debug("RebindManager reconstructing entities");
for (EntityMemento entityMemento : sortParentFirst(memento.getEntityMementos()).values()) {
@@@ -644,14 -621,13 +705,22 @@@
exceptionHandler.onDone();
if (!isEmpty) {
++<<<<<<< HEAD
+ LOG.info("Rebind complete: {} app{}, {} entit{}, {} location{}, {} polic{}, {} enricher{}, {} catalog item{}", new Object[]{
++=======
+ LOG.info("Rebind complete: {} app{}, {} entit{}, {} location{}, {} polic{}, {} enricher{}, {} feed{}", new Object[] {
++>>>>>>> apache-gh/pr/108
apps.size(), Strings.s(apps),
rebindContext.getEntities().size(), Strings.ies(rebindContext.getEntities()),
rebindContext.getLocations().size(), Strings.s(rebindContext.getLocations()),
rebindContext.getPolicies().size(), Strings.ies(rebindContext.getPolicies()),
rebindContext.getEnrichers().size(), Strings.s(rebindContext.getEnrichers()),
++<<<<<<< HEAD
+ rebindContext.getCatalogItems().size(), Strings.s(rebindContext.getCatalogItems())
+ });
++=======
+ rebindContext.getFeeds().size(), Strings.s(rebindContext.getFeeds()) });
++>>>>>>> apache-gh/pr/108
}
// Return the top-level applications
@@@ -830,12 -807,25 +899,34 @@@
}
}
++<<<<<<< HEAD
+ @SuppressWarnings({ "rawtypes" })
+ private CatalogItem<?, ?> newCatalogItem(CatalogItemMemento memento, Reflections reflections) {
+ String id = memento.getId();
+ String itemType = checkNotNull(memento.getType(), "catalog item type of %s must not be null in memento", id);
+ Class<? extends CatalogItem> clazz = reflections.loadClass(itemType, CatalogItem.class);
+ return invokeConstructor(reflections, clazz, new Object[]{});
++=======
+ /**
+ * Constructs a new enricher, passing to its constructor the enricher id and all of memento.getConfig().
+ */
+ private Feed newFeed(FeedMemento memento, Reflections reflections) {
+ String id = memento.getId();
+ String feedType = checkNotNull(memento.getType(), "feed type of %s must not be null in memento", id);
+ Class<? extends Feed> feedClazz = (Class<? extends Feed>) reflections.loadClass(feedType);
+
+ if (InternalFactory.isNewStyle(feedClazz)) {
+ InternalPolicyFactory policyFactory = managementContext.getPolicyFactory();
+ Feed feed = policyFactory.constructFeed(feedClazz);
+ FlagUtils.setFieldsFromFlags(ImmutableMap.of("id", id), feed);
+ ((AbstractFeed)feed).setManagementContext(managementContext);
+
+ return feed;
+
+ } else {
+ throw new IllegalStateException("rebind of feed without no-arg constructor unsupported: id="+id+"; type="+feedType);
+ }
++>>>>>>> apache-gh/pr/108
}
private <T> T invokeConstructor(Reflections reflections, Class<T> clazz, Object[]... possibleArgs) {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/core/src/main/java/brooklyn/entity/rebind/dto/BrooklynMementoImpl.java
----------------------------------------------------------------------
diff --cc core/src/main/java/brooklyn/entity/rebind/dto/BrooklynMementoImpl.java
index cff9895,5ed0bc3..7ca7e5e
--- a/core/src/main/java/brooklyn/entity/rebind/dto/BrooklynMementoImpl.java
+++ b/core/src/main/java/brooklyn/entity/rebind/dto/BrooklynMementoImpl.java
@@@ -26,9 -26,9 +26,10 @@@ import java.util.Map
import brooklyn.BrooklynVersion;
import brooklyn.mementos.BrooklynMemento;
+import brooklyn.mementos.CatalogItemMemento;
import brooklyn.mementos.EnricherMemento;
import brooklyn.mementos.EntityMemento;
+ import brooklyn.mementos.FeedMemento;
import brooklyn.mementos.LocationMemento;
import brooklyn.mementos.Memento;
import brooklyn.mementos.PolicyMemento;
@@@ -53,8 -53,8 +54,13 @@@ public class BrooklynMementoImpl implem
protected final Map<String, LocationMemento> locations = Maps.newConcurrentMap();
protected final Map<String, PolicyMemento> policies = Maps.newConcurrentMap();
protected final Map<String, EnricherMemento> enrichers = Maps.newConcurrentMap();
++<<<<<<< HEAD
+ protected final Map<String, CatalogItemMemento> catalogItems = Maps.newConcurrentMap();
+
++=======
+ protected final Map<String, FeedMemento> feeds = Maps.newConcurrentMap();
+
++>>>>>>> apache-gh/pr/108
public Builder brooklynVersion(String val) {
brooklynVersion = val; return this;
}
@@@ -75,9 -75,9 +81,15 @@@
} else if (memento instanceof PolicyMemento) {
policy((PolicyMemento)memento);
} else if (memento instanceof EnricherMemento) {
++<<<<<<< HEAD
+ enricher((EnricherMemento) memento);
+ } else if (memento instanceof CatalogItemMemento) {
+ catalogItem((CatalogItemMemento) memento);
++=======
+ enricher((EnricherMemento)memento);
+ } else if (memento instanceof FeedMemento) {
+ feed((FeedMemento)memento);
++>>>>>>> apache-gh/pr/108
} else {
throw new IllegalStateException("Unexpected memento type :"+memento);
}
@@@ -110,11 -113,8 +125,16 @@@
public Builder enrichers(Map<String, EnricherMemento> vals) {
enrichers.putAll(vals); return this;
}
++<<<<<<< HEAD
+ public Builder catalogItems(Map<String, CatalogItemMemento> vals) {
+ catalogItems.putAll(vals); return this;
+ }
+ public Builder catalogItem(CatalogItemMemento val) {
+ catalogItems.put(val.getId(), val); return this;
++=======
+ public Builder feeds(Map<String, FeedMemento> vals) {
+ feeds.putAll(vals); return this;
++>>>>>>> apache-gh/pr/108
}
public BrooklynMemento build() {
return new BrooklynMementoImpl(this);
@@@ -129,8 -129,8 +149,13 @@@
private Map<String, LocationMemento> locations;
private Map<String, PolicyMemento> policies;
private Map<String, EnricherMemento> enrichers;
++<<<<<<< HEAD
+ private Map<String, CatalogItemMemento> catalogItems;
+
++=======
+ private Map<String, FeedMemento> feeds;
+
++>>>>>>> apache-gh/pr/108
private BrooklynMementoImpl(Builder builder) {
brooklynVersion = builder.brooklynVersion;
applicationIds = builder.applicationIds;
@@@ -139,7 -139,7 +164,11 @@@
locations = builder.locations;
policies = builder.policies;
enrichers = builder.enrichers;
++<<<<<<< HEAD
+ catalogItems = builder.catalogItems;
++=======
+ feeds = builder.feeds;
++>>>>>>> apache-gh/pr/108
}
@Override
@@@ -163,8 -163,8 +192,13 @@@
}
@Override
++<<<<<<< HEAD
+ public CatalogItemMemento getCatalogItemMemento(String id) {
+ return catalogItems.get(id);
++=======
+ public FeedMemento getFeedMemento(String id) {
+ return feeds.get(id);
++>>>>>>> apache-gh/pr/108
}
@Override
@@@ -191,13 -191,13 +225,18 @@@
public Collection<String> getEnricherIds() {
return Collections.unmodifiableSet(enrichers.keySet());
}
-
+
+ @Override
+ public Collection<String> getCatalogItemIds() {
+ return Collections.unmodifiableSet(catalogItems.keySet());
+ }
+
@Override
+ public Collection<String> getFeedIds() {
+ return Collections.unmodifiableSet(feeds.keySet());
+ }
+
+ @Override
public Collection<String> getTopLevelLocationIds() {
return Collections.unmodifiableList(topLevelLocationIds);
}
@@@ -220,9 -220,9 +259,16 @@@
public Map<String, EnricherMemento> getEnricherMementos() {
return Collections.unmodifiableMap(enrichers);
}
++<<<<<<< HEAD
+
+ @Override
+ public Map<String, CatalogItemMemento> getCatalogItemMementos() {
+ return Collections.unmodifiableMap(catalogItems);
++=======
+
+ @Override
+ public Map<String, FeedMemento> getFeedMementos() {
+ return Collections.unmodifiableMap(feeds);
++>>>>>>> apache-gh/pr/108
}
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/core/src/main/java/brooklyn/entity/rebind/dto/BrooklynMementoManifestImpl.java
----------------------------------------------------------------------
diff --cc core/src/main/java/brooklyn/entity/rebind/dto/BrooklynMementoManifestImpl.java
index e76407f,8a67f50..65f2397
--- a/core/src/main/java/brooklyn/entity/rebind/dto/BrooklynMementoManifestImpl.java
+++ b/core/src/main/java/brooklyn/entity/rebind/dto/BrooklynMementoManifestImpl.java
@@@ -40,8 -40,8 +40,13 @@@ public class BrooklynMementoManifestImp
protected final Map<String, String> locationIdToType = Maps.newConcurrentMap();
protected final Map<String, String> policyIdToType = Maps.newConcurrentMap();
protected final Map<String, String> enricherIdToType = Maps.newConcurrentMap();
++<<<<<<< HEAD
+ protected final Map<String, String> catalogItemIdToType = Maps.newConcurrentMap();
+
++=======
+ protected final Map<String, String> feedIdToType = Maps.newConcurrentMap();
+
++>>>>>>> apache-gh/pr/108
public Builder brooklynVersion(String val) {
brooklynVersion = val; return this;
}
@@@ -69,13 -69,12 +74,22 @@@
public Builder enrichers(Map<String, String> vals) {
enricherIdToType.putAll(vals); return this;
}
++<<<<<<< HEAD
+ public Builder catalogItem(String id, String type) {
+ catalogItemIdToType.put(id, type); return this;
+ }
+ public Builder catalogItems(Map<String, String> vals) {
+ catalogItemIdToType.putAll(vals); return this;
+ }
+
++=======
+ public Builder feed(String id, String type) {
+ feedIdToType.put(id, type); return this;
+ }
+ public Builder feed(Map<String, String> vals) {
+ feedIdToType.putAll(vals); return this;
+ }
++>>>>>>> apache-gh/pr/108
public BrooklynMementoManifest build() {
return new BrooklynMementoManifestImpl(this);
}
@@@ -85,14 -84,14 +99,23 @@@
private final Map<String, String> locationIdToType;
private final Map<String, String> policyIdToType;
private final Map<String, String> enricherIdToType;
++<<<<<<< HEAD
+ private final Map<String, String> catalogItemIdToType;
+
++=======
+ private final Map<String, String> feedIdToType;
+
++>>>>>>> apache-gh/pr/108
private BrooklynMementoManifestImpl(Builder builder) {
entityIdToType = builder.entityIdToType;
locationIdToType = builder.locationIdToType;
policyIdToType = builder.policyIdToType;
enricherIdToType = builder.enricherIdToType;
++<<<<<<< HEAD
+ catalogItemIdToType = builder.catalogItemIdToType;
++=======
+ feedIdToType = builder.feedIdToType;
++>>>>>>> apache-gh/pr/108
}
@Override
@@@ -114,19 -113,15 +137,24 @@@
public Map<String, String> getEnricherIdToType() {
return Collections.unmodifiableMap(enricherIdToType);
}
-
+
+ @Override
+ public Map<String, String> getCatalogItemIdToType() {
+ return Collections.unmodifiableMap(catalogItemIdToType);
+ }
+
@Override
+ public Map<String, String> getFeedIdToType() {
+ return Collections.unmodifiableMap(feedIdToType);
+ }
+
+ @Override
public boolean isEmpty() {
- return entityIdToType.isEmpty() && locationIdToType.isEmpty() && policyIdToType.isEmpty() && enricherIdToType.isEmpty();
+ return entityIdToType.isEmpty() &&
+ locationIdToType.isEmpty() &&
+ policyIdToType.isEmpty() &&
+ enricherIdToType.isEmpty() &&
+ catalogItemIdToType.isEmpty();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/core/src/main/java/brooklyn/entity/rebind/dto/MementosGenerators.java
----------------------------------------------------------------------
diff --cc core/src/main/java/brooklyn/entity/rebind/dto/MementosGenerators.java
index eade132,d6fb733..c8b5de2
--- a/core/src/main/java/brooklyn/entity/rebind/dto/MementosGenerators.java
+++ b/core/src/main/java/brooklyn/entity/rebind/dto/MementosGenerators.java
@@@ -42,9 -43,9 +44,10 @@@ import brooklyn.location.basic.Location
import brooklyn.management.ManagementContext;
import brooklyn.management.Task;
import brooklyn.mementos.BrooklynMemento;
+import brooklyn.mementos.CatalogItemMemento;
import brooklyn.mementos.EnricherMemento;
import brooklyn.mementos.EntityMemento;
+ import brooklyn.mementos.FeedMemento;
import brooklyn.mementos.LocationMemento;
import brooklyn.mementos.Memento;
import brooklyn.mementos.PolicyMemento;
@@@ -73,9 -74,9 +76,15 @@@ public class MementosGenerators
} else if (instance instanceof Policy) {
return newPolicyMemento((Policy)instance);
} else if (instance instanceof Enricher) {
++<<<<<<< HEAD
+ return newEnricherMemento((Enricher) instance);
+ } else if (instance instanceof CatalogItem) {
+ return newCatalogItemMemento((CatalogItem) instance);
++=======
+ return newEnricherMemento((Enricher)instance);
+ } else if (instance instanceof Feed) {
+ return newFeedMemento((Feed)instance);
++>>>>>>> apache-gh/pr/108
} else {
throw new IllegalArgumentException("Unexpected brooklyn type: "+(instance == null ? "null" : instance.getClass())+" ("+instance+")");
}
@@@ -326,24 -333,28 +340,45 @@@
return builder.build();
}
+
+ public static CatalogItemMemento newCatalogItemMemento(CatalogItem<?, ?> catalogItem) {
+ BasicCatalogItemMemento.Builder builder = BasicCatalogItemMemento.builder();
+ populateBrooklynObjectMementoBuilder(catalogItem, builder);
+ builder.catalogItemJavaType(catalogItem.getCatalogItemJavaType())
+ .catalogItemType(catalogItem.getCatalogItemType())
+ .description(catalogItem.getDescription())
+ .iconUrl(catalogItem.getIconUrl())
+ .javaType(catalogItem.getJavaType())
+ .libraries(catalogItem.getLibraries())
+ .registeredTypeName(catalogItem.getRegisteredTypeName())
+ .specType(catalogItem.getSpecType())
+ .version(catalogItem.getVersion())
+ .planYaml(catalogItem.getPlanYaml())
+ ;
+ return builder.build();
+ }
+ /**
+ * Given a feed, extracts its state for serialization.
+ */
+ public static FeedMemento newFeedMemento(Feed feed) {
+ BasicFeedMemento.Builder builder = BasicFeedMemento.builder();
+ populateBrooklynObjectMementoBuilder(feed, builder);
+
+ // TODO persist config keys as well? Or only support those defined on policy class;
+ // current code will lose the ConfigKey type on rebind for anything not defined on class.
+ // Whereas entities support that.
+ // TODO Do we need the "nonPersistableFlagNames" that locations use?
+ Map<ConfigKey<?>, Object> config = ((AbstractFeed)feed).getConfigMap().getAllConfig();
+ for (Map.Entry<ConfigKey<?>, Object> entry : config.entrySet()) {
+ ConfigKey<?> key = checkNotNull(entry.getKey(), "config=%s", config);
+ Object value = configValueToPersistable(entry.getValue());
+ builder.config.put(key.getName(), value);
+ }
+
+ return builder.build();
+ }
+
private static void populateBrooklynObjectMementoBuilder(BrooklynObject instance, AbstractMemento.Builder<?> builder) {
builder.id = instance.getId();
builder.displayName = instance.getDisplayName();
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/core/src/main/java/brooklyn/entity/rebind/dto/MutableBrooklynMemento.java
----------------------------------------------------------------------
diff --cc core/src/main/java/brooklyn/entity/rebind/dto/MutableBrooklynMemento.java
index eca739d,152ca98..fe7683e
--- a/core/src/main/java/brooklyn/entity/rebind/dto/MutableBrooklynMemento.java
+++ b/core/src/main/java/brooklyn/entity/rebind/dto/MutableBrooklynMemento.java
@@@ -28,9 -28,9 +28,10 @@@ import org.codehaus.jackson.annotate.Js
import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
import brooklyn.mementos.BrooklynMemento;
+import brooklyn.mementos.CatalogItemMemento;
import brooklyn.mementos.EnricherMemento;
import brooklyn.mementos.EntityMemento;
+ import brooklyn.mementos.FeedMemento;
import brooklyn.mementos.LocationMemento;
import brooklyn.mementos.PolicyMemento;
@@@ -57,7 -57,7 +58,11 @@@ public class MutableBrooklynMemento imp
private final Map<String, LocationMemento> locations = Maps.newLinkedHashMap();
private final Map<String, PolicyMemento> policies = Maps.newLinkedHashMap();
private final Map<String, EnricherMemento> enrichers = Maps.newLinkedHashMap();
++<<<<<<< HEAD
+ private final Map<String, CatalogItemMemento> catalogItems = Maps.newLinkedHashMap();
++=======
+ private final Map<String, FeedMemento> feeds = Maps.newLinkedHashMap();
++>>>>>>> apache-gh/pr/108
public MutableBrooklynMemento() {
}
@@@ -92,12 -92,11 +97,20 @@@
public void updateEnricherMemento(EnricherMemento memento) {
updateEnricherMementos(ImmutableSet.of(memento));
}
++<<<<<<< HEAD
+
+ public void updateCatalogItemMemento(CatalogItemMemento memento) {
+ updateCatalogItemMementos(ImmutableSet.of(memento));
+ }
+
+
++=======
+
+ public void updateFeedMemento(FeedMemento memento) {
+ updateFeedMementos(ImmutableSet.of(memento));
+ }
+
++>>>>>>> apache-gh/pr/108
public void updateEntityMementos(Collection<EntityMemento> mementos) {
for (EntityMemento memento : mementos) {
entities.put(memento.getId(), memento);
@@@ -129,13 -128,13 +142,23 @@@
enrichers.put(memento.getId(), memento);
}
}
++<<<<<<< HEAD
+
+ public void updateCatalogItemMementos(Collection<CatalogItemMemento> mementos) {
+ for (CatalogItemMemento memento : mementos) {
+ catalogItems.put(memento.getId(), memento);
+ }
+ }
+
++=======
+
+ public void updateFeedMementos(Collection<FeedMemento> mementos) {
+ for (FeedMemento memento : mementos) {
+ feeds.put(memento.getId(), memento);
+ }
+ }
+
++>>>>>>> apache-gh/pr/108
/**
* Removes the entities with the given ids.
*/
@@@ -167,10 -166,10 +190,17 @@@
}
/**
++<<<<<<< HEAD
+ * Removes the catalog items with the given ids.
+ */
+ public void removeCatalogItems(Collection<String> ids) {
+ catalogItems.keySet().removeAll(ids);
++=======
+ * Removes the feeds with the given ids.
+ */
+ public void removeFeeds(Collection<String> ids) {
+ feeds.keySet().removeAll(ids);
++>>>>>>> apache-gh/pr/108
}
@Override
@@@ -188,17 -187,18 +218,22 @@@
return policies.get(id);
}
-
@Override
public EnricherMemento getEnricherMemento(String id) {
- return enrichers.get(id);
+ return enrichers.get(id);
+ }
+
+ @Override
+ public CatalogItemMemento getCatalogItemMemento(String id) {
+ return catalogItems.get(id);
}
-
+
@Override
+ public FeedMemento getFeedMemento(String id) {
+ return feeds.get(id);
+ }
+
+ @Override
public Collection<String> getApplicationIds() {
return ImmutableList.copyOf(applicationIds);
}
@@@ -223,13 -223,13 +258,18 @@@
public Collection<String> getEnricherIds() {
return Collections.unmodifiableSet(enrichers.keySet());
}
-
+
+ @Override
+ public Collection<String> getCatalogItemIds() {
+ return Collections.unmodifiableSet(catalogItems.keySet());
+ }
+
@Override
+ public Collection<String> getFeedIds() {
+ return Collections.unmodifiableSet(feeds.keySet());
+ }
+
+ @Override
public Collection<String> getTopLevelLocationIds() {
return Collections.unmodifiableCollection(topLevelLocationIds);
}
@@@ -253,9 -253,9 +293,16 @@@
public Map<String, EnricherMemento> getEnricherMementos() {
return ImmutableMap.copyOf(enrichers);
}
++<<<<<<< HEAD
+
+ @Override
+ public Map<String, CatalogItemMemento> getCatalogItemMementos() {
+ return ImmutableMap.copyOf(catalogItems);
++=======
+
+ @Override
+ public Map<String, FeedMemento> getFeedMementos() {
+ return ImmutableMap.copyOf(feeds);
++>>>>>>> apache-gh/pr/108
}
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
----------------------------------------------------------------------
diff --cc core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
index cb87bd4,98607e2..a931229
--- a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
+++ b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
@@@ -50,10 -50,9 +50,11 @@@ import brooklyn.entity.rebind.persister
import brooklyn.mementos.BrooklynMemento;
import brooklyn.mementos.BrooklynMementoManifest;
import brooklyn.mementos.BrooklynMementoPersister;
+import brooklyn.mementos.BrooklynMementoRawData;
+import brooklyn.mementos.CatalogItemMemento;
import brooklyn.mementos.EnricherMemento;
import brooklyn.mementos.EntityMemento;
+ import brooklyn.mementos.FeedMemento;
import brooklyn.mementos.LocationMemento;
import brooklyn.mementos.Memento;
import brooklyn.mementos.PolicyMemento;
@@@ -121,7 -119,7 +122,11 @@@ public class BrooklynMementoPersisterTo
objectStore.createSubPath("locations");
objectStore.createSubPath("policies");
objectStore.createSubPath("enrichers");
++<<<<<<< HEAD
+ objectStore.createSubPath("catalog");
++=======
+ objectStore.createSubPath("feeds");
++>>>>>>> apache-gh/pr/108
// FIXME does it belong here or to ManagementPlaneSyncRecordPersisterToObjectStore ?
objectStore.createSubPath("plane");
@@@ -320,59 -175,99 +325,92 @@@
List<String> locationSubPathList;
List<String> policySubPathList;
List<String> enricherSubPathList;
++<<<<<<< HEAD
+ List<String> catalogSubPathList;
++=======
+ List<String> feedSubPathList;
++>>>>>>> apache-gh/pr/108
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
} 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(),
+ 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() });
-
- final BrooklynMementoManifestImpl.Builder builder = BrooklynMementoManifestImpl.builder();
++>>>>>>> apache-gh/pr/108
List<ListenableFuture<?>> futures = Lists.newArrayList();
+ class VisitorWrapper implements Runnable {
+ private final String subPath;
+ private final BrooklynObjectType type;
+ public VisitorWrapper(String subPath, BrooklynObjectType type) {
+ this.subPath = subPath;
+ this.type = type;
+ }
+ public void run() {
+ try {
+ String contents = read(subPath);
+ visitor.visit(contents, type, subPath);
+ } catch (Exception e) {
+ Exceptions.propagateIfFatal(e);
+ exceptionHandler.onLoadMementoFailed(type, "Memento "+subPath, e);
+ }
+ }
+ }
+
for (final String subPath : entitySubPathList) {
- futures.add(executor.submit(new Runnable() {
- public void run() {
- try {
- String contents = read(subPath);
- String id = (String) XmlUtil.xpath(contents, "/entity/id");
- String type = (String) XmlUtil.xpath(contents, "/entity/type");
- builder.entity(id, type);
- } catch (Exception e) {
- Exceptions.propagateIfFatal(e);
- exceptionHandler.onLoadMementoFailed(BrooklynObjectType.ENTITY, "Memento "+subPath, e);
- }
- }}));
+ futures.add(executor.submit(new VisitorWrapper(subPath, BrooklynObjectType.ENTITY)));
}
for (final String subPath : locationSubPathList) {
- futures.add(executor.submit(new Runnable() {
- public void run() {
- try {
- String contents = read(subPath);
- String id = (String) XmlUtil.xpath(contents, "/location/id");
- String type = (String) XmlUtil.xpath(contents, "/location/type");
- builder.location(id, type);
- } catch (Exception e) {
- Exceptions.propagateIfFatal(e);
- exceptionHandler.onLoadMementoFailed(BrooklynObjectType.LOCATION, "Memento "+subPath, e);
- }
- }}));
+ futures.add(executor.submit(new VisitorWrapper(subPath, BrooklynObjectType.LOCATION)));
}
for (final String subPath : policySubPathList) {
- futures.add(executor.submit(new Runnable() {
- public void run() {
- try {
- String contents = read(subPath);
- String id = (String) XmlUtil.xpath(contents, "/policy/id");
- String type = (String) XmlUtil.xpath(contents, "/policy/type");
- builder.policy(id, type);
- } catch (Exception e) {
- Exceptions.propagateIfFatal(e);
- exceptionHandler.onLoadMementoFailed(BrooklynObjectType.POLICY, "Memento "+subPath, e);
- }
- }}));
+ futures.add(executor.submit(new VisitorWrapper(subPath, BrooklynObjectType.POLICY)));
}
for (final String subPath : enricherSubPathList) {
- futures.add(executor.submit(new Runnable() {
- public void run() {
- try {
- String contents = read(subPath);
- String id = (String) XmlUtil.xpath(contents, "/enricher/id");
- String type = (String) XmlUtil.xpath(contents, "/enricher/type");
- builder.enricher(id, type);
- } catch (Exception e) {
- Exceptions.propagateIfFatal(e);
- exceptionHandler.onLoadMementoFailed(BrooklynObjectType.ENRICHER, "Memento "+subPath, e);
- }
- }}));
+ futures.add(executor.submit(new VisitorWrapper(subPath, BrooklynObjectType.ENRICHER)));
}
++<<<<<<< HEAD
+ 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.
@@@ -402,60 -297,139 +440,150 @@@
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
}
- @Override
- public BrooklynMemento loadMemento(LookupContext lookupContext, final RebindExceptionHandler exceptionHandler) throws IOException {
+ @Beta
+ public void checkpoint(BrooklynMementoRawData newMemento, PersistenceExceptionHandler exceptionHandler) {
if (!running) {
- throw new IllegalStateException("Persister not running; cannot load memento from " + objectStore.getSummaryName());
+ if (LOG.isDebugEnabled()) LOG.debug("Ignoring checkpointing entire memento, because not running");
+ return;
+ }
++<<<<<<< HEAD
+
+ try {
+ lock.writeLock().lockInterruptibly();
+ } catch (InterruptedException e) {
+ 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 {
- for (final String subPath : entitySubPathList) {
- futures.add(executor.submit(new MementoLoader(subPath, BrooklynObjectType.ENTITY)));
+ objectStore.prepareForMasterUse();
+
+ Stopwatch stopwatch = Stopwatch.createStarted();
+ List<ListenableFuture<?>> futures = Lists.newArrayList();
+
+ for (Map.Entry<String, String> entry : newMemento.getEntities().entrySet()) {
+ futures.add(asyncPersist("entities", BrooklynObjectType.ENTITY, entry.getKey(), entry.getValue(), exceptionHandler));
}
- for (final String subPath : locationSubPathList) {
- futures.add(executor.submit(new MementoLoader(subPath, BrooklynObjectType.LOCATION)));
+ for (Map.Entry<String, String> entry : newMemento.getLocations().entrySet()) {
+ futures.add(asyncPersist("locations", BrooklynObjectType.LOCATION, entry.getKey(), entry.getValue(), exceptionHandler));
}
- for (final String subPath : policySubPathList) {
- futures.add(executor.submit(new MementoLoader(subPath, BrooklynObjectType.POLICY)));
+ for (Map.Entry<String, String> entry : newMemento.getPolicies().entrySet()) {
+ futures.add(asyncPersist("policies", BrooklynObjectType.POLICY, entry.getKey(), entry.getValue(), exceptionHandler));
}
- for (final String subPath : enricherSubPathList) {
- futures.add(executor.submit(new MementoLoader(subPath, BrooklynObjectType.ENRICHER)));
+ 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.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, failing fast if any exceptions.
+ // 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).
+ Futures.successfulAsList(futures).get();
Futures.allAsList(futures).get();
} catch (Exception e) {
- Exceptions.propagateIfFatal(e);
-
- List<Exception> exceptions = Lists.newArrayList();
-
- for (ListenableFuture<?> future : futures) {
- if (future.isDone()) {
- try {
- future.get();
- } catch (InterruptedException e2) {
- throw Exceptions.propagate(e2);
- } catch (ExecutionException e2) {
- LOG.warn("Problem loading memento", e2);
- exceptions.add(e2);
- }
- future.cancel(true);
- }
- }
- if (exceptions.isEmpty()) {
- throw Exceptions.propagate(e);
- } else {
- // Normally there should be at lesat one failure; otherwise all.get() would not have failed.
- throw new CompoundRuntimeException("Problem loading mementos", exceptions);
- }
+ // TODO is the logging here as good as it was prior to https://github.com/apache/incubator-brooklyn/pull/177/files ?
+ throw Exceptions.propagate(e);
}
-
+
+ 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
}
-
- return result;
}
-
+
+
@Override
public void checkpoint(BrooklynMemento newMemento, PersistenceExceptionHandler exceptionHandler) {
if (!running) {
@@@ -468,7 -442,7 +596,11 @@@
.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
.build();
Stopwatch stopwatch = deltaImpl(delta, exceptionHandler);
@@@ -523,10 -494,10 +655,17 @@@
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));
+ }
+
++>>>>>>> apache-gh/pr/108
for (String id : delta.removedEntityIds()) {
futures.add(asyncDelete("entities", id, exceptionHandler));
}
@@@ -539,8 -510,8 +678,13 @@@
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
}
try {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
----------------------------------------------------------------------
diff --cc core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
index 038cfda,d04b734..002f13a
--- a/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
+++ b/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
@@@ -40,9 -40,9 +40,15 @@@ 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_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();
@@@ -54,7 -54,7 +60,11 @@@
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
}
static {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a361cc50/utils/common/src/main/java/brooklyn/util/guava/Maybe.java
----------------------------------------------------------------------