You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by dr...@apache.org on 2017/05/19 10:27:42 UTC
[3/4] brooklyn-server git commit: Delete deprecated
persistence/rebind code
Delete deprecated persistence/rebind code
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/846314a7
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/846314a7
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/846314a7
Branch: refs/heads/master
Commit: 846314a7734b6a251f128047fb7fbb19ca1bb69d
Parents: 3c35a1e
Author: Aled Sage <al...@gmail.com>
Authored: Thu May 18 16:01:20 2017 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Fri May 19 10:47:26 2017 +0100
----------------------------------------------------------------------
.../mgmt/rebind/BasicEntityRebindSupport.java | 18 ----
.../mgmt/rebind/dto/MementosGenerators.java | 87 +-------------------
.../core/mgmt/rebind/RebindEntityTest.java | 35 --------
.../mgmt/rebind/RebindManagerSorterTest.java | 2 +-
4 files changed, 4 insertions(+), 138 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/846314a7/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
index f3e4b5b..aa3e7a8 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
@@ -19,7 +19,6 @@ package org.apache.brooklyn.core.mgmt.rebind;
import static com.google.common.base.Preconditions.checkNotNull;
-import java.util.Collections;
import java.util.Map;
import org.apache.brooklyn.api.effector.Effector;
@@ -41,7 +40,6 @@ import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
import org.apache.brooklyn.core.feed.AbstractFeed;
import org.apache.brooklyn.core.location.Machines;
-import org.apache.brooklyn.core.mgmt.rebind.dto.MementosGenerators;
import org.apache.brooklyn.core.objs.AbstractBrooklynObject;
import org.apache.brooklyn.core.policy.AbstractPolicy;
import org.apache.brooklyn.entity.group.AbstractGroupImpl;
@@ -64,22 +62,6 @@ public class BasicEntityRebindSupport extends AbstractBrooklynObjectRebindSuppor
this.entity = checkNotNull(entity, "entity");
}
- // Can rely on super-type once the deprecated getMementoWithProperties is deleted
- @Override
- public EntityMemento getMemento() {
- return getMementoWithProperties(Collections.<String,Object>emptyMap());
- }
-
- /**
- * @deprecated since 0.7.0; use generic config/attributes rather than "custom fields", so use {@link #getMemento()}
- */
- @Deprecated
- protected EntityMemento getMementoWithProperties(Map<String,?> props) {
- EntityMemento memento = MementosGenerators.newEntityMementoBuilder(entity).customFields(props).build();
- if (LOG.isTraceEnabled()) LOG.trace("Creating memento for entity: {}", memento.toVerboseString());
- return memento;
- }
-
@Override
@SuppressWarnings("unchecked")
protected void addCustoms(RebindContext rebindContext, EntityMemento memento) {
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/846314a7/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementosGenerators.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementosGenerators.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementosGenerators.java
index dce5c97..3a33498 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementosGenerators.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementosGenerators.java
@@ -72,7 +72,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.annotations.Beta;
-import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicates;
import com.google.common.collect.Sets;
@@ -83,12 +82,6 @@ public class MementosGenerators {
private static final Logger log = LoggerFactory.getLogger(MementosGenerators.class);
- /** @deprecated since 0.7.0 use {@link #newBasicMemento(BrooklynObject)} */
- @Deprecated
- public static Memento newMemento(BrooklynObject instance) {
- return newBasicMemento(instance);
- }
-
/**
* Inspects a brooklyn object to create a basic corresponding memento.
* <p>
@@ -158,19 +151,8 @@ public class MementosGenerators {
/**
* Inspects an entity to create a corresponding memento.
- * <p>
- * @deprecated since 0.7.0, see {@link #newBasicMemento(BrooklynObject)}
- */
- @Deprecated
- public static EntityMemento newEntityMemento(Entity entity) {
- return newEntityMementoBuilder(entity).build();
- }
-
- /**
- * @deprecated since 0.7.0; use {@link #newBasicMemento(BrooklynObject)} instead
*/
- @Deprecated
- public static BasicEntityMemento.Builder newEntityMementoBuilder(Entity entityRaw) {
+ private static EntityMemento newEntityMemento(Entity entityRaw) {
EntityInternal entity = (EntityInternal) entityRaw;
BasicEntityMemento.Builder builder = BasicEntityMemento.builder();
populateBrooklynObjectMementoBuilder(entity, builder);
@@ -244,24 +226,10 @@ public class MementosGenerators {
}
}
- return builder;
+ return builder.build();
}
/**
- * @deprecated since 0.7.0, see {@link #newBasicMemento(BrooklynObject)}
- */
- @Deprecated
- public static Function<Entity, EntityMemento> entityMementoFunction() {
- return new Function<Entity,EntityMemento>() {
- @Override
- public EntityMemento apply(Entity input) {
- return MementosGenerators.newEntityMemento(input);
- }
- };
- }
-
-
- /**
* Given a location, extracts its state for serialization.
*
* For bits of state that are references to other locations, these are treated in a special way:
@@ -311,20 +279,6 @@ public class MementosGenerators {
}
/**
- * @deprecated since 0.7.0, see {@link #newBasicMemento(BrooklynObject)}
- */
- @Deprecated
- public static Function<Location, LocationMemento> locationMementoFunction() {
- return new Function<Location,LocationMemento>() {
- @Override
- public LocationMemento apply(Location input) {
- return MementosGenerators.newLocationMemento(input);
- }
- };
- }
-
-
- /**
* Given a policy, extracts its state for serialization.
*
* @deprecated since 0.7.0, see {@link #newBasicMemento(BrooklynObject)}
@@ -356,19 +310,6 @@ public class MementosGenerators {
}
/**
- * @deprecated since 0.7.0, see {@link #newBasicMemento(BrooklynObject)}
- */
- @Deprecated
- public static Function<Policy, PolicyMemento> policyMementoFunction() {
- return new Function<Policy,PolicyMemento>() {
- @Override
- public PolicyMemento apply(Policy input) {
- return MementosGenerators.newPolicyMemento(input);
- }
- };
- }
-
- /**
* Given an enricher, extracts its state for serialization.
* @deprecated since 0.7.0, see {@link #newBasicMemento(BrooklynObject)}
*/
@@ -421,11 +362,7 @@ public class MementosGenerators {
return builder.build();
}
- /**
- * @deprecated since 0.7.0, see {@link #newBasicMemento(BrooklynObject)}
- */
- @Deprecated
- public static CatalogItemMemento newCatalogItemMemento(CatalogItem<?, ?> catalogItem) {
+ private static CatalogItemMemento newCatalogItemMemento(CatalogItem<?, ?> catalogItem) {
if (catalogItem instanceof CatalogItemDo<?,?>) {
catalogItem = ((CatalogItemDo<?,?>)catalogItem).getDto();
}
@@ -524,22 +461,4 @@ public class MementosGenerators {
}
return value;
}
-
- public static Function<Enricher, EnricherMemento> enricherMementoFunction() {
- return new Function<Enricher,EnricherMemento>() {
- @Override
- public EnricherMemento apply(Enricher input) {
- return MementosGenerators.newEnricherMemento(input);
- }
- };
- }
-
- public static Function<Feed, FeedMemento> feedMementoFunction() {
- return new Function<Feed,FeedMemento>() {
- @Override
- public FeedMemento apply(Feed input) {
- return MementosGenerators.newFeedMemento(input);
- }
- };
- }
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/846314a7/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java
index 32720b9..8c2e7b7 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java
@@ -238,17 +238,6 @@ public class RebindEntityTest extends RebindTestFixtureWithApp {
}
@Test
- public void testCanCustomizeRebind() throws Exception {
- MyEntity2 origE = origApp.createAndManageChild(EntitySpec.create(MyEntity2.class).configure("myfield", "myval"));
-
- newApp = rebind();
-
- MyEntity2 newE = (MyEntity2) Iterables.find(newApp.getChildren(), Predicates.instanceOf(MyEntity2.class));
- assertEquals(newE.getMyfield(), "myval");
- Assert.assertEquals(newE, origE);
- }
-
- @Test
public void testRebindsSubscriptions() throws Exception {
MyEntity2 origE = origApp.createAndManageChild(EntitySpec.create(MyEntity2.class).configure("subscribe", true));
@@ -835,14 +824,9 @@ public class RebindEntityTest extends RebindTestFixtureWithApp {
Boolean.class, "test.subscribe", "Whether to do some subscriptions on re-bind", false);
public List<String> getEvents();
-
- public String getMyfield();
}
public static class MyEntity2Impl extends AbstractEntity implements MyEntity2 {
- @SetFromFlag
- String myfield;
-
final List<String> events = new CopyOnWriteArrayList<String>();
@SuppressWarnings("unused")
@@ -857,11 +841,6 @@ public class RebindEntityTest extends RebindTestFixtureWithApp {
}
@Override
- public String getMyfield() {
- return myfield;
- }
-
- @Override
public void onManagementStarting() {
if (getConfig(SUBSCRIBE)) {
subscriptions().subscribe(getApplication(), TestApplication.MY_ATTRIBUTE, new SensorEventListener<String>() {
@@ -871,20 +850,6 @@ public class RebindEntityTest extends RebindTestFixtureWithApp {
});
}
}
-
- @Override
- public RebindSupport<EntityMemento> getRebindSupport() {
- return new BasicEntityRebindSupport(this) {
- @Override public EntityMemento getMemento() {
- // Note: using MutableMap so accepts nulls
- return getMementoWithProperties(MutableMap.<String,Object>of("myfield", myfield));
- }
- @Override protected void doReconstruct(RebindContext rebindContext, EntityMemento memento) {
- super.doReconstruct(rebindContext, memento);
- myfield = (String) memento.getCustomField("myfield");
- }
- };
- }
}
@ImplementedBy(MyLatchingEntityImpl.class)
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/846314a7/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerSorterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerSorterTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerSorterTest.java
index 6387b81..598c0d5 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerSorterTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerSorterTest.java
@@ -140,7 +140,7 @@ public class RebindManagerSorterTest {
private Map<String, EntityMemento> toMementos(Iterable<? extends Entity> entities) {
Map<String, EntityMemento> result = Maps.newLinkedHashMap();
for (Entity entity : entities) {
- result.put(entity.getId(), MementosGenerators.newEntityMemento(Entities.deproxy(entity)));
+ result.put(entity.getId(), (EntityMemento) MementosGenerators.newBasicMemento(Entities.deproxy(entity)));
}
return result;
}