[BROOKLYN-162] Move ./api/policy 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/904f9508 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/904f9508 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/904f9508 Branch: refs/heads/master Commit: 904f9508035fc9e56c99c35b92786def7e33e729 Parents: 458d1b1 Author: Hadrian Zbarcea <[email protected]> Authored: Fri Aug 14 00:09:18 2015 -0400 Committer: Hadrian Zbarcea <[email protected]> Committed: Fri Aug 14 00:09:18 2015 -0400 ---------------------------------------------------------------------- .../org/apache/brooklyn/api/entity/Entity.java | 8 +- .../org/apache/brooklyn/api/entity/Feed.java | 2 +- .../api/entity/proxying/EntitySpec.java | 8 +- .../api/entity/rebind/BrooklynObjectType.java | 4 +- .../entity/rebind/RebindExceptionHandler.java | 4 +- .../brooklyn/api/management/EntityManager.java | 8 +- .../api/mementos/BrooklynMementoPersister.java | 4 +- .../apache/brooklyn/api/mementos/Memento.java | 2 +- .../apache/brooklyn/api/policy/Enricher.java | 71 ++++++ .../brooklyn/api/policy/EnricherSpec.java | 214 +++++++++++++++++++ .../brooklyn/api/policy/EnricherType.java | 36 ++++ .../brooklyn/api/policy/EntityAdjunct.java | 55 +++++ .../org/apache/brooklyn/api/policy/Policy.java | 83 +++++++ .../apache/brooklyn/api/policy/PolicySpec.java | 152 +++++++++++++ .../apache/brooklyn/api/policy/PolicyType.java | 36 ++++ .../org/apache/brooklyn/policy/Enricher.java | 71 ------ .../apache/brooklyn/policy/EnricherSpec.java | 214 ------------------- .../apache/brooklyn/policy/EnricherType.java | 36 ---- .../apache/brooklyn/policy/EntityAdjunct.java | 55 ----- .../java/org/apache/brooklyn/policy/Policy.java | 83 ------- .../org/apache/brooklyn/policy/PolicySpec.java | 152 ------------- .../org/apache/brooklyn/policy/PolicyType.java | 36 ---- .../main/java/brooklyn/basic/BrooklynTypes.java | 4 +- .../brooklyn/catalog/CatalogPredicates.java | 4 +- .../catalog/internal/BasicBrooklynCatalog.java | 4 +- .../catalog/internal/CatalogClasspathDo.java | 2 +- .../catalog/internal/CatalogPolicyItemDto.java | 4 +- .../main/java/brooklyn/enricher/Enrichers.java | 4 +- .../enricher/basic/AbstractEnricher.java | 4 +- .../enricher/basic/EnricherDynamicType.java | 4 +- .../enricher/basic/EnricherTypeSnapshot.java | 2 +- .../brooklyn/entity/basic/AbstractEntity.java | 10 +- .../java/brooklyn/entity/basic/Entities.java | 4 +- .../brooklyn/entity/basic/EntityAdjuncts.java | 4 +- .../basic/EntityTransientCopyInternal.java | 4 +- .../brooklyn/entity/basic/PolicyDescriptor.java | 2 +- .../entity/basic/ServiceStateLogic.java | 6 +- .../entity/group/DynamicClusterImpl.java | 2 +- .../entity/proxying/InternalEntityFactory.java | 8 +- .../entity/proxying/InternalPolicyFactory.java | 8 +- .../AbstractBrooklynObjectRebindSupport.java | 2 +- .../rebind/ImmediateDeltaChangeListener.java | 4 +- .../rebind/PeriodicDeltaChangeListener.java | 4 +- .../entity/rebind/RebindContextImpl.java | 4 +- .../rebind/RebindContextLookupContext.java | 4 +- .../rebind/RebindExceptionHandlerImpl.java | 4 +- .../brooklyn/entity/rebind/RebindIteration.java | 4 +- .../entity/rebind/dto/MementosGenerators.java | 6 +- .../persister/BrooklynPersistenceUtils.java | 4 +- .../rebind/persister/XmlMementoSerializer.java | 4 +- .../internal/EntityChangeListener.java | 4 +- .../internal/EntityManagementSupport.java | 4 +- .../management/internal/LocalEntityManager.java | 8 +- .../internal/NonDeploymentEntityManager.java | 8 +- .../policy/basic/AbstractEntityAdjunct.java | 2 +- .../brooklyn/policy/basic/AbstractPolicy.java | 4 +- .../java/brooklyn/policy/basic/AdjunctType.java | 2 +- .../java/brooklyn/policy/basic/Policies.java | 2 +- .../policy/basic/PolicyDynamicType.java | 4 +- .../policy/basic/PolicyTypeSnapshot.java | 2 +- .../location/basic/LocationTypeSnapshot.java | 2 +- .../java/brooklyn/enricher/EnrichersTest.java | 2 +- .../enricher/SensorPropagatingEnricherTest.java | 2 +- .../enricher/basic/BasicEnricherTest.java | 4 +- .../YamlRollingTimeWindowMeanEnricherTest.java | 2 +- .../YamlTimeWeightedDeltaEnricherTest.java | 2 +- .../brooklyn/entity/basic/EntitySpecTest.java | 10 +- .../entity/basic/PolicyRegistrationTest.java | 6 +- .../entity/basic/ServiceStateLogicTest.java | 2 +- .../entity/group/GroupPickUpEntitiesTest.java | 2 +- .../group/MembershipTrackingPolicyTest.java | 2 +- .../entity/rebind/RebindEnricherTest.java | 4 +- .../entity/rebind/RebindFailuresTest.java | 8 +- .../entity/rebind/RebindPolicyTest.java | 6 +- .../BrooklynMementoPersisterTestFixture.java | 4 +- .../persister/XmlMementoSerializerTest.java | 4 +- .../osgi/OsgiVersionMoreEntityTest.java | 2 +- .../brooklyn/policy/basic/BasicPolicyTest.java | 2 +- .../brooklyn/policy/basic/EnricherTypeTest.java | 2 +- .../brooklyn/policy/basic/PolicyTypeTest.java | 2 +- .../EntityPersistencePerformanceTest.java | 4 +- .../brooklyn/demo/CumulusRDFApplication.java | 4 +- .../demo/HighAvailabilityCassandraCluster.java | 4 +- .../brooklyn/demo/RiakClusterExample.java | 4 +- .../brooklyn/demo/WideAreaCassandraCluster.java | 4 +- ...lusterDatabaseExampleAppIntegrationTest.java | 2 +- .../os/AdvertiseWinrmLoginPolicyTest.java | 2 +- .../policy/os/CreateUserPolicyLiveTest.java | 2 +- .../policy/os/CreateUserPolicyTest.java | 2 +- .../policy/autoscaling/AutoScalerPolicy.java | 2 +- .../policy/ha/ConditionalSuspendPolicy.java | 2 +- .../autoscaling/AutoScalerPolicyTest.java | 2 +- .../ha/ConnectionFailureDetectorTest.java | 2 +- .../brooklyn/policy/ha/HaPolicyRebindTest.java | 4 +- ...ServiceFailureDetectorStabilizationTest.java | 2 +- .../policy/ha/ServiceFailureDetectorTest.java | 2 +- .../brooklyn/policy/ha/ServiceReplacerTest.java | 2 +- .../policy/ha/ServiceRestarterTest.java | 2 +- .../entity/basic/SoftwareProcessImpl.java | 2 +- .../brooklyn/entity/pool/ServerPoolImpl.java | 2 +- .../entity/service/InitdServiceInstaller.java | 4 +- .../entity/service/SystemServiceEnricher.java | 4 +- .../service/SystemServiceInstallerFactory.java | 2 +- .../service/SystemServiceEnricherTest.java | 4 +- .../entity/messaging/kafka/KafkaCluster.java | 2 +- .../entity/zookeeper/ZooKeeperEnsembleImpl.java | 2 +- .../entity/network/bind/BindDnsServerImpl.java | 4 +- .../bind/BindDnsServerIntegrationTest.java | 2 +- .../network/bind/BindDnsServerLiveTest.java | 2 +- .../cassandra/CassandraDatacenterImpl.java | 2 +- .../nosql/cassandra/CassandraFabricImpl.java | 2 +- .../nosql/couchbase/CouchbaseClusterImpl.java | 4 +- .../nosql/mongodb/MongoDBReplicaSetImpl.java | 2 +- .../sharding/MongoDBRouterClusterImpl.java | 2 +- .../sharding/MongoDBShardedDeploymentImpl.java | 2 +- .../entity/nosql/riak/RiakClusterImpl.java | 4 +- .../entity/dns/AbstractGeoDnsServiceImpl.java | 4 +- .../entity/proxy/AbstractControllerImpl.java | 6 +- .../AbstractNonProvisionedControllerImpl.java | 2 +- .../entity/proxy/nginx/NginxControllerImpl.java | 2 +- .../BrooklynEntityDecorationResolver.java | 8 +- .../BrooklynYamlTypeInstantiatorTest.java | 2 +- .../camp/brooklyn/EnrichersYamlTest.java | 2 +- .../brooklyn/JavaWebAppsIntegrationTest.java | 2 +- .../camp/brooklyn/PoliciesYamlTest.java | 2 +- .../CatalogOsgiVersionMoreEntityTest.java | 4 +- .../brooklyn/catalog/CatalogYamlCombiTest.java | 2 +- .../brooklyn/catalog/CatalogYamlPolicyTest.java | 2 +- .../brooklyn/catalog/CatalogYamlRebindTest.java | 4 +- .../org/apache/brooklyn/cli/ItemLister.java | 4 +- .../apache/brooklyn/cli/lister/ClassFinder.java | 4 +- .../qa/load/SimulatedNginxControllerImpl.java | 4 +- .../qa/longevity/webcluster/WebClusterApp.java | 2 +- .../rest/resources/CatalogResource.java | 4 +- .../rest/resources/PolicyConfigResource.java | 2 +- .../brooklyn/rest/resources/PolicyResource.java | 4 +- .../rest/transform/CatalogTransformer.java | 4 +- .../rest/transform/PolicyTransformer.java | 2 +- .../rest/util/BrooklynRestResourceUtils.java | 2 +- .../util/BrooklynRestResourceUtilsTest.java | 2 +- .../osgi/tests/more/MoreEntityImpl.java | 2 +- .../osgi/tests/more/MoreEntityImpl.java | 2 +- 142 files changed, 879 insertions(+), 861 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/api/entity/Entity.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/entity/Entity.java b/api/src/main/java/org/apache/brooklyn/api/entity/Entity.java index 0918d14..9734f25 100644 --- a/api/src/main/java/org/apache/brooklyn/api/entity/Entity.java +++ b/api/src/main/java/org/apache/brooklyn/api/entity/Entity.java @@ -28,10 +28,10 @@ import org.apache.brooklyn.api.entity.proxying.EntitySpec; import org.apache.brooklyn.api.event.AttributeSensor; import org.apache.brooklyn.api.location.Location; import org.apache.brooklyn.api.management.Task; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.EnricherSpec; -import org.apache.brooklyn.policy.Policy; -import org.apache.brooklyn.policy.PolicySpec; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.EnricherSpec; +import org.apache.brooklyn.api.policy.Policy; +import org.apache.brooklyn.api.policy.PolicySpec; import brooklyn.config.ConfigKey; import brooklyn.config.ConfigKey.HasConfigKey; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/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 0a2205c..5530cd0 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 @@ -21,7 +21,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.api.mementos.FeedMemento; -import org.apache.brooklyn.policy.EntityAdjunct; +import org.apache.brooklyn.api.policy.EntityAdjunct; import com.google.common.annotations.Beta; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/api/entity/proxying/EntitySpec.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/entity/proxying/EntitySpec.java b/api/src/main/java/org/apache/brooklyn/api/entity/proxying/EntitySpec.java index 7a0d351..aa7113b 100644 --- a/api/src/main/java/org/apache/brooklyn/api/entity/proxying/EntitySpec.java +++ b/api/src/main/java/org/apache/brooklyn/api/entity/proxying/EntitySpec.java @@ -32,10 +32,10 @@ import org.apache.brooklyn.api.entity.Entity; import org.apache.brooklyn.api.entity.Group; import org.apache.brooklyn.api.location.Location; import org.apache.brooklyn.api.management.Task; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.EnricherSpec; -import org.apache.brooklyn.policy.Policy; -import org.apache.brooklyn.policy.PolicySpec; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.EnricherSpec; +import org.apache.brooklyn.api.policy.Policy; +import org.apache.brooklyn.api.policy.PolicySpec; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/api/entity/rebind/BrooklynObjectType.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/entity/rebind/BrooklynObjectType.java b/api/src/main/java/org/apache/brooklyn/api/entity/rebind/BrooklynObjectType.java index b4a120e..a7c924f 100644 --- a/api/src/main/java/org/apache/brooklyn/api/entity/rebind/BrooklynObjectType.java +++ b/api/src/main/java/org/apache/brooklyn/api/entity/rebind/BrooklynObjectType.java @@ -23,8 +23,8 @@ 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.location.Location; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.Policy; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.Policy; import com.google.common.annotations.Beta; import com.google.common.base.CaseFormat; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindExceptionHandler.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindExceptionHandler.java b/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindExceptionHandler.java index 24e5997..5fdd121 100644 --- a/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindExceptionHandler.java +++ b/api/src/main/java/org/apache/brooklyn/api/entity/rebind/RebindExceptionHandler.java @@ -26,8 +26,8 @@ import org.apache.brooklyn.api.entity.Entity; import org.apache.brooklyn.api.entity.Feed; import org.apache.brooklyn.api.entity.basic.EntityLocal; import org.apache.brooklyn.api.location.Location; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.Policy; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.Policy; import com.google.common.annotations.Beta; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/api/management/EntityManager.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/management/EntityManager.java b/api/src/main/java/org/apache/brooklyn/api/management/EntityManager.java index 4120587..98efc4c 100644 --- a/api/src/main/java/org/apache/brooklyn/api/management/EntityManager.java +++ b/api/src/main/java/org/apache/brooklyn/api/management/EntityManager.java @@ -27,10 +27,10 @@ import org.apache.brooklyn.api.entity.Application; import org.apache.brooklyn.api.entity.Entity; import org.apache.brooklyn.api.entity.proxying.EntitySpec; import org.apache.brooklyn.api.entity.proxying.EntityTypeRegistry; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.EnricherSpec; -import org.apache.brooklyn.policy.Policy; -import org.apache.brooklyn.policy.PolicySpec; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.EnricherSpec; +import org.apache.brooklyn.api.policy.Policy; +import org.apache.brooklyn.api.policy.PolicySpec; import com.google.common.base.Predicate; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/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 index 07a258f..ff94a68 100644 --- a/api/src/main/java/org/apache/brooklyn/api/mementos/BrooklynMementoPersister.java +++ b/api/src/main/java/org/apache/brooklyn/api/mementos/BrooklynMementoPersister.java @@ -35,8 +35,8 @@ 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 org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.Policy; import brooklyn.util.time.Duration; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/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 index 8c4a005..debdec7 100644 --- a/api/src/main/java/org/apache/brooklyn/api/mementos/Memento.java +++ b/api/src/main/java/org/apache/brooklyn/api/mementos/Memento.java @@ -24,7 +24,7 @@ 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; +import org.apache.brooklyn.api.policy.EntityAdjunct; /** * Represents the internal state of something in brooklyn, so that it can be reconstructed (e.g. after restarting brooklyn). http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/api/policy/Enricher.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/policy/Enricher.java b/api/src/main/java/org/apache/brooklyn/api/policy/Enricher.java new file mode 100644 index 0000000..1da1ace --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/policy/Enricher.java @@ -0,0 +1,71 @@ +/* + * 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.policy; + +import java.util.Map; + +import org.apache.brooklyn.api.entity.rebind.RebindSupport; +import org.apache.brooklyn.api.entity.rebind.Rebindable; +import org.apache.brooklyn.api.entity.trait.Configurable; +import org.apache.brooklyn.api.mementos.EnricherMemento; + +import brooklyn.config.ConfigKey; + +import com.google.common.annotations.Beta; + +/** + * Publishes metrics for an entity, e.g. aggregating information from other sensors/entities. + * + * Has some similarities to {@link Policy}. However, enrichers specifically do not invoke + * effectors and should only function to publish new metrics. + */ +public interface Enricher extends EntityAdjunct, Rebindable, Configurable { + /** + * A unique id for this enricher. + */ + @Override + String getId(); + + /** + * Information about the type of this entity; analogous to Java's object.getClass. + */ + @Beta + EnricherType getEnricherType(); + + /** + * Convenience method for {@code config().get(key)} + */ + <T> T getConfig(ConfigKey<T> key); + + /** + * @deprecated since 0.7.0; use {@link #config()}, such as {@code policy.config().setConfig(key, val)} + */ + @Deprecated + <T> T setConfig(ConfigKey<T> key, T val); + + /** + * Users are strongly discouraged from calling or overriding this method. + * It is for internal calls only, relating to persisting/rebinding entities. + * This method may change (or be removed) in a future release without notice. + */ + @Override + @Beta + RebindSupport<EnricherMemento> getRebindSupport(); + +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/api/policy/EnricherSpec.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/policy/EnricherSpec.java b/api/src/main/java/org/apache/brooklyn/api/policy/EnricherSpec.java new file mode 100644 index 0000000..6cdc742 --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/policy/EnricherSpec.java @@ -0,0 +1,214 @@ +/* + * 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.policy; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Collections; +import java.util.Map; + +import org.apache.brooklyn.api.basic.AbstractBrooklynObjectSpec; +import org.apache.brooklyn.api.management.Task; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import brooklyn.config.ConfigKey; +import brooklyn.config.ConfigKey.HasConfigKey; + +import com.google.common.collect.Maps; + +/** + * Gives details of an enricher to be created. It describes the enricher's configuration, and is + * reusable to create multiple enrichers with the same configuration. + * + * To create an EnricherSpec, it is strongly encouraged to use {@code create(...)} methods. + * + * @param <T> The type of enricher to be created + * + * @author aled + */ +public class EnricherSpec<T extends Enricher> extends AbstractBrooklynObjectSpec<T,EnricherSpec<T>> { + + private static final Logger log = LoggerFactory.getLogger(EnricherSpec.class); + + private final static long serialVersionUID = 1L; + + + /** + * Creates a new {@link EnricherSpec} instance for an enricher of the given type. The returned + * {@link EnricherSpec} can then be customized. + * + * @param type A {@link Enricher} class + */ + public static <T extends Enricher> EnricherSpec<T> create(Class<? extends T> type) { + return new EnricherSpec<T>(type); + } + + /** + * Creates a new {@link EnricherSpec} instance with the given config, for an enricher of the given type. + * + * This is primarily for groovy code; equivalent to {@code EnricherSpec.create(type).configure(config)}. + * + * @param config The spec's configuration (see {@link EnricherSpec#configure(Map)}). + * @param type An {@link Enricher} class + */ + public static <T extends Enricher> EnricherSpec<T> create(Map<?,?> config, Class<? extends T> type) { + return EnricherSpec.create(type).configure(config); + } + + private final Map<String, Object> flags = Maps.newLinkedHashMap(); + private final Map<ConfigKey<?>, Object> config = Maps.newLinkedHashMap(); + + protected EnricherSpec(Class<? extends T> type) { + super(type); + } + + protected void checkValidType(Class<? extends T> type) { + checkIsImplementation(type, Enricher.class); + checkIsNewStyleImplementation(type); + } + + public EnricherSpec<T> uniqueTag(String uniqueTag) { + flags.put("uniqueTag", uniqueTag); + return this; + } + + public EnricherSpec<T> configure(Map<?,?> val) { + for (Map.Entry<?, ?> entry: val.entrySet()) { + if (entry.getKey()==null) throw new NullPointerException("Null key not permitted"); + if (entry.getKey() instanceof CharSequence) + flags.put(entry.getKey().toString(), entry.getValue()); + else if (entry.getKey() instanceof ConfigKey<?>) + config.put((ConfigKey<?>)entry.getKey(), entry.getValue()); + else if (entry.getKey() instanceof HasConfigKey<?>) + config.put(((HasConfigKey<?>)entry.getKey()).getConfigKey(), entry.getValue()); + else { + log.warn("Spec "+this+" ignoring unknown config key "+entry.getKey()); + } + } + return this; + } + + public EnricherSpec<T> configure(CharSequence key, Object val) { + flags.put(checkNotNull(key, "key").toString(), val); + return this; + } + + public <V> EnricherSpec<T> configure(ConfigKey<V> key, V val) { + config.put(checkNotNull(key, "key"), val); + return this; + } + + public <V> EnricherSpec<T> configureIfNotNull(ConfigKey<V> key, V val) { + return (val != null) ? configure(key, val) : this; + } + + public <V> EnricherSpec<T> configure(ConfigKey<V> key, Task<? extends V> val) { + config.put(checkNotNull(key, "key"), val); + return this; + } + + public <V> EnricherSpec<T> configure(HasConfigKey<V> key, V val) { + config.put(checkNotNull(key, "key").getConfigKey(), val); + return this; + } + + public <V> EnricherSpec<T> configure(HasConfigKey<V> key, Task<? extends V> val) { + config.put(checkNotNull(key, "key").getConfigKey(), val); + return this; + } + + /** + * @return Read-only construction flags + * @see SetFromFlag declarations on the enricher type + */ + public Map<String, ?> getFlags() { + return Collections.unmodifiableMap(flags); + } + + /** + * @return Read-only configuration values + */ + public Map<ConfigKey<?>, Object> getConfig() { + return Collections.unmodifiableMap(config); + } + + public abstract static class ExtensibleEnricherSpec<T extends Enricher,K extends ExtensibleEnricherSpec<T,K>> extends EnricherSpec<T> { + private static final long serialVersionUID = -3649347642882809739L; + + protected ExtensibleEnricherSpec(Class<? extends T> type) { + super(type); + } + + @SuppressWarnings("unchecked") + protected K self() { + // we override the AbstractBrooklynObjectSpec method -- it's a different K here because + // EnricherSpec does not contain a parametrisable generic return type (Self) + return (K) this; + } + + @Override + public K uniqueTag(String uniqueTag) { + super.uniqueTag(uniqueTag); + return self(); + } + + @Override + public K configure(Map<?, ?> val) { + super.configure(val); + return self(); + } + + @Override + public K configure(CharSequence key, Object val) { + super.configure(key, val); + return self(); + } + + @Override + public <V> K configure(ConfigKey<V> key, V val) { + super.configure(key, val); + return self(); + } + + @Override + public <V> K configureIfNotNull(ConfigKey<V> key, V val) { + super.configureIfNotNull(key, val); + return self(); + } + + @Override + public <V> K configure(ConfigKey<V> key, Task<? extends V> val) { + super.configure(key, val); + return self(); + } + + @Override + public <V> K configure(HasConfigKey<V> key, V val) { + super.configure(key, val); + return self(); + } + + @Override + public <V> K configure(HasConfigKey<V> key, Task<? extends V> val) { + super.configure(key, val); + return self(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/api/policy/EnricherType.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/policy/EnricherType.java b/api/src/main/java/org/apache/brooklyn/api/policy/EnricherType.java new file mode 100644 index 0000000..e9706cc --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/policy/EnricherType.java @@ -0,0 +1,36 @@ +/* + * 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.policy; + +import org.apache.brooklyn.api.basic.BrooklynType; + +import com.google.common.annotations.Beta; + +/** + * Gives type information for an {@link Enricher}. It is immutable. + * + * For enrichers that can support config keys etc being added on-the-fly, + * then this EnricherType will be a snapshot and subsequent snapshots will + * include the changes. + * + * @since 0.6 + */ +@Beta +public interface EnricherType extends BrooklynType { +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/api/policy/EntityAdjunct.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/policy/EntityAdjunct.java b/api/src/main/java/org/apache/brooklyn/api/policy/EntityAdjunct.java new file mode 100644 index 0000000..a703c1a --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/policy/EntityAdjunct.java @@ -0,0 +1,55 @@ +/* + * 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.policy; + +import javax.annotation.Nullable; + +import org.apache.brooklyn.api.basic.BrooklynObject; + +/** + * EntityAdjuncts are supplementary logic that can be attached to Entities, + * such as providing sensor enrichment or event-driven policy behavior + */ +public interface EntityAdjunct extends BrooklynObject { + /** + * A unique id for this adjunct, typically created by the system with no meaning + */ + @Override + String getId(); + + /** + * Whether the adjunct is destroyed + */ + boolean isDestroyed(); + + /** + * Whether the adjunct is available/active, ie started and not stopped or interrupted + */ + boolean isRunning(); + + /** + * An optional tag used to identify adjuncts with a specific purpose, typically created by the caller. + * This is used to prevent multiple instances with the same purpose from being created, + * and to access and customize adjuncts so created. + * <p> + * This will be included in the call to {@link #getTags()}. + */ + @Nullable String getUniqueTag(); + +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/api/policy/Policy.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/policy/Policy.java b/api/src/main/java/org/apache/brooklyn/api/policy/Policy.java new file mode 100644 index 0000000..92b57b2 --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/policy/Policy.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.policy; + +import java.util.Map; + +import org.apache.brooklyn.api.entity.rebind.RebindSupport; +import org.apache.brooklyn.api.entity.rebind.Rebindable; +import org.apache.brooklyn.api.entity.trait.Configurable; +import org.apache.brooklyn.api.mementos.PolicyMemento; + +import brooklyn.config.ConfigKey; + +import com.google.common.annotations.Beta; + +/** + * Policies implement actions and thus must be suspendable; policies should continue to evaluate their sensors + * and indicate their desired planned action even if they aren't invoking them + */ +public interface Policy extends EntityAdjunct, Rebindable, Configurable { + /** + * A unique id for this policy. + */ + @Override + String getId(); + + /** + * Information about the type of this entity; analogous to Java's object.getClass. + */ + @Beta + PolicyType getPolicyType(); + + /** + * Resume the policy + */ + void resume(); + + /** + * Suspend the policy + */ + void suspend(); + + /** + * Whether the policy is suspended + */ + boolean isSuspended(); + + /** + * Convenience method for {@code config().get(key)} + */ + <T> T getConfig(ConfigKey<T> key); + + /** + * @deprecated since 0.7.0; use {@link #config()}, such as {@code policy.config().setConfig(key, val)} + */ + @Deprecated + <T> T setConfig(ConfigKey<T> key, T val); + + /** + * Users are strongly discouraged from calling or overriding this method. + * It is for internal calls only, relating to persisting/rebinding entities. + * This method may change (or be removed) in a future release without notice. + */ + @Override + @Beta + RebindSupport<PolicyMemento> getRebindSupport(); +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/api/policy/PolicySpec.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/policy/PolicySpec.java b/api/src/main/java/org/apache/brooklyn/api/policy/PolicySpec.java new file mode 100644 index 0000000..3e13db6 --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/policy/PolicySpec.java @@ -0,0 +1,152 @@ +/* + * 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.policy; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Collections; +import java.util.Map; + +import org.apache.brooklyn.api.basic.AbstractBrooklynObjectSpec; +import org.apache.brooklyn.api.management.Task; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import brooklyn.config.ConfigKey; +import brooklyn.config.ConfigKey.HasConfigKey; + +import com.google.common.collect.Maps; + +/** + * Gives details of a policy to be created. It describes the policy's configuration, and is + * reusable to create multiple policies with the same configuration. + * + * To create a PolicySpec, it is strongly encouraged to use {@code create(...)} methods. + * + * @param <T> The type of policy to be created + * + * @author aled + */ +public class PolicySpec<T extends Policy> extends AbstractBrooklynObjectSpec<T,PolicySpec<T>> { + + private static final Logger log = LoggerFactory.getLogger(PolicySpec.class); + + private final static long serialVersionUID = 1L; + + + /** + * Creates a new {@link PolicySpec} instance for a policy of the given type. The returned + * {@link PolicySpec} can then be customized. + * + * @param type A {@link Policy} class + */ + public static <T extends Policy> PolicySpec<T> create(Class<T> type) { + return new PolicySpec<T>(type); + } + + /** + * Creates a new {@link PolicySpec} instance with the given config, for a policy of the given type. + * + * This is primarily for groovy code; equivalent to {@code PolicySpec.create(type).configure(config)}. + * + * @param config The spec's configuration (see {@link PolicySpec#configure(Map)}). + * @param type A {@link Policy} class + */ + public static <T extends Policy> PolicySpec<T> create(Map<?,?> config, Class<T> type) { + return PolicySpec.create(type).configure(config); + } + + private final Map<String, Object> flags = Maps.newLinkedHashMap(); + private final Map<ConfigKey<?>, Object> config = Maps.newLinkedHashMap(); + + protected PolicySpec(Class<T> type) { + super(type); + } + + protected void checkValidType(Class<? extends T> type) { + checkIsImplementation(type, Policy.class); + checkIsNewStyleImplementation(type); + } + + public PolicySpec<T> uniqueTag(String uniqueTag) { + flags.put("uniqueTag", uniqueTag); + return this; + } + + public PolicySpec<T> configure(Map<?,?> val) { + for (Map.Entry<?, ?> entry: val.entrySet()) { + if (entry.getKey()==null) throw new NullPointerException("Null key not permitted"); + if (entry.getKey() instanceof CharSequence) + flags.put(entry.getKey().toString(), entry.getValue()); + else if (entry.getKey() instanceof ConfigKey<?>) + config.put((ConfigKey<?>)entry.getKey(), entry.getValue()); + else if (entry.getKey() instanceof HasConfigKey<?>) + config.put(((HasConfigKey<?>)entry.getKey()).getConfigKey(), entry.getValue()); + else { + log.warn("Spec "+this+" ignoring unknown config key "+entry.getKey()); + } + } + return this; + } + + public PolicySpec<T> configure(CharSequence key, Object val) { + flags.put(checkNotNull(key, "key").toString(), val); + return this; + } + + public <V> PolicySpec<T> configure(ConfigKey<V> key, V val) { + config.put(checkNotNull(key, "key"), val); + return this; + } + + public <V> PolicySpec<T> configureIfNotNull(ConfigKey<V> key, V val) { + return (val != null) ? configure(key, val) : this; + } + + public <V> PolicySpec<T> configure(ConfigKey<V> key, Task<? extends V> val) { + config.put(checkNotNull(key, "key"), val); + return this; + } + + public <V> PolicySpec<T> configure(HasConfigKey<V> key, V val) { + config.put(checkNotNull(key, "key").getConfigKey(), val); + return this; + } + + public <V> PolicySpec<T> configure(HasConfigKey<V> key, Task<? extends V> val) { + config.put(checkNotNull(key, "key").getConfigKey(), val); + return this; + } + + /** + * @return Read-only construction flags + * @see SetFromFlag declarations on the policy type + */ + public Map<String, ?> getFlags() { + return Collections.unmodifiableMap(flags); + } + + /** + * @return Read-only configuration values + */ + public Map<ConfigKey<?>, Object> getConfig() { + return Collections.unmodifiableMap(config); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/api/policy/PolicyType.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/policy/PolicyType.java b/api/src/main/java/org/apache/brooklyn/api/policy/PolicyType.java new file mode 100644 index 0000000..2703e1f --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/policy/PolicyType.java @@ -0,0 +1,36 @@ +/* + * 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.policy; + +import org.apache.brooklyn.api.basic.BrooklynType; + +import com.google.common.annotations.Beta; + +/** + * Gives type information for a {@link Policy}. It is immutable. + * + * For policies that can support config keys etc being added on-the-fly, + * then this PolicyType will be a snapshot and subsequent snapshots will + * include the changes. + * + * @since 0.5 + */ +@Beta +public interface PolicyType extends BrooklynType { +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/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 deleted file mode 100644 index 3b7608d..0000000 --- a/api/src/main/java/org/apache/brooklyn/policy/Enricher.java +++ /dev/null @@ -1,71 +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.policy; - -import java.util.Map; - -import org.apache.brooklyn.api.entity.rebind.RebindSupport; -import org.apache.brooklyn.api.entity.rebind.Rebindable; -import org.apache.brooklyn.api.entity.trait.Configurable; -import org.apache.brooklyn.api.mementos.EnricherMemento; - -import brooklyn.config.ConfigKey; - -import com.google.common.annotations.Beta; - -/** - * Publishes metrics for an entity, e.g. aggregating information from other sensors/entities. - * - * Has some similarities to {@link Policy}. However, enrichers specifically do not invoke - * effectors and should only function to publish new metrics. - */ -public interface Enricher extends EntityAdjunct, Rebindable, Configurable { - /** - * A unique id for this enricher. - */ - @Override - String getId(); - - /** - * Information about the type of this entity; analogous to Java's object.getClass. - */ - @Beta - EnricherType getEnricherType(); - - /** - * Convenience method for {@code config().get(key)} - */ - <T> T getConfig(ConfigKey<T> key); - - /** - * @deprecated since 0.7.0; use {@link #config()}, such as {@code policy.config().setConfig(key, val)} - */ - @Deprecated - <T> T setConfig(ConfigKey<T> key, T val); - - /** - * Users are strongly discouraged from calling or overriding this method. - * It is for internal calls only, relating to persisting/rebinding entities. - * This method may change (or be removed) in a future release without notice. - */ - @Override - @Beta - RebindSupport<EnricherMemento> getRebindSupport(); - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/policy/EnricherSpec.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/policy/EnricherSpec.java b/api/src/main/java/org/apache/brooklyn/policy/EnricherSpec.java deleted file mode 100644 index 4878250..0000000 --- a/api/src/main/java/org/apache/brooklyn/policy/EnricherSpec.java +++ /dev/null @@ -1,214 +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.policy; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Collections; -import java.util.Map; - -import org.apache.brooklyn.api.basic.AbstractBrooklynObjectSpec; -import org.apache.brooklyn.api.management.Task; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import brooklyn.config.ConfigKey; -import brooklyn.config.ConfigKey.HasConfigKey; - -import com.google.common.collect.Maps; - -/** - * Gives details of an enricher to be created. It describes the enricher's configuration, and is - * reusable to create multiple enrichers with the same configuration. - * - * To create an EnricherSpec, it is strongly encouraged to use {@code create(...)} methods. - * - * @param <T> The type of enricher to be created - * - * @author aled - */ -public class EnricherSpec<T extends Enricher> extends AbstractBrooklynObjectSpec<T,EnricherSpec<T>> { - - private static final Logger log = LoggerFactory.getLogger(EnricherSpec.class); - - private final static long serialVersionUID = 1L; - - - /** - * Creates a new {@link EnricherSpec} instance for an enricher of the given type. The returned - * {@link EnricherSpec} can then be customized. - * - * @param type A {@link Enricher} class - */ - public static <T extends Enricher> EnricherSpec<T> create(Class<? extends T> type) { - return new EnricherSpec<T>(type); - } - - /** - * Creates a new {@link EnricherSpec} instance with the given config, for an enricher of the given type. - * - * This is primarily for groovy code; equivalent to {@code EnricherSpec.create(type).configure(config)}. - * - * @param config The spec's configuration (see {@link EnricherSpec#configure(Map)}). - * @param type An {@link Enricher} class - */ - public static <T extends Enricher> EnricherSpec<T> create(Map<?,?> config, Class<? extends T> type) { - return EnricherSpec.create(type).configure(config); - } - - private final Map<String, Object> flags = Maps.newLinkedHashMap(); - private final Map<ConfigKey<?>, Object> config = Maps.newLinkedHashMap(); - - protected EnricherSpec(Class<? extends T> type) { - super(type); - } - - protected void checkValidType(Class<? extends T> type) { - checkIsImplementation(type, Enricher.class); - checkIsNewStyleImplementation(type); - } - - public EnricherSpec<T> uniqueTag(String uniqueTag) { - flags.put("uniqueTag", uniqueTag); - return this; - } - - public EnricherSpec<T> configure(Map<?,?> val) { - for (Map.Entry<?, ?> entry: val.entrySet()) { - if (entry.getKey()==null) throw new NullPointerException("Null key not permitted"); - if (entry.getKey() instanceof CharSequence) - flags.put(entry.getKey().toString(), entry.getValue()); - else if (entry.getKey() instanceof ConfigKey<?>) - config.put((ConfigKey<?>)entry.getKey(), entry.getValue()); - else if (entry.getKey() instanceof HasConfigKey<?>) - config.put(((HasConfigKey<?>)entry.getKey()).getConfigKey(), entry.getValue()); - else { - log.warn("Spec "+this+" ignoring unknown config key "+entry.getKey()); - } - } - return this; - } - - public EnricherSpec<T> configure(CharSequence key, Object val) { - flags.put(checkNotNull(key, "key").toString(), val); - return this; - } - - public <V> EnricherSpec<T> configure(ConfigKey<V> key, V val) { - config.put(checkNotNull(key, "key"), val); - return this; - } - - public <V> EnricherSpec<T> configureIfNotNull(ConfigKey<V> key, V val) { - return (val != null) ? configure(key, val) : this; - } - - public <V> EnricherSpec<T> configure(ConfigKey<V> key, Task<? extends V> val) { - config.put(checkNotNull(key, "key"), val); - return this; - } - - public <V> EnricherSpec<T> configure(HasConfigKey<V> key, V val) { - config.put(checkNotNull(key, "key").getConfigKey(), val); - return this; - } - - public <V> EnricherSpec<T> configure(HasConfigKey<V> key, Task<? extends V> val) { - config.put(checkNotNull(key, "key").getConfigKey(), val); - return this; - } - - /** - * @return Read-only construction flags - * @see SetFromFlag declarations on the enricher type - */ - public Map<String, ?> getFlags() { - return Collections.unmodifiableMap(flags); - } - - /** - * @return Read-only configuration values - */ - public Map<ConfigKey<?>, Object> getConfig() { - return Collections.unmodifiableMap(config); - } - - public abstract static class ExtensibleEnricherSpec<T extends Enricher,K extends ExtensibleEnricherSpec<T,K>> extends EnricherSpec<T> { - private static final long serialVersionUID = -3649347642882809739L; - - protected ExtensibleEnricherSpec(Class<? extends T> type) { - super(type); - } - - @SuppressWarnings("unchecked") - protected K self() { - // we override the AbstractBrooklynObjectSpec method -- it's a different K here because - // EnricherSpec does not contain a parametrisable generic return type (Self) - return (K) this; - } - - @Override - public K uniqueTag(String uniqueTag) { - super.uniqueTag(uniqueTag); - return self(); - } - - @Override - public K configure(Map<?, ?> val) { - super.configure(val); - return self(); - } - - @Override - public K configure(CharSequence key, Object val) { - super.configure(key, val); - return self(); - } - - @Override - public <V> K configure(ConfigKey<V> key, V val) { - super.configure(key, val); - return self(); - } - - @Override - public <V> K configureIfNotNull(ConfigKey<V> key, V val) { - super.configureIfNotNull(key, val); - return self(); - } - - @Override - public <V> K configure(ConfigKey<V> key, Task<? extends V> val) { - super.configure(key, val); - return self(); - } - - @Override - public <V> K configure(HasConfigKey<V> key, V val) { - super.configure(key, val); - return self(); - } - - @Override - public <V> K configure(HasConfigKey<V> key, Task<? extends V> val) { - super.configure(key, val); - return self(); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/policy/EnricherType.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/policy/EnricherType.java b/api/src/main/java/org/apache/brooklyn/policy/EnricherType.java deleted file mode 100644 index e96b3cd..0000000 --- a/api/src/main/java/org/apache/brooklyn/policy/EnricherType.java +++ /dev/null @@ -1,36 +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.policy; - -import org.apache.brooklyn.api.basic.BrooklynType; - -import com.google.common.annotations.Beta; - -/** - * Gives type information for an {@link Enricher}. It is immutable. - * - * For enrichers that can support config keys etc being added on-the-fly, - * then this EnricherType will be a snapshot and subsequent snapshots will - * include the changes. - * - * @since 0.6 - */ -@Beta -public interface EnricherType extends BrooklynType { -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/policy/EntityAdjunct.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/policy/EntityAdjunct.java b/api/src/main/java/org/apache/brooklyn/policy/EntityAdjunct.java deleted file mode 100644 index daa6cd0..0000000 --- a/api/src/main/java/org/apache/brooklyn/policy/EntityAdjunct.java +++ /dev/null @@ -1,55 +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.policy; - -import javax.annotation.Nullable; - -import org.apache.brooklyn.api.basic.BrooklynObject; - -/** - * EntityAdjuncts are supplementary logic that can be attached to Entities, - * such as providing sensor enrichment or event-driven policy behavior - */ -public interface EntityAdjunct extends BrooklynObject { - /** - * A unique id for this adjunct, typically created by the system with no meaning - */ - @Override - String getId(); - - /** - * Whether the adjunct is destroyed - */ - boolean isDestroyed(); - - /** - * Whether the adjunct is available/active, ie started and not stopped or interrupted - */ - boolean isRunning(); - - /** - * An optional tag used to identify adjuncts with a specific purpose, typically created by the caller. - * This is used to prevent multiple instances with the same purpose from being created, - * and to access and customize adjuncts so created. - * <p> - * This will be included in the call to {@link #getTags()}. - */ - @Nullable String getUniqueTag(); - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/policy/Policy.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/policy/Policy.java b/api/src/main/java/org/apache/brooklyn/policy/Policy.java deleted file mode 100644 index 7bf6e9f..0000000 --- a/api/src/main/java/org/apache/brooklyn/policy/Policy.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.policy; - -import java.util.Map; - -import org.apache.brooklyn.api.entity.rebind.RebindSupport; -import org.apache.brooklyn.api.entity.rebind.Rebindable; -import org.apache.brooklyn.api.entity.trait.Configurable; -import org.apache.brooklyn.api.mementos.PolicyMemento; - -import brooklyn.config.ConfigKey; - -import com.google.common.annotations.Beta; - -/** - * Policies implement actions and thus must be suspendable; policies should continue to evaluate their sensors - * and indicate their desired planned action even if they aren't invoking them - */ -public interface Policy extends EntityAdjunct, Rebindable, Configurable { - /** - * A unique id for this policy. - */ - @Override - String getId(); - - /** - * Information about the type of this entity; analogous to Java's object.getClass. - */ - @Beta - PolicyType getPolicyType(); - - /** - * Resume the policy - */ - void resume(); - - /** - * Suspend the policy - */ - void suspend(); - - /** - * Whether the policy is suspended - */ - boolean isSuspended(); - - /** - * Convenience method for {@code config().get(key)} - */ - <T> T getConfig(ConfigKey<T> key); - - /** - * @deprecated since 0.7.0; use {@link #config()}, such as {@code policy.config().setConfig(key, val)} - */ - @Deprecated - <T> T setConfig(ConfigKey<T> key, T val); - - /** - * Users are strongly discouraged from calling or overriding this method. - * It is for internal calls only, relating to persisting/rebinding entities. - * This method may change (or be removed) in a future release without notice. - */ - @Override - @Beta - RebindSupport<PolicyMemento> getRebindSupport(); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/policy/PolicySpec.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/policy/PolicySpec.java b/api/src/main/java/org/apache/brooklyn/policy/PolicySpec.java deleted file mode 100644 index de76513..0000000 --- a/api/src/main/java/org/apache/brooklyn/policy/PolicySpec.java +++ /dev/null @@ -1,152 +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.policy; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Collections; -import java.util.Map; - -import org.apache.brooklyn.api.basic.AbstractBrooklynObjectSpec; -import org.apache.brooklyn.api.management.Task; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import brooklyn.config.ConfigKey; -import brooklyn.config.ConfigKey.HasConfigKey; - -import com.google.common.collect.Maps; - -/** - * Gives details of a policy to be created. It describes the policy's configuration, and is - * reusable to create multiple policies with the same configuration. - * - * To create a PolicySpec, it is strongly encouraged to use {@code create(...)} methods. - * - * @param <T> The type of policy to be created - * - * @author aled - */ -public class PolicySpec<T extends Policy> extends AbstractBrooklynObjectSpec<T,PolicySpec<T>> { - - private static final Logger log = LoggerFactory.getLogger(PolicySpec.class); - - private final static long serialVersionUID = 1L; - - - /** - * Creates a new {@link PolicySpec} instance for a policy of the given type. The returned - * {@link PolicySpec} can then be customized. - * - * @param type A {@link Policy} class - */ - public static <T extends Policy> PolicySpec<T> create(Class<T> type) { - return new PolicySpec<T>(type); - } - - /** - * Creates a new {@link PolicySpec} instance with the given config, for a policy of the given type. - * - * This is primarily for groovy code; equivalent to {@code PolicySpec.create(type).configure(config)}. - * - * @param config The spec's configuration (see {@link PolicySpec#configure(Map)}). - * @param type A {@link Policy} class - */ - public static <T extends Policy> PolicySpec<T> create(Map<?,?> config, Class<T> type) { - return PolicySpec.create(type).configure(config); - } - - private final Map<String, Object> flags = Maps.newLinkedHashMap(); - private final Map<ConfigKey<?>, Object> config = Maps.newLinkedHashMap(); - - protected PolicySpec(Class<T> type) { - super(type); - } - - protected void checkValidType(Class<? extends T> type) { - checkIsImplementation(type, Policy.class); - checkIsNewStyleImplementation(type); - } - - public PolicySpec<T> uniqueTag(String uniqueTag) { - flags.put("uniqueTag", uniqueTag); - return this; - } - - public PolicySpec<T> configure(Map<?,?> val) { - for (Map.Entry<?, ?> entry: val.entrySet()) { - if (entry.getKey()==null) throw new NullPointerException("Null key not permitted"); - if (entry.getKey() instanceof CharSequence) - flags.put(entry.getKey().toString(), entry.getValue()); - else if (entry.getKey() instanceof ConfigKey<?>) - config.put((ConfigKey<?>)entry.getKey(), entry.getValue()); - else if (entry.getKey() instanceof HasConfigKey<?>) - config.put(((HasConfigKey<?>)entry.getKey()).getConfigKey(), entry.getValue()); - else { - log.warn("Spec "+this+" ignoring unknown config key "+entry.getKey()); - } - } - return this; - } - - public PolicySpec<T> configure(CharSequence key, Object val) { - flags.put(checkNotNull(key, "key").toString(), val); - return this; - } - - public <V> PolicySpec<T> configure(ConfigKey<V> key, V val) { - config.put(checkNotNull(key, "key"), val); - return this; - } - - public <V> PolicySpec<T> configureIfNotNull(ConfigKey<V> key, V val) { - return (val != null) ? configure(key, val) : this; - } - - public <V> PolicySpec<T> configure(ConfigKey<V> key, Task<? extends V> val) { - config.put(checkNotNull(key, "key"), val); - return this; - } - - public <V> PolicySpec<T> configure(HasConfigKey<V> key, V val) { - config.put(checkNotNull(key, "key").getConfigKey(), val); - return this; - } - - public <V> PolicySpec<T> configure(HasConfigKey<V> key, Task<? extends V> val) { - config.put(checkNotNull(key, "key").getConfigKey(), val); - return this; - } - - /** - * @return Read-only construction flags - * @see SetFromFlag declarations on the policy type - */ - public Map<String, ?> getFlags() { - return Collections.unmodifiableMap(flags); - } - - /** - * @return Read-only configuration values - */ - public Map<ConfigKey<?>, Object> getConfig() { - return Collections.unmodifiableMap(config); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/api/src/main/java/org/apache/brooklyn/policy/PolicyType.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/policy/PolicyType.java b/api/src/main/java/org/apache/brooklyn/policy/PolicyType.java deleted file mode 100644 index 8d83c28..0000000 --- a/api/src/main/java/org/apache/brooklyn/policy/PolicyType.java +++ /dev/null @@ -1,36 +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.policy; - -import org.apache.brooklyn.api.basic.BrooklynType; - -import com.google.common.annotations.Beta; - -/** - * Gives type information for a {@link Policy}. It is immutable. - * - * For policies that can support config keys etc being added on-the-fly, - * then this PolicyType will be a snapshot and subsequent snapshots will - * include the changes. - * - * @since 0.5 - */ -@Beta -public interface PolicyType extends BrooklynType { -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/basic/BrooklynTypes.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/basic/BrooklynTypes.java b/core/src/main/java/brooklyn/basic/BrooklynTypes.java index 4423bed..64dbcd0 100644 --- a/core/src/main/java/brooklyn/basic/BrooklynTypes.java +++ b/core/src/main/java/brooklyn/basic/BrooklynTypes.java @@ -24,8 +24,8 @@ import org.apache.brooklyn.api.basic.BrooklynObject; import org.apache.brooklyn.api.entity.Entity; import org.apache.brooklyn.api.event.Sensor; import org.apache.brooklyn.api.location.Location; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.Policy; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.Policy; import brooklyn.config.ConfigKey; import brooklyn.enricher.basic.EnricherDynamicType; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/catalog/CatalogPredicates.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/catalog/CatalogPredicates.java b/core/src/main/java/brooklyn/catalog/CatalogPredicates.java index e8e0e7e..a873726 100644 --- a/core/src/main/java/brooklyn/catalog/CatalogPredicates.java +++ b/core/src/main/java/brooklyn/catalog/CatalogPredicates.java @@ -28,8 +28,8 @@ import org.apache.brooklyn.api.entity.proxying.EntitySpec; import org.apache.brooklyn.api.location.Location; import org.apache.brooklyn.api.location.LocationSpec; import org.apache.brooklyn.api.management.ManagementContext; -import org.apache.brooklyn.policy.Policy; -import org.apache.brooklyn.policy.PolicySpec; +import org.apache.brooklyn.api.policy.Policy; +import org.apache.brooklyn.api.policy.PolicySpec; import brooklyn.catalog.internal.CatalogUtils; import brooklyn.management.entitlement.Entitlements; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java b/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java index 5dec71b..f129f4c 100644 --- a/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java +++ b/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java @@ -50,8 +50,8 @@ import org.apache.brooklyn.api.location.Location; import org.apache.brooklyn.api.location.LocationSpec; import org.apache.brooklyn.api.management.ManagementContext; import org.apache.brooklyn.api.management.classloading.BrooklynClassLoadingContext; -import org.apache.brooklyn.policy.Policy; -import org.apache.brooklyn.policy.PolicySpec; +import org.apache.brooklyn.api.policy.Policy; +import org.apache.brooklyn.api.policy.PolicySpec; import brooklyn.catalog.CatalogPredicates; import brooklyn.catalog.internal.CatalogClasspathDo.CatalogScanningModes; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/catalog/internal/CatalogClasspathDo.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/catalog/internal/CatalogClasspathDo.java b/core/src/main/java/brooklyn/catalog/internal/CatalogClasspathDo.java index af0713a..3acd165 100644 --- a/core/src/main/java/brooklyn/catalog/internal/CatalogClasspathDo.java +++ b/core/src/main/java/brooklyn/catalog/internal/CatalogClasspathDo.java @@ -37,7 +37,7 @@ import org.apache.brooklyn.api.entity.Application; import org.apache.brooklyn.api.entity.Entity; import org.apache.brooklyn.api.entity.proxying.ImplementedBy; import org.apache.brooklyn.api.location.Location; -import org.apache.brooklyn.policy.Policy; +import org.apache.brooklyn.api.policy.Policy; import brooklyn.entity.basic.ApplicationBuilder; import brooklyn.management.internal.ManagementContextInternal; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/catalog/internal/CatalogPolicyItemDto.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/catalog/internal/CatalogPolicyItemDto.java b/core/src/main/java/brooklyn/catalog/internal/CatalogPolicyItemDto.java index 379783f..0475876 100644 --- a/core/src/main/java/brooklyn/catalog/internal/CatalogPolicyItemDto.java +++ b/core/src/main/java/brooklyn/catalog/internal/CatalogPolicyItemDto.java @@ -18,8 +18,8 @@ */ package brooklyn.catalog.internal; -import org.apache.brooklyn.policy.Policy; -import org.apache.brooklyn.policy.PolicySpec; +import org.apache.brooklyn.api.policy.Policy; +import org.apache.brooklyn.api.policy.PolicySpec; public class CatalogPolicyItemDto extends CatalogItemDtoAbstract<Policy,PolicySpec<?>> { http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/enricher/Enrichers.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/enricher/Enrichers.java b/core/src/main/java/brooklyn/enricher/Enrichers.java index 146d928..54af8d1 100644 --- a/core/src/main/java/brooklyn/enricher/Enrichers.java +++ b/core/src/main/java/brooklyn/enricher/Enrichers.java @@ -30,8 +30,8 @@ import org.apache.brooklyn.api.entity.Entity; import org.apache.brooklyn.api.event.AttributeSensor; import org.apache.brooklyn.api.event.Sensor; import org.apache.brooklyn.api.event.SensorEvent; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.EnricherSpec; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.EnricherSpec; import brooklyn.enricher.basic.AbstractEnricher; import brooklyn.enricher.basic.Aggregator; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/enricher/basic/AbstractEnricher.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/enricher/basic/AbstractEnricher.java b/core/src/main/java/brooklyn/enricher/basic/AbstractEnricher.java index 71e8391..da5e822 100644 --- a/core/src/main/java/brooklyn/enricher/basic/AbstractEnricher.java +++ b/core/src/main/java/brooklyn/enricher/basic/AbstractEnricher.java @@ -27,8 +27,8 @@ import org.apache.brooklyn.api.entity.rebind.RebindSupport; import org.apache.brooklyn.api.event.AttributeSensor; import org.apache.brooklyn.api.event.Sensor; import org.apache.brooklyn.api.mementos.EnricherMemento; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.EnricherType; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.EnricherType; import brooklyn.config.ConfigKey; import brooklyn.entity.basic.ConfigKeys; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/enricher/basic/EnricherDynamicType.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/enricher/basic/EnricherDynamicType.java b/core/src/main/java/brooklyn/enricher/basic/EnricherDynamicType.java index 39705d0..0604941 100644 --- a/core/src/main/java/brooklyn/enricher/basic/EnricherDynamicType.java +++ b/core/src/main/java/brooklyn/enricher/basic/EnricherDynamicType.java @@ -18,8 +18,8 @@ */ package brooklyn.enricher.basic; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.EnricherType; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.EnricherType; import brooklyn.basic.BrooklynDynamicType; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/enricher/basic/EnricherTypeSnapshot.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/enricher/basic/EnricherTypeSnapshot.java b/core/src/main/java/brooklyn/enricher/basic/EnricherTypeSnapshot.java index 0c91461..a8d240d 100644 --- a/core/src/main/java/brooklyn/enricher/basic/EnricherTypeSnapshot.java +++ b/core/src/main/java/brooklyn/enricher/basic/EnricherTypeSnapshot.java @@ -20,7 +20,7 @@ package brooklyn.enricher.basic; import java.util.Map; -import org.apache.brooklyn.policy.EnricherType; +import org.apache.brooklyn.api.policy.EnricherType; import brooklyn.basic.BrooklynTypeSnapshot; import brooklyn.config.ConfigKey; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java index 855bfbf..89a691e 100644 --- a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java +++ b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java @@ -48,11 +48,11 @@ import org.apache.brooklyn.api.management.SubscriptionContext; import org.apache.brooklyn.api.management.SubscriptionHandle; import org.apache.brooklyn.api.management.Task; import org.apache.brooklyn.api.mementos.EntityMemento; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.EnricherSpec; -import org.apache.brooklyn.policy.EntityAdjunct; -import org.apache.brooklyn.policy.Policy; -import org.apache.brooklyn.policy.PolicySpec; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.EnricherSpec; +import org.apache.brooklyn.api.policy.EntityAdjunct; +import org.apache.brooklyn.api.policy.Policy; +import org.apache.brooklyn.api.policy.PolicySpec; import org.apache.commons.lang3.builder.EqualsBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/entity/basic/Entities.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/entity/basic/Entities.java b/core/src/main/java/brooklyn/entity/basic/Entities.java index 45be84b..1f09903 100644 --- a/core/src/main/java/brooklyn/entity/basic/Entities.java +++ b/core/src/main/java/brooklyn/entity/basic/Entities.java @@ -57,8 +57,8 @@ import org.apache.brooklyn.api.management.ManagementContext; import org.apache.brooklyn.api.management.Task; import org.apache.brooklyn.api.management.TaskAdaptable; import org.apache.brooklyn.api.management.TaskFactory; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.Policy; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.Policy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/entity/basic/EntityAdjuncts.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/entity/basic/EntityAdjuncts.java b/core/src/main/java/brooklyn/entity/basic/EntityAdjuncts.java index f105741..4c894d5 100644 --- a/core/src/main/java/brooklyn/entity/basic/EntityAdjuncts.java +++ b/core/src/main/java/brooklyn/entity/basic/EntityAdjuncts.java @@ -22,8 +22,8 @@ import java.util.Iterator; import java.util.List; import org.apache.brooklyn.api.entity.Entity; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.EntityAdjunct; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.EntityAdjunct; import brooklyn.entity.basic.ServiceStateLogic.ComputeServiceIndicatorsFromChildrenAndMembers; import brooklyn.entity.basic.ServiceStateLogic.ComputeServiceState; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java b/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java index be97b32..a25d17e 100644 --- a/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java +++ b/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java @@ -35,8 +35,8 @@ import org.apache.brooklyn.api.location.Location; import org.apache.brooklyn.api.management.ExecutionContext; import org.apache.brooklyn.api.management.ManagementContext; import org.apache.brooklyn.api.mementos.EntityMemento; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.Policy; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.Policy; import brooklyn.config.ConfigKey; import brooklyn.config.ConfigKey.HasConfigKey; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/entity/basic/PolicyDescriptor.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/entity/basic/PolicyDescriptor.java b/core/src/main/java/brooklyn/entity/basic/PolicyDescriptor.java index d99432c..15716a4 100644 --- a/core/src/main/java/brooklyn/entity/basic/PolicyDescriptor.java +++ b/core/src/main/java/brooklyn/entity/basic/PolicyDescriptor.java @@ -18,7 +18,7 @@ */ package brooklyn.entity.basic; -import org.apache.brooklyn.policy.Policy; +import org.apache.brooklyn.api.policy.Policy; import com.google.common.base.Objects; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java b/core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java index da6bffc..2a551b4 100644 --- a/core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java +++ b/core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java @@ -34,9 +34,9 @@ import org.apache.brooklyn.api.event.AttributeSensor; import org.apache.brooklyn.api.event.Sensor; import org.apache.brooklyn.api.event.SensorEvent; import org.apache.brooklyn.api.event.SensorEventListener; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.EnricherSpec; -import org.apache.brooklyn.policy.EnricherSpec.ExtensibleEnricherSpec; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.EnricherSpec; +import org.apache.brooklyn.api.policy.EnricherSpec.ExtensibleEnricherSpec; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/entity/group/DynamicClusterImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/entity/group/DynamicClusterImpl.java b/core/src/main/java/brooklyn/entity/group/DynamicClusterImpl.java index ba487de..5025026 100644 --- a/core/src/main/java/brooklyn/entity/group/DynamicClusterImpl.java +++ b/core/src/main/java/brooklyn/entity/group/DynamicClusterImpl.java @@ -37,7 +37,7 @@ import org.apache.brooklyn.api.entity.proxying.EntitySpec; import org.apache.brooklyn.api.location.Location; import org.apache.brooklyn.api.location.MachineProvisioningLocation; import org.apache.brooklyn.api.management.Task; -import org.apache.brooklyn.policy.Policy; +import org.apache.brooklyn.api.policy.Policy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/entity/proxying/InternalEntityFactory.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/entity/proxying/InternalEntityFactory.java b/core/src/main/java/brooklyn/entity/proxying/InternalEntityFactory.java index b43e32f..42c532f 100644 --- a/core/src/main/java/brooklyn/entity/proxying/InternalEntityFactory.java +++ b/core/src/main/java/brooklyn/entity/proxying/InternalEntityFactory.java @@ -32,10 +32,10 @@ import org.apache.brooklyn.api.entity.basic.EntityLocal; import org.apache.brooklyn.api.entity.proxying.EntityInitializer; import org.apache.brooklyn.api.entity.proxying.EntitySpec; import org.apache.brooklyn.api.entity.proxying.EntityTypeRegistry; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.EnricherSpec; -import org.apache.brooklyn.policy.Policy; -import org.apache.brooklyn.policy.PolicySpec; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.EnricherSpec; +import org.apache.brooklyn.api.policy.Policy; +import org.apache.brooklyn.api.policy.PolicySpec; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/entity/proxying/InternalPolicyFactory.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/entity/proxying/InternalPolicyFactory.java b/core/src/main/java/brooklyn/entity/proxying/InternalPolicyFactory.java index dc79c9a..52fd7ba 100644 --- a/core/src/main/java/brooklyn/entity/proxying/InternalPolicyFactory.java +++ b/core/src/main/java/brooklyn/entity/proxying/InternalPolicyFactory.java @@ -22,10 +22,10 @@ import java.util.Map; import org.apache.brooklyn.api.entity.Feed; import org.apache.brooklyn.api.management.ManagementContext; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.EnricherSpec; -import org.apache.brooklyn.policy.Policy; -import org.apache.brooklyn.policy.PolicySpec; +import org.apache.brooklyn.api.policy.Enricher; +import org.apache.brooklyn.api.policy.EnricherSpec; +import org.apache.brooklyn.api.policy.Policy; +import org.apache.brooklyn.api.policy.PolicySpec; import brooklyn.config.ConfigKey; import brooklyn.enricher.basic.AbstractEnricher; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/904f9508/core/src/main/java/brooklyn/entity/rebind/AbstractBrooklynObjectRebindSupport.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/entity/rebind/AbstractBrooklynObjectRebindSupport.java b/core/src/main/java/brooklyn/entity/rebind/AbstractBrooklynObjectRebindSupport.java index 7f556a1..19a6cd6 100644 --- a/core/src/main/java/brooklyn/entity/rebind/AbstractBrooklynObjectRebindSupport.java +++ b/core/src/main/java/brooklyn/entity/rebind/AbstractBrooklynObjectRebindSupport.java @@ -21,7 +21,7 @@ package brooklyn.entity.rebind; import org.apache.brooklyn.api.entity.rebind.RebindContext; import org.apache.brooklyn.api.entity.rebind.RebindSupport; import org.apache.brooklyn.api.mementos.Memento; -import org.apache.brooklyn.policy.EntityAdjunct; +import org.apache.brooklyn.api.policy.EntityAdjunct; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
