Repository: ambari
Updated Branches:
  refs/heads/trunk dca4fa3e8 -> 82c384ef6


AMBARI-6460. NPEs loading stack definition service config-types


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

Branch: refs/heads/trunk
Commit: 82c384ef673ace6db8ceb053705254e15a040cc4
Parents: dca4fa3
Author: Srimanth Gunturi <sgunt...@hortonworks.com>
Authored: Thu Jul 10 12:36:07 2014 -0700
Committer: Srimanth Gunturi <sgunt...@hortonworks.com>
Committed: Thu Jul 10 12:36:07 2014 -0700

----------------------------------------------------------------------
 .../server/api/util/StackExtensionHelper.java   |  2 +-
 .../api/util/StackExtensionHelperTest.java      | 42 +++++++++
 .../PIG/configuration/pig-properties.xml        | 91 ++++++++++++++++++++
 .../stacks/HDP/2.1.1/services/PIG/metainfo.xml  | 27 ++++++
 4 files changed, 161 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/82c384ef/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java
index 6929ea9..89e9d4a 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java
@@ -649,7 +649,7 @@ public class StackExtensionHelper {
   void addConfigTypeProperty(ServiceInfo serviceInfo, String configType,
                              String propertiesGroupName, String key, String 
value) {
     Map<String, Map<String, Map<String, String>>> configTypes = 
serviceInfo.getConfigTypes();
-    if (configTypes.containsKey(configType)) {
+    if (configTypes != null && configTypes.containsKey(configType)) {
       Map<String, Map<String, String>> configDependencyProperties = 
configTypes.get(configType);
       if (!configDependencyProperties.containsKey(propertiesGroupName)) {
         configDependencyProperties.put(propertiesGroupName, new 
HashMap<String, String>());

http://git-wip-us.apache.org/repos/asf/ambari/blob/82c384ef/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java
index 9f4ed06..9e2681f 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java
@@ -332,6 +332,24 @@ public class StackExtensionHelperTest {
   }
 
   @Test
+  public void testAddConfigTypeProperty_configTypesIsNull() {
+    // init
+    File stackRoot = new File(stackRootStr);
+    StackExtensionHelper helper = new StackExtensionHelper(injector, 
stackRoot);
+    ServiceInfo serviceInfo = createMock(ServiceInfo.class);
+
+    // expectations
+    expect(serviceInfo.getConfigTypes()).andReturn(null);
+    replay(serviceInfo);
+
+    // eval
+    helper.addConfigTypeProperty(serviceInfo, "dep", "group", "key", "value");
+
+    // verification
+    verify(serviceInfo);
+  }
+
+  @Test
   public void testAddConfigTypeProperty_groupDoesNotExist() {
     // init
     File stackRoot = new File(stackRootStr);
@@ -514,6 +532,30 @@ public class StackExtensionHelperTest {
   }
 
   @Test
+  public void testPopulateServiceProperties_configTypesIsNull() throws 
Exception {
+    // init
+    File stackRoot = new File(stackRootStr);
+    StackExtensionHelper helper = new StackExtensionHelper(injector, 
stackRoot);
+    File config = new File(stackRootStr
+        + 
"HDP/2.1.1/services/PIG/configuration/pig-properties.xml".replaceAll("/", 
File.separator));
+    ServiceInfo serviceInfo = createMock(ServiceInfo.class);
+    List<PropertyInfo> properties = createNiceMock(List.class);
+
+    // expectations
+    expect(serviceInfo.getProperties()).andReturn(properties).times(1);
+    expect(properties.addAll((Collection) 
anyObject())).andReturn(true).times(1);
+    expect(serviceInfo.getConfigTypes()).andReturn(null).times(1);
+    replay(properties);
+    replay(serviceInfo);
+
+    // eval
+    helper.populateServiceProperties(config, serviceInfo);
+
+    // verification
+    verify(properties, serviceInfo);
+  }
+
+  @Test
   public void testUnmarshallConfigurationXml() throws Exception {
     File configFile = new 
File("./src/test/resources/bad-stacks/HDP/0.1/services/YARN/configuration/capacity-scheduler.xml");
     ConfigurationXml config = 
StackExtensionHelper.unmarshal(ConfigurationXml.class, configFile);

http://git-wip-us.apache.org/repos/asf/ambari/blob/82c384ef/ambari-server/src/test/resources/stacks/HDP/2.1.1/services/PIG/configuration/pig-properties.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/resources/stacks/HDP/2.1.1/services/PIG/configuration/pig-properties.xml
 
b/ambari-server/src/test/resources/stacks/HDP/2.1.1/services/PIG/configuration/pig-properties.xml
new file mode 100644
index 0000000..63b99e2
--- /dev/null
+++ 
b/ambari-server/src/test/resources/stacks/HDP/2.1.1/services/PIG/configuration/pig-properties.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<!--
+/**
+ * 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.
+ */
+-->
+
+<configuration supports_final="false">
+
+  <property>
+    <name>pig-content</name>
+    <value>
+# 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.
+
+# Pig default configuration file. All values can be overwritten by 
pig.properties and command line arguments.
+# see bin/pig -help
+
+# brief logging (no timestamps)
+brief=false
+
+# debug level, INFO is default
+debug=INFO
+
+# verbose print all log messages to screen (default to print only INFO and 
above to screen)
+verbose=false
+
+# exectype local|mapreduce, mapreduce is default
+exectype=mapreduce
+
+# Enable insertion of information about script into hadoop job conf 
+pig.script.info.enabled=true
+
+# Do not spill temp files smaller than this size (bytes)
+pig.spill.size.threshold=5000000
+
+# EXPERIMENT: Activate garbage collection when spilling a file bigger than 
this size (bytes)
+# This should help reduce the number of files being spilled.
+pig.spill.gc.activation.size=40000000
+
+# the following two parameters are to help estimate the reducer number
+pig.exec.reducers.bytes.per.reducer=1000000000
+pig.exec.reducers.max=999
+
+# Temporary location to store the intermediate data.
+pig.temp.dir=/tmp/
+
+# Threshold for merging FRJoin fragment files
+pig.files.concatenation.threshold=100
+pig.optimistic.files.concatenation=false;
+
+pig.disable.counter=false
+
+# Avoid pig failures when multiple jobs write to the same location
+pig.location.check.strict=false
+
+hcat.bin=/usr/bin/hcat
+
+    </value>
+  </property>
+
+</configuration>

http://git-wip-us.apache.org/repos/asf/ambari/blob/82c384ef/ambari-server/src/test/resources/stacks/HDP/2.1.1/services/PIG/metainfo.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/resources/stacks/HDP/2.1.1/services/PIG/metainfo.xml 
b/ambari-server/src/test/resources/stacks/HDP/2.1.1/services/PIG/metainfo.xml
new file mode 100644
index 0000000..50d3146
--- /dev/null
+++ 
b/ambari-server/src/test/resources/stacks/HDP/2.1.1/services/PIG/metainfo.xml
@@ -0,0 +1,27 @@
+<?xml version="1.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.
+-->
+<metainfo>
+  <schemaVersion>2.0</schemaVersion>
+  <services>
+    <service>
+      <name>PIG</name>
+      <comment>Scripting platform for analyzing large datasets</comment>
+      <version>0.12.1.2.1.1</version>
+    </service>
+  </services>
+</metainfo>

Reply via email to