hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r1126804 - in /hadoop/common/branches/yahoo-merge: ./ CHANGES.txt src/contrib/ec2/ src/docs/ src/java/ src/java/org/apache/hadoop/fs/FsShellPermissions.java src/test/core/ src/test/core/org/apache/hadoop/fs/TestFsShellReturnCode.java
Date Mon, 23 May 2011 23:00:31 GMT
Author: szetszwo
Date: Mon May 23 23:00:31 2011
New Revision: 1126804

URL: http://svn.apache.org/viewvc?rev=1126804&view=rev
Log:
svn merge -c 1087159 from trunk for HADOOP-7210.

Modified:
    hadoop/common/branches/yahoo-merge/   (props changed)
    hadoop/common/branches/yahoo-merge/CHANGES.txt   (contents, props changed)
    hadoop/common/branches/yahoo-merge/src/contrib/ec2/   (props changed)
    hadoop/common/branches/yahoo-merge/src/docs/   (props changed)
    hadoop/common/branches/yahoo-merge/src/java/   (props changed)
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FsShellPermissions.java
    hadoop/common/branches/yahoo-merge/src/test/core/   (props changed)
    hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/TestFsShellReturnCode.java

Propchange: hadoop/common/branches/yahoo-merge/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 23 23:00:31 2011
@@ -1,2 +1,2 @@
-/hadoop/common/trunk:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026
+/hadoop/common/trunk:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026
 /hadoop/core/branches/branch-0.19/core:713112

Modified: hadoop/common/branches/yahoo-merge/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/CHANGES.txt?rev=1126804&r1=1126803&r2=1126804&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/CHANGES.txt (original)
+++ hadoop/common/branches/yahoo-merge/CHANGES.txt Mon May 23 23:00:31 2011
@@ -73,6 +73,9 @@ Trunk (unreleased changes)
     HADOOP-7204. remove local unused fs variable from CmdHandler 
     and FsShellPermissions.changePermissions (boryas)
 
+    HADOOP-7210. Chown command is not working from FSShell
+    (Uma Maheswara Rao G via todd)
+
 Release 0.22.0 - Unreleased
 
   INCOMPATIBLE CHANGES

Propchange: hadoop/common/branches/yahoo-merge/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 23 23:00:31 2011
@@ -1,4 +1,4 @@
-/hadoop/common/trunk/CHANGES.txt:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1092832,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026
+/hadoop/common/trunk/CHANGES.txt:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1092832,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026
 /hadoop/core/branches/branch-0.18/CHANGES.txt:727226
 /hadoop/core/branches/branch-0.19/CHANGES.txt:713112
 /hadoop/core/trunk/CHANGES.txt:776175-785643,785929-786278

Propchange: hadoop/common/branches/yahoo-merge/src/contrib/ec2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 23 23:00:31 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/src/contrib/ec2:1043117,1076296,1078148,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026
+/hadoop/common/trunk/src/contrib/ec2:1043117,1076296,1078148,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026
 /hadoop/core/branches/branch-0.19/core/src/contrib/ec2:713112
 /hadoop/core/trunk/src/contrib/ec2:776175-784663

Propchange: hadoop/common/branches/yahoo-merge/src/docs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 23 23:00:31 2011
@@ -1,2 +1,2 @@
-/hadoop/common/trunk/src/docs:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026
+/hadoop/common/trunk/src/docs:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026
 /hadoop/core/branches/branch-0.19/src/docs:713112

Propchange: hadoop/common/branches/yahoo-merge/src/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 23 23:00:31 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/src/java:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026
+/hadoop/common/trunk/src/java:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026
 /hadoop/core/branches/branch-0.19/core/src/java:713112
 /hadoop/core/trunk/src/core:776175-785643,785929-786278

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FsShellPermissions.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FsShellPermissions.java?rev=1126804&r1=1126803&r2=1126804&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FsShellPermissions.java
(original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FsShellPermissions.java
Mon May 23 23:00:31 2011
@@ -103,14 +103,8 @@ class FsShellPermissions {
     protected String owner = null;
     protected String group = null;
 
-    protected ChownHandler(String cmd) { //for chgrp
-      super(cmd);
-    }
-
-    ChownHandler(String cmd, String ownerStr) throws IOException {
-      super(cmd);
-      if(!cmd.equals("chown"))
-        return;
+    ChownHandler(String ownerStr) throws IOException {
+      super("chown");
       Matcher matcher = chownPattern.matcher(ownerStr);
       if (!matcher.matches()) {
         throw new IOException("'" + ownerStr + "' does not match " +
@@ -150,7 +144,8 @@ class FsShellPermissions {
 
   /*========== chgrp ==========*/    
   
-  private static class ChgrpHandler extends ChownHandler {
+  private static class ChgrpHandler extends CmdHandler {
+    protected String group = null;
     ChgrpHandler(String groupStr) throws IOException {
       super("chgrp");
 
@@ -161,6 +156,25 @@ class FsShellPermissions {
       }
       group = matcher.group(1);
     }
+    
+    @Override
+    public void run(FileStatus file, FileSystem srcFs) throws IOException {
+
+      String newGroup = (group.equals(file.getGroup())) ?
+                        null : group;
+
+      if (newGroup != null) {
+        try {
+          srcFs.setOwner(file.getPath(), null, newGroup);
+        } catch (IOException e) {
+          LOG.debug("Error changing ownership of " + file.getPath(), e);
+          System.err.println(getName() + ": changing ownership of '" + 
+                             file.getPath() + "':" + e.getMessage());
+
+        }
+      }
+    }
+    
   }
 
   static int changePermissions(String cmd, 

Propchange: hadoop/common/branches/yahoo-merge/src/test/core/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 23 23:00:31 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/src/test/core:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026
+/hadoop/common/trunk/src/test/core:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026
 /hadoop/core/branches/branch-0.19/core/src/test/core:713112
 /hadoop/core/trunk/src/test/core:776175-785643,785929-786278

Modified: hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/TestFsShellReturnCode.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/TestFsShellReturnCode.java?rev=1126804&r1=1126803&r2=1126804&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/TestFsShellReturnCode.java
(original)
+++ hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/TestFsShellReturnCode.java
Mon May 23 23:00:31 2011
@@ -18,19 +18,19 @@
 
 package org.apache.hadoop.fs;
 
+import static org.junit.Assert.assertTrue;
+
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.PrintStream;
+import java.net.URI;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
-
-import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.io.IOUtils;
-
-import org.junit.Test;
 import org.junit.Assert;
-import static org.junit.Assert.assertTrue;
+import org.junit.Test;
 
 /**
  * This test validates that chmod, chown, chgrp returning correct exit codes
@@ -41,7 +41,6 @@ public class TestFsShellReturnCode {
       .getLog("org.apache.hadoop.fs.TestFsShellReturnCode");
 
   private static final Configuration conf = new Configuration();
-  private FileSystem fs;
 
   private static String TEST_ROOT_DIR = System.getProperty("test.build.data",
       "build/test/data/testCHReturnCode");
@@ -52,7 +51,7 @@ public class TestFsShellReturnCode {
     stm.close();
   }
 
-  public void verify(FileSystem fs, String cmd, String argv[], int cmdIndex,
+  public void verify(String cmd, String argv[], int cmdIndex,
       FsShell fsShell, int exitCode) throws Exception {
     int ec;
     ec = FsShellPermissions.changePermissions(cmd, argv, cmdIndex, fsShell);
@@ -72,9 +71,6 @@ public class TestFsShellReturnCode {
   public void testChmod() throws Exception {
 
     FsShell fsShell = new FsShell(conf);
-    if (this.fs == null) {
-      this.fs = FileSystem.get(fsShell.getConf());
-    }
 
     final String f1 = TEST_ROOT_DIR + "/" + "testChmod/fileExists";
     final String f2 = TEST_ROOT_DIR + "/" + "testChmod/fileDoesNotExist";
@@ -96,15 +92,15 @@ public class TestFsShellReturnCode {
 
     // Test 1: Test 1: exit code for chmod on existing is 0
     String argv[] = { "-chmod", "777", f1 };
-    verify(fs, "-chmod", argv, 1, fsShell, 0);
+    verify("-chmod", argv, 1, fsShell, 0);
 
     // Test 2: exit code for chmod on non-existing path is 1
     String argv2[] = { "-chmod", "777", f2 };
-    verify(fs, "-chmod", argv2, 1, fsShell, 1);
+    verify("-chmod", argv2, 1, fsShell, 1);
 
     // Test 3: exit code for chmod on non-existing path with globbed input is 1
     String argv3[] = { "-chmod", "777", f3 };
-    verify(fs, "-chmod", argv3, 1, fsShell, 1);
+    verify("-chmod", argv3, 1, fsShell, 1);
 
     // create required files
     writeFile(fileSys, p4);
@@ -116,7 +112,7 @@ public class TestFsShellReturnCode {
 
     // Test 4: exit code for chmod on existing path with globbed input is 0
     String argv4[] = { "-chmod", "777", f7 };
-    verify(fs, "-chmod", argv4, 1, fsShell, 0);
+    verify("-chmod", argv4, 1, fsShell, 0);
 
   }
 
@@ -133,9 +129,6 @@ public class TestFsShellReturnCode {
   public void testChown() throws Exception {
 
     FsShell fsShell = new FsShell(conf);
-    if (this.fs == null) {
-      this.fs = FileSystem.get(fsShell.getConf());
-    }
 
     final String f1 = TEST_ROOT_DIR + "/" + "testChown/fileExists";
     final String f2 = TEST_ROOT_DIR + "/" + "testChown/fileDoesNotExist";
@@ -157,15 +150,15 @@ public class TestFsShellReturnCode {
 
     // Test 1: exit code for chown on existing file is 0
     String argv[] = { "-chown", "admin", f1 };
-    verify(fs, "-chown", argv, 1, fsShell, 0);
+    verify("-chown", argv, 1, fsShell, 0);
 
     // Test 2: exit code for chown on non-existing path is 1
     String argv2[] = { "-chown", "admin", f2 };
-    verify(fs, "-chown", argv2, 1, fsShell, 1);
+    verify("-chown", argv2, 1, fsShell, 1);
 
     // Test 3: exit code for chown on non-existing path with globbed input is 1
     String argv3[] = { "-chown", "admin", f3 };
-    verify(fs, "-chown", argv3, 1, fsShell, 1);
+    verify("-chown", argv3, 1, fsShell, 1);
 
     // create required files
     writeFile(fileSys, p4);
@@ -177,8 +170,21 @@ public class TestFsShellReturnCode {
 
     // Test 4: exit code for chown on existing path with globbed input is 0
     String argv4[] = { "-chown", "admin", f7 };
-    verify(fs, "-chown", argv4, 1, fsShell, 0);
+    verify("-chown", argv4, 1, fsShell, 0);
 
+   //Test 5: test for setOwner invocation on FS from command handler.
+    conf.set("fs.testfs.impl","org.apache.hadoop.fs.TestFsShellReturnCode$LocalFileSystemExtn");
+    final String file = "testfs:///testFile";
+    LocalFileSystemExtn fileSystem = (LocalFileSystemExtn)FileSystem.get(new URI(file), conf);
+    String argv5[] = { "-chown", "admin:Test", file };
+    FsShellPermissions.changePermissions("-chown", argv5, 1, fsShell);
+    assertTrue("Not invoked the setOwner on Fs",fileSystem.groupname.equals("Test"));
+    assertTrue("Not invoked the setOwner on Fs",fileSystem.username.equals("admin"));
+    String argv6[] = { "-chown", "admin:", file };
+    FsShellPermissions.changePermissions("-chown", argv6, 1, fsShell);
+    assertTrue("Not invoked the setOwner on Fs",fileSystem.groupname == null);
+    assertTrue("Not invoked the setOwner on Fs",fileSystem.username.equals("admin"));
+    
   }
 
   /**
@@ -194,9 +200,6 @@ public class TestFsShellReturnCode {
   public void testChgrp() throws Exception {
 
     FsShell fsShell = new FsShell(conf);
-    if (this.fs == null) {
-      this.fs = FileSystem.get(fsShell.getConf());
-    }
 
     final String f1 = TEST_ROOT_DIR + "/" + "testChgrp/fileExists";
     final String f2 = TEST_ROOT_DIR + "/" + "testChgrp/fileDoesNotExist";
@@ -218,15 +221,15 @@ public class TestFsShellReturnCode {
 
     // Test 1: exit code for chgrp on existing file is 0
     String argv[] = { "-chgrp", "admin", f1 };
-    verify(fs, "-chgrp", argv, 1, fsShell, 0);
+    verify("-chgrp", argv, 1, fsShell, 0);
 
     // Test 2: exit code for chgrp on non existing path is 1
     String argv2[] = { "-chgrp", "admin", f2 };
-    verify(fs, "-chgrp", argv2, 1, fsShell, 1);
+    verify("-chgrp", argv2, 1, fsShell, 1);
 
     // Test 3: exit code for chgrp on non-existing path with globbed input is 1
     String argv3[] = { "-chgrp", "admin", f3 };
-    verify(fs, "-chgrp", argv3, 1, fsShell, 1);
+    verify("-chgrp", argv3, 1, fsShell, 1);
 
     // create required files
     writeFile(fileSys, p4);
@@ -238,7 +241,7 @@ public class TestFsShellReturnCode {
 
     // Test 4: exit code for chgrp on existing path with globbed input is 0
     String argv4[] = { "-chgrp", "admin", f7 };
-    verify(fs, "-chgrp", argv4, 1, fsShell, 0);
+    verify("-chgrp", argv4, 1, fsShell, 0);
 
   }
   



Mime
View raw message