hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1077755 - in /hadoop/common/branches/branch-0.20-security-patches/src: contrib/gridmix/src/test/system/org/apache/hadoop/mapred/gridmix/ test/system/conf/ test/system/java/org/apache/hadoop/test/system/
Date Fri, 04 Mar 2011 04:51:58 GMT
Author: omalley
Date: Fri Mar  4 04:51:58 2011
New Revision: 1077755

URL: http://svn.apache.org/viewvc?rev=1077755&view=rev
Log:
commit c0a9dca954b9edf17047c52334b2749b51b34c71
Author: Vinay Kumar Thota <vinayt@yahoo-inc.com>
Date:   Fri Oct 1 08:52:12 2010 +0000

    3967785 from

Modified:
    hadoop/common/branches/branch-0.20-security-patches/src/contrib/gridmix/src/test/system/org/apache/hadoop/mapred/gridmix/TestGridMixDataGeneration.java
    hadoop/common/branches/branch-0.20-security-patches/src/contrib/gridmix/src/test/system/org/apache/hadoop/mapred/gridmix/UtilsForGridmix.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/system/conf/system-test.xml
    hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/AbstractDaemonCluster.java

Modified: hadoop/common/branches/branch-0.20-security-patches/src/contrib/gridmix/src/test/system/org/apache/hadoop/mapred/gridmix/TestGridMixDataGeneration.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/contrib/gridmix/src/test/system/org/apache/hadoop/mapred/gridmix/TestGridMixDataGeneration.java?rev=1077755&r1=1077754&r2=1077755&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/contrib/gridmix/src/test/system/org/apache/hadoop/mapred/gridmix/TestGridMixDataGeneration.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/contrib/gridmix/src/test/system/org/apache/hadoop/mapred/gridmix/TestGridMixDataGeneration.java
Fri Mar  4 04:51:58 2011
@@ -109,7 +109,7 @@ public class TestGridMixDataGeneration {
        RoundRobinUserResolver.class.getName(),
        "REPLAY",
        inputSize +"m",
-       "file://" + cluster.getProxyUsersFilePath(),
+       "file://" + UtilsForGridmix.getProxyUsersFile(cluster.getHadoopProxyUsers()),
        "file:///dev/null"};
     
     int exitCode = UtilsForGridmix.runGridmixJob(gridmixDir, 

Modified: hadoop/common/branches/branch-0.20-security-patches/src/contrib/gridmix/src/test/system/org/apache/hadoop/mapred/gridmix/UtilsForGridmix.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/contrib/gridmix/src/test/system/org/apache/hadoop/mapred/gridmix/UtilsForGridmix.java?rev=1077755&r1=1077754&r2=1077755&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/contrib/gridmix/src/test/system/org/apache/hadoop/mapred/gridmix/UtilsForGridmix.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/contrib/gridmix/src/test/system/org/apache/hadoop/mapred/gridmix/UtilsForGridmix.java
Fri Mar  4 04:51:58 2011
@@ -29,6 +29,14 @@ import org.apache.hadoop.conf.Configurat
 import java.util.Date;
 import java.text.SimpleDateFormat;
 import java.io.OutputStream;
+import java.util.Set;
+import java.util.List;
+import java.util.Iterator;
+import java.util.Map;
+import java.io.File;
+import java.io.FileOutputStream;
+import org.apache.hadoop.test.system.ProxyUserDefinitions;
+import org.apache.hadoop.test.system.ProxyUserDefinitions.GroupsAndHost;
 
 /**
  * Gridmix utilities.
@@ -211,4 +219,64 @@ public class UtilsForGridmix {
     int exitCode = ToolRunner.run(conf, gridmix, args);
     return exitCode;
   }
+
+  /**
+   * Get the proxy users file.
+   * @param ProxyUserDefinitions - proxy users data container.
+   * @return String - proxy users file.
+   * @Exception - if no proxy users found in configuration.
+   */
+  public static String getProxyUsersFile(ProxyUserDefinitions pud)
+      throws Exception  {
+     String fileName = buildProxyUsersFile(pud.getProxyUsers());
+     if (fileName == null) {
+        LOG.error("Proxy users file not found.");
+        throw new Exception("Proxy users file not found.");
+     } else {
+        return fileName;
+     }
+  }
+
+  /**
+   * Build the proxy users file. 
+   * @param proxyUserData - groups and hostnames against proxy user.
+   * @return String - proxy users file.
+   * @throws Exception - if an exception occurs.
+   */
+  public static String buildProxyUsersFile(final Map<String, GroupsAndHost> 
+      proxyUserData) throws Exception {
+     FileOutputStream fos = null;
+     File file = null;
+     StringBuffer input = new StringBuffer();
+     Set users = proxyUserData.keySet();
+     Iterator itr = users.iterator();
+     while (itr.hasNext()) {
+        String user = itr.next().toString();
+        input.append(user);
+        final GroupsAndHost gah = proxyUserData.get(user);
+        final List <String> groups = gah.getGroups();
+        for (String group : groups) {
+           input.append(",");
+           input.append(group);
+        }
+        input.append("\n");
+     }
+     if (input.length() > 0) {
+        try {
+           file = File.createTempFile("proxyusers",null);
+           fos = new FileOutputStream(file);
+           fos.write(input.toString().getBytes());
+        } catch(IOException ioexp) {
+           LOG.warn(ioexp.getMessage());
+           return null;
+        } finally {
+           fos.close();
+           file.deleteOnExit();
+        }
+        LOG.info("file.toString():" + file.toString());
+        return file.toString();
+     } else {
+        return null;
+     }
+  }
 }

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/system/conf/system-test.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/system/conf/system-test.xml?rev=1077755&r1=1077754&r2=1077755&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/system/conf/system-test.xml
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/system/conf/system-test.xml
Fri Mar  4 04:51:58 2011
@@ -117,13 +117,6 @@ neutral at the forward-port stage -->
   </description>
 </property>
 <property>
-  <name>test.system.hdrc.multi-user.list.path</name>
-  <value>$(YINST_ROOT)/conf/hadoop/proxyusers</value>
-  <description>
-  Multi user list for creating the proxy users.
-  </description>
-</property>
-<property>
   <name>test.system.hdrc.multi-user.binary.path</name>
   <value>$(YINST_ROOT)/conf/hadoop/runAs</value>
   <description>

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/AbstractDaemonCluster.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/AbstractDaemonCluster.java?rev=1077755&r1=1077754&r2=1077755&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/AbstractDaemonCluster.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/AbstractDaemonCluster.java
Fri Mar  4 04:51:58 2011
@@ -29,6 +29,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Arrays;
+import java.net.URI;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
@@ -51,8 +54,6 @@ public abstract class AbstractDaemonClus
   File localFolderObj = null;
   private static final  String CONF_HADOOP_LOCAL_DIR =
       "test.system.hdrc.hadoop.local.confdir"; 
-  private static final  String CONF_HADOOP_MULTI_USER_LIST =
-      "test.system.hdrc.multi-user.list.path";
   private final static Object waitLock = new Object();
   
   /**
@@ -309,29 +310,64 @@ public abstract class AbstractDaemonClus
    */
   public ArrayList<String> getHadoopMultiUsersList() throws
      IOException {
-    String hadoopUserListPath = conf.get(CONF_HADOOP_MULTI_USER_LIST);
-    if (hadoopUserListPath == null || hadoopUserListPath.isEmpty()) {
-      LOG.error("Proxy user list path has not been passed for "
-          + CONF_HADOOP_MULTI_USER_LIST);
-      throw new IllegalArgumentException(
-          "Proxy user list hasn't been provided.");
-    }
-    File fileObj = new File(hadoopUserListPath);
-    DataInputStream disObj = new DataInputStream(new FileInputStream(fileObj));
-    ArrayList<String> usersList = new ArrayList<String>();
-    String strLine = null;
-    while((strLine = disObj.readLine()) != null){
-      usersList.add(strLine.substring(0,strLine.indexOf(',')));
-    }
-    return usersList;
+     Iterator itr = conf.iterator();
+     ArrayList<String> proxyUsers = new ArrayList<String>();
+     while (itr.hasNext()) {
+        String property = itr.next().toString();
+        if (property.indexOf("hadoop.proxyuser") >= 0 &&
+           property.indexOf("groups=") >= 0) {
+           proxyUsers.add(property.split("\\.")[2]);
+        }
+     }
+
+     if (proxyUsers.size() == 0) {
+        LOG.error("No proxy users found in the configuration.");
+        throw new IOException("No proxy users found in the configuration.");
+     }
+
+    return proxyUsers;
   }
   
   /**
-   * Get the proxy userlist path.
-   * @return String - userlist path
-   */
-  public String getProxyUsersFilePath() {
-    return null;
+   * Get the proxy user definitions from cluster from configuration.
+   * @return ProxyUserDefinitions - proxy users data like groups and hosts.
+   * @throws Exception - if no proxy users found in the config.
+   */
+  public ProxyUserDefinitions getHadoopProxyUsers() throws
+      Exception {
+     Iterator itr = conf.iterator();
+     ArrayList<String> proxyUsers = new ArrayList<String>();
+     while (itr.hasNext()) {
+        String property = itr.next().toString();
+        if (property.indexOf("hadoop.proxyuser") >= 0 &&
+           property.indexOf("groups=") >= 0) {
+           proxyUsers.add(property.split("\\.")[2]);
+        }
+     }
+   
+     if (proxyUsers.size() == 0) {
+        LOG.error("No proxy users found in the configuration.");
+        throw new Exception("No proxy users found in the configuration.");
+     } 
+    
+     ProxyUserDefinitions pud = new ProxyUserDefinitions() {
+        public boolean writeToFile(URI filePath) throws IOException {
+            throw new UnsupportedOperationException("No such methood exists.");
+        };
+     };
+    
+     for (String userName : proxyUsers) {
+        List<String> groups = Arrays.asList(conf.get("hadoop.proxyuser." + 
+            userName + ".groups").split("//,"));
+        List<String> hosts = Arrays.asList(conf.get("hadoop.proxyuser." + 
+            userName + ".hosts").split("//,"));
+        ProxyUserDefinitions.GroupsAndHost definitions = 
+            pud.new GroupsAndHost();
+        definitions.setGroups(groups);
+        definitions.setHosts(hosts);
+        pud.addProxyUser(userName, definitions);
+     }
+     return pud;
   }
 
   /**



Mime
View raw message