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 ha...@apache.org on 2008/06/05 22:46:47 UTC

svn commit: r663732 - in /hadoop/core/trunk: CHANGES.txt src/java/org/apache/hadoop/dfs/DfsPath.java src/java/org/apache/hadoop/dfs/DistributedFileSystem.java

Author: hairong
Date: Thu Jun  5 13:46:47 2008
New Revision: 663732

URL: http://svn.apache.org/viewvc?rev=663732&view=rev
Log:
HADOOP-2565. Remove DFSPath cache of FileStatus. Contributed by Tse Wo (Nicholas), SZE.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DfsPath.java
    hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=663732&r1=663731&r2=663732&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Thu Jun  5 13:46:47 2008
@@ -463,6 +463,9 @@
     HADOOP-2427. Ensure that the cwd of completed tasks is cleaned-up
     correctly on task-completion. (Amareshwari Sri Ramadasu via acmurthy) 
 
+    HADOOP-2565. Remove DFSPath cache of FileStatus. 
+    (Tsz Wo (Nicholas), SZE via hairong)
+
 Release 0.17.0 - 2008-05-18
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DfsPath.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DfsPath.java?rev=663732&r1=663731&r2=663732&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DfsPath.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DfsPath.java Thu Jun  5 13:46:47 2008
@@ -1,61 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.dfs;
-
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.FileSystem;
-
-/** 
- * DfsPath is a Path that's been annotated with some extra information.
- * The point of this class is to pass back the "common" metadata about 
- * a file with the names in a directory listing to make accesses faster.
- */
-class DfsPath extends Path {
-  DFSFileInfo info;
-
-  /**
-   * DfsPaths are fully qualified with scheme and authority.
-   */
-  public DfsPath(DFSFileInfo info, FileSystem fs) {
-    super((new Path(info.getPath().toString())).makeQualified(fs).toString());
-    this.info = info;
-  }
-
-  public boolean isDirectory() {
-    return info.isDir();
-  }
-  public boolean isFile() {
-    return ! isDirectory();
-  }
-  public long length() {
-    return info.getLen();
-  }
-  public long getContentsLength() {
-    assert !isDirectory();
-    return info.getLen();
-  }
-  public short getReplication() {
-    return info.getReplication();
-  }
-  public long getBlockSize() {
-    return info.getBlockSize();
-  }
-  public long getModificationTime() {
-    return info.getModificationTime();
-  }
-}

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java?rev=663732&r1=663731&r2=663732&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java Thu Jun  5 13:46:47 2008
@@ -200,16 +200,19 @@
     dfs.setQuota(getPathName(src), quota);
   }
   
+  private FileStatus makeQualified(FileStatus f) {
+    return new FileStatus(f.getLen(), f.isDir(), f.getReplication(),
+        f.getBlockSize(), f.getModificationTime(),
+        f.getPermission(), f.getOwner(), f.getGroup(),
+        f.getPath().makeQualified(this)); // fully-qualify path
+  }
+
   public FileStatus[] listStatus(Path p) throws IOException {
     DFSFileInfo[] infos = dfs.listPaths(getPathName(p));
     if (infos == null) return null;
     FileStatus[] stats = new FileStatus[infos.length];
     for (int i = 0; i < infos.length; i++) {
-      DFSFileInfo f = (DFSFileInfo)infos[i];
-      stats[i] = new FileStatus(f.getLen(), f.isDir(), f.getReplication(),
-                                f.getBlockSize(), f.getModificationTime(),
-                                f.getPermission(), f.getOwner(), f.getGroup(),
-                                new DfsPath(f, this)); // fully-qualify path
+      stats[i] = makeQualified(infos[i]);
     }
     return stats;
   }
@@ -369,16 +372,9 @@
    * @throws FileNotFoundException if the file does not exist.
    */
   public FileStatus getFileStatus(Path f) throws IOException {
-    if (f instanceof DfsPath) {
-      DfsPath p = (DfsPath) f;
-      return p.info;
-    }
     DFSFileInfo fi = dfs.getFileInfo(getPathName(f));
     if (fi != null) {
-      return new FileStatus(fi.getLen(), fi.isDir(), fi.getReplication(),
-          fi.getBlockSize(), fi.getModificationTime(),
-          fi.getPermission(), fi.getOwner(), fi.getGroup(),
-          new DfsPath(fi, this)); // fully-qualify path;
+      return makeQualified(fi);
     } else {
       throw new FileNotFoundException("File does not exist: " + f);
     }