hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject svn commit: r608301 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/fs/RawLocalFileSystem.java src/java/org/apache/hadoop/util/Shell.java src/test/org/apache/hadoop/fs/TestLocalFileSystemPermission.java
Date Thu, 03 Jan 2008 01:08:22 GMT
Author: nigel
Date: Wed Jan  2 17:08:20 2008
New Revision: 608301

URL: http://svn.apache.org/viewvc?rev=608301&view=rev
Log:
HADOOP-2442. Fix TestLocalFileSystemPermission.testLocalFSsetOwner to work on more platforms.
Contributed by Raghu Angadi.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/util/Shell.java
    lucene/hadoop/trunk/src/test/org/apache/hadoop/fs/TestLocalFileSystemPermission.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?rev=608301&r1=608300&r2=608301&view=diff
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Wed Jan  2 17:08:20 2008
@@ -318,6 +318,9 @@
     HADOOP-2511. Fix a javadoc warning in org.apache.hadoop.util.Shell
     introduced by HADOOP-2344. (acmurthy) 
 
+    HADOOP-2442. Fix TestLocalFileSystemPermission.testLocalFSsetOwner
+    to work on more platforms. (Raghu Angadi via nigel)
+
 Release 0.15.2 - 2008-01-02
 
   BUG FIXES

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java?rev=608301&r1=608300&r2=608301&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java Wed Jan  2 17:08:20
2008
@@ -389,7 +389,7 @@
 
     @Override
     public String getGroup() {
-      if (isPermissionLoaded()) {
+      if (!isPermissionLoaded()) {
         loadPermissionInfo();
       }
       return super.getGroup();
@@ -447,10 +447,13 @@
       throw new IOException("username == null && groupname == null");
     }
 
-    //[OWNER][:[GROUP]]
-    String s = (username == null? "": username)
-             + (groupname == null? "": ":" + groupname);
-    execCommand(pathToFile(p), Shell.SET_OWNER_COMMAND, s);
+    if (username == null) {
+      execCommand(pathToFile(p), Shell.SET_GROUP_COMMAND, groupname); 
+    } else {
+      //OWNER[:[GROUP]]
+      String s = username + (groupname == null? "": ":" + groupname);
+      execCommand(pathToFile(p), Shell.SET_OWNER_COMMAND, s);
+    }
   }
 
   /**

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/util/Shell.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/util/Shell.java?rev=608301&r1=608300&r2=608301&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/util/Shell.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/util/Shell.java Wed Jan  2 17:08:20 2008
@@ -47,11 +47,17 @@
   public static final String SET_PERMISSION_COMMAND = "chmod";
   /** a Unix command to set owner */
   public static final String SET_OWNER_COMMAND = "chown";
+  public static final String SET_GROUP_COMMAND = "chgrp";
   /** Return a Unix command to get permission information. */
   public static String[] getGET_PERMISSION_COMMAND() {
-    return new String[]{"ls", "-ld"};
+    //force /bin/ls, except on windows.
+    return new String[] {(WINDOWS ? "ls" : "/bin/ls"), "-ld"};
   }
 
+  /** Set to true on Windows platforms */
+  public static final boolean WINDOWS /* borrowed from Path.WINDOWS */
+                = System.getProperty("os.name").startsWith("Windows");
+  
   private long    interval;   // refresh interval in msec
   private long    lastTime;   // last time the command was performed
   private Map<String, String> environment; // env for the command execution

Modified: lucene/hadoop/trunk/src/test/org/apache/hadoop/fs/TestLocalFileSystemPermission.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/test/org/apache/hadoop/fs/TestLocalFileSystemPermission.java?rev=608301&r1=608300&r2=608301&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/test/org/apache/hadoop/fs/TestLocalFileSystemPermission.java (original)
+++ lucene/hadoop/trunk/src/test/org/apache/hadoop/fs/TestLocalFileSystemPermission.java Wed
Jan  2 17:08:20 2008
@@ -118,9 +118,9 @@
       System.out.println("Cannot run test");
       return;
     }
-    if (groups == null || groups.size() < 2) {
-      System.out.println("Cannot run test: need at least two groups.  groups="
-          + groups);
+    if (groups == null || groups.size() < 1) {
+      System.out.println("Cannot run test: need at least one group.  groups="
+                         + groups);
       return;
     }
 
@@ -130,10 +130,15 @@
       localfs.setOwner(f, null, g0);
       assertEquals(g0, getGroup(localfs, f));
 
-      String g1 = groups.get(1);
-      localfs.setOwner(f, null, g1);
-      assertEquals(g1, getGroup(localfs, f));
-    }
+      if (groups.size() > 1) {
+        String g1 = groups.get(1);
+        localfs.setOwner(f, null, g1);
+        assertEquals(g1, getGroup(localfs, f));
+      } else {
+        System.out.println("Not testing changing the group since user " +
+                           "belongs to only one group.");
+      }
+    } 
     finally {cleanupFile(localfs, f);}
   }
 



Mime
View raw message