OSDN Git Service

add the hdp install flavor to the hadoop recipe.
authorwhitestar <whitestar@gaea.test>
Wed, 31 Jul 2013 12:57:07 +0000 (21:57 +0900)
committerwhitestar <whitestar@gaea.test>
Wed, 31 Jul 2013 12:57:07 +0000 (21:57 +0900)
cookbooks/hadoop/attributes/default.rb
cookbooks/hadoop/recipes/hdp.rb
cookbooks/hadoop/templates/default/etc-2.0/default/hadoop-hdfs-datanode [new file with mode: 0644]
cookbooks/hadoop/templates/default/etc-2.0/hadoop/capacity-scheduler.xml
cookbooks/hadoop/templates/default/etc-2.0/hadoop/hadoop-env.sh
cookbooks/hadoop/templates/default/etc-2.0/hadoop/mapred-env.sh
cookbooks/hadoop/templates/default/etc-2.0/hadoop/yarn-env.sh
cookbooks/hadoop/templates/default/etc-2.0/hadoop/yarn-site.xml
cookbooks/hdp/recipes/yum_repo.rb
roles/test-hdp-on-localhost.rb

index cf1f241..fac045f 100644 (file)
@@ -34,7 +34,9 @@ default['hadoop']['HADOOP_PID_DIR'] = "#{node['grid']['vol_root']}/0/var/run/${U
 default['hadoop']['HADOOP_LOG_DIR'] = "#{node['grid']['vol_root']}/0/var/log/${USER}"
 default['hadoop']['HADOOP_CLASSPATH'] = ''
 default['hadoop']['HADOOP_USER_CLASSPATH_FIRST'] = false
-if node['hadoop']['version'] >= '2.0.0' then
+if node['hadoop']['install_flavor'] == 'hdp' then
+  default['hadoop']['HADOOP_CONF_DIR'] = "/etc/hadoop/conf"
+elsif node['hadoop']['version'] >= '2.0.0' then
   default['hadoop']['HADOOP_CONF_DIR'] = "#{node['hadoop']['HADOOP_PREFIX']}/etc/hadoop"
 else
   default['hadoop']['HADOOP_CONF_DIR'] = "#{node['hadoop']['HADOOP_PREFIX']}/conf"
@@ -45,8 +47,13 @@ default['hadoop']['HADOOP_SECURE_DN_PID_DIR'] = "#{node['grid']['vol_root']}/0/v
 default['hadoop']['HADOOP_SECURE_DN_LOG_DIR'] = "#{node['grid']['vol_root']}/0/var/log/${HADOOP_SECURE_DN_USER}"
 case node['hadoop']['install_flavor']
   when 'hdp'
-    default['hadoop']['HADOOP_PID_DIR'] = '/var/run/hadoop'
-    default['hadoop']['HADOOP_SECURE_DN_PID_DIR'] = '/var/run/hadoop'
+    if node['hdp']['version'] >= '2.0.0' then
+      default['hadoop']['HADOOP_PID_DIR'] = '/var/run/hadoop-hdfs'
+      default['hadoop']['HADOOP_SECURE_DN_PID_DIR'] = '/var/run/hadoop-hdfs'
+    else
+      default['hadoop']['HADOOP_PID_DIR'] = '/var/run/hadoop'
+      default['hadoop']['HADOOP_SECURE_DN_PID_DIR'] = '/var/run/hadoop'
+    end
 end
 
 ## hadoop-policy.xml
@@ -217,10 +224,18 @@ default['hadoop']['YARN_HOME'] = '${HADOOP_PREFIX}'
 default['hadoop']['YARN_PID_DIR'] = "#{node['grid']['vol_root']}/0/var/run/${USER}"
 default['hadoop']['YARN_LOG_DIR'] = "#{node['grid']['vol_root']}/0/var/log/${USER}"
 default['hadoop']['HADOOP_MAPRED_HOME'] = '${HADOOP_PREFIX}'
+case node['hadoop']['install_flavor']
+  when 'hdp'
+    default['hadoop']['YARN_PID_DIR'] = '/var/run/hadoop-yarn'
+end
 
 ## mapred-env.sh (available in the ver. 2.0.2-alpha and later.)
 default['hadoop']['HADOOP_MAPRED_PID_DIR'] = "#{node['grid']['vol_root']}/0/var/run/${USER}"
 default['hadoop']['HADOOP_MAPRED_LOG_DIR'] = "#{node['grid']['vol_root']}/0/var/log/${USER}"
+case node['hadoop']['install_flavor']
+  when 'hdp'
+    default['hadoop']['HADOOP_MAPRED_PID_DIR'] = '/var/run/hadoop-mapreduce'
+end
 
 ## core-site.xml
 default['hadoop']['fs.defaultFS'] = 'hdfs://${this.namenode.fqdn}:9000'
@@ -240,6 +255,24 @@ default['hadoop']['yarn.nodemanager.resource.memory-mb'] = '8192'
 default['hadoop']['yarn.nodemanager.resource.cpu-cores'] = '8'
 default['hadoop']['yarn.nodemanager.remote-app-log-dir'] = "#{node['grid']['vol_root']}/0/var/log/${user.name}/nm"
 default['hadoop']['yarn.nodemanager.aux-services'] = 'mapreduce.shuffle'
+case node['hadoop']['install_flavor']
+when 'apache'
+  default['hadoop']['yarn.application.classpath'] = '
+           $HADOOP_CONF_DIR,
+           $HADOOP_COMMON_HOME/share/hadoop/common/*,
+           $HADOOP_COMMON_HOME/share/hadoop/common/lib/*,
+           $HADOOP_HDFS_HOME/share/hadoop/hdfs/*,
+           $HADOOP_HDFS_HOME/share/hadoop/hdfs/lib/*,
+           $HADOOP_YARN_HOME/share/hadoop/yarn/*,
+           $HADOOP_YARN_HOME/share/hadoop/yarn/lib/*'
+when 'hdp'
+  default['hadoop']['yarn.application.classpath'] = '
+           $HADOOP_CONF_DIR,
+           $HADOOP_COMMON_HOME/*,$HADOOP_COMMON_HOME/lib/*,
+           $HADOOP_HDFS_HOME/*,$HADOOP_HDFS_HOME/lib/*,
+           $HADOOP_MAPRED_HOME/*,$HADOOP_MAPRED_HOME/lib/*,
+           $HADOOP_YARN_HOME/*,$HADOOP_YARN_HOME/lib/*'
+end
 default['hadoop']['yarn.resourcemanager.nodes.include-path'] = "#{node['hadoop']['HADOOP_CONF_DIR']}/hosts.include"
 default['hadoop']['yarn.resourcemanager.nodes.exclude-path'] = "#{node['hadoop']['HADOOP_CONF_DIR']}/hosts.exclude"
 default['hadoop']['yarn.acl.enable'] = 'true'
@@ -267,6 +300,9 @@ default['hadoop']['mapreduce.jobhistory.principal'] = 'mapred/${this.jobhistory.
 default['hadoop']['mapreduce.jobhistory.keytab'] = '${this.keytab.dir}/jh.keytab'
 
 ## capacity-scheduler.xml
+default['hadoop']['yarn.scheduler.capacity.root.acl_submit_applications'] = ' '  # nobody
+default['hadoop']['yarn.scheduler.capacity.root.acl_administer_queue'] = ' hadoop,gridops'
+default['hadoop']['yarn.scheduler.capacity.root.queues'] = 'default'
 default['hadoop']['yarn.scheduler.capacity.root.default.acl_submit_applications'] = '*'
 default['hadoop']['yarn.scheduler.capacity.root.default.acl_administer_queue'] = ' hadoop,gridops'
 
@@ -290,7 +326,8 @@ default['hadoop']['extra_configs'] = {
     #'truenode.max.xcievers' => '4096'
   },
   'yarn-site.xml' => {},  # ver. 2.0
-  'mapred-site.xml' => {}
+  'mapred-site.xml' => {},
+  'capacity-scheduler.xml' => {},
 }
 #default['hadoop'][''] = 
 
index 5fbf640..ceca9a4 100644 (file)
 # limitations under the License.
 #
 
-require 'digest/sha2'
-
 ::Chef::Recipe.send(:include, Helper)
 
 install_root = '/usr/lib/hadoop'
 conf_dir = '/etc/hadoop/conf'
 
+daemons = nil
 conf_files = nil
 
+daemons_v1 = [
+  'namenode',
+  'datanode',
+  'secondarynamenode',
+  'jobtracker',
+  'tasktracker'
+]
+
+daemons_v2 = [
+  'hdfs-namenode',
+  'hdfs-secondarynamenode',
+  'hdfs-datanode',
+  'yarn-resourcemanager',
+  'yarn-nodemanager',
+  'mapreduce-historyserver'
+]
+
 conf_files_v1 = [
   'capacity-scheduler.xml',
   'configuration.xsl',
@@ -42,6 +58,7 @@ conf_files_v1 = [
   'mapred-site.xml',
   'masters',
   'slaves',
+  # not supported.
   #'ssl-client.xml',
   #'ssl-server.xml'
 ]
@@ -49,22 +66,25 @@ conf_files_v1 = [
 conf_files_v2 = \
   conf_files_v1 \
   - [
+    'configuration.xsl',
     'fair-scheduler.xml',
+    'hadoop-policy.xml',  # missing!?
     'mapred-queue-acls.xml',
     'masters'
   ] \
   + [
-    'httpfs-env.sh',
-    'httpfs-log4j.properties',
-    'httpfs-signature.secret',
-    'httpfs-site.xml',
+    # not supported yet.
+    #'httpfs-env.sh',
+    #'httpfs-log4j.properties',
+    #'httpfs-signature.secret',
+    #'httpfs-site.xml',
     'mapred-env.sh',
     'yarn-env.sh',
     'yarn-site.xml'
   ] 
 
 version, major_version, middle_version \
-  = parse_hdp_version_number(node['hadoop']['version'])
+  = parse_hdp_version_number(node['hdp']['version'])
 equivalent_apache_hadoop_middle_version \
   = get_equivalent_apache_hadoop_version_of('hdp', middle_version)
 
@@ -76,14 +96,16 @@ end
 users = get_users(major_version)
 # do not add any hadoop accounts by Chef.
 
-# TODO: version specific installation
-%w{
-  namenode
-  datanode
-  secondarynamenode
-  jobtracker
-  tasktracker
-}.each {|daemon|
+case major_version
+  when '1'
+    daemons = daemons_v1
+    conf_files = conf_files_v1
+  when '2'
+    daemons = daemons_v2
+    conf_files = conf_files_v2
+end
+
+daemons.each {|daemon|
   package "hadoop-#{daemon}" do
     action :install
   end
@@ -93,15 +115,20 @@ users = get_users(major_version)
   end
 }
 
-%w{
-  libhdfs
-  native
-  pipes
-}.each {|native_lib|
-  package "hadoop-#{native_lib}" do
-    action :install
-  end
-}
+if major_version == '1' then
+  %w{
+    native
+    pipes
+  }.each {|native_lib|
+    package "hadoop-#{native_lib}" do
+      action :install
+    end
+  }
+else
+  # do nothing in the ver. 2
+  # native -> hadoop package
+  # pipes -> hadoop package
+end
 
 link node['hadoop']['HADOOP_PREFIX'] do
   to install_root
@@ -122,13 +149,6 @@ bash 'alternatives_hadoop-conf' do
   creates alt_conf_path
 end
 
-case major_version
-  when '1'
-    conf_files = conf_files_v1
-  when '2'
-    conf_files = conf_files_v2
-end
-
 tpl_vars = {
   :active_vol_nums => active_vol_nums
 }
@@ -167,8 +187,15 @@ if node['hadoop']['with_security'] then
         })
       end
     when '2'
-      # jsvc installation is not necessary. jsvc -> bigtop-jsvc package
-=begin      
+      # jsvc installation is not necessary.
+      # hadoop-hdfs requires bigtop-jsvc package.
+      template "/etc/default/hadoop-hdfs-datanode" do
+        source "etc-#{equivalent_apache_hadoop_middle_version}/default/hadoop-hdfs-datanode"
+        owner 'root'
+        group 'root'
+        mode '0644'
+      end
+
       file "/usr/lib/hadoop-yarn/bin/container-executor" do
         owner 'root'
         group users[:yarn][:name]
@@ -176,7 +203,7 @@ if node['hadoop']['with_security'] then
       end
       
       template "#{conf_dir}/container-executor.cfg" do
-        source "etc-#{middle_version}/hadoop/container-executor.cfg"
+        source "etc-#{equivalent_apache_hadoop_middle_version}/hadoop/container-executor.cfg"
         owner 'root'
         group 'root'
         mode '0400'
@@ -184,7 +211,6 @@ if node['hadoop']['with_security'] then
           :active_vol_nums => active_vol_nums
         })
       end
-=end
   end
 end
 case major_version
@@ -203,28 +229,25 @@ You must initialize HDFS in the first installation:
     EOM
 
     examples_jar = '/usr/lib/hadoop/hadoop-examples.jar'
-=begin
   when '2'
     log <<-EOM
 Note:
 You must initialize HDFS in the first installation:
-  $ cd #{node['grid']['app_root']}/hadoop
-  $ sudo -u hdfs ./bin/hdfs namenode -format
-  $ sudo -u hdfs ./sbin/hadoop-daemon.sh start namenode
-  $ sudo -u hdfs ./sbin/hadoop-daemon.sh start datanode
-  $ sudo -u hdfs ./bin/hadoop fs -chown hdfs:hdfs /
-  $ sudo -u hdfs ./bin/hadoop fs -chmod 755 /
-  $ sudo -u hdfs ./bin/hadoop fs -mkdir /user
-  $ sudo -u hdfs ./bin/hadoop fs -mkdir -p #{node['grid']['vol_root']}/0/var/log/yarn/nm
-  $ sudo -u hdfs ./bin/hadoop fs -chown yarn:hadoop #{node['grid']['vol_root']}/0/var/log/yarn/nm
-  $ sudo -u hdfs ./bin/hadoop fs -chmod 1777        #{node['grid']['vol_root']}/0/var/log/yarn/nm
-  $ sudo -u hdfs ./bin/hadoop fs -mkdir -p #{node['grid']['vol_root']}/0/var/lib/mapred/history
-  $ sudo -u hdfs ./bin/hadoop fs -chown -R mapred:hadoop #{node['grid']['vol_root']}/0/var/lib/mapred
-  $ sudo -u hdfs ./bin/hadoop fs -chmod -R 755           #{node['grid']['vol_root']}/0/var/lib/mapred
+  $ sudo -u hdfs hdfs namenode -format
+  $ sudo service hadoop-hdfs-namenode start
+  $ sudo service hadoop-hdfs-datanamenode start
+  $ sudo -u hdfs hadoop fs -chown hdfs:hdfs /
+  $ sudo -u hdfs hadoop fs -chmod 755 /
+  $ sudo -u hdfs hadoop fs -mkdir /user
+  $ sudo -u hdfs hadoop fs -mkdir -p #{node['grid']['vol_root']}/0/var/log/yarn/nm
+  $ sudo -u hdfs hadoop fs -chown yarn:hadoop #{node['grid']['vol_root']}/0/var/log/yarn/nm
+  $ sudo -u hdfs hadoop fs -chmod 1777        #{node['grid']['vol_root']}/0/var/log/yarn/nm
+  $ sudo -u hdfs hadoop fs -mkdir -p #{node['grid']['vol_root']}/0/var/lib/mapred/history
+  $ sudo -u hdfs hadoop fs -chown -R mapred:hadoop #{node['grid']['vol_root']}/0/var/lib/mapred
+  $ sudo -u hdfs hadoop fs -chmod -R 755           #{node['grid']['vol_root']}/0/var/lib/mapred
     EOM
 
-    examples_jar = "share/hadoop/mapreduce/hadoop-mapreduce-examples-#{version}.jar"
-=end
+    examples_jar = "/usr/lib/hadoop-mapreduce/hadoop-mapreduce-examples-<version>.jar"
 end
 
 if node['hadoop']['with_security'] then
diff --git a/cookbooks/hadoop/templates/default/etc-2.0/default/hadoop-hdfs-datanode b/cookbooks/hadoop/templates/default/etc-2.0/default/hadoop-hdfs-datanode
new file mode 100644 (file)
index 0000000..c78e32e
--- /dev/null
@@ -0,0 +1,31 @@
+# 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.
+export HADOOP_PID_DIR=/var/run/hadoop-hdfs
+export HADOOP_LOG_DIR=/var/log/hadoop-hdfs
+export HADOOP_NAMENODE_USER=hdfs
+export HADOOP_SECONDARYNAMENODE_USER=hdfs
+export HADOOP_DATANODE_USER=hdfs
+export HADOOP_IDENT_STRING=hdfs
+
+# export HADOOP_SECURE_DN_USER=hdfs
+# export HADOOP_SECURE_DN_PID_DIR=/var/run/hadoop-hdfs
+# export HADOOP_SECURE_DN_LOG_DIR=/var/log/hadoop-hdfs
+
+<% if node['hadoop']['with_security'] then -%>
+export HADOOP_SECURE_DN_USER=<%= node['hadoop']['HADOOP_SECURE_DN_USER'] %>
+export HADOOP_SECURE_DN_PID_DIR=<%= node['hadoop']['HADOOP_SECURE_DN_PID_DIR'] %>
+export HADOOP_SECURE_DN_LOG_DIR=<%= node['hadoop']['HADOOP_SECURE_DN_LOG_DIR'] %>
+<% end -%>
+
index 3657fe6..1283b15 100644 (file)
 
   <property>
     <name>yarn.scheduler.capacity.root.queues</name>
-    <value>default</value>
+    <value><%= node['hadoop']['yarn.scheduler.capacity.root.queues'] %></value>
     <description>
       The queues at the this level (root is the root queue).
     </description>
   </property>
 
   <property>
+    <name>yarn.scheduler.capacity.root.acl_submit_applications</name>
+    <value><%= node['hadoop']['yarn.scheduler.capacity.root.acl_submit_applications'] %></value>
+    <description>
+      The ACL of who can submit jobs to the root queue.
+    </description>
+  </property>
+
+  <property>
+    <name>yarn.scheduler.capacity.root.acl_administer_queue</name>
+    <value><%= node['hadoop']['yarn.scheduler.capacity.root.acl_administer_queue'] %></value>
+    <description>
+      The ACL of who can administer jobs on the root queue.
+    </description>
+  </property>
+
+  <property>
     <name>yarn.scheduler.capacity.root.default.capacity</name>
     <value>100</value>
     <description>Default queue target capacity.</description>
     </description>
   </property>
 
+<%
+this_file = 'capacity-scheduler.xml'
+if defined? node['hadoop']['extra_configs'][this_file] \
+  && ! node['hadoop']['extra_configs'][this_file].nil? then
+  node['hadoop']['extra_configs'][this_file].each do |key,value|
+-%>
+    <property>
+        <name><%= key %></name>
+        <value><%= value %></value>
+    </property>
+<%
+  end
+end 
+-%>
 </configuration>
index 7bda5f7..30124c9 100644 (file)
@@ -30,15 +30,6 @@ else
     export HADOOP_LOG_DIR=<%= node['hadoop']['HADOOP_LOG_DIR'] %>
 fi
 
-<% if node['hadoop']['with_security'] then -%>
-export HADOOP_SECURE_DN_USER=<%= node['hadoop']['HADOOP_SECURE_DN_USER'] %>
-# This property is N/A or overridden by the HADOOP_PID_DIR
-#export HADOOP_SECURE_DN_PID_DIR=/grid/vol/0/var/run/${HADOOP_SECURE_DN_USER}
-# This property is N/A or overridden by the HADOOP_LOG_DIR
-#export HADOOP_SECURE_DN_LOG_DIR=/grid/vol/0/var/log/${HADOOP_SECURE_DN_USER}
-export JSVC_HOME=<%= node['hadoop']['JSVC_HOME'] %>
-#export JSVC_HOME=/grid/usr/hadoop/sbin
-<% end -%>
 # Extra Java CLASSPATH elements.  Optional.
 if [ x"$HADOOP_CLASSPATH" = x ]; then
     export HADOOP_CLASSPATH="<%= node['hadoop']['HADOOP_CLASSPATH'] %>"
@@ -50,6 +41,17 @@ else
 fi
 export HADOOP_USER_CLASSPATH_FIRST=<%= node['hadoop']['HADOOP_USER_CLASSPATH_FIRST'] %>
 
+<% if node['hadoop']['install_flavor'] == 'apache' then -%>
+  <% if node['hadoop']['with_security'] then -%>
+export HADOOP_SECURE_DN_USER=<%= node['hadoop']['HADOOP_SECURE_DN_USER'] %>
+# This property is N/A or overridden by the HADOOP_PID_DIR
+#export HADOOP_SECURE_DN_PID_DIR=/grid/vol/0/var/run/${HADOOP_SECURE_DN_USER}
+# This property is N/A or overridden by the HADOOP_LOG_DIR
+#export HADOOP_SECURE_DN_LOG_DIR=/grid/vol/0/var/log/${HADOOP_SECURE_DN_USER}
+export JSVC_HOME=<%= node['hadoop']['JSVC_HOME'] %>
+#export JSVC_HOME=/grid/usr/hadoop/sbin
+  <% end -%>
+
 
 # The only required environment variable is JAVA_HOME.  All others are
 # optional.  When running a distributed configuration it is best to
@@ -109,6 +111,7 @@ export HADOOP_SECURE_DN_PID_DIR=${HADOOP_PID_DIR}
 # A string representing this instance of hadoop. $USER by default.
 export HADOOP_IDENT_STRING=$USER
 
+<% end -%>
 <%
 this_file = 'hadoop-env.sh'
 if defined? node['hadoop']['extra_configs'][this_file] \
index 2e0839a..318dda6 100644 (file)
@@ -22,6 +22,7 @@ export HADOOP_MAPRED_PID_DIR=<%= node['hadoop']['HADOOP_MAPRED_PID_DIR'] %>
 export HADOOP_MAPRED_LOG_DIR=<%= node['hadoop']['HADOOP_MAPRED_LOG_DIR'] %>
 
 
+<% if node['hadoop']['install_flavor'] == 'apache' then -%>
 # export JAVA_HOME=/home/y/libexec/jdk1.6.0/
 
 export HADOOP_JOB_HISTORYSERVER_HEAPSIZE=1000
@@ -34,7 +35,7 @@ export HADOOP_MAPRED_ROOT_LOGGER=INFO,RFA
 #export HADOOP_MAPRED_PID_DIR= # The pid files are stored. /tmp by default.
 #export HADOOP_MAPRED_IDENT_STRING= #A string representing this instance of hadoop. $USER by default
 #export HADOOP_MAPRED_NICENESS= #The scheduling priority for daemons. Defaults to 0.
-
+<% end -%>
 <%
 this_file = 'mapred-env.sh'
 if defined? node['hadoop']['extra_configs'][this_file] \
index c8618cd..a6bb0c3 100644 (file)
 
 export JAVA_HOME=<%= node['java']['java_home'] %>
 
+export YARN_PID_DIR=<%= node['hadoop']['YARN_PID_DIR'] %>
+export YARN_LOG_DIR=<%= node['hadoop']['YARN_LOG_DIR'] %>
+<% if node['hadoop']['install_flavor'] == 'apache' then -%>
+export YARN_HOME=<%= node['hadoop']['YARN_HOME'] %>
+
 export HADOOP_PREFIX=<%= node['hadoop']['HADOOP_PREFIX'] %>
 export HADOOP_COMMON_HOME=<%= node['hadoop']['HADOOP_COMMON_HOME'] %>
 export HADOOP_HDFS_HOME=<%= node['hadoop']['HADOOP_HDFS_HOME'] %>
-export YARN_HOME=<%= node['hadoop']['YARN_HOME'] %>
-export YARN_PID_DIR=<%= node['hadoop']['YARN_PID_DIR'] %>
-export YARN_LOG_DIR=<%= node['hadoop']['YARN_LOG_DIR'] %>
 export HADOOP_MAPRED_HOME=<%= node['hadoop']['HADOOP_MAPRED_HOME'] %>
+<% end -%>
 
 
 # User for YARN daemons
index 31a9e91..24c7bcf 100644 (file)
@@ -81,6 +81,11 @@ yarn_nodemanager_log_dirs = ''
         <value><%= node['hadoop']['yarn.nodemanager.aux-services'] %></value>
         <description>shuffle service that needs to be set for Map Reduce to run</description>
     </property>
+    <property>
+        <name>yarn.application.classpath</name>
+        <value><%= node['hadoop']['yarn.application.classpath'] %></value>
+        <description>Classpath for typical applications.</description>
+    </property>
 
     <property>
         <name>yarn.resourcemanager.nodes.include-path</name>
index 676034d..22f711c 100644 (file)
 # limitations under the License.
 #
 
-if node[:platform_family] == 'rhel' then
+def get_repo_urls(hdp_version, node_platform, node_platform_version)
   platform = nil
+  case node_platform
+    when 'centos', 'rhel'
+      platform = "centos#{node_platform_version.split('.')[0]}"
+    when 'suse'
+      platform = 'suse11'
+  end
+
+  hdp_repo_ctx = nil
+  ambari_repo_ctx = nil
+  case hdp_version
+    when '2.0.4.0'  # Community Preview (hadoop-2.1.0)
+      hdp_repo_ctx = (node_platform == 'suse') ? nil : "HDP/#{platform}/2.x/GA"
+      ambari_repo_ctx = nil
+    when '2.0.0.2'  # Alpha (hadoop-2.0.3-alpha)
+      hdp_repo_ctx = (node_platform == 'suse') ? nil : "HDP-2.0.0.2/repos/#{platform}"
+      ambari_repo_ctx = nil
+    when '2.0.0.1'  # Alpha (hadoop-2.0.2-alpha)
+      hdp_repo_ctx = (node_platform == 'suse') ? nil : "HDP-2.0.0.1/repos/#{platform}"
+      ambari_repo_ctx = nil
+    when '1.3.1'  # (hadoop-1.2.0)
+      hdp_repo_ctx = "HDP/#{platform}/1.x/GA/1.3.0.0"
+      ambari_repo_ctx = "ambari/#{platform}/1.x/updates/1.2.4.9"
+    when '1.3.0'
+      hdp_repo_ctx = "HDP/#{platform}/1.x/GA/1.3.0.0"
+      ambari_repo_ctx = "ambari/#{platform}/1.x/updates/1.2.3.7"
+    when '1.2.4', '1.2.3.1', '1.2.3'  # (hadoop-1.1.2)
+      normalized_platform = (node_platform == 'suse') ? 'centos5' : platform
+      hdp_repo_ctx = "HDP/#{normalized_platform}/1.x/updates/1.2.1"
+      ambari_repo_ctx = "ambari/#{normalized_platform}/1.x/updates/1.2.2.4"
+    when '1.2.2', '1.2.1'
+      hdp_repo_ctx = "HDP-1.2.0/repos/#{platform}"
+      ambari_repo_ctx = "ambari/#{platform}/1.x/GA"
+    when '1.2.0'
+      hdp_repo_ctx = "HDP-1.2.0/repos/#{platform}"
+      ambari_repo_ctx = nil
+    else
+      Chef::Application.fatal!("Non supported version: #{hdp_version}")
+  end
+
+  download_site_url = 'http://public-repo-1.hortonworks.com'
+
+  return [
+    (hdp_repo_ctx.nil?) ? nil : "#{download_site_url}/#{hdp_repo_ctx}/hdp.repo",
+    (ambari_repo_ctx.nil?) ? nil : "#{download_site_url}/#{ambari_repo_ctx}/ambari.repo"
+  ]
+end
+
+
+if node[:platform_family] == 'rhel' then
   hdp_repo_file = nil
   ambari_repo_file = nil
 
   case node[:platform]
     when 'centos', 'rhel'
-      platform = "#{node[:platform]}#{node[:platform_version].split('.')[0]}"
       hdp_repo_file = '/etc/yum.repos.d/hdp.repo'
       ambari_repo_file = '/etc/yum.repos.d/ambari.repo'
     when 'suse'
-      platform = 'suse11'
       hdp_repo_file = '/etc/zypp/repos.d/hdp.repo'
       ambari_repo_file = '/etc/zypp/repos.d/ambari.repo'
   end
 
-  hdp_repo_ver = nil
-  ambari_repo_ver = nil
-  version = node['hdp']['version']
-  case version
-    when '1.3.1'
-      hdp_repo_ver = '1.x/GA/1.3.0.0'
-      ambari_repo_ver = '1.x/updates/1.2.4.9'
-    when '1.2.4'
-      # ?!
-      hdp_repo_ver = '1.x/updates/1.2.1'
-      ambari_repo_ver = '1.x/updates/1.2.2.4'
-      platform = (node[:platform] == 'suse') ? 'centos5' : platform
-    when '1.2.3.1'
-      hdp_repo_ver = '1.x/updates/1.2.1'
-      ambari_repo_ver = '1.x/updates/1.2.2.4'
-      platform = (node[:platform] == 'suse') ? 'centos5' : platform
-    else
-      Chef::Application.fatal!("Non supported version: #{version}")
-  end
+  hdp_version = node['hdp']['version']
+  hdp_repo_url, ambari_repo_url \
+    = get_repo_urls(hdp_version, node[:platform], node[:platform_version])
 
-  hdp_repo_url = "http://public-repo-1.hortonworks.com/HDP/#{platform}/#{hdp_repo_ver}/hdp.repo"
-  ambari_repo_url = "http://public-repo-1.hortonworks.com/ambari/#{platform}/#{ambari_repo_ver}/ambari.repo"
+  hdp_repo_add_command \
+    = (hdp_repo_url.nil?) ? '' : "wget -nv #{hdp_repo_url} -O #{hdp_repo_file}"
+  ambari_repo_add_command \
+    = (ambari_repo_url.nil?) ? '' : "wget -nv #{ambari_repo_url} -O #{ambari_repo_file}"
 
   pkg = 'wget'
   resources(:package => pkg) rescue package pkg do
     action :install
   end
 
-  bash "add_hdp_yum_repositories-#{version}" do
+  bash "add_hdp_yum_repositories-#{hdp_version}" do
     code <<-EOC
-      wget -nv #{hdp_repo_url} -O #{hdp_repo_file}
-      wget -nv #{ambari_repo_url} -O #{ambari_repo_file}
+      #{hdp_repo_add_command}
+      #{ambari_repo_add_command}
     EOC
-    creates hdp_repo_file
-    creates ambari_repo_file
+    creates hdp_repo_file unless hdp_repo_url.nil?
+    creates ambari_repo_file unless ambari_repo_url.nil?
   end
 end
index f4097e8..2d78e74 100644 (file)
@@ -135,16 +135,13 @@ default_attributes(
     'version' => '3.4.5'
   },
   'hdp' => {
+    #'version' => '2.0.0.2',
     'version' => '1.2.3.1',
   },
   'hadoop' => {
     'install_flavor' => 'hdp',
-    'version' => '1.2.3.1',
     'HADOOP_CLASSPATH' => '',
     'HADOOP_USER_CLASSPATH_FIRST' => 'false',
-    'taskcontroller' => {
-      'min.user.id' => '500'
-    },
 =begin
     'metrics2' => {
       'namenode.sink.ganglia.servers' => 'localhost:8649',
@@ -159,9 +156,16 @@ default_attributes(
       'reducetask.sink.ganglia.servers' => 'localhost:8649'
     },
 =end
-    # for 2.0.x only >>
-    'yarn.nodemanager.linux-container-executor.resources-handler.class' \
-      => 'org.apache.hadoop.yarn.server.nodemanager.util.CgroupsLCEResourcesHandler',
+    # for 2.0.x only
+    'container-executor' => {
+      'min.user.id' => '500'
+    },
+    #'yarn.nodemanager.linux-container-executor.resources-handler.class' \
+    #  => 'org.apache.hadoop.yarn.server.nodemanager.util.CgroupsLCEResourcesHandler',
+    # for 1.x only
+    'taskcontroller' => {
+      'min.user.id' => '500'
+    },
   },
   'hbase' => {
     'version' => '0.94.7'