Selaa lähdekoodia

MAPREDUCE-4297. Usersmap file in gridmix should not fail on empty lines (Ravi Prakash via bobby)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1344763 13f79535-47bb-0310-9956-ffa450edef68
Robert Joseph Evans 13 vuotta sitten
vanhempi
commit
8bbacfaa31

+ 3 - 0
hadoop-mapreduce-project/CHANGES.txt

@@ -547,6 +547,9 @@ Release 0.23.3 - UNRELEASED
     MAPREDUCE-4152. map task left hanging after AM dies trying to connect to RM
     (Tom Graves via bobby)
 
+    MAPREDUCE-4297. Usersmap file in gridmix should not fail on empty lines
+    (Ravi Prakash via bobby)
+
 Release 0.23.2 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 2 - 1
hadoop-mapreduce-project/src/docs/src/documentation/content/xdocs/gridmix.xml

@@ -538,7 +538,8 @@ hadoop jar <gridmix-jar> org.apache.hadoop.mapred.gridmix.Gridmix \
       </source>
       <p>For backward compatibility reasons, each line of users-list file can
       contain username followed by groupnames in the form username[,group]*.
-      The groupnames will be ignored by Gridmix.
+      The groupnames will be ignored by Gridmix. Empty lines will also be 
+      ignored.
       </p>
     </section>
 

+ 5 - 2
hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/RoundRobinUserResolver.java

@@ -68,15 +68,18 @@ public class RoundRobinUserResolver implements UserResolver {
     try {
       in = new LineReader(fs.open(userloc));
       while (in.readLine(rawUgi) > 0) {//line is of the form username[,group]*
+        if(rawUgi.toString().trim().equals("")) {
+          continue; //Continue on empty line
+        }
         // e is end position of user name in this line
         int e = rawUgi.find(",");
-        if (rawUgi.getLength() == 0 || e == 0) {
+        if (e == 0) {
           throw new IOException("Missing username: " + rawUgi);
         }
         if (e == -1) {
           e = rawUgi.getLength();
         }
-        final String username = Text.decode(rawUgi.getBytes(), 0, e);
+        final String username = Text.decode(rawUgi.getBytes(), 0, e).trim();
         UserGroupInformation ugi = null;
         try {
           ugi = UserGroupInformation.createProxyUser(username,