3030import java .util .TimeZone ;
3131import java .util .zip .GZIPInputStream ;
3232
33+ import org .apache .commons .logging .Log ;
34+ import org .apache .commons .logging .LogFactory ;
3335import org .apache .hadoop .classification .InterfaceAudience ;
3436import org .apache .hadoop .conf .Configuration ;
3537import org .apache .hadoop .conf .Configured ;
5557/** Provide command line access to a FileSystem. */
5658@ InterfaceAudience .Private
5759public class FsShell extends Configured implements Tool {
60+
61+ static final Log LOG = LogFactory .getLog (FsShell .class );
5862
5963 private FileSystem fs ;
6064 private Trash trash ;
@@ -722,6 +726,7 @@ void rename(String srcf, String dstf) throws IOException {
722726 try {
723727 dstFstatus = fs .getFileStatus (dst );
724728 } catch (IOException e ) {
729+ LOG .debug ("Error getting file status of " + dst , e );
725730 }
726731 if ((srcFstatus != null ) && (dstFstatus != null )) {
727732 if (srcFstatus .isDirectory () && !dstFstatus .isDirectory ()) {
@@ -769,6 +774,7 @@ private int rename(String argv[], Configuration conf) throws IOException {
769774 //
770775 rename (argv [i ], dest );
771776 } catch (RemoteException e ) {
777+ LOG .debug ("Error renaming " + argv [i ], e );
772778 //
773779 // This is a error returned by hadoop server. Print
774780 // out the first line of the error mesage.
@@ -783,6 +789,7 @@ private int rename(String argv[], Configuration conf) throws IOException {
783789 ex .getLocalizedMessage ());
784790 }
785791 } catch (IOException e ) {
792+ LOG .debug ("Error renaming " + argv [i ], e );
786793 //
787794 // IO exception encountered locally.
788795 //
@@ -854,6 +861,7 @@ private int copy(String argv[], Configuration conf) throws IOException {
854861 //
855862 copy (argv [i ], dest , conf );
856863 } catch (RemoteException e ) {
864+ LOG .debug ("Error copying " + argv [i ], e );
857865 //
858866 // This is a error returned by hadoop server. Print
859867 // out the first line of the error mesage.
@@ -869,6 +877,7 @@ private int copy(String argv[], Configuration conf) throws IOException {
869877 ex .getLocalizedMessage ());
870878 }
871879 } catch (IOException e ) {
880+ LOG .debug ("Error copying " + argv [i ], e );
872881 //
873882 // IO exception encountered locally.
874883 //
@@ -929,6 +938,7 @@ private void delete(Path src, FileSystem srcFs, boolean recursive,
929938 return ;
930939 }
931940 } catch (IOException e ) {
941+ LOG .debug ("Error with trash" , e );
932942 Exception cause = (Exception ) e .getCause ();
933943 String msg = "" ;
934944 if (cause != null ) {
@@ -995,6 +1005,7 @@ private static FileStatus[] shellListStatus(String cmd,
9951005 } catch (FileNotFoundException fnfe ) {
9961006 System .err .println (cmd + ": could not get listing for '" + path + "'" );
9971007 } catch (IOException e ) {
1008+ LOG .debug ("Error listing " + path , e );
9981009 System .err .println (cmd +
9991010 ": could not get get listing for '" + path + "' : " +
10001011 e .getMessage ().split ("\n " )[0 ]);
@@ -1051,6 +1062,7 @@ int runCmdHandler(CmdHandler handler, String[] args,
10511062 errors += runCmdHandler (handler , file , srcFs , recursive );
10521063 }
10531064 } catch (IOException e ) {
1065+ LOG .debug ("Error getting status for " + path , e );
10541066 String msg = (e .getMessage () != null ? e .getLocalizedMessage () :
10551067 (e .getCause ().getMessage () != null ?
10561068 e .getCause ().getLocalizedMessage () : "null" ));
@@ -1383,6 +1395,7 @@ private int doall(String cmd, String argv[], int startindex) {
13831395 text (argv [i ]);
13841396 }
13851397 } catch (RemoteException e ) {
1398+ LOG .debug ("Error" , e );
13861399 //
13871400 // This is a error returned by hadoop server. Print
13881401 // out the first line of the error message.
@@ -1398,6 +1411,7 @@ private int doall(String cmd, String argv[], int startindex) {
13981411 ex .getLocalizedMessage ());
13991412 }
14001413 } catch (IOException e ) {
1414+ LOG .debug ("Error" , e );
14011415 //
14021416 // IO exception encountered locally.
14031417 //
@@ -1551,11 +1565,13 @@ public int run(String argv[]) throws Exception {
15511565 // initialize FsShell
15521566 try {
15531567 init ();
1554- } catch (RPC .VersionMismatch v ) {
1568+ } catch (RPC .VersionMismatch v ) {
1569+ LOG .debug ("Version mismatch" , v );
15551570 System .err .println ("Version Mismatch between client and server" +
15561571 "... command aborted." );
15571572 return exitCode ;
15581573 } catch (IOException e ) {
1574+ LOG .debug ("Error" , e );
15591575 System .err .println ("Bad connection to FS. Command aborted. Exception: " +
15601576 e .getLocalizedMessage ());
15611577 return exitCode ;
@@ -1644,10 +1660,12 @@ public int run(String argv[]) throws Exception {
16441660 printUsage ("" );
16451661 }
16461662 } catch (IllegalArgumentException arge ) {
1663+ LOG .debug ("Error" , arge );
16471664 exitCode = -1 ;
16481665 System .err .println (cmd .substring (1 ) + ": " + arge .getLocalizedMessage ());
16491666 printUsage (cmd );
16501667 } catch (RemoteException e ) {
1668+ LOG .debug ("Error" , e );
16511669 //
16521670 // This is a error returned by hadoop server. Print
16531671 // out the first line of the error mesage, ignore the stack trace.
@@ -1662,13 +1680,15 @@ public int run(String argv[]) throws Exception {
16621680 ex .getLocalizedMessage ());
16631681 }
16641682 } catch (IOException e ) {
1683+ LOG .debug ("Error" , e );
16651684 //
16661685 // IO exception encountered locally.
16671686 //
16681687 exitCode = -1 ;
16691688 System .err .println (cmd .substring (1 ) + ": " +
16701689 e .getLocalizedMessage ());
16711690 } catch (Exception re ) {
1691+ LOG .debug ("Error" , re );
16721692 exitCode = -1 ;
16731693 System .err .println (cmd .substring (1 ) + ": " + re .getLocalizedMessage ());
16741694 } finally {
0 commit comments