hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r530556 [7/12] - in /lucene/hadoop/trunk: ./ src/contrib/abacus/src/java/org/apache/hadoop/abacus/ src/contrib/hbase/src/java/org/apache/hadoop/hbase/ src/contrib/hbase/src/test/org/apache/hadoop/hbase/ src/contrib/streaming/src/java/org/ap...
Date Thu, 19 Apr 2007 21:34:53 GMT
Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FileSystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FileSystem.java?view=diff&rev=530556&r1=530555&r2=530556
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FileSystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FileSystem.java Thu Apr 19 14:34:41 2007
@@ -48,812 +48,812 @@
  * @author Mike Cafarella
  *****************************************************************/
 public abstract class FileSystem extends Configured {
-    public static final Log LOG = LogFactory.getLog("org.apache.hadoop.fs.FileSystem");
+  public static final Log LOG = LogFactory.getLog("org.apache.hadoop.fs.FileSystem");
 
-    // cache indexed by URI scheme and authority
-    private static final Map<String,Map<String,FileSystem>> CACHE
-      = new HashMap<String,Map<String,FileSystem>>();
-    /**
-     * Parse the cmd-line args, starting at i.  Remove consumed args
-     * from array.  We expect param in the form:
-     * '-local | -dfs <namenode:port>'
-     */
-    public static FileSystem parseArgs(String argv[], int i, Configuration conf) throws IOException {
-        /**
-        if (argv.length - i < 1) {
-            throw new IOException("Must indicate filesystem type for DFS");
-        }
-        */
-        int orig = i;
-        FileSystem fs = null;
-        String cmd = argv[i];
-        if ("-dfs".equals(cmd)) {
-            i++;
-            InetSocketAddress addr = DataNode.createSocketAddr(argv[i++]);
-            fs = new DistributedFileSystem(addr, conf);
-        } else if ("-local".equals(cmd)) {
-            i++;
-            fs = FileSystem.getLocal(conf);
-        } else {
-            fs = get(conf);                          // using default
-            LOG.info("No FS indicated, using default:"+fs.getName());
-
-        }
-        System.arraycopy(argv, i, argv, orig, argv.length - i);
-        for (int j = argv.length - i; j < argv.length; j++) {
-            argv[j] = null;
-        }
-        return fs;
-    }
-
-    /** Returns the configured filesystem implementation.*/
-    public static FileSystem get(Configuration conf) throws IOException {
-      return getNamed(conf.get("fs.default.name", "local"), conf);
-    }
-
-    /** Called after a new FileSystem instance is constructed.
-     * @param name a uri whose authority section names the host, port, etc.
-     *   for this FileSystem
-     * @param conf the configuration
-     */
-    public abstract void initialize(URI name, Configuration conf)
-      throws IOException;
+  // cache indexed by URI scheme and authority
+  private static final Map<String,Map<String,FileSystem>> CACHE
+    = new HashMap<String,Map<String,FileSystem>>();
+  /**
+   * Parse the cmd-line args, starting at i.  Remove consumed args
+   * from array.  We expect param in the form:
+   * '-local | -dfs <namenode:port>'
+   */
+  public static FileSystem parseArgs(String argv[], int i, Configuration conf) throws IOException {
+    /**
+       if (argv.length - i < 1) {
+       throw new IOException("Must indicate filesystem type for DFS");
+       }
+    */
+    int orig = i;
+    FileSystem fs = null;
+    String cmd = argv[i];
+    if ("-dfs".equals(cmd)) {
+      i++;
+      InetSocketAddress addr = DataNode.createSocketAddr(argv[i++]);
+      fs = new DistributedFileSystem(addr, conf);
+    } else if ("-local".equals(cmd)) {
+      i++;
+      fs = FileSystem.getLocal(conf);
+    } else {
+      fs = get(conf);                          // using default
+      LOG.info("No FS indicated, using default:"+fs.getName());
+
+    }
+    System.arraycopy(argv, i, argv, orig, argv.length - i);
+    for (int j = argv.length - i; j < argv.length; j++) {
+      argv[j] = null;
+    }
+    return fs;
+  }
+
+  /** Returns the configured filesystem implementation.*/
+  public static FileSystem get(Configuration conf) throws IOException {
+    return getNamed(conf.get("fs.default.name", "local"), conf);
+  }
+
+  /** Called after a new FileSystem instance is constructed.
+   * @param name a uri whose authority section names the host, port, etc.
+   *   for this FileSystem
+   * @param conf the configuration
+   */
+  public abstract void initialize(URI name, Configuration conf)
+    throws IOException;
 
-    /** Returns a URI whose scheme and authority identify this FileSystem.*/
-    public abstract URI getUri();
+  /** Returns a URI whose scheme and authority identify this FileSystem.*/
+  public abstract URI getUri();
   
-    /** @deprecated call #getUri() instead.*/
-    public abstract String getName();
+  /** @deprecated call #getUri() instead.*/
+  public abstract String getName();
 
-    /** @deprecated call #get(URI,Configuration) instead. */
-    public static FileSystem getNamed(String name, Configuration conf)
-      throws IOException {
-
-      // convert old-format name to new-format name
-      if (name.equals("local")) {         // "local" is now "file:///".
-        name = "file:///";
-      } else if (name.indexOf('/')==-1) {   // unqualified is "hdfs://"
-        name = "hdfs://"+name;
-      }
-
-      return get(URI.create(name), conf);
-    }
-
-    /**
-     * Get the local file syste
-     * @param conf the configuration to configure the file system with
-     * @return a LocalFileSystem
-     */
-    public static LocalFileSystem getLocal(Configuration conf)
-      throws IOException {
-      return (LocalFileSystem)get(LocalFileSystem.NAME, conf);
-    }
-
-    /** Returns the FileSystem for this URI's scheme and authority.  The scheme
-     * of the URI determines a configuration property name,
-     * <tt>fs.<i>scheme</i>.class</tt> whose value names the FileSystem class.
-     * The entire URI is passed to the FileSystem instance's initialize method.
-     */
-    public static synchronized FileSystem get(URI uri, Configuration conf)
-      throws IOException {
-
-      String scheme = uri.getScheme();
-      String authority = uri.getAuthority();
+  /** @deprecated call #get(URI,Configuration) instead. */
+  public static FileSystem getNamed(String name, Configuration conf)
+    throws IOException {
 
-      if (scheme == null) {                       // no scheme: use default FS
-        return get(conf);
-      }
+    // convert old-format name to new-format name
+    if (name.equals("local")) {         // "local" is now "file:///".
+      name = "file:///";
+    } else if (name.indexOf('/')==-1) {   // unqualified is "hdfs://"
+      name = "hdfs://"+name;
+    }
+
+    return get(URI.create(name), conf);
+  }
+
+  /**
+   * Get the local file syste
+   * @param conf the configuration to configure the file system with
+   * @return a LocalFileSystem
+   */
+  public static LocalFileSystem getLocal(Configuration conf)
+    throws IOException {
+    return (LocalFileSystem)get(LocalFileSystem.NAME, conf);
+  }
 
-      Map<String,FileSystem> authorityToFs = CACHE.get(scheme);
-      if (authorityToFs == null) {
-        authorityToFs = new HashMap<String,FileSystem>();
-        CACHE.put(scheme, authorityToFs);
-      }
+  /** Returns the FileSystem for this URI's scheme and authority.  The scheme
+   * of the URI determines a configuration property name,
+   * <tt>fs.<i>scheme</i>.class</tt> whose value names the FileSystem class.
+   * The entire URI is passed to the FileSystem instance's initialize method.
+   */
+  public static synchronized FileSystem get(URI uri, Configuration conf)
+    throws IOException {
 
-      FileSystem fs = authorityToFs.get(authority);
-      if (fs == null) {
-        Class fsClass = conf.getClass("fs."+scheme+".impl", null);
-        if (fsClass == null) {
-          throw new IOException("No FileSystem for scheme: " + scheme);
-        }
-        fs = (FileSystem)ReflectionUtils.newInstance(fsClass, conf);
-        fs.initialize(uri, conf);
-        authorityToFs.put(authority, fs);
-      }
+    String scheme = uri.getScheme();
+    String authority = uri.getAuthority();
 
-      return fs;
+    if (scheme == null) {                       // no scheme: use default FS
+      return get(conf);
     }
 
-    /**
-     * Close all cached filesystems. Be sure those filesystems are not
-     * used anymore.
-     * 
-     * @throws IOException
-     */
-    public static synchronized void closeAll() throws IOException{
-      for(Map<String, FileSystem>  fss : CACHE.values()){
-        for(FileSystem fs : fss.values()){
-          fs.close();
-        }
-      }
+    Map<String,FileSystem> authorityToFs = CACHE.get(scheme);
+    if (authorityToFs == null) {
+      authorityToFs = new HashMap<String,FileSystem>();
+      CACHE.put(scheme, authorityToFs);
     }
 
-    /** Make sure that a path specifies a FileSystem. */
-    public Path makeQualified(Path path) {
-      checkPath(path);
-
-      if (!path.isAbsolute())
-        path = new Path(getWorkingDirectory(), path);
-
-      URI pathUri = path.toUri();
-      URI fsUri = getUri();
-      
-      String scheme = pathUri.getScheme();
-      String authority = pathUri.getAuthority();
-
-      if (scheme != null &&
-          (authority != null || fsUri.getAuthority() == null))
-        return path;
-
-      if (scheme == null) {
-        scheme = fsUri.getScheme();
-      }
-
-      if (authority == null) {
-        authority = fsUri.getAuthority();
-        if (authority == null) {
-          authority = "";
-        }
+    FileSystem fs = authorityToFs.get(authority);
+    if (fs == null) {
+      Class fsClass = conf.getClass("fs."+scheme+".impl", null);
+      if (fsClass == null) {
+        throw new IOException("No FileSystem for scheme: " + scheme);
       }
-
-      return new Path(scheme+":"+"//"+authority + pathUri.getPath());
-    }
-    
-    ///////////////////////////////////////////////////////////////
-    // FileSystem
-    ///////////////////////////////////////////////////////////////
-
-    protected FileSystem() {
-      super(null);
-    }
-
-    /** Check that a Path belongs to this FileSystem. */
-    protected void checkPath(Path path) {
-      URI uri = path.toUri();
-      if (uri.getScheme() == null)                // fs is relative 
-        return;
-      String thisAuthority = this.getUri().getAuthority();
-      String thatAuthority = uri.getAuthority();
-      if (!(this.getUri().getScheme().equals(uri.getScheme()) &&
-            (thisAuthority == null && thatAuthority == null)
-            || thisAuthority.equals(thatAuthority)))
-        throw new IllegalArgumentException("Wrong FS: "+path+
-                                           ", expected: "+this.getUri());
+      fs = (FileSystem)ReflectionUtils.newInstance(fsClass, conf);
+      fs.initialize(uri, conf);
+      authorityToFs.put(authority, fs);
     }
 
-    /**
-     * Return a 2D array of size 1x1 or greater, containing hostnames 
-     * where portions of the given file can be found.  For a nonexistent 
-     * file or regions, null will be returned.
-     *
-     * This call is most helpful with DFS, where it returns 
-     * hostnames of machines that contain the given file.
-     *
-     * The FileSystem will simply return an elt containing 'localhost'.
-     */
-    public abstract String[][] getFileCacheHints(Path f, long start, long len) throws IOException;
+    return fs;
+  }
 
-    /**
-     * Opens an FSDataInputStream at the indicated Path.
-     * @param f the file name to open
-     * @param bufferSize the size of the buffer to be used.
-     */
-    public abstract FSDataInputStream open(Path f, int bufferSize)
-    throws IOException;
-    
-    /**
-     * Opens an FSDataInputStream at the indicated Path.
-     * @param f the file to open
-     */
-    public FSDataInputStream open(Path f) throws IOException {
-      return open(f, getConf().getInt("io.file.buffer.size", 4096));
+  /**
+   * Close all cached filesystems. Be sure those filesystems are not
+   * used anymore.
+   * 
+   * @throws IOException
+   */
+  public static synchronized void closeAll() throws IOException{
+    for(Map<String, FileSystem>  fss : CACHE.values()){
+      for(FileSystem fs : fss.values()){
+        fs.close();
+      }
     }
+  }
 
-    /**
-     * Opens an FSDataOutputStream at the indicated Path.
-     * Files are overwritten by default.
-     */
-    public FSDataOutputStream create(Path f) throws IOException {
-      return create(f, true, 
-                    getConf().getInt("io.file.buffer.size", 4096),
-                    getDefaultReplication(),
-                    getDefaultBlockSize());
-    }
+  /** Make sure that a path specifies a FileSystem. */
+  public Path makeQualified(Path path) {
+    checkPath(path);
 
-    /**
-     * Create an FSDataOutputStream at the indicated Path with write-progress
-     * reporting.
-     * Files are overwritten by default.
-     */
-    public FSDataOutputStream create(Path f, Progressable progress) throws IOException {
-      return create(f, true, 
-                    getConf().getInt("io.file.buffer.size", 4096),
-                    getDefaultReplication(),
-                    getDefaultBlockSize(), progress);
-    }
+    if (!path.isAbsolute())
+      path = new Path(getWorkingDirectory(), path);
 
-    /**
-     * Opens an FSDataOutputStream at the indicated Path.
-     * Files are overwritten by default.
-     */
-    public FSDataOutputStream create(Path f, short replication)
-      throws IOException {
-      return create(f, true, 
-                    getConf().getInt("io.file.buffer.size", 4096),
-                    replication,
-                    getDefaultBlockSize());
-    }
+    URI pathUri = path.toUri();
+    URI fsUri = getUri();
+      
+    String scheme = pathUri.getScheme();
+    String authority = pathUri.getAuthority();
 
-    /**
-     * Opens an FSDataOutputStream at the indicated Path with write-progress
-     * reporting.
-     * Files are overwritten by default.
-     */
-    public FSDataOutputStream create(Path f, short replication, Progressable progress)
-      throws IOException {
-      return create(f, true, 
-                    getConf().getInt("io.file.buffer.size", 4096),
-                    replication,
-                    getDefaultBlockSize(), progress);
-    }
+    if (scheme != null &&
+        (authority != null || fsUri.getAuthority() == null))
+      return path;
 
-    
-    /**
-     * Opens an FSDataOutputStream at the indicated Path.
-     * @param f the file name to open
-     * @param overwrite if a file with this name already exists, then if true,
-     *   the file will be overwritten, and if false an error will be thrown.
-     * @param bufferSize the size of the buffer to be used.
-     */
-    public FSDataOutputStream create( Path f, 
-                                      boolean overwrite,
-                                      int bufferSize
-                                    ) throws IOException {
-      return create( f, overwrite, bufferSize, 
-                     getDefaultReplication(),
-                     getDefaultBlockSize());
-    }
-    
-    /**
-     * Opens an FSDataOutputStream at the indicated Path with write-progress
-     * reporting.
-     * @param f the file name to open
-     * @param overwrite if a file with this name already exists, then if true,
-     *   the file will be overwritten, and if false an error will be thrown.
-     * @param bufferSize the size of the buffer to be used.
-     */
-    public FSDataOutputStream create( Path f, 
-                                      boolean overwrite,
-                                      int bufferSize,
-                                      Progressable progress
-                                    ) throws IOException {
-      return create( f, overwrite, bufferSize, 
-                     getDefaultReplication(),
-                     getDefaultBlockSize(), progress);
-    }
-    
-    
-    /**
-     * Opens an FSDataOutputStream at the indicated Path.
-     * @param f the file name to open
-     * @param overwrite if a file with this name already exists, then if true,
-     *   the file will be overwritten, and if false an error will be thrown.
-     * @param bufferSize the size of the buffer to be used.
-     * @param replication required block replication for the file. 
-     */
-    public FSDataOutputStream create( Path f, 
-                                      boolean overwrite,
-                                      int bufferSize,
-                                      short replication,
-                                      long blockSize
-                                    ) throws IOException {
-      return create(f, overwrite, bufferSize, replication, blockSize, null);
+    if (scheme == null) {
+      scheme = fsUri.getScheme();
     }
 
-    /**
-     * Opens an FSDataOutputStream at the indicated Path with write-progress
-     * reporting.
-     * @param f the file name to open
-     * @param overwrite if a file with this name already exists, then if true,
-     *   the file will be overwritten, and if false an error will be thrown.
-     * @param bufferSize the size of the buffer to be used.
-     * @param replication required block replication for the file. 
-     */
-    public abstract FSDataOutputStream create( Path f, 
-                                               boolean overwrite,
-                                               int bufferSize,
-                                               short replication,
-                                               long blockSize,
-                                               Progressable progress
-                                             ) throws IOException;
-
-    /**
-     * Creates the given Path as a brand-new zero-length file.  If
-     * create fails, or if it already existed, return false.
-     */
-    public boolean createNewFile(Path f) throws IOException {
-      if (exists(f)) {
-        return false;
-      } else {
-        create(f, false, getConf().getInt("io.file.buffer.size", 4096)).close();
-        return true;
+    if (authority == null) {
+      authority = fsUri.getAuthority();
+      if (authority == null) {
+        authority = "";
       }
     }
 
-    /**
-     * Get replication.
-     * 
-     * @param src file name
-     * @return file replication
-     * @throws IOException
-     */
-    public abstract short getReplication(Path src) throws IOException;
-
-    /**
-     * Set replication for an existing file.
-     * 
-     * @param src file name
-     * @param replication new replication
-     * @throws IOException
-     * @return true if successful;
-     *         false if file does not exist or is a directory
-     */
-    public abstract boolean setReplication(Path src, short replication) throws IOException;
-
-    /**
-     * Renames Path src to Path dst.  Can take place on local fs
-     * or remote DFS.
-     */
-    public abstract boolean rename(Path src, Path dst) throws IOException;
-    
-    /** Delete a file */
-    public abstract boolean delete(Path f) throws IOException;
-    
-    /** Check if exists.
-     * @param f source file
-     */
-    public abstract boolean exists(Path f) throws IOException;
-
-    /** True iff the named path is a directory. */
-    public abstract boolean isDirectory(Path f) throws IOException;
-
-    /** True iff the named path is a regular file. */
-    public boolean isFile(Path f) throws IOException {
-      if (exists(f) && ! isDirectory(f)) {
-        return true;
-      } else {
-        return false;
-      }
-    }
+    return new Path(scheme+":"+"//"+authority + pathUri.getPath());
+  }
     
-    /** The number of bytes in a file. */
-    public abstract long getLength(Path f) throws IOException;
+  ///////////////////////////////////////////////////////////////
+  // FileSystem
+  ///////////////////////////////////////////////////////////////
+
+  protected FileSystem() {
+    super(null);
+  }
+
+  /** Check that a Path belongs to this FileSystem. */
+  protected void checkPath(Path path) {
+    URI uri = path.toUri();
+    if (uri.getScheme() == null)                // fs is relative 
+      return;
+    String thisAuthority = this.getUri().getAuthority();
+    String thatAuthority = uri.getAuthority();
+    if (!(this.getUri().getScheme().equals(uri.getScheme()) &&
+          (thisAuthority == null && thatAuthority == null)
+          || thisAuthority.equals(thatAuthority)))
+      throw new IllegalArgumentException("Wrong FS: "+path+
+                                         ", expected: "+this.getUri());
+  }
+
+  /**
+   * Return a 2D array of size 1x1 or greater, containing hostnames 
+   * where portions of the given file can be found.  For a nonexistent 
+   * file or regions, null will be returned.
+   *
+   * This call is most helpful with DFS, where it returns 
+   * hostnames of machines that contain the given file.
+   *
+   * The FileSystem will simply return an elt containing 'localhost'.
+   */
+  public abstract String[][] getFileCacheHints(Path f, long start, long len) throws IOException;
+
+  /**
+   * Opens an FSDataInputStream at the indicated Path.
+   * @param f the file name to open
+   * @param bufferSize the size of the buffer to be used.
+   */
+  public abstract FSDataInputStream open(Path f, int bufferSize)
+    throws IOException;
     
-    /** Return the number of bytes of the given path 
-     * If <i>f</i> is a file, return the size of the file;
-     * If <i>f</i> is a directory, return the size of the directory tree
-     */
-    public long getContentLength(Path f) throws IOException {
-      if (!isDirectory(f)) {
-        // f is a file
-        return getLength(f);
-      }
-      
-      // f is a diretory
-      Path[] contents = listPaths(f);
-      long size = 0;
-      for(int i=0; i<contents.length; i++) {
-        size += getContentLength(contents[i]);
-      }
-      return size;
+  /**
+   * Opens an FSDataInputStream at the indicated Path.
+   * @param f the file to open
+   */
+  public FSDataInputStream open(Path f) throws IOException {
+    return open(f, getConf().getInt("io.file.buffer.size", 4096));
+  }
+
+  /**
+   * Opens an FSDataOutputStream at the indicated Path.
+   * Files are overwritten by default.
+   */
+  public FSDataOutputStream create(Path f) throws IOException {
+    return create(f, true, 
+                  getConf().getInt("io.file.buffer.size", 4096),
+                  getDefaultReplication(),
+                  getDefaultBlockSize());
+  }
+
+  /**
+   * Create an FSDataOutputStream at the indicated Path with write-progress
+   * reporting.
+   * Files are overwritten by default.
+   */
+  public FSDataOutputStream create(Path f, Progressable progress) throws IOException {
+    return create(f, true, 
+                  getConf().getInt("io.file.buffer.size", 4096),
+                  getDefaultReplication(),
+                  getDefaultBlockSize(), progress);
+  }
+
+  /**
+   * Opens an FSDataOutputStream at the indicated Path.
+   * Files are overwritten by default.
+   */
+  public FSDataOutputStream create(Path f, short replication)
+    throws IOException {
+    return create(f, true, 
+                  getConf().getInt("io.file.buffer.size", 4096),
+                  replication,
+                  getDefaultBlockSize());
+  }
+
+  /**
+   * Opens an FSDataOutputStream at the indicated Path with write-progress
+   * reporting.
+   * Files are overwritten by default.
+   */
+  public FSDataOutputStream create(Path f, short replication, Progressable progress)
+    throws IOException {
+    return create(f, true, 
+                  getConf().getInt("io.file.buffer.size", 4096),
+                  replication,
+                  getDefaultBlockSize(), progress);
+  }
+
+    
+  /**
+   * Opens an FSDataOutputStream at the indicated Path.
+   * @param f the file name to open
+   * @param overwrite if a file with this name already exists, then if true,
+   *   the file will be overwritten, and if false an error will be thrown.
+   * @param bufferSize the size of the buffer to be used.
+   */
+  public FSDataOutputStream create(Path f, 
+                                   boolean overwrite,
+                                   int bufferSize
+                                   ) throws IOException {
+    return create(f, overwrite, bufferSize, 
+                  getDefaultReplication(),
+                  getDefaultBlockSize());
+  }
+    
+  /**
+   * Opens an FSDataOutputStream at the indicated Path with write-progress
+   * reporting.
+   * @param f the file name to open
+   * @param overwrite if a file with this name already exists, then if true,
+   *   the file will be overwritten, and if false an error will be thrown.
+   * @param bufferSize the size of the buffer to be used.
+   */
+  public FSDataOutputStream create(Path f, 
+                                   boolean overwrite,
+                                   int bufferSize,
+                                   Progressable progress
+                                   ) throws IOException {
+    return create(f, overwrite, bufferSize, 
+                  getDefaultReplication(),
+                  getDefaultBlockSize(), progress);
+  }
+    
+    
+  /**
+   * Opens an FSDataOutputStream at the indicated Path.
+   * @param f the file name to open
+   * @param overwrite if a file with this name already exists, then if true,
+   *   the file will be overwritten, and if false an error will be thrown.
+   * @param bufferSize the size of the buffer to be used.
+   * @param replication required block replication for the file. 
+   */
+  public FSDataOutputStream create(Path f, 
+                                   boolean overwrite,
+                                   int bufferSize,
+                                   short replication,
+                                   long blockSize
+                                   ) throws IOException {
+    return create(f, overwrite, bufferSize, replication, blockSize, null);
+  }
+
+  /**
+   * Opens an FSDataOutputStream at the indicated Path with write-progress
+   * reporting.
+   * @param f the file name to open
+   * @param overwrite if a file with this name already exists, then if true,
+   *   the file will be overwritten, and if false an error will be thrown.
+   * @param bufferSize the size of the buffer to be used.
+   * @param replication required block replication for the file. 
+   */
+  public abstract FSDataOutputStream create(Path f, 
+                                            boolean overwrite,
+                                            int bufferSize,
+                                            short replication,
+                                            long blockSize,
+                                            Progressable progress
+                                            ) throws IOException;
+
+  /**
+   * Creates the given Path as a brand-new zero-length file.  If
+   * create fails, or if it already existed, return false.
+   */
+  public boolean createNewFile(Path f) throws IOException {
+    if (exists(f)) {
+      return false;
+    } else {
+      create(f, false, getConf().getInt("io.file.buffer.size", 4096)).close();
+      return true;
+    }
+  }
+
+  /**
+   * Get replication.
+   * 
+   * @param src file name
+   * @return file replication
+   * @throws IOException
+   */
+  public abstract short getReplication(Path src) throws IOException;
+
+  /**
+   * Set replication for an existing file.
+   * 
+   * @param src file name
+   * @param replication new replication
+   * @throws IOException
+   * @return true if successful;
+   *         false if file does not exist or is a directory
+   */
+  public abstract boolean setReplication(Path src, short replication) throws IOException;
+
+  /**
+   * Renames Path src to Path dst.  Can take place on local fs
+   * or remote DFS.
+   */
+  public abstract boolean rename(Path src, Path dst) throws IOException;
+    
+  /** Delete a file */
+  public abstract boolean delete(Path f) throws IOException;
+    
+  /** Check if exists.
+   * @param f source file
+   */
+  public abstract boolean exists(Path f) throws IOException;
+
+  /** True iff the named path is a directory. */
+  public abstract boolean isDirectory(Path f) throws IOException;
+
+  /** True iff the named path is a regular file. */
+  public boolean isFile(Path f) throws IOException {
+    if (exists(f) && !isDirectory(f)) {
+      return true;
+    } else {
+      return false;
+    }
+  }
+    
+  /** The number of bytes in a file. */
+  public abstract long getLength(Path f) throws IOException;
+    
+  /** Return the number of bytes of the given path 
+   * If <i>f</i> is a file, return the size of the file;
+   * If <i>f</i> is a directory, return the size of the directory tree
+   */
+  public long getContentLength(Path f) throws IOException {
+    if (!isDirectory(f)) {
+      // f is a file
+      return getLength(f);
+    }
+      
+    // f is a diretory
+    Path[] contents = listPaths(f);
+    long size = 0;
+    for(int i=0; i<contents.length; i++) {
+      size += getContentLength(contents[i]);
     }
+    return size;
+  }
 
-    final private static PathFilter DEFAULT_FILTER = new PathFilter() {
+  final private static PathFilter DEFAULT_FILTER = new PathFilter() {
       public boolean accept(Path file) {
         return true;
       }     
     };
     
-    /** List files in a directory. */
-    public abstract Path[] listPaths(Path f) throws IOException;
+  /** List files in a directory. */
+  public abstract Path[] listPaths(Path f) throws IOException;
     
-    /** 
-     * Filter files in the given pathes using the default checksum filter. 
-     * @param files a list of paths
-     * @return a list of files under the source paths
-     * @exception IOException
-     */
-    public Path[] listPaths(Path[] files ) throws IOException {
-      return listPaths(files, DEFAULT_FILTER);
-    }
-
-    /** Filter files in a directory. */
-    private void listPaths(ArrayList<Path> results, Path f, PathFilter filter)
-      throws IOException {
-      Path listing[] = listPaths(f);
-      if (listing != null) {
-        for (int i = 0; i < listing.length; i++) {
-          if (filter.accept(listing[i])) {
-            results.add(listing[i]);
-          }
-        }
-      }      
-    }
-    
-    /** Filter files in a directory. */
-    public Path[] listPaths(Path f, PathFilter filter) throws IOException {
-      ArrayList<Path> results = new ArrayList<Path>();
-      listPaths(results, f, filter);
-      return (Path[]) results.toArray(new Path[results.size()]);
-    }
-    
-    /** 
-     * Filter files in a list directories using user-supplied path filter. 
-     * @param files a list of paths
-     * @return a list of files under the source paths
-     * @exception IOException
-     */
-    public Path[] listPaths(Path[] files, PathFilter filter)
+  /** 
+   * Filter files in the given pathes using the default checksum filter. 
+   * @param files a list of paths
+   * @return a list of files under the source paths
+   * @exception IOException
+   */
+  public Path[] listPaths(Path[] files) throws IOException {
+    return listPaths(files, DEFAULT_FILTER);
+  }
+
+  /** Filter files in a directory. */
+  private void listPaths(ArrayList<Path> results, Path f, PathFilter filter)
+    throws IOException {
+    Path listing[] = listPaths(f);
+    if (listing != null) {
+      for (int i = 0; i < listing.length; i++) {
+        if (filter.accept(listing[i])) {
+          results.add(listing[i]);
+        }
+      }
+    }      
+  }
+    
+  /** Filter files in a directory. */
+  public Path[] listPaths(Path f, PathFilter filter) throws IOException {
+    ArrayList<Path> results = new ArrayList<Path>();
+    listPaths(results, f, filter);
+    return (Path[]) results.toArray(new Path[results.size()]);
+  }
+    
+  /** 
+   * Filter files in a list directories using user-supplied path filter. 
+   * @param files a list of paths
+   * @return a list of files under the source paths
+   * @exception IOException
+   */
+  public Path[] listPaths(Path[] files, PathFilter filter)
     throws IOException {
-      ArrayList<Path> results = new ArrayList<Path>();
-      for(int i=0; i<files.length; i++) {
-        listPaths(results, files[i], filter);
+    ArrayList<Path> results = new ArrayList<Path>();
+    for(int i=0; i<files.length; i++) {
+      listPaths(results, files[i], filter);
+    }
+    return (Path[]) results.toArray(new Path[results.size()]);
+  }
+    
+  /**
+   * <p>Return all the files that match filePattern and are not checksum
+   * files. Results are sorted by their names.
+   * 
+   * <p>
+   * A filename pattern is composed of <i>regular</i> characters and
+   * <i>special pattern matching</i> characters, which are:
+   *
+   * <dl>
+   *  <dd>
+   *   <dl>
+   *    <p>
+   *    <dt> <tt> ? </tt>
+   *    <dd> Matches any single character.
+   *
+   *    <p>
+   *    <dt> <tt> * </tt>
+   *    <dd> Matches zero or more characters.
+   *
+   *    <p>
+   *    <dt> <tt> [<i>abc</i>] </tt>
+   *    <dd> Matches a single character from character set
+   *     <tt>{<i>a,b,c</i>}</tt>.
+   *
+   *    <p>
+   *    <dt> <tt> [<i>a</i>-<i>b</i>] </tt>
+   *    <dd> Matches a single character from the character range
+   *     <tt>{<i>a...b</i>}</tt>.  Note that character <tt><i>a</i></tt> must be
+   *     lexicographically less than or equal to character <tt><i>b</i></tt>.
+   *
+   *    <p>
+   *    <dt> <tt> [^<i>a</i>] </tt>
+   *    <dd> Matches a single character that is not from character set or range
+   *     <tt>{<i>a</i>}</tt>.  Note that the <tt>^</tt> character must occur
+   *     immediately to the right of the opening bracket.
+   *
+   *    <p>
+   *    <dt> <tt> \<i>c</i> </tt>
+   *    <dd> Removes (escapes) any special meaning of character <i>c</i>.
+   *
+   *   </dl>
+   *  </dd>
+   * </dl>
+   *
+   * @param filePattern a regular expression specifying file pattern
+
+   * @return an array of paths that match the file pattern
+   * @throws IOException
+   */
+  public Path[] globPaths(Path filePattern) throws IOException {
+    return globPaths(filePattern, DEFAULT_FILTER);
+  }
+    
+  /** glob all the file names that matches filePattern
+   * and is accepted by filter.
+   */
+  public Path[] globPaths(Path filePattern, PathFilter filter) 
+    throws IOException {
+    Path [] parents = new Path[1];
+    int level = 0;
+    String filename = filePattern.toUri().getPath();
+    if ("".equals(filename) || Path.SEPARATOR.equals(filename)) {
+      parents[0] = filePattern;
+      return parents;
+    }
+      
+    String [] components = filename.split(Path.SEPARATOR);
+    if (filePattern.isAbsolute()) {
+      parents[0] = new Path(Path.SEPARATOR);
+      level = 1;
+    } else {
+      parents[0] = new Path("");
+    }
+      
+    Path[] results = globPathsLevel(parents, components, level, filter);
+    Arrays.sort(results);
+    return results;
+  }
+    
+  private Path[] globPathsLevel(Path[] parents,
+                                String [] filePattern, int level, PathFilter filter) throws IOException {
+    if (level == filePattern.length)
+      return parents;
+    GlobFilter fp = new GlobFilter(filePattern[level], filter);
+    if (fp.hasPattern()) {
+      parents = listPaths(parents, fp);
+    } else {
+      for(int i=0; i<parents.length; i++) {
+        parents[i] = new Path(parents[i], filePattern[level]);
       }
-      return (Path[]) results.toArray(new Path[results.size()]);
     }
-    
-    /**
-     * <p>Return all the files that match filePattern and are not checksum
-     * files. Results are sorted by their names.
-     * 
-     * <p>
-     * A filename pattern is composed of <i>regular</i> characters and
-     * <i>special pattern matching</i> characters, which are:
-     *
-     * <dl>
-     *  <dd>
-     *   <dl>
-     *    <p>
-     *    <dt> <tt> ? </tt>
-     *    <dd> Matches any single character.
-     *
-     *    <p>
-     *    <dt> <tt> * </tt>
-     *    <dd> Matches zero or more characters.
-     *
-     *    <p>
-     *    <dt> <tt> [<i>abc</i>] </tt>
-     *    <dd> Matches a single character from character set
-     *     <tt>{<i>a,b,c</i>}</tt>.
-     *
-     *    <p>
-     *    <dt> <tt> [<i>a</i>-<i>b</i>] </tt>
-     *    <dd> Matches a single character from the character range
-     *     <tt>{<i>a...b</i>}</tt>.  Note that character <tt><i>a</i></tt> must be
-     *     lexicographically less than or equal to character <tt><i>b</i></tt>.
-     *
-     *    <p>
-     *    <dt> <tt> [^<i>a</i>] </tt>
-     *    <dd> Matches a single character that is not from character set or range
-     *     <tt>{<i>a</i>}</tt>.  Note that the <tt>^</tt> character must occur
-     *     immediately to the right of the opening bracket.
-     *
-     *    <p>
-     *    <dt> <tt> \<i>c</i> </tt>
-     *    <dd> Removes (escapes) any special meaning of character <i>c</i>.
-     *
-     *   </dl>
-     *  </dd>
-     * </dl>
-     *
-     * @param filePattern a regular expression specifying file pattern
-
-     * @return an array of paths that match the file pattern
-     * @throws IOException
-     */
-    public Path[] globPaths(Path filePattern) throws IOException {
-      return globPaths(filePattern, DEFAULT_FILTER);
-    }
-    
-    /** glob all the file names that matches filePattern
-     * and is accepted by filter.
-     */
-    public Path[] globPaths(Path filePattern, PathFilter filter) 
-        throws IOException {
-      Path [] parents = new Path[1];
-      int level = 0;
-      String filename = filePattern.toUri().getPath();
-      if("".equals(filename) || Path.SEPARATOR.equals(filename)) {
-        parents[0] = filePattern;
-        return parents;
-      }
+    return globPathsLevel(parents, filePattern, level+1, filter);      
+  }
+ 
+  private static class GlobFilter implements PathFilter {
+    private PathFilter userFilter = DEFAULT_FILTER;
+    private Pattern regex;
+    private boolean hasPattern = false;
       
-      String [] components = filename.split(Path.SEPARATOR);
-      if(filePattern.isAbsolute()) {
-        parents[0] = new Path(Path.SEPARATOR);
-        level = 1;
-      } else {
-        parents[0] = new Path( "" );
-      }
+    /** Default pattern character: Escape any special meaning. */
+    private static final char  PAT_ESCAPE = '\\';
+    /** Default pattern character: Any single character. */
+    private static final char  PAT_ANY = '.';
+    /** Default pattern character: Character set close. */
+    private static final char  PAT_SET_CLOSE = ']';
       
-      Path[] results = globPathsLevel(parents, components, level, filter);
-      Arrays.sort(results);
-      return results;
-    }
-    
-    private Path[] globPathsLevel(Path[] parents,
-        String [] filePattern, int level, PathFilter filter) throws IOException {
-      if (level == filePattern.length)
-        return parents;
-      GlobFilter fp = new GlobFilter(filePattern[level], filter);
-      if( fp.hasPattern()) {
-        parents = listPaths(parents, fp);
-      } else {
-        for(int i=0; i<parents.length; i++) {
-          parents[i] = new Path(parents[i], filePattern[level]);
-        }
-      }
-      return globPathsLevel(parents, filePattern, level+1, filter);      
+    GlobFilter() {
     }
- 
-    private static class GlobFilter implements PathFilter {
-      private PathFilter userFilter = DEFAULT_FILTER;
-      private Pattern regex;
-      private boolean hasPattern = false;
-      
-      /** Default pattern character: Escape any special meaning. */
-      private static final char  PAT_ESCAPE = '\\';
-      /** Default pattern character: Any single character. */
-      private static final char  PAT_ANY = '.';
-      /** Default pattern character: Character set close. */
-      private static final char  PAT_SET_CLOSE = ']';
-      
-      GlobFilter() {
-      }
       
-      GlobFilter(String filePattern) throws IOException {
-        setRegex(filePattern);
-      }
+    GlobFilter(String filePattern) throws IOException {
+      setRegex(filePattern);
+    }
       
-      GlobFilter(String filePattern, PathFilter filter) throws IOException {
-        userFilter = filter;
-        setRegex(filePattern);
-      }
+    GlobFilter(String filePattern, PathFilter filter) throws IOException {
+      userFilter = filter;
+      setRegex(filePattern);
+    }
       
-      void setRegex(String filePattern) throws IOException {
-        int len;
-        int setOpen;
-        boolean setRange;
-        StringBuffer fileRegex = new StringBuffer();
-
-        // Validate the pattern
-        len = filePattern.length();
-        if (len == 0)
-          return;
+    void setRegex(String filePattern) throws IOException {
+      int len;
+      int setOpen;
+      boolean setRange;
+      StringBuffer fileRegex = new StringBuffer();
 
-        setOpen = 0;
-        setRange = false;
+      // Validate the pattern
+      len = filePattern.length();
+      if (len == 0)
+        return;
+
+      setOpen = 0;
+      setRange = false;
         
-        for (int i = 0; i < len; i++) {
-          char pCh;
+      for (int i = 0; i < len; i++) {
+        char pCh;
           
-          // Examine a single pattern character
-          pCh = filePattern.charAt(i);
-          if (pCh == PAT_ESCAPE) {
-            fileRegex.append(pCh);
-            i++;
-            if (i >= len)
-              error("An escaped character does not present", filePattern, i);
-            pCh = filePattern.charAt(i);
-          } else if (pCh == '.') {
-            fileRegex.append(PAT_ESCAPE);
-          } else if (pCh == '*') {
-            fileRegex.append(PAT_ANY);
-            hasPattern = true;
-          } else if (pCh == '?') {
-            pCh = PAT_ANY;
-            hasPattern = true;
-          } else if (pCh == '[' && setOpen == 0) {
-            setOpen++;
-            hasPattern = true;
-          } else if (pCh == '^' && setOpen > 0) {
-          } else if (pCh == '-' && setOpen > 0) {
-            // Character set range
-            setRange = true;
-          } else if (pCh == PAT_SET_CLOSE && setRange) {
-            // Incomplete character set range
-            error("Incomplete character set range", filePattern, i);
-          } else if (pCh == PAT_SET_CLOSE && setOpen > 0) {
-            // End of a character set
-            if (setOpen < 2)
-              error("Unexpected end of set", filePattern, i);
-            setOpen = 0;
-          } else if (setOpen > 0) {
-            // Normal character, or the end of a character set range
-            setOpen++;
-            setRange = false;
-          }
+        // Examine a single pattern character
+        pCh = filePattern.charAt(i);
+        if (pCh == PAT_ESCAPE) {
           fileRegex.append(pCh);
+          i++;
+          if (i >= len)
+            error("An escaped character does not present", filePattern, i);
+          pCh = filePattern.charAt(i);
+        } else if (pCh == '.') {
+          fileRegex.append(PAT_ESCAPE);
+        } else if (pCh == '*') {
+          fileRegex.append(PAT_ANY);
+          hasPattern = true;
+        } else if (pCh == '?') {
+          pCh = PAT_ANY;
+          hasPattern = true;
+        } else if (pCh == '[' && setOpen == 0) {
+          setOpen++;
+          hasPattern = true;
+        } else if (pCh == '^' && setOpen > 0) {
+        } else if (pCh == '-' && setOpen > 0) {
+          // Character set range
+          setRange = true;
+        } else if (pCh == PAT_SET_CLOSE && setRange) {
+          // Incomplete character set range
+          error("Incomplete character set range", filePattern, i);
+        } else if (pCh == PAT_SET_CLOSE && setOpen > 0) {
+          // End of a character set
+          if (setOpen < 2)
+            error("Unexpected end of set", filePattern, i);
+          setOpen = 0;
+        } else if (setOpen > 0) {
+          // Normal character, or the end of a character set range
+          setOpen++;
+          setRange = false;
         }
+        fileRegex.append(pCh);
+      }
         
-        // Check for a well-formed pattern
-        if (setOpen > 0 || setRange) {
-          // Incomplete character set or character range
-          error("Expecting set closure character or end of range", filePattern,
+      // Check for a well-formed pattern
+      if (setOpen > 0 || setRange) {
+        // Incomplete character set or character range
+        error("Expecting set closure character or end of range", filePattern,
               len);
-        }
-        regex = Pattern.compile(fileRegex.toString());
-      }
-      
-      boolean hasPattern() {
-        return hasPattern;
-      }
-      
-      public boolean accept(Path path) {
-        return regex.matcher(path.getName()).matches() && userFilter.accept(path);
       }
+      regex = Pattern.compile(fileRegex.toString());
+    }
       
-      private void error(String s, String pattern, int pos) throws IOException {
-        throw new IOException("Illegal file pattern: "
-                                 +s+ " for glob "+ pattern + " at " + pos);
-      }
+    boolean hasPattern() {
+      return hasPattern;
     }
-    
-    /**
-     * Set the current working directory for the given file system. All relative
-     * paths will be resolved relative to it.
-     * 
-     * @param new_dir
-     */
-    public abstract void setWorkingDirectory(Path new_dir);
-    
-    /**
-     * Get the current working directory for the given file system
-     * @return the directory pathname
-     */
-    public abstract Path getWorkingDirectory();
-    
-    /**
-     * Make the given file and all non-existent parents into
-     * directories. Has the semantics of Unix 'mkdir -p'.
-     * Existence of the directory hierarchy is not an error.
-     */
-    public abstract boolean mkdirs(Path f) throws IOException;
-
-    /**
-     * Obtain a lock on the given Path
-     * 
-     * @deprecated FS does not support file locks anymore.
-     */
-    @Deprecated
-    public abstract void lock(Path f, boolean shared) throws IOException;
-
-    /**
-     * Release the lock
-     * 
-     * @deprecated FS does not support file locks anymore.     
-     */
-    @Deprecated
-    public abstract void release(Path f) throws IOException;
-
-    /**
-     * The src file is on the local disk.  Add it to FS at
-     * the given dst name and the source is kept intact afterwards
-     */
-    public void copyFromLocalFile(Path src, Path dst)
+      
+    public boolean accept(Path path) {
+      return regex.matcher(path.getName()).matches() && userFilter.accept(path);
+    }
+      
+    private void error(String s, String pattern, int pos) throws IOException {
+      throw new IOException("Illegal file pattern: "
+                            +s+ " for glob "+ pattern + " at " + pos);
+    }
+  }
+    
+  /**
+   * Set the current working directory for the given file system. All relative
+   * paths will be resolved relative to it.
+   * 
+   * @param new_dir
+   */
+  public abstract void setWorkingDirectory(Path new_dir);
+    
+  /**
+   * Get the current working directory for the given file system
+   * @return the directory pathname
+   */
+  public abstract Path getWorkingDirectory();
+    
+  /**
+   * Make the given file and all non-existent parents into
+   * directories. Has the semantics of Unix 'mkdir -p'.
+   * Existence of the directory hierarchy is not an error.
+   */
+  public abstract boolean mkdirs(Path f) throws IOException;
+
+  /**
+   * Obtain a lock on the given Path
+   * 
+   * @deprecated FS does not support file locks anymore.
+   */
+  @Deprecated
+  public abstract void lock(Path f, boolean shared) throws IOException;
+
+  /**
+   * Release the lock
+   * 
+   * @deprecated FS does not support file locks anymore.     
+   */
+  @Deprecated
+  public abstract void release(Path f) throws IOException;
+
+  /**
+   * The src file is on the local disk.  Add it to FS at
+   * the given dst name and the source is kept intact afterwards
+   */
+  public void copyFromLocalFile(Path src, Path dst)
     throws IOException {
-      copyFromLocalFile(false, src, dst);
-    }
+    copyFromLocalFile(false, src, dst);
+  }
 
-    /**
-     * The src file is on the local disk.  Add it to FS at
-     * the given dst name, removing the source afterwards.
-     */
-    public void moveFromLocalFile(Path src, Path dst)
+  /**
+   * The src file is on the local disk.  Add it to FS at
+   * the given dst name, removing the source afterwards.
+   */
+  public void moveFromLocalFile(Path src, Path dst)
     throws IOException {
-      copyFromLocalFile(true, src, dst);
-    }
+    copyFromLocalFile(true, src, dst);
+  }
 
-    /**
-     * The src file is on the local disk.  Add it to FS at
-     * the given dst name.
-     * delSrc indicates if the source should be removed
-     */
-    public abstract void copyFromLocalFile(boolean delSrc, Path src, Path dst)
+  /**
+   * The src file is on the local disk.  Add it to FS at
+   * the given dst name.
+   * delSrc indicates if the source should be removed
+   */
+  public abstract void copyFromLocalFile(boolean delSrc, Path src, Path dst)
     throws IOException;
     
-    /**
-     * The src file is under FS, and the dst is on the local disk.
-     * Copy it from FS control to the local dst name.
-     */
-    public void copyToLocalFile(Path src, Path dst) throws IOException {
-      copyToLocalFile(false, src, dst);
-    }
-    
-    /**
-     * The src file is under FS, and the dst is on the local disk.
-     * Copy it from FS control to the local dst name.
-     * Remove the source afterwards
-     */
-    public void moveToLocalFile(Path src, Path dst) throws IOException {
-      copyToLocalFile(true, src, dst);
-    }
-
-    /**
-     * The src file is under FS, and the dst is on the local disk.
-     * Copy it from FS control to the local dst name.
-     * delSrc indicates if the src will be removed or not.
-     */   
-    public abstract void copyToLocalFile(boolean delSrc, Path src, Path dst)
+  /**
+   * The src file is under FS, and the dst is on the local disk.
+   * Copy it from FS control to the local dst name.
+   */
+  public void copyToLocalFile(Path src, Path dst) throws IOException {
+    copyToLocalFile(false, src, dst);
+  }
+    
+  /**
+   * The src file is under FS, and the dst is on the local disk.
+   * Copy it from FS control to the local dst name.
+   * Remove the source afterwards
+   */
+  public void moveToLocalFile(Path src, Path dst) throws IOException {
+    copyToLocalFile(true, src, dst);
+  }
+
+  /**
+   * The src file is under FS, and the dst is on the local disk.
+   * Copy it from FS control to the local dst name.
+   * delSrc indicates if the src will be removed or not.
+   */   
+  public abstract void copyToLocalFile(boolean delSrc, Path src, Path dst)
     throws IOException;
 
-    /**
-     * Returns a local File that the user can write output to.  The caller
-     * provides both the eventual FS target name and the local working
-     * file.  If the FS is local, we write directly into the target.  If
-     * the FS is remote, we write into the tmp local area.
-     */
-    public abstract Path startLocalOutput(Path fsOutputFile, Path tmpLocalFile) throws IOException;
-
-    /**
-     * Called when we're all done writing to the target.  A local FS will
-     * do nothing, because we've written to exactly the right place.  A remote
-     * FS will copy the contents of tmpLocalFile to the correct target at
-     * fsOutputFile.
-     */
-    public abstract void completeLocalOutput(Path fsOutputFile, Path tmpLocalFile) throws IOException;
-
-    /**
-     * No more filesystem operations are needed.  Will
-     * release any held locks.
-     */
-    public void close() throws IOException {
-      URI uri = getUri();
-      synchronized (FileSystem.class) {
-        Map<String,FileSystem> authorityToFs = CACHE.get(uri.getScheme());
-        if (authorityToFs != null) {
-          authorityToFs.remove(uri.getAuthority());
-        }
-      }
-    }
-
-    /** Return the total size of all files in the filesystem.*/
-    public long getUsed() throws IOException{
-      long used = 0;
-      Path[] files = listPaths(new Path("/"));
-      for(Path file:files){
-        used += getContentLength(file);
-      }
-      return used;
-    }
-
-    /**
-     * Get the block size for a particular file.
-     * @param f the filename
-     * @return the number of bytes in a block
-     */
-    public abstract long getBlockSize(Path f) throws IOException;
-    
-    /** Return the number of bytes that large input files should be optimally
-     * be split into to minimize i/o time. */
-    public long getDefaultBlockSize() {
-      // default to 32MB: large enough to minimize the impact of seeks
-      return getConf().getLong("fs.local.block.size", 32 * 1024 * 1024);
-    }
-    
-    /**
-     * Get the default replication.
-     */
-    public abstract short getDefaultReplication();
+  /**
+   * Returns a local File that the user can write output to.  The caller
+   * provides both the eventual FS target name and the local working
+   * file.  If the FS is local, we write directly into the target.  If
+   * the FS is remote, we write into the tmp local area.
+   */
+  public abstract Path startLocalOutput(Path fsOutputFile, Path tmpLocalFile) throws IOException;
+
+  /**
+   * Called when we're all done writing to the target.  A local FS will
+   * do nothing, because we've written to exactly the right place.  A remote
+   * FS will copy the contents of tmpLocalFile to the correct target at
+   * fsOutputFile.
+   */
+  public abstract void completeLocalOutput(Path fsOutputFile, Path tmpLocalFile) throws IOException;
+
+  /**
+   * No more filesystem operations are needed.  Will
+   * release any held locks.
+   */
+  public void close() throws IOException {
+    URI uri = getUri();
+    synchronized (FileSystem.class) {
+      Map<String,FileSystem> authorityToFs = CACHE.get(uri.getScheme());
+      if (authorityToFs != null) {
+        authorityToFs.remove(uri.getAuthority());
+      }
+    }
+  }
+
+  /** Return the total size of all files in the filesystem.*/
+  public long getUsed() throws IOException{
+    long used = 0;
+    Path[] files = listPaths(new Path("/"));
+    for(Path file:files){
+      used += getContentLength(file);
+    }
+    return used;
+  }
+
+  /**
+   * Get the block size for a particular file.
+   * @param f the filename
+   * @return the number of bytes in a block
+   */
+  public abstract long getBlockSize(Path f) throws IOException;
+    
+  /** Return the number of bytes that large input files should be optimally
+   * be split into to minimize i/o time. */
+  public long getDefaultBlockSize() {
+    // default to 32MB: large enough to minimize the impact of seeks
+    return getConf().getLong("fs.local.block.size", 32 * 1024 * 1024);
+  }
+    
+  /**
+   * Get the default replication.
+   */
+  public abstract short getDefaultReplication();
 
 }

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FileUtil.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FileUtil.java?view=diff&rev=530556&r1=530555&r2=530556
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FileUtil.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FileUtil.java Thu Apr 19 14:34:41 2007
@@ -40,7 +40,7 @@
     if (contents != null) {
       for (int i = 0; i < contents.length; i++) {
         if (contents[i].isFile()) {
-          if (! contents[i].delete()) {
+          if (!contents[i].delete()) {
             return false;
           }
         } else {
@@ -54,7 +54,7 @@
           }
           // if not an empty directory or symlink let
           // fullydelete handle it.
-          if (! fullyDelete(contents[i])) {
+          if (!fullyDelete(contents[i])) {
             return false;
           }
         }
@@ -67,7 +67,7 @@
   public static boolean copy(FileSystem srcFS, Path src, 
                              FileSystem dstFS, Path dst, 
                              boolean deleteSource,
-                             Configuration conf ) throws IOException {
+                             Configuration conf) throws IOException {
     dst = checkDest(src.getName(), dstFS, dst);
 
     if (srcFS.isDirectory(src)) {
@@ -117,7 +117,7 @@
           InputStream in = srcFS.open(contents[i]);
           try {
             copyContent(in, out, conf, false);
-            if(addString!=null)
+            if (addString!=null)
               out.write(addString.getBytes("UTF-8"));
                 
           } finally {
@@ -141,7 +141,7 @@
   public static boolean copy(File src,
                              FileSystem dstFS, Path dst,
                              boolean deleteSource,
-                             Configuration conf ) throws IOException {
+                             Configuration conf) throws IOException {
     dst = checkDest(src.getName(), dstFS, dst);
 
     if (src.isDirectory()) {
@@ -171,7 +171,7 @@
   /** Copy FileSystem files to local files. */
   public static boolean copy(FileSystem srcFS, Path src, 
                              File dst, boolean deleteSource,
-                             Configuration conf ) throws IOException {
+                             Configuration conf) throws IOException {
 
     dst = checkDest(src.getName(), dst);
 
@@ -215,7 +215,7 @@
         bytesRead = in.read(buf);
       }
     } finally {
-      if(close)
+      if (close)
         out.close();
     }
   }
@@ -284,7 +284,7 @@
   public static void unZip(File inFile, File unzipDir) throws IOException {
     Enumeration entries;
     ZipFile zipFile = new ZipFile(inFile);
-    ;
+
     try {
       entries = zipFile.entries();
       while (entries.hasMoreElements()) {
@@ -334,44 +334,44 @@
     private static String[] hardLinkCommand;
     
     static {
-      switch( getOSType() ) {
+      switch(getOSType()) {
       case OS_TYPE_WINXP:
-        hardLinkCommand = new String[] {"fsutil","hardlink","create",null,null};
+        hardLinkCommand = new String[] {"fsutil","hardlink","create", null, null};
         break;
       case OS_TYPE_UNIX:
       default:
-        hardLinkCommand = new String[] {"ln",null,null};
+        hardLinkCommand = new String[] {"ln", null, null};
       }
     }
 
     static OSType getOSType() {
       String osName = System.getProperty("os.name");
-      if( osName.indexOf( "Windows") >= 0 && 
-          (osName.indexOf( "XpP") >= 0 || osName.indexOf( "2003") >= 0 ) )
+      if (osName.indexOf("Windows") >= 0 && 
+          (osName.indexOf("XpP") >= 0 || osName.indexOf("2003") >= 0))
         return OSType.OS_TYPE_WINXP;
       else
         return OSType.OS_TYPE_UNIX;
     }
     
     public static void createHardLink(File target, 
-                                      File linkName ) throws IOException {
+                                      File linkName) throws IOException {
       int len = hardLinkCommand.length;
       hardLinkCommand[len-2] = target.getCanonicalPath();
       hardLinkCommand[len-1] = linkName.getCanonicalPath();
       // execute shell command
-      Process process = Runtime.getRuntime().exec( hardLinkCommand );
+      Process process = Runtime.getRuntime().exec(hardLinkCommand);
       try {
         if (process.waitFor() != 0) {
           String errMsg = new BufferedReader(new InputStreamReader(
                                                                    process.getInputStream())).readLine();
-          if( errMsg == null )  errMsg = "";
+          if (errMsg == null)  errMsg = "";
           String inpMsg = new BufferedReader(new InputStreamReader(
                                                                    process.getErrorStream())).readLine();
-          if( inpMsg == null )  inpMsg = "";
-          throw new IOException( errMsg + inpMsg );
+          if (inpMsg == null)  inpMsg = "";
+          throw new IOException(errMsg + inpMsg);
         }
       } catch (InterruptedException e) {
-        throw new IOException( StringUtils.stringifyException( e ));
+        throw new IOException(StringUtils.stringifyException(e));
       } finally {
         process.destroy();
       }
@@ -387,7 +387,7 @@
    */
   public static int symLink(String target, String linkname) throws IOException{
     String cmd = "ln -s " + target + " " + linkname;
-    Process p = Runtime.getRuntime().exec( cmd, null );
+    Process p = Runtime.getRuntime().exec(cmd, null);
     int returnVal = -1;
     try{
       returnVal = p.waitFor();
@@ -408,7 +408,7 @@
   public static int chmod(String filename, String perm
                           ) throws IOException, InterruptedException {
     String cmd = "chmod " + perm + " " + filename;
-    Process p = Runtime.getRuntime().exec( cmd, null );
+    Process p = Runtime.getRuntime().exec(cmd, null);
     return p.waitFor();
   }
 }

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FilterFileSystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FilterFileSystem.java?view=diff&rev=530556&r1=530555&r2=530556
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FilterFileSystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FilterFileSystem.java Thu Apr 19 14:34:41 2007
@@ -44,7 +44,7 @@
   
   protected FileSystem fs;
   
-  public FilterFileSystem( FileSystem fs) {
+  public FilterFileSystem(FileSystem fs) {
     this.fs = fs;
   }
 
@@ -114,13 +114,13 @@
    * @param bufferSize the size of the buffer to be used.
    * @param replication required block replication for the file. 
    */
-  public FSDataOutputStream create( Path f, 
-                                    boolean overwrite,
-                                    int bufferSize,
-                                    short replication,
-                                    long blockSize,
-                                    Progressable progress
-                                    ) throws IOException {
+  public FSDataOutputStream create(Path f, 
+                                   boolean overwrite,
+                                   int bufferSize,
+                                   short replication,
+                                   long blockSize,
+                                   Progressable progress
+                                   ) throws IOException {
     return fs.create(f, overwrite, bufferSize, replication, blockSize, progress);
   }
 
@@ -217,7 +217,7 @@
    * @deprecated FS does not support file locks anymore.
    */
   @Deprecated
-    public void lock(Path f, boolean shared) throws IOException {
+  public void lock(Path f, boolean shared) throws IOException {
     fs.lock(f, shared);
   }
 
@@ -227,7 +227,7 @@
    * @deprecated FS does not support file locks anymore.     
    */
   @Deprecated
-    public void release(Path f) throws IOException {
+  public void release(Path f) throws IOException {
     fs.release(f);
   }
 
@@ -296,7 +296,7 @@
   }
 
   @Override
-    public Configuration getConf() {
+  public Configuration getConf() {
     return fs.getConf();
   }
 }

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=530556&r1=530555&r2=530556
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FsShell.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FsShell.java Thu Apr 19 14:34:41 2007
@@ -121,7 +121,7 @@
    * @see org.apache.hadoop.fs.FileSystem.globPaths 
    */
   void copyToLocal(String[]argv, int pos) throws IOException {
-    if(argv.length-pos<2 || (argv.length-pos==2 && argv[pos].equalsIgnoreCase("-crc"))) {
+    if (argv.length-pos<2 || (argv.length-pos==2 && argv[pos].equalsIgnoreCase("-crc"))) {
       System.err.println("Usage: -get [-crc] <src> <dst>");
       System.exit(-1);
     }
@@ -132,19 +132,19 @@
     }
     String srcf = argv[pos++];
     String dstf = argv[pos++];
-    if( dstf.equals("-")) {
+    if (dstf.equals("-")) {
       if (copyCrc) {
         System.err.println("-crc option is not valid when destination is stdout.");
       }
       cat(srcf);
     } else {
-      Path [] srcs = fs.globPaths( new Path(srcf) );
-      if( srcs.length > 1 && !new File( dstf ).isDirectory()) {
-        throw new IOException( "When copying multiple files, " 
-                               + "destination should be a directory." );
+      Path [] srcs = fs.globPaths(new Path(srcf));
+      if (srcs.length > 1 && !new File(dstf).isDirectory()) {
+        throw new IOException("When copying multiple files, " 
+                              + "destination should be a directory.");
       }
-      Path dst = new Path( dstf );
-      for( int i=0; i<srcs.length; i++ ) {
+      Path dst = new Path(dstf);
+      for(int i=0; i<srcs.length; i++) {
         ((DistributedFileSystem)fs).copyToLocalFile(srcs[i], dst, copyCrc);
       }
     }
@@ -178,9 +178,9 @@
    * @see org.apache.hadoop.fs.FileSystem.globPaths 
    */
   void copyMergeToLocal(String srcf, Path dst, boolean endline) throws IOException {
-    Path [] srcs = fs.globPaths( new Path( srcf ) );
-    for( int i=0; i<srcs.length; i++ ) {
-      if(endline) {
+    Path [] srcs = fs.globPaths(new Path(srcf));
+    for(int i=0; i<srcs.length; i++) {
+      if (endline) {
         FileUtil.copyMerge(fs, srcs[i], 
                            FileSystem.getLocal(conf), dst, false, conf, "\n");
       } else {
@@ -206,8 +206,8 @@
    * @see org.apache.hadoop.fs.FileSystem.globPaths 
    */
   void cat(String srcf) throws IOException {
-    Path [] srcs = fs.globPaths( new Path( srcf ) );
-    for( int i=0; i<srcs.length; i++ ) {
+    Path [] srcs = fs.globPaths(new Path(srcf));
+    for(int i=0; i<srcs.length; i++) {
       printToStdout(srcs[i]);
     }
   }
@@ -219,7 +219,7 @@
    * @throws IOException 
    */
   private void setReplication(String[] cmd, int pos) throws IOException {
-    if(cmd.length-pos<2 || (cmd.length-pos==2 && cmd[pos].equalsIgnoreCase("-R"))) {
+    if (cmd.length-pos<2 || (cmd.length-pos==2 && cmd[pos].equalsIgnoreCase("-R"))) {
       System.err.println("Usage: [-R] <repvalue> <path>");
       System.exit(-1);
     }
@@ -227,7 +227,7 @@
     boolean recursive = false;
     short rep = 3;
       
-    if("-R".equalsIgnoreCase(cmd[pos])) {
+    if ("-R".equalsIgnoreCase(cmd[pos])) {
       recursive=true;
       pos++;
         
@@ -256,16 +256,16 @@
    */
   public void setReplication(short newRep, String srcf, boolean recursive)
     throws IOException {
-    Path[] srcs = fs.globPaths( new Path(srcf) );
-    for( int i=0; i<srcs.length; i++ ) {
-      setReplication( newRep, srcs[i], recursive );
+    Path[] srcs = fs.globPaths(new Path(srcf));
+    for(int i=0; i<srcs.length; i++) {
+      setReplication(newRep, srcs[i], recursive);
     }
   }
     
   private void setReplication(short newRep, Path src, boolean recursive)
     throws IOException {
   	
-    if(!fs.isDirectory(src)) {
+    if (!fs.isDirectory(src)) {
       setFileReplication(src, newRep);
       return;
     }
@@ -277,9 +277,9 @@
 
       for (int i = 0; i < items.length; i++) {
         Path cur = items[i];
-        if(!fs.isDirectory(cur)) {
+        if (!fs.isDirectory(cur)) {
           setFileReplication(cur, newRep);
-        } else if(recursive) {
+        } else if (recursive) {
           setReplication(newRep, cur, recursive);
         }
       }
@@ -295,7 +295,7 @@
    */
   private void setFileReplication(Path file, short newRep) throws IOException {
     	
-    if(fs.setReplication(file, newRep)) {
+    if (fs.setReplication(file, newRep)) {
       System.out.println("Replication " + newRep + " set: " + file);
     } else {
       System.err.println("Could not set replication for: " + file);
@@ -311,7 +311,7 @@
    * @see org.apache.hadoop.fs.FileSystem#globPaths(Path)
    */
   public void ls(String srcf, boolean recursive) throws IOException {
-    Path[] srcs = fs.globPaths( new Path(srcf) );
+    Path[] srcs = fs.globPaths(new Path(srcf));
     boolean printHeader = (srcs.length == 1) ? true: false;
     for(int i=0; i<srcs.length; i++) {
       ls(srcs[i], recursive, printHeader);
@@ -319,12 +319,12 @@
   }
 
   /* list all files under the directory <i>src</i>*/
-  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);
     if (items == null) {
       throw new IOException("Could not get listing for " + src);
     } else {
-      if(!recursive && printHeader ) {
+      if (!recursive && printHeader) {
         System.out.println("Found " + items.length + " items");
       }
       for (int i = 0; i < items.length; i++) {
@@ -334,7 +334,7 @@
                               "<dir>" : 
                               ("<r " + fs.getReplication(cur) 
                                + ">\t" + fs.getLength(cur))));
-        if(recursive && fs.isDirectory(cur)) {
+        if (recursive && fs.isDirectory(cur)) {
           ls(cur, recursive, printHeader);
         }
       }
@@ -348,7 +348,7 @@
    * @see org.apache.hadoop.fs.FileSystem#globPaths(Path)
    */
   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) {
       throw new IOException("Could not get listing for " + src);
     } else {
@@ -368,12 +368,12 @@
    * @see org.apache.hadoop.fs.FileSystem#globPaths(Path)
    */
   public void dus(String src) throws IOException {
-    Path paths[] = fs.globPaths( new Path(src) );
-    if( paths==null && paths.length==0 ) {
-      throw new IOException( "dus: No match: " + src );
+    Path paths[] = fs.globPaths(new Path(src));
+    if (paths==null && paths.length==0) {
+      throw new IOException("dus: No match: " + src);
     }
     for(int i=0; i<paths.length; i++) {
-      Path items[] = fs.listPaths( paths[i] );
+      Path items[] = fs.listPaths(paths[i]);
       if (items != null) {
         long totalSize=0;
         for(int j=0; j<items.length; j++) {
@@ -407,13 +407,13 @@
    * @see org.apache.hadoop.fs.FileSystem#globPaths(Path)
    */
   public void rename(String srcf, String dstf) throws IOException {
-    Path [] srcs = fs.globPaths( new Path(srcf) );
+    Path [] srcs = fs.globPaths(new Path(srcf));
     Path dst = new Path(dstf);
-    if( srcs.length > 1 && !fs.isDirectory(dst)) {
-      throw new IOException( "When moving multiple files, " 
-                             + "destination should be a directory." );
+    if (srcs.length > 1 && !fs.isDirectory(dst)) {
+      throw new IOException("When moving multiple files, " 
+                            + "destination should be a directory.");
     }
-    for( int i=0; i<srcs.length; i++ ) {
+    for(int i=0; i<srcs.length; i++) {
       if (fs.rename(srcs[i], dst)) {
         System.out.println("Renamed " + srcs[i] + " to " + dstf);
       } else {
@@ -442,8 +442,8 @@
     if (argv.length > 3) {
       Path dst = new Path(dest);
       if (!fs.isDirectory(dst)) {
-        throw new IOException( "When moving multiple files, " 
-                               + "destination " + dest + " should be a directory." );
+        throw new IOException("When moving multiple files, " 
+                              + "destination " + dest + " should be a directory.");
       }
     }
     //
@@ -493,13 +493,13 @@
    * @see org.apache.hadoop.fs.FileSystem#globPaths(Path)
    */
   public void copy(String srcf, String dstf, Configuration conf) throws IOException {
-    Path [] srcs = fs.globPaths( new Path(srcf) );
+    Path [] srcs = fs.globPaths(new Path(srcf));
     Path dst = new Path(dstf);
-    if( srcs.length > 1 && !fs.isDirectory(dst)) {
-      throw new IOException( "When copying multiple files, " 
-                             + "destination should be a directory." );
+    if (srcs.length > 1 && !fs.isDirectory(dst)) {
+      throw new IOException("When copying multiple files, " 
+                            + "destination should be a directory.");
     }
-    for( int i=0; i<srcs.length; i++ ) {
+    for(int i=0; i<srcs.length; i++) {
       FileUtil.copy(fs, srcs[i], fs, dst, false, conf);
     }
   }
@@ -524,8 +524,8 @@
     if (argv.length > 3) {
       Path dst = new Path(dest);
       if (!fs.isDirectory(dst)) {
-        throw new IOException( "When copying multiple files, " 
-                               + "destination " + dest + " should be a directory." );
+        throw new IOException("When copying multiple files, " 
+                              + "destination " + dest + " should be a directory.");
       }
     }
     //
@@ -572,14 +572,14 @@
    * @see org.apache.hadoop.fs.FileSystem#globPaths(Path)
    */
   public void delete(String srcf, boolean recursive) throws IOException {
-    Path [] srcs = fs.globPaths( new Path(srcf) );
-    for( int i=0; i<srcs.length; i++ ) {
+    Path [] srcs = fs.globPaths(new Path(srcf));
+    for(int i=0; i<srcs.length; i++) {
       delete(srcs[i], recursive);
     }
   }
     
   /* delete a file */
-  private void delete(Path src, boolean recursive ) throws IOException {
+  private void delete(Path src, boolean recursive) throws IOException {
     if (fs.isDirectory(src) && !recursive) {
       throw new IOException("Cannot remove directory \"" + src +
                             "\", use -rmr instead");
@@ -613,7 +613,7 @@
     } else if (len < 1024 * 1024 * 1024) {
       val = (1.0 * len) / (1024 * 1024);
       ending = " MB";
-    } else if (len < 128L * 1024 * 1024 * 1024 ) {
+    } else if (len < 128L * 1024 * 1024 * 1024) {
       val = (1.0 * len) / (1024 * 1024 * 1024);
       ending = " GB";
     } else if (len < 1024L * 1024 * 1024 * 1024 * 1024) {
@@ -915,7 +915,7 @@
       System.err.println("           [-fs <local | file system URI>]");
       System.err.println("           [-conf <configuration file>]");
       System.err.println("           [-D <[property=value>]");
-      System.err.println("           [-ls <path>]" );
+      System.err.println("           [-ls <path>]");
       System.err.println("           [-lsr <path>]");
       System.err.println("           [-du <path>]");
       System.err.println("           [-dus <path>]");
@@ -941,7 +941,7 @@
   /**
    * run
    */
-  public int run( String argv[] ) throws Exception {
+  public int run(String argv[]) throws Exception {
 
     if (argv.length < 1) {
       printUsage(""); 
@@ -1001,7 +1001,7 @@
       } else if ("-get".equals(cmd) || "-copyToLocal".equals(cmd)) {
         copyToLocal(argv, i);
       } else if ("-getmerge".equals(cmd)) {
-        if(argv.length>i+2)
+        if (argv.length>i+2)
           copyMergeToLocal(argv[i++], new Path(argv[i++]), Boolean.parseBoolean(argv[i++]));
         else
           copyMergeToLocal(argv[i++], new Path(argv[i++]));
@@ -1039,7 +1039,7 @@
         } else {
           du("");
         }
-      } else if( "-dus".equals(cmd)) {
+      } else if ("-dus".equals(cmd)) {
         if (i < argv.length) {
           exitCode = doall(cmd, argv, conf, i);
         } else {
@@ -1072,7 +1072,7 @@
         System.err.println(cmd.substring(1) + ": " + 
                            ex.getLocalizedMessage());  
       }
-    } catch (IOException e ) {
+    } catch (IOException e) {
       //
       // IO exception encountered locally.
       // 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/InMemoryFileSystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/InMemoryFileSystem.java?view=diff&rev=530556&r1=530555&r2=530556
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/InMemoryFileSystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/InMemoryFileSystem.java Thu Apr 19 14:34:41 2007
@@ -89,7 +89,7 @@
      */
     public String[][] getFileCacheHints(Path f, long start, long len)
       throws IOException {
-      if (! exists(f)) {
+      if (!exists(f)) {
         return null;
       } else {
         return new String[][] {{"inmemory"}};
@@ -194,7 +194,7 @@
                                      short replication, long blockSize, Progressable progress)
       throws IOException {
       synchronized (this) {
-        if (exists(f) && ! overwrite) {
+        if (exists(f) && !overwrite) {
           throw new IOException("File already exists:"+f);
         }
         FileAttributes fAttr =(FileAttributes) tempFileAttribs.remove(getPath(f));

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/LocalFileSystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/LocalFileSystem.java?view=diff&rev=530556&r1=530555&r2=530556
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/LocalFileSystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/LocalFileSystem.java Thu Apr 19 14:34:41 2007
@@ -34,7 +34,7 @@
     super(new RawLocalFileSystem());
   }
     
-  public LocalFileSystem( FileSystem rawLocalFileSystem ) {
+  public LocalFileSystem(FileSystem rawLocalFileSystem) {
     super(rawLocalFileSystem);
   }
     
@@ -44,13 +44,13 @@
   }
 
   @Override
-    public void copyFromLocalFile(boolean delSrc, Path src, Path dst)
+  public void copyFromLocalFile(boolean delSrc, Path src, Path dst)
     throws IOException {
     FileUtil.copy(this, src, this, dst, delSrc, getConf());
   }
 
   @Override
-    public void copyToLocalFile(boolean delSrc, Path src, Path dst)
+  public void copyToLocalFile(boolean delSrc, Path src, Path dst)
     throws IOException {
     FileUtil.copy(this, src, this, dst, delSrc, getConf());
   }
@@ -88,7 +88,7 @@
         }
       }
       String suffix = "." + new Random().nextInt();
-      File badFile = new File(badDir,f.getName()+suffix);
+      File badFile = new File(badDir, f.getName()+suffix);
       LOG.warn("Moving bad file " + f + " to " + badFile);
       in.close();                               // close it first
       f.renameTo(badFile);                      // rename it

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/Path.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/Path.java?view=diff&rev=530556&r1=530555&r2=530556
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/Path.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/Path.java Thu Apr 19 14:34:41 2007
@@ -176,7 +176,7 @@
   public Path getParent() {
     String path = uri.getPath();
     int lastSlash = path.lastIndexOf('/');
-    int start = hasWindowsDrive(path,true) ? 3 : 0;
+    int start = hasWindowsDrive(path, true) ? 3 : 0;
     if ((path.length() == start) ||               // empty path
         (lastSlash == start && path.length() == start+1)) { // at root
       return null;
@@ -186,7 +186,7 @@
       parent = "";
     } else {
       int end = hasWindowsDrive(path, true) ? 3 : 0;
-      parent = path.substring(0,lastSlash==end?end+1:lastSlash);
+      parent = path.substring(0, lastSlash==end?end+1:lastSlash);
     }
     return new Path(uri.getScheme(), uri.getAuthority(), parent);
   }

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java?view=diff&rev=530556&r1=530555&r2=530556
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java Thu Apr 19 14:34:41 2007
@@ -60,7 +60,7 @@
    * Return null if otherwise.
    */
   public String[][] getFileCacheHints(Path f, long start, long len) throws IOException {
-    if (! exists(f)) {
+    if (!exists(f)) {
       return null;
     } else {
       String result[][] = new String[1][];
@@ -183,7 +183,7 @@
   public FSDataOutputStream create(Path f, boolean overwrite, int bufferSize,
                                    short replication, long blockSize, Progressable progress)
     throws IOException {
-    if (exists(f) && ! overwrite) {
+    if (exists(f) && !overwrite) {
       throw new IOException("File already exists:"+f);
     }
     Path parent = f.getParent();
@@ -201,9 +201,9 @@
   }
   
   /** Set the replication of the given file */
-  public boolean setReplication( Path src,
-                                 short replication
-                                 ) throws IOException {
+  public boolean setReplication(Path src,
+                                short replication
+                                ) throws IOException {
     return true;
   }
   
@@ -236,9 +236,9 @@
     File localf = pathToFile(f);
     Path[] results;
     
-    if(!localf.exists())
+    if (!localf.exists())
       return null;
-    else if(localf.isFile()) {
+    else if (localf.isFile()) {
       results = new Path[1];
       results[0] = f;
       return results;
@@ -270,12 +270,12 @@
    * Set the working directory to the given directory.
    */
   @Override
-    public void setWorkingDirectory(Path newDir) {
+  public void setWorkingDirectory(Path newDir) {
     workingDir = newDir;
   }
   
   @Override
-    public Path getWorkingDirectory() {
+  public Path getWorkingDirectory() {
     return workingDir;
   }
   
@@ -337,13 +337,13 @@
   }
   
   @Override
-    public void copyFromLocalFile(boolean delSrc, Path src, Path dst)
+  public void copyFromLocalFile(boolean delSrc, Path src, Path dst)
     throws IOException {
     FileUtil.copy(this, src, this, dst, delSrc, getConf());
   }
   
   @Override
-    public void copyToLocalFile(boolean delSrc, Path src, Path dst)
+  public void copyToLocalFile(boolean delSrc, Path src, Path dst)
     throws IOException {
     FileUtil.copy(this, src, this, dst, delSrc, getConf());
   }

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/s3/S3FileSystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/s3/S3FileSystem.java?view=diff&rev=530556&r1=530555&r2=530556
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/s3/S3FileSystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/s3/S3FileSystem.java Thu Apr 19 14:34:41 2007
@@ -64,21 +64,21 @@
     FileSystemStore store = new Jets3tFileSystemStore();
     
     RetryPolicy basePolicy = RetryPolicies.retryUpToMaximumCountWithFixedSleep(
-        conf.getInt("fs.s3.maxRetries", 4),
-        conf.getLong("fs.s3.sleepTimeSeconds", 10), TimeUnit.SECONDS);
+                                                                               conf.getInt("fs.s3.maxRetries", 4),
+                                                                               conf.getLong("fs.s3.sleepTimeSeconds", 10), TimeUnit.SECONDS);
     Map<Class<? extends Exception>,RetryPolicy> exceptionToPolicyMap =
       new HashMap<Class<? extends Exception>, RetryPolicy>();
     exceptionToPolicyMap.put(IOException.class, basePolicy);
     exceptionToPolicyMap.put(S3Exception.class, basePolicy);
     
     RetryPolicy methodPolicy = RetryPolicies.retryByException(
-        RetryPolicies.TRY_ONCE_THEN_FAIL, exceptionToPolicyMap);
+                                                              RetryPolicies.TRY_ONCE_THEN_FAIL, exceptionToPolicyMap);
     Map<String,RetryPolicy> methodNameToPolicyMap = new HashMap<String,RetryPolicy>();
     methodNameToPolicyMap.put("storeBlock", methodPolicy);
     methodNameToPolicyMap.put("retrieveBlock", methodPolicy);
     
     return (FileSystemStore) RetryProxy.create(FileSystemStore.class,
-        store, methodNameToPolicyMap);
+                                               store, methodNameToPolicyMap);
   }
   
   @Override
@@ -116,7 +116,7 @@
       store.storeINode(absolutePath, INode.DIRECTORY_INODE);
     } else if (inode.isFile()) {
       throw new IOException(String.format(
-          "Can't make directory for path %s since it is a file.", absolutePath));
+                                          "Can't make directory for path %s since it is a file.", absolutePath));
     }
     Path parent = absolutePath.getParent();
     return (parent == null || mkdirs(parent));
@@ -167,8 +167,8 @@
 
   @Override
   public FSDataOutputStream create(Path file, boolean overwrite, int bufferSize,
-      short replication, long blockSize, Progressable progress)
-      throws IOException {
+                                   short replication, long blockSize, Progressable progress)
+    throws IOException {
 
     INode inode = store.retrieveINode(makeAbsolute(file));
     if (inode != null) {
@@ -185,16 +185,16 @@
         }
       }      
     }
-    return new FSDataOutputStream( 
-            new S3OutputStream(getConf(), store, makeAbsolute(file),
-                blockSize, progress), bufferSize );
+    return new FSDataOutputStream(
+                                  new S3OutputStream(getConf(), store, makeAbsolute(file),
+                                                     blockSize, progress), bufferSize);
   }
 
   @Override
   public FSDataInputStream open(Path path, int bufferSize) throws IOException {
     INode inode = checkFile(path);
-    return new FSDataInputStream( new S3InputStream(getConf(), store, inode),
-            bufferSize);
+    return new FSDataInputStream(new S3InputStream(getConf(), store, inode),
+                                 bufferSize);
   }
 
   @Override
@@ -262,7 +262,7 @@
         return false;
       }
       for (Path p : contents) {
-        if (! delete(p)) {
+        if (!delete(p)) {
           return false;
         }
       }
@@ -301,7 +301,7 @@
    */
   @Override
   public boolean setReplication(Path path, short replication)
-      throws IOException {
+    throws IOException {
     return true;
   }
 
@@ -328,7 +328,7 @@
    */
   @Override
   public String[][] getFileCacheHints(Path f, long start, long len)
-      throws IOException {
+    throws IOException {
     // TODO: Check this is the correct behavior
     if (!exists(f)) {
       return null;
@@ -337,14 +337,14 @@
   }
 
   /** @deprecated */ @Deprecated
-  @Override
-  public void lock(Path path, boolean shared) throws IOException {
+    @Override
+    public void lock(Path path, boolean shared) throws IOException {
     // TODO: Design and implement
   }
 
   /** @deprecated */ @Deprecated
-  @Override
-  public void release(Path path) throws IOException {
+    @Override
+    public void release(Path path) throws IOException {
     // TODO: Design and implement
   }
 
@@ -360,13 +360,13 @@
 
   @Override
   public Path startLocalOutput(Path fsOutputFile, Path tmpLocalFile)
-      throws IOException {
+    throws IOException {
     return tmpLocalFile;
   }
 
   @Override
   public void completeLocalOutput(Path fsOutputFile, Path tmpLocalFile)
-      throws IOException {
+    throws IOException {
     moveFromLocalFile(tmpLocalFile, fsOutputFile);
   }
 



Mime
View raw message