hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhr...@apache.org
Subject svn commit: r562286 - /lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FsShell.java
Date Thu, 02 Aug 2007 23:14:35 GMT
Author: dhruba
Date: Thu Aug  2 16:14:34 2007
New Revision: 562286

URL: http://svn.apache.org/viewvc?view=rev&rev=562286
Log:
HADOOP-1666.  FsShell object can be used for multiple fs commands.
Contributed by Dhruba Borthakur.


Modified:
    lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FsShell.java

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FsShell.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FsShell.java?view=diff&rev=562286&r1=562285&r2=562286
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FsShell.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FsShell.java Thu Aug  2 16:14:34 2007
@@ -44,12 +44,19 @@
   /**
    */
   public FsShell() {
+    fs = null;
+    trash = null;
   }
 
   protected void init() throws IOException {
     conf.setQuietMode(true);
-    this.fs = FileSystem.get(conf);
-    this.trash = new Trash(conf);
+    if (this.fs == null) {
+      this.fs = FileSystem.get(conf);
+    }
+    if (this.trash == null) {
+      this.trash = new Trash(conf);
+    }
+    System.out.println("XXX FsShell init done");
   }
 
   /**
@@ -1310,16 +1317,28 @@
       System.err.println(cmd.substring(1) + ": " + 
                          e.getLocalizedMessage());  
     } finally {
-      fs.close();
     }
     return exitCode;
   }
 
+  public void close() throws IOException {
+    if (fs != null) {
+      fs.close();
+      fs = null;
+    }
+  }
+
   /**
    * main() has some simple utility methods
    */
   public static void main(String argv[]) throws Exception {
-    int res = new FsShell().doMain(new Configuration(), argv);
+    FsShell shell = new FsShell();
+    int res;
+    try {
+      res = shell.doMain(new Configuration(), argv);
+    } finally {
+      shell.close();
+    }
     System.exit(res);
   }
 



Mime
View raw message