001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.wal; 019 020import java.io.FileNotFoundException; 021import java.io.IOException; 022import java.net.URI; 023import org.apache.hadoop.fs.FSDataInputStream; 024import org.apache.hadoop.fs.FSDataOutputStream; 025import org.apache.hadoop.fs.FileStatus; 026import org.apache.hadoop.fs.FileSystem; 027import org.apache.hadoop.fs.Path; 028import org.apache.hadoop.fs.permission.FsPermission; 029import org.apache.hadoop.util.Progressable; 030 031/** 032 * Create a non-abstract "proxy" for FileSystem because FileSystem is an abstract class and not an 033 * interface. Only interfaces can be used with the Java Proxy class to override functionality via an 034 * InvocationHandler. 035 */ 036public class FileSystemProxy extends FileSystem { 037 private final FileSystem real; 038 039 public FileSystemProxy(FileSystem real) { 040 this.real = real; 041 } 042 043 @Override 044 public FSDataInputStream open(Path p) throws IOException { 045 return real.open(p); 046 } 047 048 @Override 049 public URI getUri() { 050 return real.getUri(); 051 } 052 053 @Override 054 public FSDataInputStream open(Path f, int bufferSize) throws IOException { 055 return real.open(f, bufferSize); 056 } 057 058 @Override 059 public FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite, 060 int bufferSize, short replication, long blockSize, Progressable progress) throws IOException { 061 return real.create(f, permission, overwrite, bufferSize, replication, blockSize, progress); 062 } 063 064 @Override 065 public FSDataOutputStream append(Path f, int bufferSize, Progressable progress) 066 throws IOException { 067 return real.append(f, bufferSize, progress); 068 } 069 070 @Override 071 public boolean rename(Path src, Path dst) throws IOException { 072 return real.rename(src, dst); 073 } 074 075 @Override 076 public boolean delete(Path f, boolean recursive) throws IOException { 077 return real.delete(f, recursive); 078 } 079 080 @Override 081 public FileStatus[] listStatus(Path f) throws FileNotFoundException, IOException { 082 return real.listStatus(f); 083 } 084 085 @Override 086 public void setWorkingDirectory(Path new_dir) { 087 real.setWorkingDirectory(new_dir); 088 } 089 090 @Override 091 public Path getWorkingDirectory() { 092 return real.getWorkingDirectory(); 093 } 094 095 @Override 096 public boolean mkdirs(Path f, FsPermission permission) throws IOException { 097 return real.mkdirs(f, permission); 098 } 099 100 @Override 101 public FileStatus getFileStatus(Path f) throws IOException { 102 return real.getFileStatus(f); 103 } 104}