You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2015/08/12 11:00:58 UTC
[05/15] incubator-brooklyn git commit: [BROOKLYN-162] Package rename
in ./api/mementos
[BROOKLYN-162] Package rename in ./api/mementos
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/88b9219a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/88b9219a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/88b9219a
Branch: refs/heads/master
Commit: 88b9219ac204301b575ae1fb5f9e78712ec361f2
Parents: 12e3c23
Author: Hadrian Zbarcea <ha...@apache.org>
Authored: Tue Aug 11 22:36:17 2015 -0400
Committer: Hadrian Zbarcea <ha...@apache.org>
Committed: Tue Aug 11 22:36:17 2015 -0400
----------------------------------------------------------------------
api/src/main/java/brooklyn/entity/Feed.java | 2 +-
.../rebind/PersistenceExceptionHandler.java | 3 +-
.../brooklyn/entity/rebind/RebindContext.java | 3 +-
.../brooklyn/entity/rebind/RebindManager.java | 5 +-
.../brooklyn/entity/rebind/RebindSupport.java | 4 +-
.../java/brooklyn/entity/rebind/Rebindable.java | 2 +-
.../ha/ManagementPlaneSyncRecord.java | 4 +-
.../ha/ManagementPlaneSyncRecordPersister.java | 5 +-
.../java/brooklyn/mementos/BrooklynMemento.java | 64 -------
.../mementos/BrooklynMementoManifest.java | 58 ------
.../mementos/BrooklynMementoPersister.java | 139 --------------
.../mementos/BrooklynMementoRawData.java | 185 -------------------
.../brooklyn/mementos/CatalogItemMemento.java | 49 -----
.../java/brooklyn/mementos/EnricherMemento.java | 33 ----
.../java/brooklyn/mementos/EntityMemento.java | 80 --------
.../java/brooklyn/mementos/FeedMemento.java | 33 ----
.../java/brooklyn/mementos/LocationMemento.java | 38 ----
.../main/java/brooklyn/mementos/Memento.java | 84 ---------
.../java/brooklyn/mementos/PolicyMemento.java | 35 ----
.../main/java/brooklyn/mementos/TreeNode.java | 48 -----
.../apache/brooklyn/catalog/CatalogItem.java | 3 +-
.../brooklyn/mementos/BrooklynMemento.java | 64 +++++++
.../mementos/BrooklynMementoManifest.java | 58 ++++++
.../mementos/BrooklynMementoPersister.java | 139 ++++++++++++++
.../mementos/BrooklynMementoRawData.java | 185 +++++++++++++++++++
.../brooklyn/mementos/CatalogItemMemento.java | 49 +++++
.../brooklyn/mementos/EnricherMemento.java | 33 ++++
.../apache/brooklyn/mementos/EntityMemento.java | 80 ++++++++
.../apache/brooklyn/mementos/FeedMemento.java | 33 ++++
.../brooklyn/mementos/LocationMemento.java | 38 ++++
.../org/apache/brooklyn/mementos/Memento.java | 84 +++++++++
.../apache/brooklyn/mementos/PolicyMemento.java | 35 ++++
.../org/apache/brooklyn/mementos/TreeNode.java | 48 +++++
.../org/apache/brooklyn/policy/Enricher.java | 3 +-
.../java/org/apache/brooklyn/policy/Policy.java | 3 +-
.../catalog/internal/CatalogItemDo.java | 4 +-
.../internal/CatalogItemDtoAbstract.java | 4 +-
.../enricher/basic/AbstractEnricher.java | 2 +-
.../brooklyn/entity/basic/AbstractEntity.java | 2 +-
.../brooklyn/entity/basic/EntityInternal.java | 3 +-
.../basic/EntityTransientCopyInternal.java | 2 +-
.../AbstractBrooklynObjectRebindSupport.java | 2 +-
.../rebind/ActivePartialRebindIteration.java | 8 +-
.../rebind/BasicCatalogItemRebindSupport.java | 2 +-
.../rebind/BasicEnricherRebindSupport.java | 3 +-
.../entity/rebind/BasicEntityRebindSupport.java | 2 +-
.../entity/rebind/BasicFeedRebindSupport.java | 3 +-
.../rebind/BasicLocationRebindSupport.java | 2 +-
.../entity/rebind/BasicPolicyRebindSupport.java | 3 +-
.../rebind/ImmediateDeltaChangeListener.java | 14 +-
.../rebind/InitialFullRebindIteration.java | 2 +-
.../rebind/PeriodicDeltaChangeListener.java | 2 +-
.../rebind/PersistenceExceptionHandlerImpl.java | 2 +-
.../entity/rebind/PersisterDeltaImpl.java | 18 +-
.../entity/rebind/RebindContextImpl.java | 2 +-
.../rebind/RebindContextLookupContext.java | 2 +-
.../brooklyn/entity/rebind/RebindIteration.java | 26 +--
.../entity/rebind/RebindManagerImpl.java | 6 +-
.../entity/rebind/dto/AbstractMemento.java | 3 +-
.../rebind/dto/AbstractTreeNodeMemento.java | 4 +-
.../rebind/dto/BasicCatalogItemMemento.java | 4 +-
.../entity/rebind/dto/BasicEnricherMemento.java | 3 +-
.../entity/rebind/dto/BasicEntityMemento.java | 6 +-
.../entity/rebind/dto/BasicFeedMemento.java | 3 +-
.../entity/rebind/dto/BasicLocationMemento.java | 5 +-
.../entity/rebind/dto/BasicPolicyMemento.java | 3 +-
.../entity/rebind/dto/BrooklynMementoImpl.java | 17 +-
.../rebind/dto/BrooklynMementoManifestImpl.java | 5 +-
.../rebind/dto/EntityMementoManifestImpl.java | 2 +-
.../entity/rebind/dto/MementoValidators.java | 6 +-
.../entity/rebind/dto/MementosGenerators.java | 16 +-
.../rebind/dto/MutableBrooklynMemento.java | 15 +-
.../BrooklynMementoPersisterToObjectStore.java | 14 +-
.../persister/BrooklynPersistenceUtils.java | 4 +-
.../rebind/persister/MementoSerializer.java | 5 +-
.../persister/RetryingMementoSerializer.java | 3 +-
.../rebind/persister/XmlMementoSerializer.java | 2 +-
.../transformer/BrooklynMementoTransformer.java | 2 +-
.../rebind/transformer/CompoundTransformer.java | 3 +-
.../DeleteOrphanedLocationsTransformer.java | 7 +-
.../java/brooklyn/event/feed/AbstractFeed.java | 2 +-
.../location/access/PortForwardManagerImpl.java | 2 +-
.../location/basic/AbstractLocation.java | 2 +-
.../location/basic/LocationInternal.java | 3 +-
.../NonDeploymentManagementContext.java | 6 +-
.../brooklyn/policy/basic/AbstractPolicy.java | 2 +-
.../entity/rebind/RebindEntityTest.java | 4 +-
.../rebind/RebindLocalhostLocationTest.java | 2 +-
.../entity/rebind/RebindLocationTest.java | 2 +-
.../entity/rebind/RebindManagerSorterTest.java | 4 +-
.../entity/rebind/RebindPolicyTest.java | 2 +-
.../entity/rebind/RebindTestFixture.java | 4 +-
.../brooklyn/entity/rebind/RebindTestUtils.java | 4 +-
.../BrooklynMementoPersisterTestFixture.java | 6 +-
.../persister/XmlMementoSerializerTest.java | 2 +-
.../transformer/CompoundTransformerTest.java | 2 +-
.../brooklyn/launcher/BrooklynLauncher.java | 6 +-
...lynLauncherRebindToCloudObjectStoreTest.java | 3 +-
98 files changed, 1034 insertions(+), 1001 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/entity/Feed.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/Feed.java b/api/src/main/java/brooklyn/entity/Feed.java
index e34a041..4cbe021 100644
--- a/api/src/main/java/brooklyn/entity/Feed.java
+++ b/api/src/main/java/brooklyn/entity/Feed.java
@@ -18,11 +18,11 @@
*/
package brooklyn.entity;
+import org.apache.brooklyn.mementos.FeedMemento;
import org.apache.brooklyn.policy.EntityAdjunct;
import brooklyn.entity.rebind.RebindSupport;
import brooklyn.entity.rebind.Rebindable;
-import brooklyn.mementos.FeedMemento;
import com.google.common.annotations.Beta;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/entity/rebind/PersistenceExceptionHandler.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/rebind/PersistenceExceptionHandler.java b/api/src/main/java/brooklyn/entity/rebind/PersistenceExceptionHandler.java
index ba0d12c..9c8385a 100644
--- a/api/src/main/java/brooklyn/entity/rebind/PersistenceExceptionHandler.java
+++ b/api/src/main/java/brooklyn/entity/rebind/PersistenceExceptionHandler.java
@@ -18,8 +18,9 @@
*/
package brooklyn.entity.rebind;
+import org.apache.brooklyn.mementos.Memento;
+
import brooklyn.basic.BrooklynObject;
-import brooklyn.mementos.Memento;
import com.google.common.annotations.Beta;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/entity/rebind/RebindContext.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/rebind/RebindContext.java b/api/src/main/java/brooklyn/entity/rebind/RebindContext.java
index 17935b3..a17ccbe 100644
--- a/api/src/main/java/brooklyn/entity/rebind/RebindContext.java
+++ b/api/src/main/java/brooklyn/entity/rebind/RebindContext.java
@@ -20,8 +20,9 @@ package brooklyn.entity.rebind;
import java.util.Map;
+import org.apache.brooklyn.mementos.BrooklynMementoPersister.LookupContext;
+
import brooklyn.basic.BrooklynObject;
-import brooklyn.mementos.BrooklynMementoPersister.LookupContext;
import com.google.common.annotations.Beta;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/entity/rebind/RebindManager.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/rebind/RebindManager.java b/api/src/main/java/brooklyn/entity/rebind/RebindManager.java
index 8e4cb29..8cebfb9 100644
--- a/api/src/main/java/brooklyn/entity/rebind/RebindManager.java
+++ b/api/src/main/java/brooklyn/entity/rebind/RebindManager.java
@@ -24,10 +24,11 @@ import java.util.concurrent.TimeoutException;
import javax.annotation.Nullable;
+import org.apache.brooklyn.mementos.BrooklynMementoPersister;
+import org.apache.brooklyn.mementos.BrooklynMementoRawData;
+
import brooklyn.entity.Application;
import brooklyn.management.ha.ManagementNodeState;
-import brooklyn.mementos.BrooklynMementoPersister;
-import brooklyn.mementos.BrooklynMementoRawData;
import brooklyn.util.time.Duration;
import com.google.common.annotations.Beta;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/entity/rebind/RebindSupport.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/rebind/RebindSupport.java b/api/src/main/java/brooklyn/entity/rebind/RebindSupport.java
index 878e93a..e896c0f 100644
--- a/api/src/main/java/brooklyn/entity/rebind/RebindSupport.java
+++ b/api/src/main/java/brooklyn/entity/rebind/RebindSupport.java
@@ -18,8 +18,8 @@
*/
package brooklyn.entity.rebind;
-import brooklyn.mementos.BrooklynMementoPersister;
-import brooklyn.mementos.Memento;
+import org.apache.brooklyn.mementos.BrooklynMementoPersister;
+import org.apache.brooklyn.mementos.Memento;
/**
* Supporter instance for behaviour related to rebinding a given entity/location/policy.
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/entity/rebind/Rebindable.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/rebind/Rebindable.java b/api/src/main/java/brooklyn/entity/rebind/Rebindable.java
index aa15f6a..b5134b9 100644
--- a/api/src/main/java/brooklyn/entity/rebind/Rebindable.java
+++ b/api/src/main/java/brooklyn/entity/rebind/Rebindable.java
@@ -18,7 +18,7 @@
*/
package brooklyn.entity.rebind;
-import brooklyn.mementos.Memento;
+import org.apache.brooklyn.mementos.Memento;
import com.google.common.annotations.Beta;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/management/ha/ManagementPlaneSyncRecord.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/management/ha/ManagementPlaneSyncRecord.java b/api/src/main/java/brooklyn/management/ha/ManagementPlaneSyncRecord.java
index f601eb2..f70e3e3 100644
--- a/api/src/main/java/brooklyn/management/ha/ManagementPlaneSyncRecord.java
+++ b/api/src/main/java/brooklyn/management/ha/ManagementPlaneSyncRecord.java
@@ -20,8 +20,8 @@ package brooklyn.management.ha;
import java.util.Map;
-import brooklyn.mementos.BrooklynMemento;
-import brooklyn.mementos.BrooklynMementoPersister;
+import org.apache.brooklyn.mementos.BrooklynMemento;
+import org.apache.brooklyn.mementos.BrooklynMementoPersister;
import com.google.common.annotations.Beta;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/management/ha/ManagementPlaneSyncRecordPersister.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/management/ha/ManagementPlaneSyncRecordPersister.java b/api/src/main/java/brooklyn/management/ha/ManagementPlaneSyncRecordPersister.java
index f2d42fc..922deaa 100644
--- a/api/src/main/java/brooklyn/management/ha/ManagementPlaneSyncRecordPersister.java
+++ b/api/src/main/java/brooklyn/management/ha/ManagementPlaneSyncRecordPersister.java
@@ -22,7 +22,8 @@ import java.io.IOException;
import java.util.Collection;
import java.util.concurrent.TimeoutException;
-import brooklyn.mementos.BrooklynMementoPersister;
+import org.apache.brooklyn.mementos.BrooklynMementoPersister;
+
import brooklyn.util.time.Duration;
import com.google.common.annotations.Beta;
@@ -40,7 +41,7 @@ import com.google.common.annotations.VisibleForTesting;
public interface ManagementPlaneSyncRecordPersister {
/**
- * Analogue to {@link BrooklynMementoPersister#loadMemento(brooklyn.mementos.BrooklynMementoPersister.LookupContext)}
+ * Analogue to {@link BrooklynMementoPersister#loadMemento(org.apache.brooklyn.mementos.BrooklynMementoPersister.LookupContext)}
* <p>
* Note that this method is *not* thread safe.
*/
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/mementos/BrooklynMemento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/mementos/BrooklynMemento.java b/api/src/main/java/brooklyn/mementos/BrooklynMemento.java
deleted file mode 100644
index 4aa36c6..0000000
--- a/api/src/main/java/brooklyn/mementos/BrooklynMemento.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.mementos;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * Represents an entire persisted Brooklyn management context, with all its entities and locations.
- *
- * The referential integrity of this memento is not guaranteed. For example, an entity memento might
- * reference a child entity that does not exist. This is an inevitable consequence of not using a
- * stop-the-world persistence strategy, and is essential for a distributed brooklyn to be performant.
- *
- * Code using this memento should be tolerant of such inconsistencies (e.g. log a warning about the
- * missing entity, and then ignore dangling references when constructing the entities/locations, so
- * that code will not subsequently get NPEs when iterating over children for example).
- *
- * @author aled
- */
-public interface BrooklynMemento extends Serializable {
-
- public EntityMemento getEntityMemento(String id);
- public LocationMemento getLocationMemento(String id);
- public PolicyMemento getPolicyMemento(String id);
- public EnricherMemento getEnricherMemento(String id);
- public FeedMemento getFeedMemento(String id);
- public CatalogItemMemento getCatalogItemMemento(String id);
-
- public Collection<String> getApplicationIds();
- public Collection<String> getTopLevelLocationIds();
-
- public Collection<String> getEntityIds();
- public Collection<String> getLocationIds();
- public Collection<String> getPolicyIds();
- public Collection<String> getEnricherIds();
- public Collection<String> getFeedIds();
- public Collection<String> getCatalogItemIds();
-
- public Map<String, EntityMemento> getEntityMementos();
- public Map<String, LocationMemento> getLocationMementos();
- public Map<String, PolicyMemento> getPolicyMementos();
- public Map<String, EnricherMemento> getEnricherMementos();
- public Map<String, FeedMemento> getFeedMementos();
- public Map<String, CatalogItemMemento> getCatalogItemMementos();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/mementos/BrooklynMementoManifest.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/mementos/BrooklynMementoManifest.java b/api/src/main/java/brooklyn/mementos/BrooklynMementoManifest.java
deleted file mode 100644
index 6187e29..0000000
--- a/api/src/main/java/brooklyn/mementos/BrooklynMementoManifest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.mementos;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Map;
-
-import brooklyn.entity.trait.Identifiable;
-
-/**
- * Represents a manifest of the entities etc in the overall memento.
- *
- * @author aled
- */
-public interface BrooklynMementoManifest extends Serializable {
- public interface EntityMementoManifest extends Identifiable{
- public String getId();
- public String getType();
- public String getParent();
- public String getCatalogItemId();
- }
-
- public Map<String, EntityMementoManifest> getEntityIdToManifest();
-
- public Map<String, String> getLocationIdToType();
-
- public Map<String, String> getPolicyIdToType();
-
- public Map<String, String> getEnricherIdToType();
-
- public Map<String, String> getFeedIdToType();
-
- public CatalogItemMemento getCatalogItemMemento(String id);
-
- public Collection<String> getCatalogItemIds();
-
- public Map<String, CatalogItemMemento> getCatalogItemMementos();
-
- public boolean isEmpty();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/mementos/BrooklynMementoPersister.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/mementos/BrooklynMementoPersister.java b/api/src/main/java/brooklyn/mementos/BrooklynMementoPersister.java
deleted file mode 100644
index 9207721..0000000
--- a/api/src/main/java/brooklyn/mementos/BrooklynMementoPersister.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.mementos;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Set;
-import java.util.concurrent.TimeoutException;
-
-import javax.annotation.Nullable;
-
-import brooklyn.basic.BrooklynObject;
-
-import org.apache.brooklyn.catalog.CatalogItem;
-import org.apache.brooklyn.policy.Enricher;
-import org.apache.brooklyn.policy.Policy;
-
-import brooklyn.entity.Entity;
-import brooklyn.entity.Feed;
-import brooklyn.entity.rebind.BrooklynObjectType;
-import brooklyn.entity.rebind.PersistenceExceptionHandler;
-import brooklyn.entity.rebind.RebindExceptionHandler;
-import brooklyn.entity.rebind.RebindManager;
-import brooklyn.location.Location;
-import brooklyn.management.ManagementContext;
-import brooklyn.util.time.Duration;
-
-import com.google.common.annotations.Beta;
-import com.google.common.annotations.VisibleForTesting;
-
-/**
- * Controls the persisting and reading back of mementos. Used by {@link RebindManager}
- * to support brooklyn restart.
- */
-public interface BrooklynMementoPersister {
-
- public static interface LookupContext {
- ManagementContext lookupManagementContext();
- Entity lookupEntity(String id);
- Location lookupLocation(String id);
- Policy lookupPolicy(String id);
- Enricher lookupEnricher(String id);
- Feed lookupFeed(String id);
- CatalogItem<?, ?> lookupCatalogItem(String id);
-
- BrooklynObject lookup(BrooklynObjectType type, String objectId);
- /** like {@link #lookup(BrooklynObjectType, String)} but doesn't record an exception if not found */
- BrooklynObject peek(BrooklynObjectType type, String objectId);
- }
-
- /**
- * Loads raw data contents of the mementos.
- * <p>
- * Some classes (esp deprecated ones) may return null here,
- * meaning that the {@link #loadMementoManifest(BrooklynMementoRawData, RebindExceptionHandler)}
- * and {@link #loadMemento(BrooklynMementoRawData, LookupContext, RebindExceptionHandler)} methods
- * will populate the raw data via another source.
- */
- BrooklynMementoRawData loadMementoRawData(RebindExceptionHandler exceptionHandler);
-
- /**
- * Loads minimal manifest information (almost entirely *not* deserialized).
- * Implementations should load the raw data if {@link BrooklynMementoRawData} is not supplied,
- * but callers are encouraged to supply that for optimal performance.
- */
- BrooklynMementoManifest loadMementoManifest(@Nullable BrooklynMementoRawData mementoData, RebindExceptionHandler exceptionHandler) throws IOException;
-
- /**
- * Retrieves the memento class, containing deserialized objects (but not the {@link BrooklynObject} class).
- * Implementations should load the raw data if {@link BrooklynMementoRawData} is not supplied,
- * but callers are encouraged to supply that for optimal performance.
- * <p>
- * Note that this method is *not* thread safe.
- */
- BrooklynMemento loadMemento(@Nullable BrooklynMementoRawData mementoData, LookupContext lookupContext, RebindExceptionHandler exceptionHandler) throws IOException;
-
- /** applies a full checkpoint (write) of all state */
- void checkpoint(BrooklynMementoRawData newMemento, PersistenceExceptionHandler exceptionHandler);
- /** applies a partial write of state delta */
- void delta(Delta delta, PersistenceExceptionHandler exceptionHandler);
- /** inserts an additional delta to be written on the next delta request */
- @Beta
- void queueDelta(Delta delta);
-
- void enableWriteAccess();
- void disableWriteAccess(boolean graceful);
- /** permanently shuts down all access to the remote store */
- void stop(boolean graceful);
-
- @VisibleForTesting
- void waitForWritesCompleted(Duration timeout) throws InterruptedException, TimeoutException;
-
- String getBackingStoreDescription();
-
- /** All methods on this interface are unmodifiable by the caller. Sub-interfaces may introduce modifiers. */
- // NB: the type-specific methods aren't actually used anymore; we could remove them to simplify the impl (and use a multiset there)
- public interface Delta {
- Collection<LocationMemento> locations();
- Collection<EntityMemento> entities();
- Collection<PolicyMemento> policies();
- Collection<EnricherMemento> enrichers();
- Collection<FeedMemento> feeds();
- Collection<CatalogItemMemento> catalogItems();
-
- Collection<String> removedLocationIds();
- Collection<String> removedEntityIds();
- Collection<String> removedPolicyIds();
- Collection<String> removedEnricherIds();
- Collection<String> removedFeedIds();
- Collection<String> removedCatalogItemIds();
-
- Collection<? extends Memento> getObjectsOfType(BrooklynObjectType type);
- Collection<String> getRemovedIdsOfType(BrooklynObjectType type);
- }
-
- @Beta
- public interface MutableDelta extends Delta {
- void add(BrooklynObjectType type, Memento memento);
- void addAll(BrooklynObjectType type, Iterable<? extends Memento> memento);
- void removed(BrooklynObjectType type, Set<String> removedIdsOfType);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/mementos/BrooklynMementoRawData.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/mementos/BrooklynMementoRawData.java b/api/src/main/java/brooklyn/mementos/BrooklynMementoRawData.java
deleted file mode 100644
index 049b0c2..0000000
--- a/api/src/main/java/brooklyn/mementos/BrooklynMementoRawData.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.mementos;
-
-import java.util.Collections;
-import java.util.Map;
-
-import brooklyn.entity.rebind.BrooklynObjectType;
-
-import com.google.common.annotations.Beta;
-import com.google.common.collect.Maps;
-
-/**
- * Represents the raw persisted data.
- */
-@Beta
-public class BrooklynMementoRawData {
-
- // TODO Should this be on an interface?
- // The file-based (or object-store based) structure for storing data may well change; is this representation sufficient?
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- protected String brooklynVersion;
- protected final Map<String, String> entities = Maps.newConcurrentMap();
- protected final Map<String, String> locations = Maps.newConcurrentMap();
- protected final Map<String, String> policies = Maps.newConcurrentMap();
- protected final Map<String, String> enrichers = Maps.newConcurrentMap();
- protected final Map<String, String> feeds = Maps.newConcurrentMap();
- protected final Map<String, String> catalogItems = Maps.newConcurrentMap();
-
- public Builder brooklynVersion(String val) {
- brooklynVersion = val; return this;
- }
- public Builder entity(String id, String val) {
- entities.put(id, val); return this;
- }
- public Builder entities(Map<String, String> vals) {
- entities.putAll(vals); return this;
- }
- public Builder location(String id, String val) {
- locations.put(id, val); return this;
- }
- public Builder locations(Map<String, String> vals) {
- locations.putAll(vals); return this;
- }
- public Builder policy(String id, String val) {
- policies.put(id, val); return this;
- }
- public Builder policies(Map<String, String> vals) {
- policies.putAll(vals); return this;
- }
- public Builder enricher(String id, String val) {
- enrichers.put(id, val); return this;
- }
- public Builder enrichers(Map<String, String> vals) {
- enrichers.putAll(vals); return this;
- }
- public Builder feed(String id, String val) {
- feeds.put(id, val); return this;
- }
- public Builder feeds(Map<String, String> vals) {
- feeds.putAll(vals); return this;
- }
- public Builder catalogItem(String id, String val) {
- catalogItems.put(id, val); return this;
- }
- public Builder catalogItems(Map<String, String> vals) {
- catalogItems.putAll(vals); return this;
- }
-
- public Builder put(BrooklynObjectType type, String id, String val) {
- switch (type) {
- case ENTITY: return entity(id, val);
- case LOCATION: return location(id, val);
- case POLICY: return policy(id, val);
- case ENRICHER: return enricher(id, val);
- case FEED: return feed(id, val);
- case CATALOG_ITEM: return catalogItem(id, val);
- case UNKNOWN:
- default:
- throw new IllegalArgumentException(type+" not supported");
- }
- }
- public Builder putAll(BrooklynObjectType type, Map<String,String> vals) {
- switch (type) {
- case ENTITY: return entities(vals);
- case LOCATION: return locations(vals);
- case POLICY: return policies(vals);
- case ENRICHER: return enrichers(vals);
- case FEED: return feeds(vals);
- case CATALOG_ITEM: return catalogItems(vals);
- case UNKNOWN:
- default:
- throw new IllegalArgumentException(type+" not supported");
- }
- }
-
- public BrooklynMementoRawData build() {
- return new BrooklynMementoRawData(this);
- }
- }
-
- private final Map<String, String> entities;
- private final Map<String, String> locations;
- private final Map<String, String> policies;
- private final Map<String, String> enrichers;
- private final Map<String, String> feeds;
- private final Map<String, String> catalogItems;
-
- private BrooklynMementoRawData(Builder builder) {
- entities = builder.entities;
- locations = builder.locations;
- policies = builder.policies;
- enrichers = builder.enrichers;
- feeds = builder.feeds;
- catalogItems = builder.catalogItems;
- }
-
- public Map<String, String> getEntities() {
- return Collections.unmodifiableMap(entities);
- }
-
- public Map<String, String> getLocations() {
- return Collections.unmodifiableMap(locations);
- }
-
- public Map<String, String> getPolicies() {
- return Collections.unmodifiableMap(policies);
- }
-
- public Map<String, String> getEnrichers() {
- return Collections.unmodifiableMap(enrichers);
- }
-
- public Map<String, String> getFeeds() {
- return Collections.unmodifiableMap(feeds);
- }
-
- public Map<String, String> getCatalogItems() {
- return Collections.unmodifiableMap(catalogItems);
- }
-
- // to handle reset catalog
- @Beta
- public void clearCatalogItems() {
- catalogItems.clear();
- }
-
- public boolean isEmpty() {
- return entities.isEmpty() && locations.isEmpty() && policies.isEmpty() && enrichers.isEmpty() && feeds.isEmpty() && catalogItems.isEmpty();
- }
-
- public Map<String, String> getObjectsOfType(BrooklynObjectType type) {
- switch (type) {
- case ENTITY: return getEntities();
- case LOCATION: return getLocations();
- case POLICY: return getPolicies();
- case ENRICHER: return getEnrichers();
- case FEED: return getFeeds();
- case CATALOG_ITEM: return getCatalogItems();
- default:
- throw new IllegalArgumentException("Type "+type+" not supported");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/mementos/CatalogItemMemento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/mementos/CatalogItemMemento.java b/api/src/main/java/brooklyn/mementos/CatalogItemMemento.java
deleted file mode 100644
index d4b3fea..0000000
--- a/api/src/main/java/brooklyn/mementos/CatalogItemMemento.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.mementos;
-
-import java.util.Collection;
-
-import org.apache.brooklyn.catalog.CatalogItem;
-
-public interface CatalogItemMemento extends Memento {
-
- String getDescription();
-
- String getSymbolicName();
-
- String getIconUrl();
-
- String getVersion();
-
- String getPlanYaml();
-
- String getJavaType();
-
- Collection<CatalogItem.CatalogBundle> getLibraries();
-
- CatalogItem.CatalogItemType getCatalogItemType();
-
- Class<?> getCatalogItemJavaType();
-
- Class<?> getSpecType();
-
- boolean isDeprecated();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/mementos/EnricherMemento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/mementos/EnricherMemento.java b/api/src/main/java/brooklyn/mementos/EnricherMemento.java
deleted file mode 100644
index db7a007..0000000
--- a/api/src/main/java/brooklyn/mementos/EnricherMemento.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.mementos;
-
-import java.util.Map;
-
-import brooklyn.entity.rebind.RebindSupport;
-
-/**
- * Represents the state of an enricher, so that it can be reconstructed (e.g. after restarting brooklyn).
- *
- * @see RebindSupport
- */
-public interface EnricherMemento extends Memento {
-
- Map<String, Object> getConfig();
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/mementos/EntityMemento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/mementos/EntityMemento.java b/api/src/main/java/brooklyn/mementos/EntityMemento.java
deleted file mode 100644
index 0d23d7d..0000000
--- a/api/src/main/java/brooklyn/mementos/EntityMemento.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.mementos;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import brooklyn.config.ConfigKey;
-import brooklyn.entity.Effector;
-import brooklyn.entity.rebind.RebindSupport;
-import brooklyn.event.AttributeSensor;
-
-/**
- * Represents the state of an entity, so that it can be reconstructed (e.g. after restarting brooklyn).
- *
- * @see RebindSupport
- *
- * @author aled
- */
-public interface EntityMemento extends Memento, TreeNode {
-
- /** all dynamic effectors (ie differences between those registered on the entity type */
- public List<Effector<?>> getEffectors();
-
- public Map<ConfigKey<?>, Object> getConfig();
-
- /** true if the entity is top-level (parentless) and an application
- * (there may be parentless "orphaned" entities, for which this is false,
- * and "application" instances nested inside other apps, for which this is again)
- */
- public boolean isTopLevelApp();
-
- public Map<String, Object> getConfigUnmatched();
-
- public Map<AttributeSensor<?>, Object> getAttributes();
-
- /**
- * The ids of the member entities, if this is a Group; otherwise empty.
- *
- * @see Group.getMembers()
- */
- public List<String> getMembers();
-
- /**
- * The ids of the locations for this entity.
- */
- public List<String> getLocations();
-
- /**
- * The ids of the policies of this entity.
- */
- public Collection<String> getPolicies();
-
- /**
- * The ids of the enrichers of this entity.
- */
- public Collection<String> getEnrichers();
-
- /**
- * The ids of the sensor feeds attached to this entity.
- */
- public Collection<String> getFeeds();
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/mementos/FeedMemento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/mementos/FeedMemento.java b/api/src/main/java/brooklyn/mementos/FeedMemento.java
deleted file mode 100644
index 42db6a4..0000000
--- a/api/src/main/java/brooklyn/mementos/FeedMemento.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.mementos;
-
-import java.util.Map;
-
-import brooklyn.entity.rebind.RebindSupport;
-
-/**
- * Represents the state of a feed, so that it can be reconstructed (e.g. after restarting brooklyn).
- *
- * @see RebindSupport
- */
-public interface FeedMemento extends Memento {
-
- Map<String, Object> getConfig();
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/mementos/LocationMemento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/mementos/LocationMemento.java b/api/src/main/java/brooklyn/mementos/LocationMemento.java
deleted file mode 100644
index ea3a9bc..0000000
--- a/api/src/main/java/brooklyn/mementos/LocationMemento.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.mementos;
-
-import java.util.Map;
-import java.util.Set;
-
-import brooklyn.entity.rebind.RebindSupport;
-
-/**
- * Represents the state of a location, so that it can be reconstructed (e.g. after restarting brooklyn).
- *
- * @see RebindSupport
- *
- * @author aled
- */
-public interface LocationMemento extends TreeNode, Memento {
-
- Map<String, Object> getLocationConfig();
- Set<String> getLocationConfigUnused();
- String getLocationConfigDescription();
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/mementos/Memento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/mementos/Memento.java b/api/src/main/java/brooklyn/mementos/Memento.java
deleted file mode 100644
index 35b54f9..0000000
--- a/api/src/main/java/brooklyn/mementos/Memento.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.mementos;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Map;
-
-import org.apache.brooklyn.policy.EntityAdjunct;
-
-import brooklyn.entity.Entity;
-import brooklyn.entity.rebind.RebindSupport;
-
-/**
- * Represents the internal state of something in brooklyn, so that it can be reconstructed (e.g. after restarting brooklyn).
- *
- * @see RebindSupport
- *
- * @author aled
- */
-public interface Memento extends Serializable {
-
- /**
- * The version of brooklyn used when this memento was generated.
- */
- String getBrooklynVersion();
-
- String getId();
-
- public String getType();
-
- public String getCatalogItemId();
-
- public String getDisplayName();
-
- /**
- * A (weakly-typed) property set for this memento.
- * These can be used to avoid sub-classing the entity memento, but developers can sub-class to get strong typing if desired.
- *
- * @deprecated since 0.7.0; use config/attributes so generic persistence will work, rather than requiring "custom fields"
- */
- @Deprecated
- public Object getCustomField(String name);
-
- /**
- * @deprecated since 0.7.0; use config/attributes so generic persistence will work, rather than requiring "custom fields"
- */
- @Deprecated
- public Map<String, ? extends Object> getCustomFields();
-
- public String toVerboseString();
-
- public void injectTypeClass(Class<?> clazz);
-
- /**
- * Returns the injected type class, or null if not injected.
- * <p>
- * This is useful for ensuring the correct classloader is used (e.g. for {@link EntityMemento}
- * previously calling {@code EntityTypes.getDefinedSensors(getType())}.
- */
- public Class<?> getTypeClass();
-
- public Collection<Object> getTags();
-
- /** Null for {@link Entity}, but important for adjuncts; see {@link EntityAdjunct#getUniqueTag()} */
- public String getUniqueTag();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/mementos/PolicyMemento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/mementos/PolicyMemento.java b/api/src/main/java/brooklyn/mementos/PolicyMemento.java
deleted file mode 100644
index 491bfd4..0000000
--- a/api/src/main/java/brooklyn/mementos/PolicyMemento.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.mementos;
-
-import java.util.Map;
-
-import brooklyn.entity.rebind.RebindSupport;
-
-/**
- * Represents the state of an policy, so that it can be reconstructed (e.g. after restarting brooklyn).
- *
- * @see RebindSupport
- *
- * @author aled
- */
-public interface PolicyMemento extends Memento {
-
- Map<String, Object> getConfig();
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/brooklyn/mementos/TreeNode.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/mementos/TreeNode.java b/api/src/main/java/brooklyn/mementos/TreeNode.java
deleted file mode 100644
index 0c67d8f..0000000
--- a/api/src/main/java/brooklyn/mementos/TreeNode.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.mementos;
-
-import java.util.List;
-
-/**
- * A simple tree structure, where a node references a parent and children using their ids.
- *
- * e.g. could be used to represent the entity hierarchy within mementos, where the
- * String is the id of parent/child entities.
- *
- * @author aled
- */
-public interface TreeNode {
-
- /**
- * The id of this node in the tree. This id will be used by the parent's getChildren(),
- * and by each child's getParent().
- */
- String getId();
-
- /**
- * The id of the parent entity, or null if none.
- */
- String getParent();
-
- /**
- * The ids of the children.
- */
- List<String> getChildren();
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/org/apache/brooklyn/catalog/CatalogItem.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/catalog/CatalogItem.java b/api/src/main/java/org/apache/brooklyn/catalog/CatalogItem.java
index 97560a4..dc05961 100644
--- a/api/src/main/java/org/apache/brooklyn/catalog/CatalogItem.java
+++ b/api/src/main/java/org/apache/brooklyn/catalog/CatalogItem.java
@@ -22,10 +22,11 @@ import java.util.Collection;
import javax.annotation.Nullable;
+import org.apache.brooklyn.mementos.CatalogItemMemento;
+
import brooklyn.basic.BrooklynObject;
import brooklyn.entity.rebind.RebindSupport;
import brooklyn.entity.rebind.Rebindable;
-import brooklyn.mementos.CatalogItemMemento;
import com.google.common.annotations.Beta;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMemento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMemento.java b/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMemento.java
new file mode 100644
index 0000000..836b7e8
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMemento.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.mementos;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * Represents an entire persisted Brooklyn management context, with all its entities and locations.
+ *
+ * The referential integrity of this memento is not guaranteed. For example, an entity memento might
+ * reference a child entity that does not exist. This is an inevitable consequence of not using a
+ * stop-the-world persistence strategy, and is essential for a distributed brooklyn to be performant.
+ *
+ * Code using this memento should be tolerant of such inconsistencies (e.g. log a warning about the
+ * missing entity, and then ignore dangling references when constructing the entities/locations, so
+ * that code will not subsequently get NPEs when iterating over children for example).
+ *
+ * @author aled
+ */
+public interface BrooklynMemento extends Serializable {
+
+ public EntityMemento getEntityMemento(String id);
+ public LocationMemento getLocationMemento(String id);
+ public PolicyMemento getPolicyMemento(String id);
+ public EnricherMemento getEnricherMemento(String id);
+ public FeedMemento getFeedMemento(String id);
+ public CatalogItemMemento getCatalogItemMemento(String id);
+
+ public Collection<String> getApplicationIds();
+ public Collection<String> getTopLevelLocationIds();
+
+ public Collection<String> getEntityIds();
+ public Collection<String> getLocationIds();
+ public Collection<String> getPolicyIds();
+ public Collection<String> getEnricherIds();
+ public Collection<String> getFeedIds();
+ public Collection<String> getCatalogItemIds();
+
+ public Map<String, EntityMemento> getEntityMementos();
+ public Map<String, LocationMemento> getLocationMementos();
+ public Map<String, PolicyMemento> getPolicyMementos();
+ public Map<String, EnricherMemento> getEnricherMementos();
+ public Map<String, FeedMemento> getFeedMementos();
+ public Map<String, CatalogItemMemento> getCatalogItemMementos();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMementoManifest.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMementoManifest.java b/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMementoManifest.java
new file mode 100644
index 0000000..99c53c6
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMementoManifest.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.mementos;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Map;
+
+import brooklyn.entity.trait.Identifiable;
+
+/**
+ * Represents a manifest of the entities etc in the overall memento.
+ *
+ * @author aled
+ */
+public interface BrooklynMementoManifest extends Serializable {
+ public interface EntityMementoManifest extends Identifiable{
+ public String getId();
+ public String getType();
+ public String getParent();
+ public String getCatalogItemId();
+ }
+
+ public Map<String, EntityMementoManifest> getEntityIdToManifest();
+
+ public Map<String, String> getLocationIdToType();
+
+ public Map<String, String> getPolicyIdToType();
+
+ public Map<String, String> getEnricherIdToType();
+
+ public Map<String, String> getFeedIdToType();
+
+ public CatalogItemMemento getCatalogItemMemento(String id);
+
+ public Collection<String> getCatalogItemIds();
+
+ public Map<String, CatalogItemMemento> getCatalogItemMementos();
+
+ public boolean isEmpty();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMementoPersister.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMementoPersister.java b/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMementoPersister.java
new file mode 100644
index 0000000..c888fcf
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMementoPersister.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.mementos;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Set;
+import java.util.concurrent.TimeoutException;
+
+import javax.annotation.Nullable;
+
+import brooklyn.basic.BrooklynObject;
+
+import org.apache.brooklyn.catalog.CatalogItem;
+import org.apache.brooklyn.policy.Enricher;
+import org.apache.brooklyn.policy.Policy;
+
+import brooklyn.entity.Entity;
+import brooklyn.entity.Feed;
+import brooklyn.entity.rebind.BrooklynObjectType;
+import brooklyn.entity.rebind.PersistenceExceptionHandler;
+import brooklyn.entity.rebind.RebindExceptionHandler;
+import brooklyn.entity.rebind.RebindManager;
+import brooklyn.location.Location;
+import brooklyn.management.ManagementContext;
+import brooklyn.util.time.Duration;
+
+import com.google.common.annotations.Beta;
+import com.google.common.annotations.VisibleForTesting;
+
+/**
+ * Controls the persisting and reading back of mementos. Used by {@link RebindManager}
+ * to support brooklyn restart.
+ */
+public interface BrooklynMementoPersister {
+
+ public static interface LookupContext {
+ ManagementContext lookupManagementContext();
+ Entity lookupEntity(String id);
+ Location lookupLocation(String id);
+ Policy lookupPolicy(String id);
+ Enricher lookupEnricher(String id);
+ Feed lookupFeed(String id);
+ CatalogItem<?, ?> lookupCatalogItem(String id);
+
+ BrooklynObject lookup(BrooklynObjectType type, String objectId);
+ /** like {@link #lookup(BrooklynObjectType, String)} but doesn't record an exception if not found */
+ BrooklynObject peek(BrooklynObjectType type, String objectId);
+ }
+
+ /**
+ * Loads raw data contents of the mementos.
+ * <p>
+ * Some classes (esp deprecated ones) may return null here,
+ * meaning that the {@link #loadMementoManifest(BrooklynMementoRawData, RebindExceptionHandler)}
+ * and {@link #loadMemento(BrooklynMementoRawData, LookupContext, RebindExceptionHandler)} methods
+ * will populate the raw data via another source.
+ */
+ BrooklynMementoRawData loadMementoRawData(RebindExceptionHandler exceptionHandler);
+
+ /**
+ * Loads minimal manifest information (almost entirely *not* deserialized).
+ * Implementations should load the raw data if {@link BrooklynMementoRawData} is not supplied,
+ * but callers are encouraged to supply that for optimal performance.
+ */
+ BrooklynMementoManifest loadMementoManifest(@Nullable BrooklynMementoRawData mementoData, RebindExceptionHandler exceptionHandler) throws IOException;
+
+ /**
+ * Retrieves the memento class, containing deserialized objects (but not the {@link BrooklynObject} class).
+ * Implementations should load the raw data if {@link BrooklynMementoRawData} is not supplied,
+ * but callers are encouraged to supply that for optimal performance.
+ * <p>
+ * Note that this method is *not* thread safe.
+ */
+ BrooklynMemento loadMemento(@Nullable BrooklynMementoRawData mementoData, LookupContext lookupContext, RebindExceptionHandler exceptionHandler) throws IOException;
+
+ /** applies a full checkpoint (write) of all state */
+ void checkpoint(BrooklynMementoRawData newMemento, PersistenceExceptionHandler exceptionHandler);
+ /** applies a partial write of state delta */
+ void delta(Delta delta, PersistenceExceptionHandler exceptionHandler);
+ /** inserts an additional delta to be written on the next delta request */
+ @Beta
+ void queueDelta(Delta delta);
+
+ void enableWriteAccess();
+ void disableWriteAccess(boolean graceful);
+ /** permanently shuts down all access to the remote store */
+ void stop(boolean graceful);
+
+ @VisibleForTesting
+ void waitForWritesCompleted(Duration timeout) throws InterruptedException, TimeoutException;
+
+ String getBackingStoreDescription();
+
+ /** All methods on this interface are unmodifiable by the caller. Sub-interfaces may introduce modifiers. */
+ // NB: the type-specific methods aren't actually used anymore; we could remove them to simplify the impl (and use a multiset there)
+ public interface Delta {
+ Collection<LocationMemento> locations();
+ Collection<EntityMemento> entities();
+ Collection<PolicyMemento> policies();
+ Collection<EnricherMemento> enrichers();
+ Collection<FeedMemento> feeds();
+ Collection<CatalogItemMemento> catalogItems();
+
+ Collection<String> removedLocationIds();
+ Collection<String> removedEntityIds();
+ Collection<String> removedPolicyIds();
+ Collection<String> removedEnricherIds();
+ Collection<String> removedFeedIds();
+ Collection<String> removedCatalogItemIds();
+
+ Collection<? extends Memento> getObjectsOfType(BrooklynObjectType type);
+ Collection<String> getRemovedIdsOfType(BrooklynObjectType type);
+ }
+
+ @Beta
+ public interface MutableDelta extends Delta {
+ void add(BrooklynObjectType type, Memento memento);
+ void addAll(BrooklynObjectType type, Iterable<? extends Memento> memento);
+ void removed(BrooklynObjectType type, Set<String> removedIdsOfType);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMementoRawData.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMementoRawData.java b/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMementoRawData.java
new file mode 100644
index 0000000..d48db0f
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMementoRawData.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.mementos;
+
+import java.util.Collections;
+import java.util.Map;
+
+import brooklyn.entity.rebind.BrooklynObjectType;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.Maps;
+
+/**
+ * Represents the raw persisted data.
+ */
+@Beta
+public class BrooklynMementoRawData {
+
+ // TODO Should this be on an interface?
+ // The file-based (or object-store based) structure for storing data may well change; is this representation sufficient?
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ protected String brooklynVersion;
+ protected final Map<String, String> entities = Maps.newConcurrentMap();
+ protected final Map<String, String> locations = Maps.newConcurrentMap();
+ protected final Map<String, String> policies = Maps.newConcurrentMap();
+ protected final Map<String, String> enrichers = Maps.newConcurrentMap();
+ protected final Map<String, String> feeds = Maps.newConcurrentMap();
+ protected final Map<String, String> catalogItems = Maps.newConcurrentMap();
+
+ public Builder brooklynVersion(String val) {
+ brooklynVersion = val; return this;
+ }
+ public Builder entity(String id, String val) {
+ entities.put(id, val); return this;
+ }
+ public Builder entities(Map<String, String> vals) {
+ entities.putAll(vals); return this;
+ }
+ public Builder location(String id, String val) {
+ locations.put(id, val); return this;
+ }
+ public Builder locations(Map<String, String> vals) {
+ locations.putAll(vals); return this;
+ }
+ public Builder policy(String id, String val) {
+ policies.put(id, val); return this;
+ }
+ public Builder policies(Map<String, String> vals) {
+ policies.putAll(vals); return this;
+ }
+ public Builder enricher(String id, String val) {
+ enrichers.put(id, val); return this;
+ }
+ public Builder enrichers(Map<String, String> vals) {
+ enrichers.putAll(vals); return this;
+ }
+ public Builder feed(String id, String val) {
+ feeds.put(id, val); return this;
+ }
+ public Builder feeds(Map<String, String> vals) {
+ feeds.putAll(vals); return this;
+ }
+ public Builder catalogItem(String id, String val) {
+ catalogItems.put(id, val); return this;
+ }
+ public Builder catalogItems(Map<String, String> vals) {
+ catalogItems.putAll(vals); return this;
+ }
+
+ public Builder put(BrooklynObjectType type, String id, String val) {
+ switch (type) {
+ case ENTITY: return entity(id, val);
+ case LOCATION: return location(id, val);
+ case POLICY: return policy(id, val);
+ case ENRICHER: return enricher(id, val);
+ case FEED: return feed(id, val);
+ case CATALOG_ITEM: return catalogItem(id, val);
+ case UNKNOWN:
+ default:
+ throw new IllegalArgumentException(type+" not supported");
+ }
+ }
+ public Builder putAll(BrooklynObjectType type, Map<String,String> vals) {
+ switch (type) {
+ case ENTITY: return entities(vals);
+ case LOCATION: return locations(vals);
+ case POLICY: return policies(vals);
+ case ENRICHER: return enrichers(vals);
+ case FEED: return feeds(vals);
+ case CATALOG_ITEM: return catalogItems(vals);
+ case UNKNOWN:
+ default:
+ throw new IllegalArgumentException(type+" not supported");
+ }
+ }
+
+ public BrooklynMementoRawData build() {
+ return new BrooklynMementoRawData(this);
+ }
+ }
+
+ private final Map<String, String> entities;
+ private final Map<String, String> locations;
+ private final Map<String, String> policies;
+ private final Map<String, String> enrichers;
+ private final Map<String, String> feeds;
+ private final Map<String, String> catalogItems;
+
+ private BrooklynMementoRawData(Builder builder) {
+ entities = builder.entities;
+ locations = builder.locations;
+ policies = builder.policies;
+ enrichers = builder.enrichers;
+ feeds = builder.feeds;
+ catalogItems = builder.catalogItems;
+ }
+
+ public Map<String, String> getEntities() {
+ return Collections.unmodifiableMap(entities);
+ }
+
+ public Map<String, String> getLocations() {
+ return Collections.unmodifiableMap(locations);
+ }
+
+ public Map<String, String> getPolicies() {
+ return Collections.unmodifiableMap(policies);
+ }
+
+ public Map<String, String> getEnrichers() {
+ return Collections.unmodifiableMap(enrichers);
+ }
+
+ public Map<String, String> getFeeds() {
+ return Collections.unmodifiableMap(feeds);
+ }
+
+ public Map<String, String> getCatalogItems() {
+ return Collections.unmodifiableMap(catalogItems);
+ }
+
+ // to handle reset catalog
+ @Beta
+ public void clearCatalogItems() {
+ catalogItems.clear();
+ }
+
+ public boolean isEmpty() {
+ return entities.isEmpty() && locations.isEmpty() && policies.isEmpty() && enrichers.isEmpty() && feeds.isEmpty() && catalogItems.isEmpty();
+ }
+
+ public Map<String, String> getObjectsOfType(BrooklynObjectType type) {
+ switch (type) {
+ case ENTITY: return getEntities();
+ case LOCATION: return getLocations();
+ case POLICY: return getPolicies();
+ case ENRICHER: return getEnrichers();
+ case FEED: return getFeeds();
+ case CATALOG_ITEM: return getCatalogItems();
+ default:
+ throw new IllegalArgumentException("Type "+type+" not supported");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/org/apache/brooklyn/mementos/CatalogItemMemento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/mementos/CatalogItemMemento.java b/api/src/main/java/org/apache/brooklyn/mementos/CatalogItemMemento.java
new file mode 100644
index 0000000..5a0edda
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/mementos/CatalogItemMemento.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.mementos;
+
+import java.util.Collection;
+
+import org.apache.brooklyn.catalog.CatalogItem;
+
+public interface CatalogItemMemento extends Memento {
+
+ String getDescription();
+
+ String getSymbolicName();
+
+ String getIconUrl();
+
+ String getVersion();
+
+ String getPlanYaml();
+
+ String getJavaType();
+
+ Collection<CatalogItem.CatalogBundle> getLibraries();
+
+ CatalogItem.CatalogItemType getCatalogItemType();
+
+ Class<?> getCatalogItemJavaType();
+
+ Class<?> getSpecType();
+
+ boolean isDeprecated();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/org/apache/brooklyn/mementos/EnricherMemento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/mementos/EnricherMemento.java b/api/src/main/java/org/apache/brooklyn/mementos/EnricherMemento.java
new file mode 100644
index 0000000..c2e89b5
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/mementos/EnricherMemento.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.mementos;
+
+import java.util.Map;
+
+import brooklyn.entity.rebind.RebindSupport;
+
+/**
+ * Represents the state of an enricher, so that it can be reconstructed (e.g. after restarting brooklyn).
+ *
+ * @see RebindSupport
+ */
+public interface EnricherMemento extends Memento {
+
+ Map<String, Object> getConfig();
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/org/apache/brooklyn/mementos/EntityMemento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/mementos/EntityMemento.java b/api/src/main/java/org/apache/brooklyn/mementos/EntityMemento.java
new file mode 100644
index 0000000..4a5f902
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/mementos/EntityMemento.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.mementos;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import brooklyn.config.ConfigKey;
+import brooklyn.entity.Effector;
+import brooklyn.entity.rebind.RebindSupport;
+import brooklyn.event.AttributeSensor;
+
+/**
+ * Represents the state of an entity, so that it can be reconstructed (e.g. after restarting brooklyn).
+ *
+ * @see RebindSupport
+ *
+ * @author aled
+ */
+public interface EntityMemento extends Memento, TreeNode {
+
+ /** all dynamic effectors (ie differences between those registered on the entity type */
+ public List<Effector<?>> getEffectors();
+
+ public Map<ConfigKey<?>, Object> getConfig();
+
+ /** true if the entity is top-level (parentless) and an application
+ * (there may be parentless "orphaned" entities, for which this is false,
+ * and "application" instances nested inside other apps, for which this is again)
+ */
+ public boolean isTopLevelApp();
+
+ public Map<String, Object> getConfigUnmatched();
+
+ public Map<AttributeSensor<?>, Object> getAttributes();
+
+ /**
+ * The ids of the member entities, if this is a Group; otherwise empty.
+ *
+ * @see Group.getMembers()
+ */
+ public List<String> getMembers();
+
+ /**
+ * The ids of the locations for this entity.
+ */
+ public List<String> getLocations();
+
+ /**
+ * The ids of the policies of this entity.
+ */
+ public Collection<String> getPolicies();
+
+ /**
+ * The ids of the enrichers of this entity.
+ */
+ public Collection<String> getEnrichers();
+
+ /**
+ * The ids of the sensor feeds attached to this entity.
+ */
+ public Collection<String> getFeeds();
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/org/apache/brooklyn/mementos/FeedMemento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/mementos/FeedMemento.java b/api/src/main/java/org/apache/brooklyn/mementos/FeedMemento.java
new file mode 100644
index 0000000..f3b30f3
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/mementos/FeedMemento.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.mementos;
+
+import java.util.Map;
+
+import brooklyn.entity.rebind.RebindSupport;
+
+/**
+ * Represents the state of a feed, so that it can be reconstructed (e.g. after restarting brooklyn).
+ *
+ * @see RebindSupport
+ */
+public interface FeedMemento extends Memento {
+
+ Map<String, Object> getConfig();
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/org/apache/brooklyn/mementos/LocationMemento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/mementos/LocationMemento.java b/api/src/main/java/org/apache/brooklyn/mementos/LocationMemento.java
new file mode 100644
index 0000000..5d6cc84
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/mementos/LocationMemento.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.mementos;
+
+import java.util.Map;
+import java.util.Set;
+
+import brooklyn.entity.rebind.RebindSupport;
+
+/**
+ * Represents the state of a location, so that it can be reconstructed (e.g. after restarting brooklyn).
+ *
+ * @see RebindSupport
+ *
+ * @author aled
+ */
+public interface LocationMemento extends TreeNode, Memento {
+
+ Map<String, Object> getLocationConfig();
+ Set<String> getLocationConfigUnused();
+ String getLocationConfigDescription();
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/org/apache/brooklyn/mementos/Memento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/mementos/Memento.java b/api/src/main/java/org/apache/brooklyn/mementos/Memento.java
new file mode 100644
index 0000000..25dea5b
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/mementos/Memento.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.mementos;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.brooklyn.policy.EntityAdjunct;
+
+import brooklyn.entity.Entity;
+import brooklyn.entity.rebind.RebindSupport;
+
+/**
+ * Represents the internal state of something in brooklyn, so that it can be reconstructed (e.g. after restarting brooklyn).
+ *
+ * @see RebindSupport
+ *
+ * @author aled
+ */
+public interface Memento extends Serializable {
+
+ /**
+ * The version of brooklyn used when this memento was generated.
+ */
+ String getBrooklynVersion();
+
+ String getId();
+
+ public String getType();
+
+ public String getCatalogItemId();
+
+ public String getDisplayName();
+
+ /**
+ * A (weakly-typed) property set for this memento.
+ * These can be used to avoid sub-classing the entity memento, but developers can sub-class to get strong typing if desired.
+ *
+ * @deprecated since 0.7.0; use config/attributes so generic persistence will work, rather than requiring "custom fields"
+ */
+ @Deprecated
+ public Object getCustomField(String name);
+
+ /**
+ * @deprecated since 0.7.0; use config/attributes so generic persistence will work, rather than requiring "custom fields"
+ */
+ @Deprecated
+ public Map<String, ? extends Object> getCustomFields();
+
+ public String toVerboseString();
+
+ public void injectTypeClass(Class<?> clazz);
+
+ /**
+ * Returns the injected type class, or null if not injected.
+ * <p>
+ * This is useful for ensuring the correct classloader is used (e.g. for {@link EntityMemento}
+ * previously calling {@code EntityTypes.getDefinedSensors(getType())}.
+ */
+ public Class<?> getTypeClass();
+
+ public Collection<Object> getTags();
+
+ /** Null for {@link Entity}, but important for adjuncts; see {@link EntityAdjunct#getUniqueTag()} */
+ public String getUniqueTag();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/org/apache/brooklyn/mementos/PolicyMemento.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/mementos/PolicyMemento.java b/api/src/main/java/org/apache/brooklyn/mementos/PolicyMemento.java
new file mode 100644
index 0000000..ee75801
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/mementos/PolicyMemento.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.mementos;
+
+import java.util.Map;
+
+import brooklyn.entity.rebind.RebindSupport;
+
+/**
+ * Represents the state of an policy, so that it can be reconstructed (e.g. after restarting brooklyn).
+ *
+ * @see RebindSupport
+ *
+ * @author aled
+ */
+public interface PolicyMemento extends Memento {
+
+ Map<String, Object> getConfig();
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/org/apache/brooklyn/mementos/TreeNode.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/mementos/TreeNode.java b/api/src/main/java/org/apache/brooklyn/mementos/TreeNode.java
new file mode 100644
index 0000000..d150f03
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/mementos/TreeNode.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.mementos;
+
+import java.util.List;
+
+/**
+ * A simple tree structure, where a node references a parent and children using their ids.
+ *
+ * e.g. could be used to represent the entity hierarchy within mementos, where the
+ * String is the id of parent/child entities.
+ *
+ * @author aled
+ */
+public interface TreeNode {
+
+ /**
+ * The id of this node in the tree. This id will be used by the parent's getChildren(),
+ * and by each child's getParent().
+ */
+ String getId();
+
+ /**
+ * The id of the parent entity, or null if none.
+ */
+ String getParent();
+
+ /**
+ * The ids of the children.
+ */
+ List<String> getChildren();
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/88b9219a/api/src/main/java/org/apache/brooklyn/policy/Enricher.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/policy/Enricher.java b/api/src/main/java/org/apache/brooklyn/policy/Enricher.java
index 07ddce9..5897fd4 100644
--- a/api/src/main/java/org/apache/brooklyn/policy/Enricher.java
+++ b/api/src/main/java/org/apache/brooklyn/policy/Enricher.java
@@ -20,11 +20,12 @@ package org.apache.brooklyn.policy;
import java.util.Map;
+import org.apache.brooklyn.mementos.EnricherMemento;
+
import brooklyn.config.ConfigKey;
import brooklyn.entity.rebind.RebindSupport;
import brooklyn.entity.rebind.Rebindable;
import brooklyn.entity.trait.Configurable;
-import brooklyn.mementos.EnricherMemento;
import com.google.common.annotations.Beta;