ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [07/12] ambari git commit: AMBARI-18609. Implement a way to configure Stack Upgrade Merger to skip particular properties to be merged from stack defaults (aonishuk)
Date Tue, 18 Oct 2016 19:32:59 GMT
AMBARI-18609. Implement a way to configure Stack Upgrade Merger to skip particular properties
to be merged from stack defaults (aonishuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3fc0b3e6
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3fc0b3e6
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3fc0b3e6

Branch: refs/heads/branch-feature-AMBARI-18456
Commit: 3fc0b3e66b605bc628e9994be1c96c2c46396388
Parents: 61cc3a9
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Tue Oct 18 17:54:51 2016 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Tue Oct 18 17:54:51 2016 +0300

----------------------------------------------------------------------
 .../internal/UpgradeResourceProvider.java       |  4 +-
 .../ambari/server/state/ConfigHelper.java       | 17 +++---
 .../ambari/server/state/PropertyInfo.java       | 11 ++++
 .../state/PropertyStackUpgradeBehavior.java     | 57 ++++++++++++++++++++
 .../src/main/resources/configuration-schema.xsd |  5 ++
 .../services/STORM/configuration/storm-site.xml |  1 +
 .../StackUpgradeConfigurationMergeTest.java     |  4 +-
 .../internal/UpgradeResourceProviderTest.java   |  6 +--
 8 files changed, 91 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3fc0b3e6/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
index d37e32b..7b7a7a3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
@@ -1111,10 +1111,10 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
       // used when determining if a property has been customized and should be
       // overriden with the new stack value)
       Map<String, Map<String, String>> oldStackDefaultConfigurationsByType =
configHelper.getDefaultProperties(
-          currentStackId, cluster);
+          currentStackId, cluster, true);
 
       // populate a map with default configurations from the new stack
-      newConfigurationsByType = configHelper.getDefaultProperties(targetStackId, cluster);
+      newConfigurationsByType = configHelper.getDefaultProperties(targetStackId, cluster,
true);
 
       // We want to skip updating config-types of services that are not in the upgrade pack.
       // Care should be taken as some config-types could be in services that are in and out

http://git-wip-us.apache.org/repos/asf/ambari/blob/3fc0b3e6/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
index 70c24f9..197ffdd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
@@ -944,11 +944,12 @@ public class ConfigHelper {
    * @param cluster
    *          the cluster to use when determining which services default
    *          configurations to include (not {@code null}).
+   * @param onStackUpgradeFilter if true skip {@code <on-stack-upgrade merge="false"/>}
properties
    * @return a mapping of configuration type to map of key/value pairs for the
    *         default configurations.
    * @throws AmbariException
    */
-  public Map<String, Map<String, String>> getDefaultProperties(StackId stack,
Cluster cluster)
+  public Map<String, Map<String, String>> getDefaultProperties(StackId stack,
Cluster cluster, boolean onStackUpgradeFilter)
       throws AmbariException {
     Map<String, Map<String, String>> defaultPropertiesByType = new HashMap<String,
Map<String, String>>();
 
@@ -962,9 +963,10 @@ public class ConfigHelper {
       if (!defaultPropertiesByType.containsKey(type)) {
         defaultPropertiesByType.put(type, new HashMap<String, String>());
       }
-
-      defaultPropertiesByType.get(type).put(stackDefaultProperty.getName(),
-          stackDefaultProperty.getValue());
+      if (!onStackUpgradeFilter || stackDefaultProperty.getPropertyStackUpgradeBehavior().isMerge())
{
+        defaultPropertiesByType.get(type).put(stackDefaultProperty.getName(),
+            stackDefaultProperty.getValue());
+      }
     }
 
     // for every installed service, populate the default service properties
@@ -979,9 +981,10 @@ public class ConfigHelper {
         if (!defaultPropertiesByType.containsKey(type)) {
           defaultPropertiesByType.put(type, new HashMap<String, String>());
         }
-
-        defaultPropertiesByType.get(type).put(serviceDefaultProperty.getName(),
-            serviceDefaultProperty.getValue());
+        if (!onStackUpgradeFilter || serviceDefaultProperty.getPropertyStackUpgradeBehavior().isMerge())
{
+          defaultPropertiesByType.get(type).put(serviceDefaultProperty.getName(),
+              serviceDefaultProperty.getValue());
+        }
       }
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/3fc0b3e6/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
index f89be4d..81de76c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
@@ -53,6 +53,9 @@ public class PropertyInfo {
   @XmlElement(name="on-ambari-upgrade", required = true)
   private PropertyUpgradeBehavior propertyAmbariUpgradeBehavior;
 
+  @XmlElement(name="on-stack-upgrade")
+  private PropertyStackUpgradeBehavior propertyStackUpgradeBehavior = new PropertyStackUpgradeBehavior();
+
   @XmlAttribute(name = "require-input")
   private boolean requireInput;
 
@@ -248,6 +251,14 @@ public class PropertyInfo {
       '}';
   }
 
+  public PropertyStackUpgradeBehavior getPropertyStackUpgradeBehavior() {
+    return propertyStackUpgradeBehavior;
+  }
+
+  public void setPropertyStackUpgradeBehavior(PropertyStackUpgradeBehavior propertyStackUpgradeBehavior)
{
+    this.propertyStackUpgradeBehavior = propertyStackUpgradeBehavior;
+  }
+
   public enum PropertyType {
     PASSWORD,
     USER,

http://git-wip-us.apache.org/repos/asf/ambari/blob/3fc0b3e6/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyStackUpgradeBehavior.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyStackUpgradeBehavior.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyStackUpgradeBehavior.java
new file mode 100644
index 0000000..5e11601
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyStackUpgradeBehavior.java
@@ -0,0 +1,57 @@
+/**
+ * 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.ambari.server.state;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ * Represents a behavior used during ambari upgrade for property
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+public class PropertyStackUpgradeBehavior {
+
+  /**
+   * If true, then merge this property during stack-upgrade
+   */
+  @XmlAttribute(name="merge", required = false)
+  private boolean merge = true;
+
+  public PropertyStackUpgradeBehavior() {
+  }
+
+  public PropertyStackUpgradeBehavior(boolean merge) {
+    this.merge = merge;
+  }
+
+  /**
+   * @return policy of merging this property during stack-upgrade
+   */
+  public boolean isMerge() {
+    return merge;
+  }
+
+  /**
+   * set policy of merging this property during stack-upgrade
+   * @param merge if true, then merge this property during stack-upgrade
+   */
+  public void setMerge(boolean merge) {
+    this.merge = merge;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/3fc0b3e6/ambari-server/src/main/resources/configuration-schema.xsd
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/configuration-schema.xsd b/ambari-server/src/main/resources/configuration-schema.xsd
index 41d4e51..daba29f 100644
--- a/ambari-server/src/main/resources/configuration-schema.xsd
+++ b/ambari-server/src/main/resources/configuration-schema.xsd
@@ -41,6 +41,7 @@
       <xs:element name="deleted" type="xs:boolean" minOccurs="0"/>
       <xs:element name="final" type="xs:boolean" minOccurs="0"/>
       <xs:element name="on-ambari-upgrade" type="propertyUpgradeBehavior" minOccurs="1"/>
+      <xs:element name="on-stack-upgrade" type="propertyStackUpgradeBehavior" minOccurs="0"/>
       <xs:element name="property-type" minOccurs="0">
         <xs:simpleType>
           <xs:list itemType="propertyType"/>
@@ -72,6 +73,10 @@
     <xs:attribute name="update" type="xs:boolean" use="optional"/>
   </xs:complexType>
 
+  <xs:complexType name="propertyStackUpgradeBehavior">
+    <xs:attribute name="merge" type="xs:boolean" use="optional" default="true"/>
+  </xs:complexType>
+
   <xs:complexType name="valueAttributesInfo">
     <xs:all>
       <xs:element name="type" type="xs:string" minOccurs="0"/>

http://git-wip-us.apache.org/repos/asf/ambari/blob/3fc0b3e6/ambari-server/src/main/resources/stacks/HDP/2.3/services/STORM/configuration/storm-site.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/services/STORM/configuration/storm-site.xml
b/ambari-server/src/main/resources/stacks/HDP/2.3/services/STORM/configuration/storm-site.xml
index b71f4a9..2392079 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/services/STORM/configuration/storm-site.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/services/STORM/configuration/storm-site.xml
@@ -69,5 +69,6 @@
       </property>
     </depends-on>
     <on-ambari-upgrade add="false"/>
+    <on-stack-upgrade merge="false"/>
   </property>
 </configuration>

http://git-wip-us.apache.org/repos/asf/ambari/blob/3fc0b3e6/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackUpgradeConfigurationMergeTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackUpgradeConfigurationMergeTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackUpgradeConfigurationMergeTest.java
index 4f2580a..a49fc09 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackUpgradeConfigurationMergeTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackUpgradeConfigurationMergeTest.java
@@ -193,11 +193,11 @@ public class StackUpgradeConfigurationMergeTest extends EasyMockSupport
{
 
     // HDP 2.4 configs
     EasyMock.expect(configHelper.getDefaultProperties(EasyMock.eq(s_currentStackId),
-        EasyMock.anyObject(Cluster.class))).andReturn(oldStackDefaultConfigurationsByType);
+        EasyMock.anyObject(Cluster.class), EasyMock.anyBoolean())).andReturn(oldStackDefaultConfigurationsByType);
 
     // HDP 2.5 configs
     EasyMock.expect(configHelper.getDefaultProperties(EasyMock.eq(s_targetStackId),
-        EasyMock.anyObject(Cluster.class))).andReturn(newConfigurationsByType);
+        EasyMock.anyObject(Cluster.class), EasyMock.anyBoolean())).andReturn(newConfigurationsByType);
 
     // CURRENT HDP 2.4 configs
     Config currentClusterConfigFoo = createNiceMock(Config.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/3fc0b3e6/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
index 63892cf..c8325e0 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
@@ -154,7 +154,7 @@ public class UpgradeResourceProviderTest {
 
     expect(
         configHelper.getDefaultProperties(EasyMock.anyObject(StackId.class),
-            EasyMock.anyObject(Cluster.class))).andReturn(
+            EasyMock.anyObject(Cluster.class), EasyMock.anyBoolean())).andReturn(
         new HashMap<String, Map<String, String>>()).anyTimes();
 
 
@@ -1168,11 +1168,11 @@ public class UpgradeResourceProviderTest {
     EasyMock.reset(configHelper);
 
     expect(
-        configHelper.getDefaultProperties(EasyMock.eq(stack211), EasyMock.anyObject(Cluster.class))).andReturn(
+        configHelper.getDefaultProperties(EasyMock.eq(stack211), EasyMock.anyObject(Cluster.class),
EasyMock.anyBoolean())).andReturn(
         stack211Configs).anyTimes();
 
     expect(
-        configHelper.getDefaultProperties(EasyMock.eq(stack220), EasyMock.anyObject(Cluster.class))).andReturn(
+        configHelper.getDefaultProperties(EasyMock.eq(stack220), EasyMock.anyObject(Cluster.class),
EasyMock.anyBoolean())).andReturn(
         stack220Configs).anyTimes();
 
     Capture<Map<String, Map<String, String>>> expectedConfigurationsCapture
= new Capture<Map<String, Map<String, String>>>();


Mime
View raw message