Author: szetszwo Date: Wed May 25 23:34:26 2011 New Revision: 1127728 URL: http://svn.apache.org/viewvc?rev=1127728&view=rev Log: svn merge -c 1102861 from trunk for HADOOP-7285.
Added: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/Test.java - copied unchanged from r1102861, hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/Test.java 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/java/org/apache/hadoop/fs/shell/FsCommand.java hadoop/common/branches/yahoo-merge/src/test/core/ (props changed) hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/cli/testConf.xml Propchange: hadoop/common/branches/yahoo-merge/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed May 25 23:34:26 2011 @@ -1,2 +1,2 @@ -/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,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102940,1104426 +/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,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1104426 /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=1127728&r1=1127727&r2=1127728&view=diff ============================================================================== --- hadoop/common/branches/yahoo-merge/CHANGES.txt (original) +++ hadoop/common/branches/yahoo-merge/CHANGES.txt Wed May 25 23:34:26 2011 @@ -71,6 +71,9 @@ Trunk (unreleased changes) HADOOP-7267. Refactor the rm/rmr/expunge commands to conform to new FsCommand class. (Daryn Sharp via szetszwo) + HADOOP-7285. Refactor the test command to conform to new FsCommand + class. (Daryn Sharp via todd) + HADOOP-7289. In ivy.xml, test conf should not extend common conf. (Eric Yang via szetszwo) Propchange: hadoop/common/branches/yahoo-merge/CHANGES.txt ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed May 25 23:34:26 2011 @@ -1,4 +1,4 @@ -/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,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102940,1104426 +/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,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1104426 /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 Wed May 25 23:34:26 2011 @@ -1,3 +1,3 @@ -/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,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102940,1104426 +/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,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1104426 /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 Wed May 25 23:34:26 2011 @@ -1,2 +1,2 @@ -/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,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102940,1104426 +/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,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1104426 /hadoop/core/branches/branch-0.19/src/docs:713112 Propchange: hadoop/common/branches/yahoo-merge/src/java/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed May 25 23:34:26 2011 @@ -1,3 +1,3 @@ -/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,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102940,1104426 +/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,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1104426 /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=1127728&r1=1127727&r2=1127728&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 Wed May 25 23:34:26 2011 @@ -432,32 +432,6 @@ public class FsShell extends Configured } /** - * Check file types. - */ - int test(String argv[], int i) throws IOException { - if (!argv[i].startsWith("-") || argv[i].length() > 2) - throw new IOException("Not a flag: " + argv[i]); - char flag = argv[i].toCharArray()[1]; - PathData item = new PathData(argv[++i], getConf()); - - if ((flag != 'e') && !item.exists) { - // TODO: it's backwards compat, but why is this throwing an exception? - // it's not like the shell test cmd - throw new PathNotFoundException(item.toString()); - } - switch(flag) { - case 'e': - return item.exists ? 0 : 1; - case 'z': - return (item.stat.getLen() == 0) ? 0 : 1; - case 'd': - return item.stat.isDirectory() ? 0 : 1; - default: - throw new IOException("Unknown flag: " + flag); - } - } - - /** * Move files that match the file pattern <i>srcf</i> * to a destination file. * When moving mutiple files, the destination must be a directory. @@ -670,8 +644,7 @@ public class FsShell extends Configured "[-moveFromLocal <localsrc> ... <dst>] [" + GET_SHORT_USAGE + "\n\t" + "[" + COPYTOLOCAL_SHORT_USAGE + "] [-moveToLocal <src> <localdst>]\n\t" + - "[-report]\n\t" + - "[-test -[ezd] <path>]"; + "[-report]"; String conf ="-conf <configuration file>: Specify an application configuration file."; @@ -734,9 +707,6 @@ public class FsShell extends Configured String moveToLocal = "-moveToLocal <src> <localdst>: Not implemented yet \n"; - String test = "-test -[ezd] <path>: If file { exists, has zero length, is a directory\n" + - "\t\tthen return 0, else return 1.\n"; - String help = "-help [cmd]: \tDisplays help for given command or all commands if none\n" + "\t\tis specified.\n"; @@ -773,8 +743,6 @@ public class FsShell extends Configured System.out.println(moveToLocal); } else if ("get".equals(cmd)) { System.out.println(get); - } else if ("test".equals(cmd)) { - System.out.println(test); } else if ("help".equals(cmd)) { System.out.println(help); } else { @@ -797,7 +765,6 @@ public class FsShell extends Configured System.out.println(get); System.out.println(copyToLocal); System.out.println(moveToLocal); - System.out.println(test); for (String thisCmdName : commandFactory.getNames()) { printHelp(commandFactory.getInstance(thisCmdName)); @@ -890,9 +857,6 @@ public class FsShell extends Configured } else if ("-moveToLocal".equals(cmd)) { System.err.println("Usage: java FsShell" + " [" + cmd + " [-crc] <src> <localdst>]"); - } else if ("-test".equals(cmd)) { - System.err.println("Usage: java FsShell" + - " [-test -[ezd] <path>]"); } else { System.err.println("Usage: java FsShell"); System.err.println(" [-df [<path>]]"); @@ -906,7 +870,6 @@ public class FsShell extends Configured System.err.println(" [" + GET_SHORT_USAGE + "]"); System.err.println(" [" + COPYTOLOCAL_SHORT_USAGE + "]"); System.err.println(" [-moveToLocal [-crc] <src> <localdst>]"); - System.err.println(" [-test -[ezd] <path>]"); for (String name : commandFactory.getNames()) { instance = commandFactory.getInstance(name); System.err.println(" [" + instance.getUsage() + "]"); @@ -938,7 +901,7 @@ public class FsShell extends Configured // // verify that we have enough command line parameters // - if ("-put".equals(cmd) || "-test".equals(cmd) || + if ("-put".equals(cmd) || "-copyFromLocal".equals(cmd) || "-moveFromLocal".equals(cmd)) { if (argv.length < 3) { printUsage(cmd); @@ -1013,8 +976,6 @@ public class FsShell extends Configured du(argv, i); } else if ("-dus".equals(cmd)) { dus(argv, i); - } else if ("-test".equals(cmd)) { - exitCode = test(argv, i); } else if ("-help".equals(cmd)) { if (i < argv.length) { printHelp(argv[i]); @@ -1081,30 +1042,7 @@ public class FsShell extends Configured } System.exit(res); } - - /** - * Accumulate exceptions if there is any. Throw them at last. - */ - private abstract class DelayedExceptionThrowing { - abstract void process(Path p, FileSystem srcFs) throws IOException; - - final void globAndProcess(Path srcPattern, FileSystem srcFs - ) throws IOException { - List<IOException> exceptions = new ArrayList<IOException>(); - for(Path p : FileUtil.stat2Paths(srcFs.globStatus(srcPattern), - srcPattern)) - try { process(p, srcFs); } - catch(IOException ioe) { exceptions.add(ioe); } - - if (!exceptions.isEmpty()) - if (exceptions.size() == 1) - throw exceptions.get(0); - else - throw new IOException("Multiple IOExceptions: " + exceptions); - } - } - - + /** * Utility class for a line of du output */ Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/FsCommand.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/FsCommand.java?rev=1127728&r1=1127727&r2=1127728&view=diff ============================================================================== --- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/FsCommand.java (original) +++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/FsCommand.java Wed May 25 23:34:26 2011 @@ -53,6 +53,7 @@ abstract public class FsCommand extends factory.registerCommands(SetReplication.class); factory.registerCommands(Stat.class); factory.registerCommands(Tail.class); + factory.registerCommands(Test.class); factory.registerCommands(Touch.class); } Propchange: hadoop/common/branches/yahoo-merge/src/test/core/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed May 25 23:34:26 2011 @@ -1,3 +1,3 @@ -/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,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102940,1104426 +/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,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1104426 /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/cli/testConf.xml URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/cli/testConf.xml?rev=1127728&r1=1127727&r2=1127728&view=diff ============================================================================== --- hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/cli/testConf.xml (original) +++ hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/cli/testConf.xml Wed May 25 23:34:26 2011 @@ -564,7 +564,7 @@ <comparators> <comparator> <type>RegexpComparator</type> - <expected-output>^-test -\[ezd\] <path>: If file \{ exists, has zero length, is a directory( )*</expected-output> + <expected-output>^-test -\[ezd\] <path>:\s+If file exists, has zero length, is a directory( )*</expected-output> </comparator> <comparator> <type>RegexpComparator</type>