+ * 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.ozone; + +import org.apache.hadoop.fs.Path; + +/** + * Class to hold the internal information of a FileStatus. + *
+ * As FileStatus class is not compatible between 3.x and 2.x hadoop we can + * use this adapter to hold all the required information. Hadoop 3.x FileStatus + * information can be converted to this class, and this class can be used to + * create hadoop 2.x FileStatus. + *
+ * FileStatus (Hadoop 3.x) --> FileStatusAdapter --> FileStatus (Hadoop 2.x) + */ +public final class FileStatusAdapter { + + private final long length; + private final Path path; + private final boolean isdir; + private final short blockReplication; + private final long blocksize; + private final long modificationTime; + private final long accessTime; + private final short permission; + private final String owner; + private final String group; + private final Path symlink; + + @SuppressWarnings("checkstyle:ParameterNumber") + public FileStatusAdapter(long length, Path path, boolean isdir, + short blockReplication, long blocksize, long modificationTime, + long accessTime, short permission, String owner, + String group, Path symlink) { + this.length = length; + this.path = path; + this.isdir = isdir; + this.blockReplication = blockReplication; + this.blocksize = blocksize; + this.modificationTime = modificationTime; + this.accessTime = accessTime; + this.permission = permission; + this.owner = owner; + this.group = group; + this.symlink = symlink; + } + + public Path getPath() { + return path; + } + + public boolean isDir() { + return isdir; + } + + public short getBlockReplication() { + return blockReplication; + } + + public long getBlocksize() { + return blocksize; + } + + public long getModificationTime() { + return modificationTime; + } + + public long getAccessTime() { + return accessTime; + } + + public short getPermission() { + return permission; + } + + public String getOwner() { + return owner; + } + + public String getGroup() { + return group; + } + + public Path getSymlink() { + return symlink; + } + + public long getLength() { + return length; + } + +} diff --git a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/FilteredClassLoader.java b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/FilteredClassLoader.java index 2643cab41b8..a90797efdd8 100644 --- a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/FilteredClassLoader.java +++ b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/FilteredClassLoader.java @@ -52,17 +52,19 @@ public class FilteredClassLoader extends URLClassLoader { public FilteredClassLoader(URL[] urls, ClassLoader parent) { super(urls, null); + delegatedClasses.add("org.apache.hadoop.crypto.key.KeyProvider"); delegatedClasses.add("org.apache.hadoop.fs.ozone.OzoneClientAdapter"); + delegatedClasses.add("org.apache.hadoop.fs.ozone.FileStatusAdapter"); delegatedClasses.add("org.apache.hadoop.security.token.Token"); delegatedClasses.add("org.apache.hadoop.fs.ozone.BasicKeyInfo"); delegatedClasses.add("org.apache.hadoop.fs.ozone.OzoneFSOutputStream"); delegatedClasses.add("org.apache.hadoop.fs.ozone.OzoneFSStorageStatistics"); delegatedClasses.add("org.apache.hadoop.fs.ozone.Statistic"); delegatedClasses.add("org.apache.hadoop.fs.Seekable"); - + delegatedClasses.add("org.apache.hadoop.io.Text"); + delegatedClasses.add("org.apache.hadoop.fs.Path"); delegatedClasses.addAll(StringUtils.getTrimmedStringCollection( System.getenv("HADOOP_OZONE_DELEGATED_CLASSES"))); - this.delegate = parent; systemClassLoader = getSystemClassLoader(); diff --git a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzoneClientAdapter.java b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzoneClientAdapter.java index 390925c0780..0ae8c8ff1d8 100644 --- a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzoneClientAdapter.java +++ b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzoneClientAdapter.java @@ -17,18 +17,17 @@ */ package org.apache.hadoop.fs.ozone; -import org.apache.hadoop.crypto.key.KeyProvider; -import org.apache.hadoop.ozone.security.OzoneTokenIdentifier; -import org.apache.hadoop.security.token.Token; - -import org.apache.hadoop.ozone.om.helpers.OzoneFileStatus; - import java.io.IOException; import java.io.InputStream; import java.net.URI; import java.util.Iterator; import java.util.List; +import org.apache.hadoop.crypto.key.KeyProvider; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.ozone.security.OzoneTokenIdentifier; +import org.apache.hadoop.security.token.Token; + /** * Lightweight adapter to separate hadoop/ozone classes. *
@@ -53,8 +52,9 @@ public interface OzoneClientAdapter {
Iterator