Browse Source

HADOOP-554. Fix DFSShell to return -1 for errors.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@467494 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 năm trước cách đây
mục cha
commit
470cbce4ea

+ 3 - 0
CHANGES.txt

@@ -37,6 +37,9 @@ Trunk (unreleased changes)
 10. HADOOP-625.  Add a servlet to all http daemons that displays a
 10. HADOOP-625.  Add a servlet to all http daemons that displays a
     stack dump, useful for debugging.  (omalley via cutting)
     stack dump, useful for debugging.  (omalley via cutting)
 
 
+11. HADOOP-554.  Fix DFSShell to return -1 for errors.
+    (Dhruba Borthakur via cutting) 
+
 
 
 Release 0.7.2 - 2006-10-18
 Release 0.7.2 - 2006-10-18
 
 

+ 6 - 2
src/java/org/apache/hadoop/dfs/DFSShell.java

@@ -264,7 +264,7 @@ public class DFSShell extends ToolBase {
     private void ls(Path src, boolean recursive, boolean printHeader ) throws IOException {
     private void ls(Path src, boolean recursive, boolean printHeader ) throws IOException {
         Path items[] = fs.listPaths(src);
         Path items[] = fs.listPaths(src);
         if (items == null) {
         if (items == null) {
-            System.out.println("Could not get listing for " + src);
+            throw new IOException("Could not get listing for " + src);
         } else {
         } else {
             if(!recursive && printHeader ) {
             if(!recursive && printHeader ) {
             	System.out.println("Found " + items.length + " items");
             	System.out.println("Found " + items.length + " items");
@@ -292,7 +292,7 @@ public class DFSShell extends ToolBase {
     public void du(String src) throws IOException {
     public void du(String src) throws IOException {
         Path items[] = fs.listPaths( fs.globPaths( new Path(src) ) );
         Path items[] = fs.listPaths( fs.globPaths( new Path(src) ) );
         if (items == null) {
         if (items == null) {
-            System.out.println("Could not get listing for " + src);
+            throw new IOException("Could not get listing for " + src);
         } else {
         } else {
             System.out.println("Found " + items.length + " items");
             System.out.println("Found " + items.length + " items");
             for (int i = 0; i < items.length; i++) {
             for (int i = 0; i < items.length; i++) {
@@ -591,6 +591,10 @@ public class DFSShell extends ToolBase {
         // initialize DFSShell
         // initialize DFSShell
         try {
         try {
             init();
             init();
+        } catch (RPC.VersionMismatch v) { 
+            System.err.println("Version Mismatch between client and server" +
+                               "... command aborted.");
+            return exitCode;
         } catch (IOException e) {
         } catch (IOException e) {
             System.err.println("Bad connection to DFS... command aborted.");
             System.err.println("Bad connection to DFS... command aborted.");
             return exitCode;
             return exitCode;