diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java index 5ddf52a2d0..8132db47f9 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java @@ -49,9 +49,7 @@ import org.apache.hadoop.fs.Options.ChecksumOpt; import org.apache.hadoop.fs.Options.Rename; import org.apache.hadoop.fs.permission.AclEntry; -import org.apache.hadoop.fs.permission.AclReadFlag; import org.apache.hadoop.fs.permission.AclStatus; -import org.apache.hadoop.fs.permission.AclWriteFlag; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.io.MultipleIOException; import org.apache.hadoop.io.Text; @@ -2278,11 +2276,9 @@ public void deleteSnapshot(Path path, String snapshotName) * * @param path Path to modify * @param aclSpec List describing modifications - * @param flags EnumSet containing flags (such as recursive) * @throws IOException if an ACL could not be modified */ - public void modifyAclEntries(Path path, List aclSpec, - EnumSet flags) throws IOException { + public void modifyAclEntries(Path path, Iterable aclSpec) throws IOException { throw new UnsupportedOperationException(getClass().getSimpleName() + " doesn't support modifyAclEntries"); } @@ -2293,11 +2289,9 @@ public void modifyAclEntries(Path path, List aclSpec, * * @param path Path to modify * @param aclSpec List describing entries to remove - * @param flags EnumSet containing flags (such as recursive) * @throws IOException if an ACL could not be modified */ - public void removeAclEntries(Path path, List aclSpec, - EnumSet flags) throws IOException { + public void removeAclEntries(Path path, Iterable aclSpec) throws IOException { throw new UnsupportedOperationException(getClass().getSimpleName() + " doesn't support removeAclEntries"); } @@ -2306,10 +2300,9 @@ public void removeAclEntries(Path path, List aclSpec, * Removes all default ACL entries from files and directories. * * @param path Path to modify - * @param flags EnumSet containing flags (such as recursive) * @throws IOException if an ACL could not be modified */ - public void removeDefaultAcl(Path path, EnumSet flags) + public void removeDefaultAcl(Path path) throws IOException { throw new UnsupportedOperationException(getClass().getSimpleName() + " doesn't support removeDefaultAcl"); @@ -2321,10 +2314,9 @@ public void removeDefaultAcl(Path path, EnumSet flags) * bits. * * @param path Path to modify - * @param flags EnumSet containing flags (such as recursive) * @throws IOException if an ACL could not be removed */ - public void removeAcl(Path path, EnumSet flags) + public void removeAcl(Path path) throws IOException { throw new UnsupportedOperationException(getClass().getSimpleName() + " doesn't support removeAcl"); @@ -2337,11 +2329,9 @@ public void removeAcl(Path path, EnumSet flags) * @param path Path to modify * @param aclSpec List describing modifications, must include entries * for user, group, and others for compatibility with permission bits. - * @param flags EnumSet containing flags (such as recursive) * @throws IOException if an ACL could not be modified */ - public void setAcl(Path path, List aclSpec, - EnumSet flags) throws IOException { + public void setAcl(Path path, Iterable aclSpec) throws IOException { throw new UnsupportedOperationException(getClass().getSimpleName() + " doesn't support setAcl"); } @@ -2350,14 +2340,12 @@ public void setAcl(Path path, List aclSpec, * Gets the ACLs of files and directories. * * @param path Path to get - * @param flags EnumSet containing flags (such as recursive) * @return RemoteIterator which returns each AclStatus * @throws IOException if an ACL could not be read */ - public RemoteIterator listAclStatus(Path path, - EnumSet flags) throws IOException { + public AclStatus getAclStatus(Path path) throws IOException { throw new UnsupportedOperationException(getClass().getSimpleName() - + " doesn't support listAclStatus"); + + " doesn't support getAclStatus"); } // making it volatile to be able to do a double checked locking diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java index fe2040bfe8..5072a4db08 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java @@ -22,14 +22,12 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.EnumSet; -import java.util.List; + import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.permission.AclEntry; -import org.apache.hadoop.fs.permission.AclReadFlag; import org.apache.hadoop.fs.permission.AclStatus; -import org.apache.hadoop.fs.permission.AclWriteFlag; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.fs.ContentSummary; import org.apache.hadoop.fs.Options.ChecksumOpt; @@ -514,38 +512,34 @@ public void deleteSnapshot(Path path, String snapshotName) } @Override - public void modifyAclEntries(Path path, List aclSpec, - EnumSet flags) throws IOException { - fs.modifyAclEntries(path, aclSpec, flags); + public void modifyAclEntries(Path path, Iterable aclSpec) throws IOException { + fs.modifyAclEntries(path, aclSpec); } @Override - public void removeAclEntries(Path path, List aclSpec, - EnumSet flags) throws IOException { - fs.removeAclEntries(path, aclSpec, flags); + public void removeAclEntries(Path path, Iterable aclSpec) throws IOException { + fs.removeAclEntries(path, aclSpec); } @Override - public void removeDefaultAcl(Path path, EnumSet flags) + public void removeDefaultAcl(Path path) throws IOException { - fs.removeDefaultAcl(path, flags); + fs.removeDefaultAcl(path); } @Override - public void removeAcl(Path path, EnumSet flags) + public void removeAcl(Path path) throws IOException { - fs.removeAcl(path, flags); + fs.removeAcl(path); } @Override - public void setAcl(Path path, List aclSpec, - EnumSet flags) throws IOException { - fs.setAcl(path, aclSpec, flags); + public void setAcl(Path path, Iterable aclSpec) throws IOException { + fs.setAcl(path, aclSpec); } @Override - public RemoteIterator listAclStatus(Path path, - EnumSet flags) throws IOException { - return fs.listAclStatus(path, flags); + public AclStatus getAclStatus(Path path) throws IOException { + return fs.getAclStatus(path); } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/Acl.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/Acl.java deleted file mode 100644 index a998b40608..0000000000 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/Acl.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * 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.permission; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import com.google.common.base.Objects; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; - -/** - * Defines an Access Control List, which is a set of rules for enforcement of - * permissions on a file or directory. An Acl contains a set of multiple - * {@link AclEntry} instances. The ACL entries define the permissions enforced - * for different classes of users: owner, named user, owning group, named group - * and others. The Acl also contains additional flags associated with the file, - * such as the sticky bit. Acl instances are immutable. Use a {@link Builder} - * to create a new instance. - */ -@InterfaceAudience.Public -@InterfaceStability.Evolving -public class Acl { - private final List entries; - private final boolean stickyBit; - - /** - * Returns the sticky bit. - * - * @return boolean sticky bit - */ - public boolean getStickyBit() { - return stickyBit; - } - - /** - * Returns the list of all ACL entries, ordered by their natural ordering. - * The list is unmodifiable. - * - * @return List unmodifiable ordered list of all ACL entries - */ - public List getEntries() { - return entries; - } - - @Override - public boolean equals(Object o) { - if (o == null) { - return false; - } - if (getClass() != o.getClass()) { - return false; - } - Acl other = (Acl)o; - return Objects.equal(entries, other.entries) && - Objects.equal(stickyBit, other.stickyBit); - } - - @Override - public int hashCode() { - return Objects.hashCode(entries, stickyBit); - } - - @Override - public String toString() { - return new StringBuilder() - .append("entries: ").append(entries) - .append(", stickyBit: ").append(stickyBit) - .toString(); - } - - /** - * Builder for creating new Acl instances. - */ - public static class Builder { - private List entries = new ArrayList(); - private boolean stickyBit = false; - - /** - * Adds an ACL entry. - * - * @param entry AclEntry entry to add - * @return Builder this builder, for call chaining - */ - public Builder addEntry(AclEntry entry) { - entries.add(entry); - return this; - } - - /** - * Sets sticky bit. If this method is not called, then the builder assumes - * false. - * - * @param stickyBit boolean sticky bit - * @return Builder this builder, for call chaining - */ - public Builder setStickyBit(boolean stickyBit) { - this.stickyBit = stickyBit; - return this; - } - - /** - * Builds a new Acl populated with the set properties. - * - * @return Acl new Acl - */ - public Acl build() { - return new Acl(entries, stickyBit); - } - } - - /** - * Private constructor. - * - * @param entries List list of all ACL entries - * @param boolean sticky bit - */ - private Acl(List entries, boolean stickyBit) { - List entriesCopy = new ArrayList(entries); - Collections.sort(entriesCopy); - this.entries = Collections.unmodifiableList(entriesCopy); - this.stickyBit = stickyBit; - } -} diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/AclReadFlag.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/AclReadFlag.java deleted file mode 100644 index 0058e95cef..0000000000 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/AclReadFlag.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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.permission; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; - -/** - * Flags that control behavior of operations for reading ACL information. - */ -@InterfaceAudience.Public -@InterfaceStability.Evolving -public enum AclReadFlag { - /** - * Read ACLs for all files and directories recursively in the sub-tree of the - * specified path. - */ - RECURSIVE -} diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/AclStatus.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/AclStatus.java index cad959984a..138154f40a 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/AclStatus.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/AclStatus.java @@ -17,33 +17,26 @@ */ package org.apache.hadoop.fs.permission; -import com.google.common.base.Objects; +import java.util.Collections; +import java.util.List; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; -import org.apache.hadoop.fs.Path; + +import com.google.common.base.Objects; +import com.google.common.collect.Lists; /** - * An AclStatus represents an association of a specific file {@link Path} with - * an {@link Acl}. AclStatus instances are immutable. Use a {@link Builder} to - * create a new instance. + * An AclStatus contains the ACL information of a specific file. AclStatus + * instances are immutable. Use a {@link Builder} to create a new instance. */ @InterfaceAudience.Public @InterfaceStability.Evolving public class AclStatus { - private final Path file; private final String owner; private final String group; - private final Acl acl; - - /** - * Returns the file associated to this ACL. - * - * @return Path file associated to this ACL - */ - public Path getFile() { - return file; - } + private final boolean stickyBit; + private final Iterable entries; /** * Returns the file owner. @@ -64,12 +57,21 @@ public String getGroup() { } /** - * Returns the ACL. - * - * @return Acl the ACL + * Returns the sticky bit. + * + * @return boolean sticky bit */ - public Acl getAcl() { - return acl; + public boolean isStickyBit() { + return stickyBit; + } + + /** + * Returns the list of all ACL entries, ordered by their natural ordering. + * + * @return Iterable unmodifiable ordered list of all ACL entries + */ + public Iterable getEntries() { + return entries; } @Override @@ -81,24 +83,26 @@ public boolean equals(Object o) { return false; } AclStatus other = (AclStatus)o; - return Objects.equal(file, other.file) && - Objects.equal(owner, other.owner) && - Objects.equal(group, other.group) && - Objects.equal(acl, other.acl); + return Objects.equal(owner, other.owner) + && Objects.equal(group, other.group) + && stickyBit == other.stickyBit + && Objects.equal(entries, other.entries); } @Override public int hashCode() { - return Objects.hashCode(file, owner, group, acl); + return Objects.hashCode(owner, group, stickyBit, entries); } @Override public String toString() { return new StringBuilder() - .append("file: ").append(file) - .append(", owner: ").append(owner) + .append("owner: ").append(owner) .append(", group: ").append(group) - .append(", acl: {").append(acl).append('}') + .append(", acl: {") + .append("entries: ").append(entries) + .append(", stickyBit: ").append(stickyBit) + .append('}') .toString(); } @@ -106,21 +110,10 @@ public String toString() { * Builder for creating new Acl instances. */ public static class Builder { - private Path file; private String owner; private String group; - private Acl acl; - - /** - * Sets the file associated to this ACL. - * - * @param file Path file associated to this ACL - * @return Builder this builder, for call chaining - */ - public Builder setFile(Path file) { - this.file = file; - return this; - } + private boolean stickyBit; + private List entries = Lists.newArrayList(); /** * Sets the file owner. @@ -128,7 +121,7 @@ public Builder setFile(Path file) { * @param owner String file owner * @return Builder this builder, for call chaining */ - public Builder setOwner(String owner) { + public Builder owner(String owner) { this.owner = owner; return this; } @@ -139,29 +132,54 @@ public Builder setOwner(String owner) { * @param group String file group * @return Builder this builder, for call chaining */ - public Builder setGroup(String group) { + public Builder group(String group) { this.group = group; return this; } /** - * Sets the ACL. + * Adds an ACL entry. * - * @param acl Acl the ACL + * @param e AclEntry entry to add * @return Builder this builder, for call chaining */ - public Builder setAcl(Acl acl) { - this.acl = acl; + public Builder addEntry(AclEntry e) { + this.entries.add(e); return this; } /** - * Builds a new Acl populated with the set properties. + * Adds a list of ACL entries. * - * @return Acl new Acl + * @param entries AclEntry entries to add + * @return Builder this builder, for call chaining + */ + public Builder addEntries(Iterable entries) { + for (AclEntry e : entries) + this.entries.add(e); + return this; + } + + /** + * Sets sticky bit. If this method is not called, then the builder assumes + * false. + * + * @param stickyBit + * boolean sticky bit + * @return Builder this builder, for call chaining + */ + public Builder stickyBit(boolean stickyBit) { + this.stickyBit = stickyBit; + return this; + } + + /** + * Builds a new AclStatus populated with the set properties. + * + * @return AclStatus new AclStatus */ public AclStatus build() { - return new AclStatus(file, owner, group, acl); + return new AclStatus(owner, group, stickyBit, entries); } } @@ -171,12 +189,16 @@ public AclStatus build() { * @param file Path file associated to this ACL * @param owner String file owner * @param group String file group - * @param acl Acl the ACL + * @param stickyBit the sticky bit + * @param entries the ACL entries */ - private AclStatus(Path file, String owner, String group, Acl acl) { - this.file = file; + private AclStatus(String owner, String group, boolean stickyBit, + Iterable entries) { this.owner = owner; this.group = group; - this.acl = acl; + this.stickyBit = stickyBit; + List entriesCopy = Lists.newArrayList(entries); + Collections.sort(entriesCopy); + this.entries = entriesCopy; } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/AclWriteFlag.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/AclWriteFlag.java deleted file mode 100644 index 2474103945..0000000000 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/AclWriteFlag.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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.permission; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; - -/** - * Flags that control behavior of operations for writing ACL information. - */ -@InterfaceAudience.Public -@InterfaceStability.Evolving -public enum AclWriteFlag { - /** - * Modify ACLs for all files and directories recursively in the sub-tree of - * the specified path. - */ - RECURSIVE -} diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java index 5131cbdcec..d628bb1a33 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.net.URI; import java.util.EnumSet; -import java.util.List; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; @@ -37,11 +36,8 @@ import org.apache.hadoop.fs.FsServerDefaults; import org.apache.hadoop.fs.FsStatus; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.fs.RemoteIterator; import org.apache.hadoop.fs.permission.AclEntry; -import org.apache.hadoop.fs.permission.AclReadFlag; import org.apache.hadoop.fs.permission.AclStatus; -import org.apache.hadoop.fs.permission.AclWriteFlag; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.util.Progressable; @@ -285,39 +281,35 @@ public void setTimes(final Path f, final long mtime, final long atime) } @Override - public void modifyAclEntries(Path path, List aclSpec, - EnumSet flags) throws IOException { - super.modifyAclEntries(fullPath(path), aclSpec, flags); + public void modifyAclEntries(Path path, Iterable aclSpec) throws IOException { + super.modifyAclEntries(fullPath(path), aclSpec); } @Override - public void removeAclEntries(Path path, List aclSpec, - EnumSet flags) throws IOException { - super.removeAclEntries(fullPath(path), aclSpec, flags); + public void removeAclEntries(Path path, Iterable aclSpec) throws IOException { + super.removeAclEntries(fullPath(path), aclSpec); } @Override - public void removeDefaultAcl(Path path, EnumSet flags) + public void removeDefaultAcl(Path path) throws IOException { - super.removeDefaultAcl(fullPath(path), flags); + super.removeDefaultAcl(fullPath(path)); } @Override - public void removeAcl(Path path, EnumSet flags) + public void removeAcl(Path path) throws IOException { - super.removeAcl(fullPath(path), flags); + super.removeAcl(fullPath(path)); } @Override - public void setAcl(Path path, List aclSpec, - EnumSet flags) throws IOException { - super.setAcl(fullPath(path), aclSpec, flags); + public void setAcl(Path path, Iterable aclSpec) throws IOException { + super.setAcl(fullPath(path), aclSpec); } @Override - public RemoteIterator listAclStatus(Path path, - EnumSet flags) throws IOException { - return super.listAclStatus(fullPath(path), flags); + public AclStatus getAclStatus(Path path) throws IOException { + return super.getAclStatus(fullPath(path)); } @Override diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java index 5b7f7dead9..861a7a3f91 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java @@ -28,7 +28,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.StringTokenizer; import java.util.Map.Entry; import org.apache.hadoop.classification.InterfaceAudience; @@ -45,14 +44,10 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FsConstants; import org.apache.hadoop.fs.FsServerDefaults; -import org.apache.hadoop.fs.InvalidPathException; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.fs.RemoteIterator; import org.apache.hadoop.fs.UnsupportedFileSystemException; import org.apache.hadoop.fs.permission.AclEntry; -import org.apache.hadoop.fs.permission.AclReadFlag; import org.apache.hadoop.fs.permission.AclStatus; -import org.apache.hadoop.fs.permission.AclWriteFlag; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.fs.viewfs.InodeTree.INode; import org.apache.hadoop.fs.viewfs.InodeTree.INodeLink; @@ -479,51 +474,47 @@ public void setTimes(final Path f, final long mtime, final long atime) } @Override - public void modifyAclEntries(Path path, List aclSpec, - EnumSet flags) throws IOException { + public void modifyAclEntries(Path path, Iterable aclSpec) throws IOException { InodeTree.ResolveResult res = fsState.resolve(getUriPath(path), true); - res.targetFileSystem.modifyAclEntries(res.remainingPath, aclSpec, flags); + res.targetFileSystem.modifyAclEntries(res.remainingPath, aclSpec); } @Override - public void removeAclEntries(Path path, List aclSpec, - EnumSet flags) throws IOException { + public void removeAclEntries(Path path, Iterable aclSpec) throws IOException { InodeTree.ResolveResult res = fsState.resolve(getUriPath(path), true); - res.targetFileSystem.removeAclEntries(res.remainingPath, aclSpec, flags); + res.targetFileSystem.removeAclEntries(res.remainingPath, aclSpec); } @Override - public void removeDefaultAcl(Path path, EnumSet flags) + public void removeDefaultAcl(Path path) throws IOException { InodeTree.ResolveResult res = fsState.resolve(getUriPath(path), true); - res.targetFileSystem.removeDefaultAcl(res.remainingPath, flags); + res.targetFileSystem.removeDefaultAcl(res.remainingPath); } @Override - public void removeAcl(Path path, EnumSet flags) + public void removeAcl(Path path) throws IOException { InodeTree.ResolveResult res = fsState.resolve(getUriPath(path), true); - res.targetFileSystem.removeAcl(res.remainingPath, flags); + res.targetFileSystem.removeAcl(res.remainingPath); } @Override - public void setAcl(Path path, List aclSpec, - EnumSet flags) throws IOException { + public void setAcl(Path path, Iterable aclSpec) throws IOException { InodeTree.ResolveResult res = fsState.resolve(getUriPath(path), true); - res.targetFileSystem.setAcl(res.remainingPath, aclSpec, flags); + res.targetFileSystem.setAcl(res.remainingPath, aclSpec); } @Override - public RemoteIterator listAclStatus(Path path, - EnumSet flags) throws IOException { + public AclStatus getAclStatus(Path path) throws IOException { InodeTree.ResolveResult res = fsState.resolve(getUriPath(path), true); - return res.targetFileSystem.listAclStatus(res.remainingPath, flags); + return res.targetFileSystem.getAclStatus(res.remainingPath); } @Override diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java index 11756064cb..63b4298f83 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java @@ -22,9 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.permission.AclEntry; -import org.apache.hadoop.fs.permission.AclReadFlag; import org.apache.hadoop.fs.permission.AclStatus; -import org.apache.hadoop.fs.permission.AclWriteFlag; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.security.Credentials; import org.apache.hadoop.security.token.Token; @@ -37,7 +35,6 @@ import java.lang.reflect.Modifier; import java.util.EnumSet; import java.util.Iterator; -import java.util.List; import static org.apache.hadoop.fs.Options.ChecksumOpt; import static org.apache.hadoop.fs.Options.CreateOpts; @@ -170,18 +167,12 @@ public void renameSnapshot(Path path, String snapshotOldName, String snapshotNewName) throws IOException; public void deleteSnapshot(Path path, String snapshotName) throws IOException; - public void modifyAclEntries(Path path, List aclSpec, - EnumSet flags) throws IOException; - public void removeAclEntries(Path path, List aclSpec, - EnumSet flags) throws IOException; - public void removeDefaultAcl(Path path, EnumSet flags) - throws IOException; - public void removeAcl(Path path, EnumSet flags) - throws IOException; - public void setAcl(Path path, List aclSpec, - EnumSet flags) throws IOException; - public RemoteIterator listAclStatus(Path path, - EnumSet flags) throws IOException; + public void modifyAclEntries(Path path, Iterable aclSpec) throws IOException; + public void removeAclEntries(Path path, Iterable aclSpec) throws IOException; + public void removeDefaultAcl(Path path) throws IOException; + public void removeAcl(Path path) throws IOException; + public void setAcl(Path path, Iterable aclSpec) throws IOException; + public AclStatus getAclStatus(Path path) throws IOException; } @Test diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestAcl.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestAcl.java index 035322ef3d..94db270f98 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestAcl.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestAcl.java @@ -21,20 +21,21 @@ import java.util.List; +import org.junit.BeforeClass; import org.junit.Test; -import org.apache.hadoop.fs.Path; +import com.google.common.collect.Lists; /** * Tests covering basic functionality of the ACL objects. */ public class TestAcl { - private static final Acl ACL1, ACL2, ACL3, ACL4; - private static final AclEntry ENTRY1, ENTRY2, ENTRY3, ENTRY4, ENTRY5, ENTRY6, + private static AclEntry ENTRY1, ENTRY2, ENTRY3, ENTRY4, ENTRY5, ENTRY6, ENTRY7, ENTRY8, ENTRY9, ENTRY10, ENTRY11, ENTRY12, ENTRY13; - private static final AclStatus STATUS1, STATUS2, STATUS3; + private static AclStatus STATUS1, STATUS2, STATUS3, STATUS4; - static { + @BeforeClass + public static void setUp() { // named user AclEntry.Builder aclEntryBuilder = new AclEntry.Builder() .setType(AclEntryType.USER) @@ -107,31 +108,21 @@ public class TestAcl { .setScope(AclEntryScope.DEFAULT) .build(); - Acl.Builder aclBuilder = new Acl.Builder() + AclStatus.Builder aclStatusBuilder = new AclStatus.Builder() + .owner("owner1") + .group("group1") .addEntry(ENTRY1) .addEntry(ENTRY3) .addEntry(ENTRY4); - ACL1 = aclBuilder.build(); - ACL2 = aclBuilder.build(); - ACL3 = new Acl.Builder() - .setStickyBit(true) - .build(); - - AclStatus.Builder aclStatusBuilder = new AclStatus.Builder() - .setFile(new Path("file1")) - .setOwner("owner1") - .setGroup("group1") - .setAcl(ACL1); STATUS1 = aclStatusBuilder.build(); STATUS2 = aclStatusBuilder.build(); STATUS3 = new AclStatus.Builder() - .setFile(new Path("file2")) - .setOwner("owner2") - .setGroup("group2") - .setAcl(ACL3) + .owner("owner2") + .group("group2") + .stickyBit(true) .build(); - ACL4 = new Acl.Builder() + STATUS4 = new AclStatus.Builder() .addEntry(ENTRY1) .addEntry(ENTRY3) .addEntry(ENTRY4) @@ -147,39 +138,6 @@ public class TestAcl { .build(); } - @Test - public void testAclEquals() { - assertNotSame(ACL1, ACL2); - assertNotSame(ACL1, ACL3); - assertNotSame(ACL2, ACL3); - assertEquals(ACL1, ACL1); - assertEquals(ACL2, ACL2); - assertEquals(ACL1, ACL2); - assertEquals(ACL2, ACL1); - assertFalse(ACL1.equals(ACL3)); - assertFalse(ACL2.equals(ACL3)); - assertFalse(ACL1.equals(null)); - assertFalse(ACL1.equals(new Object())); - } - - @Test - public void testAclHashCode() { - assertEquals(ACL1.hashCode(), ACL2.hashCode()); - assertFalse(ACL1.hashCode() == ACL3.hashCode()); - } - - @Test - public void testAclEntriesImmutable() { - AclEntry entry = new AclEntry.Builder().build(); - List entries = ACL1.getEntries(); - try { - entries.add(entry); - fail("expected adding ACL entry to fail"); - } catch (UnsupportedOperationException e) { - // expected - } - } - @Test public void testEntryEquals() { assertNotSame(ENTRY1, ENTRY2); @@ -223,7 +181,7 @@ public void testEntryNaturalOrdering() { ENTRY10, // default mask ENTRY4 // default other }; - List actual = ACL4.getEntries(); + List actual = Lists.newArrayList(STATUS4.getEntries()); assertNotNull(actual); assertEquals(expected.length, actual.size()); for (int i = 0; i < expected.length; ++i) { @@ -267,25 +225,19 @@ public void testStatusHashCode() { @Test public void testToString() { - assertEquals( - "entries: [user:user1:rwx, group:group2:rw-, default:other::---], stickyBit: false", - ACL1.toString()); - assertEquals( - "entries: [user:user1:rwx, group:group2:rw-, default:other::---], stickyBit: false", - ACL2.toString()); - assertEquals("entries: [], stickyBit: true", ACL3.toString()); assertEquals("user:user1:rwx", ENTRY1.toString()); assertEquals("user:user1:rwx", ENTRY2.toString()); assertEquals("group:group2:rw-", ENTRY3.toString()); assertEquals("default:other::---", ENTRY4.toString()); + assertEquals( - "file: file1, owner: owner1, group: group1, acl: {entries: [user:user1:rwx, group:group2:rw-, default:other::---], stickyBit: false}", + "owner: owner1, group: group1, acl: {entries: [user:user1:rwx, group:group2:rw-, default:other::---], stickyBit: false}", STATUS1.toString()); assertEquals( - "file: file1, owner: owner1, group: group1, acl: {entries: [user:user1:rwx, group:group2:rw-, default:other::---], stickyBit: false}", + "owner: owner1, group: group1, acl: {entries: [user:user1:rwx, group:group2:rw-, default:other::---], stickyBit: false}", STATUS2.toString()); assertEquals( - "file: file2, owner: owner2, group: group2, acl: {entries: [], stickyBit: true}", + "owner: owner2, group: group2, acl: {entries: [], stickyBit: true}", STATUS3.toString()); } } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java index e3b1b8b37d..e8d4656858 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.net.URI; import java.util.Collections; -import java.util.EnumSet; import java.util.List; import org.apache.hadoop.conf.Configuration; @@ -33,8 +32,6 @@ import org.apache.hadoop.fs.FsConstants; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.permission.AclEntry; -import org.apache.hadoop.fs.permission.AclReadFlag; -import org.apache.hadoop.fs.permission.AclWriteFlag; import org.apache.hadoop.fs.viewfs.ChRootedFileSystem; import org.junit.After; import org.junit.Assert; @@ -378,26 +375,24 @@ public void testAclMethodsPathTranslation() throws IOException { Path chrootPath = new Path("/c"); Path rawPath = new Path("/a/b/c"); List entries = Collections.emptyList(); - EnumSet writeFlags = EnumSet.noneOf(AclWriteFlag.class); - EnumSet readFlags = EnumSet.noneOf(AclReadFlag.class); - chrootFs.modifyAclEntries(chrootPath, entries, writeFlags); - verify(mockFs).modifyAclEntries(rawPath, entries, writeFlags); + chrootFs.modifyAclEntries(chrootPath, entries); + verify(mockFs).modifyAclEntries(rawPath, entries); - chrootFs.removeAclEntries(chrootPath, entries, writeFlags); - verify(mockFs).removeAclEntries(rawPath, entries, writeFlags); + chrootFs.removeAclEntries(chrootPath, entries); + verify(mockFs).removeAclEntries(rawPath, entries); - chrootFs.removeDefaultAcl(chrootPath, writeFlags); - verify(mockFs).removeDefaultAcl(rawPath, writeFlags); + chrootFs.removeDefaultAcl(chrootPath); + verify(mockFs).removeDefaultAcl(rawPath); - chrootFs.removeAcl(chrootPath, writeFlags); - verify(mockFs).removeAcl(rawPath, writeFlags); + chrootFs.removeAcl(chrootPath); + verify(mockFs).removeAcl(rawPath); - chrootFs.setAcl(chrootPath, entries, writeFlags); - verify(mockFs).setAcl(rawPath, entries, writeFlags); + chrootFs.setAcl(chrootPath, entries); + verify(mockFs).setAcl(rawPath, entries); - chrootFs.listAclStatus(chrootPath, readFlags); - verify(mockFs).listAclStatus(rawPath, readFlags); + chrootFs.getAclStatus(chrootPath); + verify(mockFs).getAclStatus(rawPath); } static class MockFileSystem extends FilterFileSystem { diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java index 69477b97a9..cb1f413bda 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.net.URI; import java.util.Collections; -import java.util.EnumSet; import java.util.List; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; @@ -30,8 +29,6 @@ import org.apache.hadoop.fs.LocalFileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.permission.AclEntry; -import org.apache.hadoop.fs.permission.AclReadFlag; -import org.apache.hadoop.fs.permission.AclWriteFlag; import org.apache.hadoop.fs.viewfs.TestChRootedFileSystem.MockFileSystem; import org.junit.*; import static org.junit.Assert.*; @@ -103,38 +100,36 @@ public void testAclMethods() throws Exception { Path viewFsPath2 = new Path("/mounts/mockfs2/d/e/f"); Path mockFsPath2 = new Path("/d/e/f"); List entries = Collections.emptyList(); - EnumSet writeFlags = EnumSet.noneOf(AclWriteFlag.class); - EnumSet readFlags = EnumSet.noneOf(AclReadFlag.class); - viewFs.modifyAclEntries(viewFsPath1, entries, writeFlags); - verify(mockFs1).modifyAclEntries(mockFsPath1, entries, writeFlags); - viewFs.modifyAclEntries(viewFsPath2, entries, writeFlags); - verify(mockFs2).modifyAclEntries(mockFsPath2, entries, writeFlags); + viewFs.modifyAclEntries(viewFsPath1, entries); + verify(mockFs1).modifyAclEntries(mockFsPath1, entries); + viewFs.modifyAclEntries(viewFsPath2, entries); + verify(mockFs2).modifyAclEntries(mockFsPath2, entries); - viewFs.removeAclEntries(viewFsPath1, entries, writeFlags); - verify(mockFs1).removeAclEntries(mockFsPath1, entries, writeFlags); - viewFs.removeAclEntries(viewFsPath2, entries, writeFlags); - verify(mockFs2).removeAclEntries(mockFsPath2, entries, writeFlags); + viewFs.removeAclEntries(viewFsPath1, entries); + verify(mockFs1).removeAclEntries(mockFsPath1, entries); + viewFs.removeAclEntries(viewFsPath2, entries); + verify(mockFs2).removeAclEntries(mockFsPath2, entries); - viewFs.removeDefaultAcl(viewFsPath1, writeFlags); - verify(mockFs1).removeDefaultAcl(mockFsPath1, writeFlags); - viewFs.removeDefaultAcl(viewFsPath2, writeFlags); - verify(mockFs2).removeDefaultAcl(mockFsPath2, writeFlags); + viewFs.removeDefaultAcl(viewFsPath1); + verify(mockFs1).removeDefaultAcl(mockFsPath1); + viewFs.removeDefaultAcl(viewFsPath2); + verify(mockFs2).removeDefaultAcl(mockFsPath2); - viewFs.removeAcl(viewFsPath1, writeFlags); - verify(mockFs1).removeAcl(mockFsPath1, writeFlags); - viewFs.removeAcl(viewFsPath2, writeFlags); - verify(mockFs2).removeAcl(mockFsPath2, writeFlags); + viewFs.removeAcl(viewFsPath1); + verify(mockFs1).removeAcl(mockFsPath1); + viewFs.removeAcl(viewFsPath2); + verify(mockFs2).removeAcl(mockFsPath2); - viewFs.setAcl(viewFsPath1, entries, writeFlags); - verify(mockFs1).setAcl(mockFsPath1, entries, writeFlags); - viewFs.setAcl(viewFsPath2, entries, writeFlags); - verify(mockFs2).setAcl(mockFsPath2, entries, writeFlags); + viewFs.setAcl(viewFsPath1, entries); + verify(mockFs1).setAcl(mockFsPath1, entries); + viewFs.setAcl(viewFsPath2, entries); + verify(mockFs2).setAcl(mockFsPath2, entries); - viewFs.listAclStatus(viewFsPath1, readFlags); - verify(mockFs1).listAclStatus(mockFsPath1, readFlags); - viewFs.listAclStatus(viewFsPath2, readFlags); - verify(mockFs2).listAclStatus(mockFsPath2, readFlags); + viewFs.getAclStatus(viewFsPath1); + verify(mockFs1).getAclStatus(mockFsPath1); + viewFs.getAclStatus(viewFsPath2); + verify(mockFs2).getAclStatus(mockFsPath2); } void checkVerifyChecksum(boolean flag) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4685.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4685.txt index 8b04e7b368..fce9e3eb47 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4685.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4685.txt @@ -9,6 +9,9 @@ HDFS-4685 (Unreleased) IMPROVEMENTS HDFS-5594. FileSystem API for ACLs. (cnauroth) + HDFS-5650. Remove AclReadFlag and AclWriteFlag in FileSystem API. + (Haohui Mai via cnauroth) + OPTIMIZATIONS BUG FIXES