You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ey...@apache.org on 2011/10/05 00:50:28 UTC

svn commit: r1179000 - in /hadoop/common/branches/branch-0.20-security-205: CHANGES.txt src/packages/hadoop-setup-conf.sh src/packages/templates/conf/hdfs-site.xml

Author: eyang
Date: Tue Oct  4 22:50:28 2011
New Revision: 1179000

URL: http://svn.apache.org/viewvc?rev=1179000&view=rev
Log:
HADOOP-7707. Added toggle for dfs.support.append, webhdfs and hadoop proxy
user to setup config script. (Arpit Gupta via Eric Yang)

Modified:
    hadoop/common/branches/branch-0.20-security-205/CHANGES.txt
    hadoop/common/branches/branch-0.20-security-205/src/packages/hadoop-setup-conf.sh
    hadoop/common/branches/branch-0.20-security-205/src/packages/templates/conf/hdfs-site.xml

Modified: hadoop/common/branches/branch-0.20-security-205/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/CHANGES.txt?rev=1179000&r1=1178999&r2=1179000&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.20-security-205/CHANGES.txt Tue Oct  4 22:50:28 2011
@@ -356,6 +356,9 @@ Release 0.20.205.0 - 2011.09.28
     HADOOP-7708. Fixed hadoop-setup-conf.sh to handle config file
     consistently.  (Eric Yang)
 
+    HADOOP-7707. Added toggle for dfs.support.append, webhdfs and hadoop proxy
+    user to setup config script. (Arpit Gupta via Eric Yang)
+
 Release 0.20.204.0 - 2011-8-25
 
   NEW FEATURES

Modified: hadoop/common/branches/branch-0.20-security-205/src/packages/hadoop-setup-conf.sh
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/src/packages/hadoop-setup-conf.sh?rev=1179000&r1=1178999&r2=1179000&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/src/packages/hadoop-setup-conf.sh (original)
+++ hadoop/common/branches/branch-0.20-security-205/src/packages/hadoop-setup-conf.sh Tue Oct  4 22:50:28 2011
@@ -51,6 +51,9 @@ usage: $0 <parameters>
      --taskscheduler=org.apache.hadoop.mapred.JobQueueTaskScheduler  Set task scheduler
      --datanodes=hostname1,hostname2,...                             SET the datanodes
      --tasktrackers=hostname1,hostname2,...                          SET the tasktrackers
+     --dfs-webhdfs-enabled=false|true                                Enable webhdfs
+     --dfs-support-append=false|true                                 Enable append
+     --hadoop-proxy-users='user1:groups:hosts;user2:groups:hosts'    Setup proxy users for hadoop
   "
   exit 1
 }
@@ -90,6 +93,78 @@ template_generator() {
   done
 }
 
+#########################################
+# Function to modify a value of a field in an xml file
+# Params: $1 is the file with full path; $2 is the property, $3 is the new value
+#########################################
+function addPropertyToXMLConf
+{
+  #read the file name with full path
+  local file=$1
+  #get the property name
+  local property=$2
+  #get what value should be set for that
+  local propValue=$3
+  #get the description
+  local desc=$4
+  #get the value for the final tag
+  local finalVal=$5
+
+  #create the property text, make sure the / are escaped
+  propText="<property>\n<name>$property<\/name>\n<value>$propValue<\/value>"
+  #if description is not empty add it
+  if [ ! -z $desc ]
+  then
+    propText="${propText}<description>$desc<\/description>\n"
+  fi
+  
+  #if final is not empty add it
+  if [ ! -z $finalVal ]
+  then
+    propText="${propText}final>$finalVal<\/final>\n"
+  fi
+
+  #add the ending tag
+  propText="${propText}<\/property>\n"
+
+  #add the property to the file
+  endText="<\/configuration>"
+  #add the text using sed at the end of the file
+  sed -i "s|$endText|$propText$endText|" $file
+}
+
+##########################################
+# Function to setup up the proxy user settings
+#########################################
+function setupProxyUsers
+{
+  #if hadoop proxy users are sent, setup hadoop proxy
+  if [ ! -z $HADOOP_PROXY_USERS ]
+  then
+    oldIFS=$IFS
+    IFS=';'
+    #process each proxy config
+    for proxy in $HADOOP_PROXY_USERS
+    do
+      #get the user, group and hosts information for each proxy
+      IFS=':'
+      arr=($proxy)
+      user="${arr[0]}"
+      groups="${arr[1]}"
+      hosts="${arr[2]}"
+      #determine the property names and values
+      proxy_groups_property="hadoop.proxyuser.${user}.groups"
+      proxy_groups_val="$groups"
+      addPropertyToXMLConf "${HADOOP_CONF_DIR}/hdfs-site.xml" "$proxy_groups_property" "$proxy_groups_val"
+      proxy_hosts_property="hadoop.proxyuser.${user}.hosts"
+      proxy_hosts_val="$hosts"
+      addPropertyToXMLConf "${HADOOP_CONF_DIR}/hdfs-site.xml" "$proxy_hosts_property" "$proxy_hosts_val"
+      IFS=';'
+    done
+    IFS=$oldIFS
+  fi
+}
+
 OPTS=$(getopt \
   -n $0 \
   -o '' \
@@ -118,6 +193,9 @@ OPTS=$(getopt \
   -l 'kinit-location:' \
   -l 'datanodes:' \
   -l 'tasktrackers:' \
+  -l 'dfs-webhdfs-enabled:' \
+  -l 'hadoop-proxy-users:' \
+  -l 'dfs-support-append:' \
   -o 'h' \
   -- "$@") 
   
@@ -237,6 +315,18 @@ while true ; do
       AUTOMATED=1
       TASKTRACKERS=$(echo $TASKTRACKERS | tr ',' ' ')
       ;;
+    --dfs-webhdfs-enabled)
+      DFS_WEBHDFS_ENABLED=$2; shift 2
+      AUTOMATED=1
+      ;;
+    --hadoop-proxy-users)
+      HADOOP_PROXY_USERS=$2; shift 2
+      AUTOMATED=1
+      ;;
+    --dfs-support-append)
+      DFS_SUPPORT_APPEND=$2; shift 2
+      AUTOMATED=1
+      ;;
     --)
       shift ; break
       ;;
@@ -406,6 +496,9 @@ if [ "${AUTOSETUP}" == "1" -o "${AUTOSET
   template_generator ${HADOOP_PREFIX}/share/hadoop/templates/conf/log4j.properties ${HADOOP_CONF_DIR}/log4j.properties
   template_generator ${HADOOP_PREFIX}/share/hadoop/templates/conf/hadoop-metrics2.properties ${HADOOP_CONF_DIR}/hadoop-metrics2.properties
 
+  #setup up the proxy users
+  setupProxyUsers
+
   #set the owner of the hadoop dir to root
   chown root ${HADOOP_PREFIX}
   chown root:${HADOOP_GROUP} ${HADOOP_CONF_DIR}/hadoop-env.sh
@@ -450,6 +543,9 @@ else
   template_generator ${HADOOP_PREFIX}/share/hadoop/templates/conf/log4j.properties ${HADOOP_CONF_DIR}/log4j.properties
   template_generator ${HADOOP_PREFIX}/share/hadoop/templates/conf/hadoop-metrics2.properties ${HADOOP_CONF_DIR}/hadoop-metrics2.properties
 
+  #setup up the proxy users
+  setupProxyUsers
+
   chown root:${HADOOP_GROUP} ${HADOOP_CONF_DIR}/hadoop-env.sh
   chmod 755 ${HADOOP_CONF_DIR}/hadoop-env.sh
   #set taskcontroller

Modified: hadoop/common/branches/branch-0.20-security-205/src/packages/templates/conf/hdfs-site.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/src/packages/templates/conf/hdfs-site.xml?rev=1179000&r1=1178999&r2=1179000&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/src/packages/templates/conf/hdfs-site.xml (original)
+++ hadoop/common/branches/branch-0.20-security-205/src/packages/templates/conf/hdfs-site.xml Tue Oct  4 22:50:28 2011
@@ -228,4 +228,14 @@
       excluded.
     </description>
   </property>
+  <property>
+    <name>dfs.webhdfs.enabled</name>
+    <value>${DFS_WEBHDFS_ENABLED}</value>
+    <description>Enable or disable webhdfs. Defaults to false</description>
+  </property>
+  <property>
+    <name>dfs.support.append</name>
+    <value>${DFS_SUPPORT_APPEND}</value>
+    <description>Enable or disable append. Defaults to false</description>
+  </property>
 </configuration>