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 dh...@apache.org on 2007/08/03 01:14:35 UTC
svn commit: r562286 -
/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FsShell.java
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);
}