You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2012/05/09 20:47:34 UTC

svn commit: r1336345 - /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java

Author: apurtell
Date: Wed May  9 18:47:33 2012
New Revision: 1336345

URL: http://svn.apache.org/viewvc?rev=1336345&view=rev
Log:
HBASE-5964. HFileSystem: "No FileSystem for scheme: hdfs"

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java?rev=1336345&r1=1336344&r2=1336345&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java Wed May  9 18:47:33 2012
@@ -30,6 +30,7 @@ import org.apache.hadoop.fs.FSDataInputS
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.LocalFileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.util.Methods;
 import org.apache.hadoop.util.ReflectionUtils;
 import org.apache.hadoop.util.Progressable;
 
@@ -141,12 +142,23 @@ public class HFileSystem extends FilterF
   private static FileSystem newInstanceFileSystem(Configuration conf)
     throws IOException {
     URI uri = FileSystem.getDefaultUri(conf);
+    FileSystem fs = null;
     Class<?> clazz = conf.getClass("fs." + uri.getScheme() + ".impl", null);
-    if (clazz == null) {
+    if (clazz != null) {
+      // This will be true for Hadoop 1.0, or 0.20.
+      fs = (FileSystem)ReflectionUtils.newInstance(clazz, conf);
+      fs.initialize(uri, conf);
+    } else {
+      // For Hadoop 2.0, we have to go through FileSystem for the filesystem
+      // implementation to be loaded by the service loader in case it has not
+      // been loaded yet.
+      Configuration clone = new Configuration(conf);
+      clone.setBoolean("fs." + uri.getScheme() + ".impl.disable.cache", true);
+      fs = FileSystem.get(uri, clone);
+    }
+    if (fs == null) {
       throw new IOException("No FileSystem for scheme: " + uri.getScheme());
     }
-    FileSystem fs = (FileSystem)ReflectionUtils.newInstance(clazz, conf);
-    fs.initialize(uri, conf);
     return fs;
   }