فهرست منبع

HADOOP-6719. Insert all missing methods in FilterFs.
(Rodrigo Schmidt via dhruba)



git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@937093 13f79535-47bb-0310-9956-ffa450edef68

Dhruba Borthakur 15 سال پیش
والد
کامیت
1e82194428
3فایلهای تغییر یافته به همراه114 افزوده شده و 0 حذف شده
  1. 3 0
      CHANGES.txt
  2. 50 0
      src/java/org/apache/hadoop/fs/FilterFs.java
  3. 61 0
      src/test/core/org/apache/hadoop/fs/TestFilterFs.java

+ 3 - 0
CHANGES.txt

@@ -336,6 +336,9 @@ Trunk (unreleased changes)
     HADOOP-6690. FilterFileSystem correctly handles setTimes call.
     (Rodrigo Schmidt via dhruba)
 
+    HADOOP-6719. Insert all missing methods in FilterFs.
+    (Rodrigo Schmidt via dhruba)
+
 Release 0.21.0 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 50 - 0
src/java/org/apache/hadoop/fs/FilterFs.java

@@ -16,13 +16,17 @@ package org.apache.hadoop.fs;
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.EnumSet;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.fs.FileSystem.Statistics;
 import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.security.AccessControlException;
 import org.apache.hadoop.util.Progressable;
 
 /**
@@ -51,11 +55,21 @@ public abstract class FilterFs extends AbstractFileSystem {
     myFs = fs;
   }
 
+  @Override
+  protected Statistics getStatistics() {
+    return myFs.getStatistics();
+  }
+
   @Override
   protected Path getInitialWorkingDirectory() {
     return myFs.getInitialWorkingDirectory();
   }
   
+  @Override
+  protected Path getHomeDirectory() {
+    return myFs.getHomeDirectory();
+  }
+  
   @Override
   protected FSDataOutputStream createInternal(Path f,
     EnumSet<CreateFlag> flag, FsPermission absolutePermission, int bufferSize,
@@ -102,6 +116,12 @@ public abstract class FilterFs extends AbstractFileSystem {
     return myFs.getFileLinkStatus(f);
   }
   
+  @Override
+  protected FsStatus getFsStatus(final Path f) throws AccessControlException,
+    FileNotFoundException, UnresolvedLinkException, IOException {
+    return myFs.getFsStatus(f);
+  }
+
   @Override
   protected FsStatus getFsStatus() throws IOException {
     return myFs.getFsStatus();
@@ -117,6 +137,21 @@ public abstract class FilterFs extends AbstractFileSystem {
     return myFs.getUriDefaultPort();
   }
 
+  @Override
+  protected URI getUri() {
+    return myFs.getUri();
+  }
+  
+  @Override
+  protected void checkPath(Path path) {
+    myFs.checkPath(path);
+  }
+  
+  @Override
+  protected String getUriPath(final Path p) {
+    return myFs.getUriPath(p);
+  }
+  
   @Override
   protected FileStatus[] listStatus(Path f) 
       throws IOException, UnresolvedLinkException {
@@ -132,6 +167,13 @@ public abstract class FilterFs extends AbstractFileSystem {
     
   }
 
+  @Override
+  protected FSDataInputStream open(final Path f) throws AccessControlException,
+    FileNotFoundException, UnresolvedLinkException, IOException {
+    checkPath(f);
+    return myFs.open(f);
+  }
+
   @Override
   protected FSDataInputStream open(Path f, int bufferSize) 
     throws IOException, UnresolvedLinkException {
@@ -147,6 +189,14 @@ public abstract class FilterFs extends AbstractFileSystem {
     myFs.rename(src, dst, Options.Rename.NONE);
   }
 
+  @Override
+  protected void renameInternal(final Path src, final Path dst,
+      boolean overwrite) throws AccessControlException,
+      FileAlreadyExistsException, FileNotFoundException,
+      ParentNotDirectoryException, UnresolvedLinkException, IOException {
+    myFs.renameInternal(src, dst, overwrite);
+  }
+  
   @Override
   protected void setOwner(Path f, String username, String groupname)
     throws IOException, UnresolvedLinkException {

+ 61 - 0
src/test/core/org/apache/hadoop/fs/TestFilterFs.java

@@ -0,0 +1,61 @@
+/**
+ * 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.fs;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.URI;
+
+import junit.framework.TestCase;
+import org.apache.commons.logging.Log;
+
+public class TestFilterFs extends TestCase {
+
+  private static final Log LOG = FileSystem.LOG;
+
+  public static class DontCheck {
+    public void checkScheme(URI uri, String supportedScheme) { }
+  }
+  
+  public void testFilterFileSystem() throws Exception {
+    for (Method m : AbstractFileSystem.class.getDeclaredMethods()) {
+      if (Modifier.isStatic(m.getModifiers()))
+        continue;
+      if (Modifier.isPrivate(m.getModifiers()))
+        continue;
+      if (Modifier.isFinal(m.getModifiers()))
+        continue;
+      
+      try {
+        DontCheck.class.getMethod(m.getName(), m.getParameterTypes());
+        LOG.info("Skipping " + m);
+      } catch (NoSuchMethodException exc) {
+        LOG.info("Testing " + m);
+        try{
+          FilterFs.class.getDeclaredMethod(m.getName(), m.getParameterTypes());
+        }
+        catch(NoSuchMethodException exc2){
+          LOG.error("FilterFileSystem doesn't implement " + m);
+          throw exc2;
+        }
+      }
+    }
+  }
+  
+}