hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r390218 - /lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java
Date Thu, 30 Mar 2006 19:09:47 GMT
Author: cutting
Date: Thu Mar 30 11:09:46 2006
New Revision: 390218

URL: http://svn.apache.org/viewcvs?rev=390218&view=rev
Log:
Fix for HADOOP-112.  All operations on local files are now performed
through a LocalFileSystem.  In particular, listing the local
directory, which was causing this bug, when CRC files were included
in the listing.  Now they are correctly excluded.

Modified:
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java?rev=390218&r1=390217&r2=390218&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java Thu Mar
30 11:09:46 2006
@@ -155,15 +155,17 @@
             }
         }
 
-        if (src.isDirectory()) {
+        FileSystem localFs = getNamed("local", getConf());
+
+        if (localFs.isDirectory(src)) {
             mkdirs(dst);
-            File contents[] = src.listFiles();
+            File contents[] = localFs.listFiles(src);
             for (int i = 0; i < contents.length; i++) {
                 doFromLocalFile(contents[i], new File(dst, contents[i].getName()), deleteSource);
             }
         } else {
             byte buf[] = new byte[getConf().getInt("io.file.buffer.size", 4096)];
-            InputStream in = new BufferedInputStream(new FileInputStream(src));
+            InputStream in = localFs.open(src);
             try {
                 OutputStream out = create(dst);
                 try {
@@ -180,7 +182,7 @@
             } 
         }
         if (deleteSource)
-            src.delete();
+            localFs.delete(src);
     }
 
     public void copyToLocalFile(File src, File dst) throws IOException {
@@ -196,8 +198,10 @@
         }
         dst = dst.getCanonicalFile();
 
+        FileSystem localFs = getNamed("local", getConf());
+
         if (isDirectory(src)) {
-            dst.mkdirs();
+            localFs.mkdirs(dst);
             File contents[] = listFiles(src);
             for (int i = 0; i < contents.length; i++) {
                 copyToLocalFile(contents[i], new File(dst, contents[i].getName()));
@@ -206,7 +210,7 @@
             byte buf[] = new byte[getConf().getInt("io.file.buffer.size", 4096)];
             InputStream in = open(src);
             try {
-                OutputStream out = FileSystem.getNamed("local", getConf()).create(dst);
+                OutputStream out = localFs.create(dst);
                 try {
                     int bytesRead = in.read(buf);
                     while (bytesRead >= 0) {



Mime
View raw message