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 sz...@apache.org on 2011/05/23 23:58:30 UTC
svn commit: r1126776 - in /hadoop/common/branches/yahoo-merge: ./
CHANGES.txt src/contrib/ec2/ src/docs/ src/java/
src/java/org/apache/hadoop/fs/FsShell.java src/test/core/
src/test/core/org/apache/hadoop/fs/TestFsShellReturnCode.java
Author: szetszwo
Date: Mon May 23 21:58:29 2011
New Revision: 1126776
URL: http://svn.apache.org/viewvc?rev=1126776&view=rev
Log:
svn merge -c 1092519 from trunk for HADOOP-7207.
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/FsShell.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 21:58:29 2011
@@ -1,2 +1,2 @@
-/hadoop/common/trunk:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092565,1094750,1095121,1100026
+/hadoop/common/trunk:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,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=1126776&r1=1126775&r2=1126776&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/CHANGES.txt (original)
+++ hadoop/common/branches/yahoo-merge/CHANGES.txt Mon May 23 21:58:29 2011
@@ -48,6 +48,8 @@ Trunk (unreleased changes)
HADOOP-7216. Add FsCommand.runAll() with deprecated annotation for the
transition of Command base class improvement. (Daryn Sharp via szetszwo)
+ HADOOP-7207. fs member of FSShell is not really needed (boryas)
+
HADOOP-7231. Fix synopsis for -count. (Daryn Sharp via eli).
Release 0.22.0 - Unreleased
Propchange: hadoop/common/branches/yahoo-merge/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 23 21:58:29 2011
@@ -1,4 +1,4 @@
-/hadoop/common/trunk/CHANGES.txt:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092565,1092832,1094750,1095121,1100026
+/hadoop/common/trunk/CHANGES.txt:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1092832,1094750,1095121,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 21:58:29 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/src/contrib/ec2:1043117,1078148,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092565,1094750,1095121,1100026
+/hadoop/common/trunk/src/contrib/ec2:1043117,1078148,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,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 21:58:29 2011
@@ -1,2 +1,2 @@
-/hadoop/common/trunk/src/docs:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092565,1094750,1095121,1100026
+/hadoop/common/trunk/src/docs:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,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 21:58:29 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/src/java:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092565,1094750,1095121,1100026
+/hadoop/common/trunk/src/java:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,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/FsShell.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FsShell.java?rev=1126776&r1=1126775&r2=1126776&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FsShell.java (original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FsShell.java Mon May 23 21:58:29 2011
@@ -56,7 +56,7 @@ import org.apache.hadoop.util.ToolRunner
@InterfaceAudience.Private
public class FsShell extends Configured implements Tool {
- protected FileSystem fs;
+ private FileSystem fs;
private Trash trash;
protected CommandFactory commandFactory;
@@ -88,14 +88,22 @@ public class FsShell extends Configured
commandFactory = new CommandFactory();
}
- protected void init() throws IOException {
- getConf().setQuietMode(true);
- if (this.fs == null) {
- this.fs = FileSystem.get(getConf());
- }
+ protected FileSystem getFS() throws IOException {
+ if(fs == null)
+ fs = FileSystem.get(getConf());
+
+ return fs;
+ }
+
+ protected Trash getTrash() throws IOException {
if (this.trash == null) {
this.trash = new Trash(getConf());
}
+ return this.trash;
+ }
+
+ protected void init() throws IOException {
+ getConf().setQuietMode(true);
}
@@ -506,11 +514,12 @@ public class FsShell extends Configured
System.out.flush();
boolean printWarning = false;
- FileStatus status = fs.getFileStatus(f);
+ FileSystem pFS = f.getFileSystem(getConf());
+ FileStatus status = pFS.getFileStatus(f);
long len = status.getLen();
for(boolean done = false; !done; ) {
- BlockLocation[] locations = fs.getFileBlockLocations(status, 0, len);
+ BlockLocation[] locations = pFS.getFileBlockLocations(status, 0, len);
int i = 0;
for(; i < locations.length &&
locations[i].getHosts().length == rep; i++)
@@ -1080,7 +1089,8 @@ public class FsShell extends Configured
//
if (argv.length > 3) {
Path dst = new Path(dest);
- if (!fs.isDirectory(dst)) {
+ FileSystem pFS = dst.getFileSystem(conf);
+ if (!pFS.isDirectory(dst)) {
throw new IOException("When copying multiple files, "
+ "destination " + dest + " should be a directory.");
}
@@ -1188,15 +1198,15 @@ public class FsShell extends Configured
}
private void expunge() throws IOException {
- trash.expunge();
- trash.checkpoint();
+ getTrash().expunge();
+ getTrash().checkpoint();
}
/**
* Returns the Trash object associated with this shell.
*/
- public Path getCurrentTrashDir() {
- return trash.getCurrentTrashDir();
+ public Path getCurrentTrashDir() throws IOException {
+ return getTrash().getCurrentTrashDir();
}
/**
Propchange: hadoop/common/branches/yahoo-merge/src/test/core/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 23 21:58:29 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/src/test/core:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092565,1094750,1095121,1100026
+/hadoop/common/trunk/src/test/core:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,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=1126776&r1=1126775&r2=1126776&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 21:58:29 2011
@@ -271,6 +271,54 @@ public class TestFsShellReturnCode {
}
}
+ @Test
+ public void testInvalidDefautlFS() throws Exception {
+ // if default fs doesn't exist or is invalid, but the path provided in
+ // arguments is valid - fsshell should work
+ FsShell shell = new FsShell();
+ Configuration conf = new Configuration();
+ FsConfig.setDefaultFS(conf, "hhhh://doesnotexist/");
+ shell.setConf(conf);
+ String [] args = new String[2];
+ args[0] = "-ls";
+ args[1] = "file:///"; // this is valid, so command should run
+ int res = shell.run(args);
+ System.out.println("res =" + res);
+ shell.setConf(conf);
+ final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ final PrintStream out = new PrintStream(bytes);
+ final PrintStream oldErr = System.err;
+ System.setErr(out);
+ final String results;
+ try {
+ int run = shell.run(args);
+ results = bytes.toString();
+ LOG.info("result=" + results);
+ assertTrue("Return code should be 0", run == 0);
+ } finally {
+ IOUtils.closeStream(out);
+ System.setErr(oldErr);
+ }
+
+ }
-
-}
\ No newline at end of file
+ static class LocalFileSystemExtn extends RawLocalFileSystem {
+
+ private String username;
+ private String groupname;
+
+ @Override
+ public void setOwner(Path p, String username, String groupname)
+ throws IOException {
+ this.username = username;
+ this.groupname = groupname;
+
+ }
+
+ @Override
+ public FileStatus getFileStatus(Path f) throws IOException {
+ return new FileStatus();
+ }
+ }
+
+}