You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2016/10/11 14:50:50 UTC
[1/2] brooklyn-server git commit: deserializingClassRenames: handle
renames in ConfigInheritance
Repository: brooklyn-server
Updated Branches:
refs/heads/master fea8a6e6a -> 0b5c1bed6
deserializingClassRenames: handle renames in ConfigInheritance
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/28d0493a
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/28d0493a
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/28d0493a
Branch: refs/heads/master
Commit: 28d0493a7174cca28bc1bba71bc4e034f86d63db
Parents: 6f6763c
Author: Aled Sage <al...@gmail.com>
Authored: Mon Oct 10 14:13:54 2016 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Mon Oct 10 14:16:40 2016 +0100
----------------------------------------------------------------------
.../deserializingClassRenames.properties | 6 +-
...RebindWithDeserializingClassRenamesTest.java | 98 +++++++++++++
.../rebind/deserializing-class-names/toruf2wxg4 | 137 +++++++++++++++++++
3 files changed, 240 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/28d0493a/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties
----------------------------------------------------------------------
diff --git a/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties b/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties
index 7909006..64981fb 100644
--- a/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties
+++ b/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties
@@ -1429,4 +1429,8 @@ brooklyn.test.entity.TestClusterImpl
brooklyn.test.entity.TestApplication : org.apache.brooklyn.core.test.entity.TestApplication
brooklyn.test.entity.TestApplicationImpl : org.apache.brooklyn.core.test.entity.TestApplicationImpl
brooklyn.test.entity.BlockingEntity : org.apache.brooklyn.core.test.entity.BlockingEntity
-brooklyn.test.entity.BlockingEntityImpl : org.apache.brooklyn.core.test.entity.BlockingEntityImpl
\ No newline at end of file
+brooklyn.test.entity.BlockingEntityImpl : org.apache.brooklyn.core.test.entity.BlockingEntityImpl
+
+org.apache.brooklyn.config.ConfigInheritance$None : org.apache.brooklyn.config.ConfigInheritance$Legacy$None
+org.apache.brooklyn.config.ConfigInheritance$Always : org.apache.brooklyn.config.ConfigInheritance$Legacy$Always
+org.apache.brooklyn.config.ConfigInheritance$Merged : org.apache.brooklyn.config.ConfigInheritance$Legacy$Merged
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/28d0493a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindWithDeserializingClassRenamesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindWithDeserializingClassRenamesTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindWithDeserializingClassRenamesTest.java
new file mode 100644
index 0000000..c5e48c9
--- /dev/null
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindWithDeserializingClassRenamesTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.core.mgmt.rebind;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.apache.brooklyn.config.ConfigInheritance;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.ConfigKeys.InheritanceContext;
+import org.apache.brooklyn.core.config.ConfigPredicates;
+import org.apache.brooklyn.core.entity.EntityInternal;
+import org.apache.brooklyn.util.core.ResourceUtils;
+import org.apache.brooklyn.util.os.Os;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import com.google.common.io.Files;
+
+public class RebindWithDeserializingClassRenamesTest extends RebindTestFixtureWithApp {
+
+ @Test
+ @SuppressWarnings("deprecation")
+ public void testRebindWillRenameLegacyConfigInheritance() throws Exception {
+ Map<String, String> expectedTransforms = ImmutableMap.<String, String>builder()
+ .put("org.apache.brooklyn.config.ConfigInheritance$None", "org.apache.brooklyn.config.ConfigInheritance$Legacy$None")
+ .put("org.apache.brooklyn.config.ConfigInheritance$Always", "org.apache.brooklyn.config.ConfigInheritance$Legacy$Always")
+ .put("org.apache.brooklyn.config.ConfigInheritance$Merged", "org.apache.brooklyn.config.ConfigInheritance$Legacy$Merged")
+ .build();
+
+ String entityId = "toruf2wxg4";
+ String entityResource = "org/apache/brooklyn/core/test/rebind/deserializing-class-names/"+entityId;
+ String persistedEntity = ResourceUtils.create(RebindWithDeserializingClassRenamesTest.class).getResourceAsString(entityResource);
+
+ // Orig state contains the old names (and not the new names)
+ for (Map.Entry<String, String> entry : expectedTransforms.entrySet()) {
+ assertTrue(persistedEntity.contains(entry.getKey()));
+ assertFalse(persistedEntity.contains(entry.getValue()));
+ }
+
+ File persistedEntityFile = new File(mementoDir, Os.mergePaths("entities", entityId));
+ Files.write(persistedEntity.getBytes(), persistedEntityFile);
+
+ rebind();
+
+ // After rebind, we've re-written the persisted state so it contains the new names (and not old names)
+ RebindTestUtils.waitForPersisted(mgmt());
+ String newPersistedEntity = Joiner.on("\n").join(Files.readLines(persistedEntityFile, Charsets.UTF_8));
+ for (Map.Entry<String, String> entry : expectedTransforms.entrySet()) {
+ assertFalse(newPersistedEntity.contains(entry.getKey()));
+ assertTrue(newPersistedEntity.contains(entry.getValue()));
+ }
+
+ // Check the config keys are as expected
+ EntityInternal entity = (EntityInternal) mgmt().getEntityManager().getEntity(entityId);
+ Map<ConfigKey<?>, Object> config = entity.config().getAllLocalRaw();
+ ConfigKey<?> keyWithInheritanceNone = Iterables.find(config.keySet(), ConfigPredicates.nameEqualTo("my.config.inheritanceNone"));
+ ConfigKey<?> keyWithInheritanceAlways = Iterables.find(config.keySet(), ConfigPredicates.nameEqualTo("my.config.inheritanceAlways"));
+ ConfigKey<?> keyWithInheritanceMerged = Iterables.find(config.keySet(), ConfigPredicates.nameEqualTo("my.config.inheritanceMerged"));
+
+ assertLegacyConfigRuntimInheritanceMode(keyWithInheritanceNone, ConfigInheritance.InheritanceMode.NONE);
+ assertLegacyConfigRuntimInheritanceMode(keyWithInheritanceAlways, ConfigInheritance.InheritanceMode.IF_NO_EXPLICIT_VALUE);
+ assertLegacyConfigRuntimInheritanceMode(keyWithInheritanceMerged, ConfigInheritance.InheritanceMode.DEEP_MERGE);
+ }
+
+ @SuppressWarnings("deprecation")
+ private void assertLegacyConfigRuntimInheritanceMode(ConfigKey<?> key, ConfigInheritance.InheritanceMode expected) throws Exception {
+ ConfigInheritance val = key.getInheritanceByContext().get(InheritanceContext.RUNTIME_MANAGEMENT);
+ Method method = val.getClass().getDeclaredMethod("getMode");
+ method.setAccessible(true);
+ ConfigInheritance.InheritanceMode mode = (ConfigInheritance.InheritanceMode) method.invoke(val);
+ assertEquals(mode, expected);
+ }
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/28d0493a/core/src/test/resources/org/apache/brooklyn/core/test/rebind/deserializing-class-names/toruf2wxg4
----------------------------------------------------------------------
diff --git a/core/src/test/resources/org/apache/brooklyn/core/test/rebind/deserializing-class-names/toruf2wxg4 b/core/src/test/resources/org/apache/brooklyn/core/test/rebind/deserializing-class-names/toruf2wxg4
new file mode 100644
index 0000000..7a59b4e
--- /dev/null
+++ b/core/src/test/resources/org/apache/brooklyn/core/test/rebind/deserializing-class-names/toruf2wxg4
@@ -0,0 +1,137 @@
+<!--
+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.
+-->
+
+<entity>
+ <brooklynVersion>0.10.0-20160908.1322</brooklynVersion>
+ <type>org.apache.brooklyn.entity.stock.BasicApplicationImpl</type>
+ <id>toruf2wxg4</id>
+ <displayName>Application (toruf2wxg4)</displayName>
+ <tags>
+ <org.apache.brooklyn.core.mgmt.BrooklynTags_-NamedStringTag>
+ <kind>yaml_spec</kind>
+ <contents>services:
+- type: org.apache.brooklyn.entity.stock.BasicApplication</contents>
+ </org.apache.brooklyn.core.mgmt.BrooklynTags_-NamedStringTag>
+ </tags>
+ <config>
+ <my.config.inheritanceNone>myval</my.config.inheritanceNone>
+ <my.config.inheritanceMerged>myval</my.config.inheritanceMerged>
+ <my.config.inheritanceAlways>myval</my.config.inheritanceAlways>
+ </config>
+ <attributes>
+ <service.notUp.indicators>
+ <MutableMap/>
+ </service.notUp.indicators>
+ <entity.id>toruf2wxg4</entity.id>
+ <application.id>toruf2wxg4</application.id>
+ <catalog.id>
+ <null/>
+ </catalog.id>
+ <service.isUp type="boolean">true</service.isUp>
+ <service.problems>
+ <MutableMap/>
+ </service.problems>
+ <service.state type="org.apache.brooklyn.core.entity.lifecycle.Lifecycle">RUNNING</service.state>
+ <service.state.expected>
+ <org.apache.brooklyn.core.entity.lifecycle.Lifecycle_-Transition>
+ <state>RUNNING</state>
+ <timestampUtc>1476100554627</timestampUtc>
+ </org.apache.brooklyn.core.entity.lifecycle.Lifecycle_-Transition>
+ </service.state.expected>
+ </attributes>
+
+ <configKeys>
+ <!-- Hand-crafted config, for testing -->
+ <my.config.inheritanceNone>
+ <configKey>
+ <name>my.config.inheritanceNone</name>
+ <type>java.lang.String</type>
+ <reconfigurable>false</reconfigurable>
+ <parentInheritance class="org.apache.brooklyn.config.ConfigInheritance$None"/>
+ </configKey>
+ </my.config.inheritanceNone>
+ <my.config.inheritanceMerged>
+ <configKey>
+ <name>my.config.inheritanceMerged</name>
+ <type>java.lang.String</type>
+ <reconfigurable>false</reconfigurable>
+ <parentInheritance class="org.apache.brooklyn.config.ConfigInheritance$Merged"/>
+ </configKey>
+ </my.config.inheritanceMerged>
+ <my.config.inheritanceAlways>
+ <configKey>
+ <name>my.config.inheritanceAlways</name>
+ <type>java.lang.String</type>
+ <reconfigurable>false</reconfigurable>
+ <parentInheritance class="org.apache.brooklyn.config.ConfigInheritance$Always"/>
+ </configKey>
+ </my.config.inheritanceAlways>
+ </configKeys>
+
+ <attributeKeys>
+ <service.notUp.indicators>
+ <attributeSensor>
+ <typeToken class="org.apache.brooklyn.core.entity.Attributes$1" resolves-to="com.google.common.reflect.TypeToken$SimpleTypeToken">
+ <runtimeType class="com.google.common.reflect.Types$ParameterizedTypeImpl">
+ <argumentsList>
+ <java-class>java.lang.String</java-class>
+ <java-class>java.lang.Object</java-class>
+ </argumentsList>
+ <rawType>java.util.Map</rawType>
+ </runtimeType>
+ </typeToken>
+ <name>service.notUp.indicators</name>
+ <description>A map of namespaced indicators that the service is not up</description>
+ <persistence>REQUIRED</persistence>
+ </attributeSensor>
+ </service.notUp.indicators>
+ <service.problems>
+ <attributeSensor>
+ <typeToken class="org.apache.brooklyn.core.entity.Attributes$3" resolves-to="com.google.common.reflect.TypeToken$SimpleTypeToken">
+ <runtimeType class="com.google.common.reflect.Types$ParameterizedTypeImpl">
+ <argumentsList>
+ <java-class>java.lang.String</java-class>
+ <java-class>java.lang.Object</java-class>
+ </argumentsList>
+ <rawType>java.util.Map</rawType>
+ </runtimeType>
+ </typeToken>
+ <name>service.problems</name>
+ <description>A map of namespaced indicators of problems with a service</description>
+ <persistence>REQUIRED</persistence>
+ </attributeSensor>
+ </service.problems>
+ <service.state>
+ <attributeSensor>
+ <type>org.apache.brooklyn.core.entity.lifecycle.Lifecycle</type>
+ <name>service.state</name>
+ <description>Actual lifecycle state of the service</description>
+ <persistence>REQUIRED</persistence>
+ </attributeSensor>
+ </service.state>
+ <service.state.expected>
+ <attributeSensor>
+ <type>org.apache.brooklyn.core.entity.lifecycle.Lifecycle$Transition</type>
+ <name>service.state.expected</name>
+ <description>Last controlled change to service state, indicating what the expected state should be</description>
+ <persistence>REQUIRED</persistence>
+ </attributeSensor>
+ </service.state.expected>
+ </attributeKeys>
+</entity>
[2/2] brooklyn-server git commit: This closes #376
Posted by al...@apache.org.
This closes #376
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/0b5c1bed
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/0b5c1bed
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/0b5c1bed
Branch: refs/heads/master
Commit: 0b5c1bed6cf4dd6f872be06e25954c68efc7f426
Parents: fea8a6e 28d0493
Author: Aled Sage <al...@gmail.com>
Authored: Tue Oct 11 15:50:37 2016 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Oct 11 15:50:37 2016 +0100
----------------------------------------------------------------------
.../deserializingClassRenames.properties | 6 +-
...RebindWithDeserializingClassRenamesTest.java | 98 +++++++++++++
.../rebind/deserializing-class-names/toruf2wxg4 | 137 +++++++++++++++++++
3 files changed, 240 insertions(+), 1 deletion(-)
----------------------------------------------------------------------