[BROOKLYN-162] Move ./api/mementos to the right package
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/458d1b17 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/458d1b17 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/458d1b17 Branch: refs/heads/master Commit: 458d1b171c3e998470fb95f6d6a7607d4a7b964f Parents: d32d672 Author: Hadrian Zbarcea <[email protected]> Authored: Thu Aug 13 23:57:23 2015 -0400 Committer: Hadrian Zbarcea <[email protected]> Committed: Thu Aug 13 23:57:23 2015 -0400 ---------------------------------------------------------------------- .../brooklyn/api/catalog/CatalogItem.java | 2 +- .../org/apache/brooklyn/api/entity/Feed.java | 2 +- .../rebind/PersistenceExceptionHandler.java | 2 +- .../api/entity/rebind/RebindContext.java | 2 +- .../api/entity/rebind/RebindManager.java | 4 +- .../api/entity/rebind/RebindSupport.java | 4 +- .../brooklyn/api/entity/rebind/Rebindable.java | 2 +- .../ha/ManagementPlaneSyncRecord.java | 4 +- .../ha/ManagementPlaneSyncRecordPersister.java | 4 +- .../brooklyn/api/mementos/BrooklynMemento.java | 64 +++++++ .../api/mementos/BrooklynMementoManifest.java | 58 ++++++ .../api/mementos/BrooklynMementoPersister.java | 138 ++++++++++++++ .../api/mementos/BrooklynMementoRawData.java | 185 +++++++++++++++++++ .../api/mementos/CatalogItemMemento.java | 49 +++++ .../brooklyn/api/mementos/EnricherMemento.java | 33 ++++ .../brooklyn/api/mementos/EntityMemento.java | 81 ++++++++ .../brooklyn/api/mementos/FeedMemento.java | 33 ++++ .../brooklyn/api/mementos/LocationMemento.java | 38 ++++ .../apache/brooklyn/api/mementos/Memento.java | 83 +++++++++ .../brooklyn/api/mementos/PolicyMemento.java | 35 ++++ .../apache/brooklyn/api/mementos/TreeNode.java | 48 +++++ .../brooklyn/mementos/BrooklynMemento.java | 64 ------- .../mementos/BrooklynMementoManifest.java | 58 ------ .../mementos/BrooklynMementoPersister.java | 138 -------------- .../mementos/BrooklynMementoRawData.java | 185 ------------------- .../brooklyn/mementos/CatalogItemMemento.java | 49 ----- .../brooklyn/mementos/EnricherMemento.java | 33 ---- .../apache/brooklyn/mementos/EntityMemento.java | 81 -------- .../apache/brooklyn/mementos/FeedMemento.java | 33 ---- .../brooklyn/mementos/LocationMemento.java | 38 ---- .../org/apache/brooklyn/mementos/Memento.java | 83 --------- .../apache/brooklyn/mementos/PolicyMemento.java | 35 ---- .../org/apache/brooklyn/mementos/TreeNode.java | 48 ----- .../org/apache/brooklyn/policy/Enricher.java | 2 +- .../java/org/apache/brooklyn/policy/Policy.java | 2 +- .../catalog/internal/CatalogItemDo.java | 2 +- .../internal/CatalogItemDtoAbstract.java | 2 +- .../enricher/basic/AbstractEnricher.java | 2 +- .../brooklyn/entity/basic/AbstractEntity.java | 2 +- .../brooklyn/entity/basic/EntityInternal.java | 2 +- .../basic/EntityTransientCopyInternal.java | 2 +- .../AbstractBrooklynObjectRebindSupport.java | 2 +- .../rebind/ActivePartialRebindIteration.java | 8 +- .../rebind/BasicCatalogItemRebindSupport.java | 2 +- .../rebind/BasicEnricherRebindSupport.java | 2 +- .../entity/rebind/BasicEntityRebindSupport.java | 2 +- .../entity/rebind/BasicFeedRebindSupport.java | 2 +- .../rebind/BasicLocationRebindSupport.java | 2 +- .../entity/rebind/BasicPolicyRebindSupport.java | 2 +- .../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 | 2 +- .../rebind/dto/AbstractTreeNodeMemento.java | 4 +- .../rebind/dto/BasicCatalogItemMemento.java | 2 +- .../entity/rebind/dto/BasicEnricherMemento.java | 2 +- .../entity/rebind/dto/BasicEntityMemento.java | 6 +- .../entity/rebind/dto/BasicFeedMemento.java | 2 +- .../entity/rebind/dto/BasicLocationMemento.java | 4 +- .../entity/rebind/dto/BasicPolicyMemento.java | 2 +- .../entity/rebind/dto/BrooklynMementoImpl.java | 16 +- .../rebind/dto/BrooklynMementoManifestImpl.java | 4 +- .../rebind/dto/EntityMementoManifestImpl.java | 2 +- .../entity/rebind/dto/MementoValidators.java | 6 +- .../entity/rebind/dto/MementosGenerators.java | 16 +- .../rebind/dto/MutableBrooklynMemento.java | 14 +- .../BrooklynMementoPersisterToObjectStore.java | 12 +- .../persister/BrooklynPersistenceUtils.java | 4 +- .../rebind/persister/MementoSerializer.java | 4 +- .../persister/RetryingMementoSerializer.java | 2 +- .../rebind/persister/XmlMementoSerializer.java | 2 +- .../transformer/BrooklynMementoTransformer.java | 2 +- .../rebind/transformer/CompoundTransformer.java | 2 +- .../DeleteOrphanedLocationsTransformer.java | 6 +- .../java/brooklyn/event/feed/AbstractFeed.java | 2 +- .../NonDeploymentManagementContext.java | 4 +- .../brooklyn/policy/basic/AbstractPolicy.java | 2 +- .../location/access/PortForwardManagerImpl.java | 2 +- .../location/basic/AbstractLocation.java | 2 +- .../location/basic/LocationInternal.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 | 2 +- .../brooklyn/entity/rebind/RebindTestUtils.java | 4 +- .../BrooklynMementoPersisterTestFixture.java | 6 +- .../persister/XmlMementoSerializerTest.java | 2 +- .../transformer/CompoundTransformerTest.java | 2 +- .../brooklyn/launcher/BrooklynLauncher.java | 2 +- ...lynLauncherRebindToCloudObjectStoreTest.java | 2 +- 98 files changed, 996 insertions(+), 996 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/458d1b17/api/src/main/java/org/apache/brooklyn/api/catalog/CatalogItem.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/catalog/CatalogItem.java b/api/src/main/java/org/apache/brooklyn/api/catalog/CatalogItem.java index 8b3d394..520341f 100644 --- a/api/src/main/java/org/apache/brooklyn/api/catalog/CatalogItem.java +++ b/api/src/main/java/org/apache/brooklyn/api/catalog/CatalogItem.java @@ -25,7 +25,7 @@ import javax.annotation.Nullable; import org.apache.brooklyn.api.basic.BrooklynObject; import org.apache.brooklyn.api.entity.rebind.RebindSupport; import org.apache.brooklyn.api.entity.rebind.Rebindable; -import org.apache.brooklyn.mementos.CatalogItemMemento; +import org.apache.brooklyn.api.mementos.CatalogItemMemento; import com.google.common.annotations.Beta; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/458d1b17/api/src/main/java/org/apache/brooklyn/api/entity/Feed.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/entity/Feed.java b/api/src/main/java/org/apache/brooklyn/api/entity/Feed.java index 134f3f0..0a2205c 100644 --- a/api/src/main/java/org/apache/brooklyn/api/entity/Feed.java +++ b/api/src/main/java/org/apache/brooklyn/api/entity/Feed.java @@ -20,7 +20,7 @@ package org.apache.brooklyn.api.entity; import org.apache.brooklyn.api.entity.rebind.RebindSupport; import org.apache.brooklyn.api.entity.rebind.Rebindable; -import org.apache.brooklyn.mementos.FeedMemento; +import org.apache.brooklyn.api.mementos.FeedMemento; import org.apache.brooklyn.policy.EntityAdjunct; import com.google.common.annotations.Beta; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/458d1b17/api/src/main/java/org/apache/brooklyn/api/entity/rebind/PersistenceExceptionHandler.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/entity/rebind/PersistenceExceptionHandler.java b/api/src/main/java/org/apache/brooklyn/api/entity/rebind/PersistenceExceptionHandler.java index dafbdf2..e9f9f31 100644 --- a/api/src/main/java/org/apache/brooklyn/api/entity/rebind/PersistenceExceptionHandler.java +++ b/api/src/main/java/org/apache/brooklyn/api/entity/rebind/PersistenceExceptionHandler.java @@ -19,7 +19,7 @@ package org.apache.brooklyn.api.entity.rebind; import org.apache.brooklyn.api.basic.BrooklynObject; -import org.apache.brooklyn.mementos.Memento; +import org.apache.brooklyn.api.mementos.Memento; import com.google.common.annotations.Beta; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/458d1b17/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindContext.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindContext.java b/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindContext.java index a2b39c5..d530f3b 100644 --- a/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindContext.java +++ b/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindContext.java @@ -21,7 +21,7 @@ package org.apache.brooklyn.api.entity.rebind; import java.util.Map; import org.apache.brooklyn.api.basic.BrooklynObject; -import org.apache.brooklyn.mementos.BrooklynMementoPersister.LookupContext; +import org.apache.brooklyn.api.mementos.BrooklynMementoPersister.LookupContext; import com.google.common.annotations.Beta; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/458d1b17/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindManager.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindManager.java b/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindManager.java index 577fb58..a47faca 100644 --- a/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindManager.java +++ b/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindManager.java @@ -26,8 +26,8 @@ import javax.annotation.Nullable; import org.apache.brooklyn.api.entity.Application; import org.apache.brooklyn.api.management.ha.ManagementNodeState; -import org.apache.brooklyn.mementos.BrooklynMementoPersister; -import org.apache.brooklyn.mementos.BrooklynMementoRawData; +import org.apache.brooklyn.api.mementos.BrooklynMementoPersister; +import org.apache.brooklyn.api.mementos.BrooklynMementoRawData; import brooklyn.util.time.Duration; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/458d1b17/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindSupport.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindSupport.java b/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindSupport.java index 9cced02..e968f35 100644 --- a/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindSupport.java +++ b/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindSupport.java @@ -18,8 +18,8 @@ */ package org.apache.brooklyn.api.entity.rebind; -import org.apache.brooklyn.mementos.BrooklynMementoPersister; -import org.apache.brooklyn.mementos.Memento; +import org.apache.brooklyn.api.mementos.BrooklynMementoPersister; +import org.apache.brooklyn.api.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/458d1b17/api/src/main/java/org/apache/brooklyn/api/entity/rebind/Rebindable.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/entity/rebind/Rebindable.java b/api/src/main/java/org/apache/brooklyn/api/entity/rebind/Rebindable.java index 9a65531..ac48ae6 100644 --- a/api/src/main/java/org/apache/brooklyn/api/entity/rebind/Rebindable.java +++ b/api/src/main/java/org/apache/brooklyn/api/entity/rebind/Rebindable.java @@ -18,7 +18,7 @@ */ package org.apache.brooklyn.api.entity.rebind; -import org.apache.brooklyn.mementos.Memento; +import org.apache.brooklyn.api.mementos.Memento; import com.google.common.annotations.Beta; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/458d1b17/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecord.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecord.java b/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecord.java index 1537185..b455096 100644 --- a/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecord.java +++ b/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecord.java @@ -20,8 +20,8 @@ package org.apache.brooklyn.api.management.ha; import java.util.Map; -import org.apache.brooklyn.mementos.BrooklynMemento; -import org.apache.brooklyn.mementos.BrooklynMementoPersister; +import org.apache.brooklyn.api.mementos.BrooklynMemento; +import org.apache.brooklyn.api.mementos.BrooklynMementoPersister; import com.google.common.annotations.Beta; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/458d1b17/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecordPersister.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecordPersister.java b/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecordPersister.java index 1220865..9dfb44e 100644 --- a/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecordPersister.java +++ b/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecordPersister.java @@ -22,7 +22,7 @@ import java.io.IOException; import java.util.Collection; import java.util.concurrent.TimeoutException; -import org.apache.brooklyn.mementos.BrooklynMementoPersister; +import org.apache.brooklyn.api.mementos.BrooklynMementoPersister; import brooklyn.util.time.Duration; @@ -41,7 +41,7 @@ import com.google.common.annotations.VisibleForTesting; public interface ManagementPlaneSyncRecordPersister { /** - * Analogue to {@link BrooklynMementoPersister#loadMemento(org.apache.brooklyn.mementos.BrooklynMementoPersister.LookupContext)} + * Analogue to {@link BrooklynMementoPersister#loadMemento(org.apache.brooklyn.api.mementos.BrooklynMementoPersister.LookupContext)} * <p> * Note that this method is *not* thread safe. */ http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/458d1b17/api/src/main/java/org/apache/brooklyn/api/mementos/BrooklynMemento.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/mementos/BrooklynMemento.java b/api/src/main/java/org/apache/brooklyn/api/mementos/BrooklynMemento.java new file mode 100644 index 0000000..672fc46 --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/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.api.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/458d1b17/api/src/main/java/org/apache/brooklyn/api/mementos/BrooklynMementoManifest.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/mementos/BrooklynMementoManifest.java b/api/src/main/java/org/apache/brooklyn/api/mementos/BrooklynMementoManifest.java new file mode 100644 index 0000000..7108a7b --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/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.api.mementos; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Map; + +import org.apache.brooklyn.api.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/458d1b17/api/src/main/java/org/apache/brooklyn/api/mementos/BrooklynMementoPersister.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/mementos/BrooklynMementoPersister.java b/api/src/main/java/org/apache/brooklyn/api/mementos/BrooklynMementoPersister.java new file mode 100644 index 0000000..07a258f --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/mementos/BrooklynMementoPersister.java @@ -0,0 +1,138 @@ +/* + * 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.api.mementos; + +import java.io.IOException; +import java.util.Collection; +import java.util.Set; +import java.util.concurrent.TimeoutException; + +import javax.annotation.Nullable; + +import org.apache.brooklyn.api.basic.BrooklynObject; +import org.apache.brooklyn.api.catalog.CatalogItem; +import org.apache.brooklyn.api.entity.Entity; +import org.apache.brooklyn.api.entity.Feed; +import org.apache.brooklyn.api.entity.rebind.BrooklynObjectType; +import org.apache.brooklyn.api.entity.rebind.PersistenceExceptionHandler; +import org.apache.brooklyn.api.entity.rebind.RebindExceptionHandler; +import org.apache.brooklyn.api.entity.rebind.RebindManager; +import org.apache.brooklyn.api.location.Location; +import org.apache.brooklyn.api.management.ManagementContext; +import org.apache.brooklyn.policy.Enricher; +import org.apache.brooklyn.policy.Policy; + +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/458d1b17/api/src/main/java/org/apache/brooklyn/api/mementos/BrooklynMementoRawData.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/mementos/BrooklynMementoRawData.java b/api/src/main/java/org/apache/brooklyn/api/mementos/BrooklynMementoRawData.java new file mode 100644 index 0000000..afe1839 --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/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.api.mementos; + +import java.util.Collections; +import java.util.Map; + +import org.apache.brooklyn.api.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/458d1b17/api/src/main/java/org/apache/brooklyn/api/mementos/CatalogItemMemento.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/mementos/CatalogItemMemento.java b/api/src/main/java/org/apache/brooklyn/api/mementos/CatalogItemMemento.java new file mode 100644 index 0000000..a82cc3a --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/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.api.mementos; + +import java.util.Collection; + +import org.apache.brooklyn.api.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/458d1b17/api/src/main/java/org/apache/brooklyn/api/mementos/EnricherMemento.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/mementos/EnricherMemento.java b/api/src/main/java/org/apache/brooklyn/api/mementos/EnricherMemento.java new file mode 100644 index 0000000..cd8e60e --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/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.api.mementos; + +import java.util.Map; + +import org.apache.brooklyn.api.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/458d1b17/api/src/main/java/org/apache/brooklyn/api/mementos/EntityMemento.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/mementos/EntityMemento.java b/api/src/main/java/org/apache/brooklyn/api/mementos/EntityMemento.java new file mode 100644 index 0000000..f45e0eb --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/mementos/EntityMemento.java @@ -0,0 +1,81 @@ +/* + * 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.api.mementos; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.apache.brooklyn.api.entity.Effector; +import org.apache.brooklyn.api.entity.rebind.RebindSupport; +import org.apache.brooklyn.api.event.AttributeSensor; + +import brooklyn.config.ConfigKey; + +/** + * 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/458d1b17/api/src/main/java/org/apache/brooklyn/api/mementos/FeedMemento.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/mementos/FeedMemento.java b/api/src/main/java/org/apache/brooklyn/api/mementos/FeedMemento.java new file mode 100644 index 0000000..ac52691 --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/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.api.mementos; + +import java.util.Map; + +import org.apache.brooklyn.api.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/458d1b17/api/src/main/java/org/apache/brooklyn/api/mementos/LocationMemento.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/mementos/LocationMemento.java b/api/src/main/java/org/apache/brooklyn/api/mementos/LocationMemento.java new file mode 100644 index 0000000..fef70eb --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/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.api.mementos; + +import java.util.Map; +import java.util.Set; + +import org.apache.brooklyn.api.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/458d1b17/api/src/main/java/org/apache/brooklyn/api/mementos/Memento.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/mementos/Memento.java b/api/src/main/java/org/apache/brooklyn/api/mementos/Memento.java new file mode 100644 index 0000000..8c4a005 --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/mementos/Memento.java @@ -0,0 +1,83 @@ +/* + * 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.api.mementos; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Map; + +import org.apache.brooklyn.api.entity.Entity; +import org.apache.brooklyn.api.entity.rebind.RebindSupport; +import org.apache.brooklyn.policy.EntityAdjunct; + +/** + * 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/458d1b17/api/src/main/java/org/apache/brooklyn/api/mementos/PolicyMemento.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/mementos/PolicyMemento.java b/api/src/main/java/org/apache/brooklyn/api/mementos/PolicyMemento.java new file mode 100644 index 0000000..d19d84a --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/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.api.mementos; + +import java.util.Map; + +import org.apache.brooklyn.api.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/458d1b17/api/src/main/java/org/apache/brooklyn/api/mementos/TreeNode.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/mementos/TreeNode.java b/api/src/main/java/org/apache/brooklyn/api/mementos/TreeNode.java new file mode 100644 index 0000000..5571f1e --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/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.api.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/458d1b17/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 deleted file mode 100644 index 836b7e8..0000000 --- a/api/src/main/java/org/apache/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 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/458d1b17/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 deleted file mode 100644 index 3341a0f..0000000 --- a/api/src/main/java/org/apache/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 org.apache.brooklyn.mementos; - -import java.io.Serializable; -import java.util.Collection; -import java.util.Map; - -import org.apache.brooklyn.api.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/458d1b17/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 deleted file mode 100644 index 4727f50..0000000 --- a/api/src/main/java/org/apache/brooklyn/mementos/BrooklynMementoPersister.java +++ /dev/null @@ -1,138 +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 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 org.apache.brooklyn.api.basic.BrooklynObject; -import org.apache.brooklyn.api.catalog.CatalogItem; -import org.apache.brooklyn.api.entity.Entity; -import org.apache.brooklyn.api.entity.Feed; -import org.apache.brooklyn.api.entity.rebind.BrooklynObjectType; -import org.apache.brooklyn.api.entity.rebind.PersistenceExceptionHandler; -import org.apache.brooklyn.api.entity.rebind.RebindExceptionHandler; -import org.apache.brooklyn.api.entity.rebind.RebindManager; -import org.apache.brooklyn.api.location.Location; -import org.apache.brooklyn.api.management.ManagementContext; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.Policy; - -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/458d1b17/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 deleted file mode 100644 index ea77e90..0000000 --- a/api/src/main/java/org/apache/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 org.apache.brooklyn.mementos; - -import java.util.Collections; -import java.util.Map; - -import org.apache.brooklyn.api.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/458d1b17/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 deleted file mode 100644 index 3bf84d0..0000000 --- a/api/src/main/java/org/apache/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 org.apache.brooklyn.mementos; - -import java.util.Collection; - -import org.apache.brooklyn.api.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/458d1b17/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 deleted file mode 100644 index c3458fd..0000000 --- a/api/src/main/java/org/apache/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 org.apache.brooklyn.mementos; - -import java.util.Map; - -import org.apache.brooklyn.api.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/458d1b17/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 deleted file mode 100644 index 2b1fb14..0000000 --- a/api/src/main/java/org/apache/brooklyn/mementos/EntityMemento.java +++ /dev/null @@ -1,81 +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 org.apache.brooklyn.mementos; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.apache.brooklyn.api.entity.Effector; -import org.apache.brooklyn.api.entity.rebind.RebindSupport; -import org.apache.brooklyn.api.event.AttributeSensor; - -import brooklyn.config.ConfigKey; - -/** - * 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/458d1b17/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 deleted file mode 100644 index e9e371b..0000000 --- a/api/src/main/java/org/apache/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 org.apache.brooklyn.mementos; - -import java.util.Map; - -import org.apache.brooklyn.api.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/458d1b17/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 deleted file mode 100644 index 92d378f..0000000 --- a/api/src/main/java/org/apache/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 org.apache.brooklyn.mementos; - -import java.util.Map; -import java.util.Set; - -import org.apache.brooklyn.api.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/458d1b17/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 deleted file mode 100644 index d63d003..0000000 --- a/api/src/main/java/org/apache/brooklyn/mementos/Memento.java +++ /dev/null @@ -1,83 +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 org.apache.brooklyn.mementos; - -import java.io.Serializable; -import java.util.Collection; -import java.util.Map; - -import org.apache.brooklyn.api.entity.Entity; -import org.apache.brooklyn.api.entity.rebind.RebindSupport; -import org.apache.brooklyn.policy.EntityAdjunct; - -/** - * 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/458d1b17/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 deleted file mode 100644 index b9b5e7b..0000000 --- a/api/src/main/java/org/apache/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 org.apache.brooklyn.mementos; - -import java.util.Map; - -import org.apache.brooklyn.api.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(); -}
