View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.wal;
19  
20  import java.io.FileNotFoundException;
21  import java.io.IOException;
22  import java.net.URI;
23  
24  import org.apache.hadoop.fs.FSDataInputStream;
25  import org.apache.hadoop.fs.FSDataOutputStream;
26  import org.apache.hadoop.fs.FileStatus;
27  import org.apache.hadoop.fs.FileSystem;
28  import org.apache.hadoop.fs.Path;
29  import org.apache.hadoop.fs.permission.FsPermission;
30  import org.apache.hadoop.util.Progressable;
31  
32  /**
33   * Create a non-abstract "proxy" for FileSystem because FileSystem is an
34   * abstract class and not an interface. Only interfaces can be used with the
35   * Java Proxy class to override functionality via an InvocationHandler.
36   *
37   */
38  public class FileSystemProxy extends FileSystem {
39    private final FileSystem real;
40  
41    public FileSystemProxy(FileSystem real) {
42      this.real = real;
43    }
44  
45    @Override
46    public FSDataInputStream open(Path p) throws IOException {
47      return real.open(p);
48    }
49  
50    @Override
51    public URI getUri() {
52      return real.getUri();
53    }
54  
55    @Override
56    public FSDataInputStream open(Path f, int bufferSize) throws IOException {
57      return real.open(f, bufferSize);
58    }
59  
60    @Override
61    public FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite,
62        int bufferSize, short replication, long blockSize, Progressable progress) throws IOException {
63      return real.create(f, permission, overwrite, bufferSize, replication, blockSize, progress);
64    }
65  
66    @Override
67    public FSDataOutputStream append(Path f, int bufferSize, Progressable progress)
68        throws IOException {
69      return real.append(f, bufferSize, progress);
70    }
71  
72    @Override
73    public boolean rename(Path src, Path dst) throws IOException {
74      return real.rename(src, dst);
75    }
76  
77    @Override
78    public boolean delete(Path f, boolean recursive) throws IOException {
79      return real.delete(f, recursive);
80    }
81  
82    @Override
83    public FileStatus[] listStatus(Path f) throws FileNotFoundException, IOException {
84      return real.listStatus(f);
85    }
86  
87    @Override
88    public void setWorkingDirectory(Path new_dir) {
89      real.setWorkingDirectory(new_dir);
90    }
91  
92    @Override
93    public Path getWorkingDirectory() {
94      return real.getWorkingDirectory();
95    }
96  
97    @Override
98    public boolean mkdirs(Path f, FsPermission permission) throws IOException {
99      return real.mkdirs(f, permission);
100   }
101 
102   @Override
103   public FileStatus getFileStatus(Path f) throws IOException {
104     return real.getFileStatus(f);
105   }
106 }