HDFS-5650. Remove AclReadFlag and AclWriteFlag in FileSystem API. Contributed by Haohui Mai.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-4685@1550256 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b4d8aabe6b
commit
709040c52e
|
@ -49,9 +49,7 @@ import org.apache.hadoop.conf.Configured;
|
||||||
import org.apache.hadoop.fs.Options.ChecksumOpt;
|
import org.apache.hadoop.fs.Options.ChecksumOpt;
|
||||||
import org.apache.hadoop.fs.Options.Rename;
|
import org.apache.hadoop.fs.Options.Rename;
|
||||||
import org.apache.hadoop.fs.permission.AclEntry;
|
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.AclStatus;
|
||||||
import org.apache.hadoop.fs.permission.AclWriteFlag;
|
|
||||||
import org.apache.hadoop.fs.permission.FsPermission;
|
import org.apache.hadoop.fs.permission.FsPermission;
|
||||||
import org.apache.hadoop.io.MultipleIOException;
|
import org.apache.hadoop.io.MultipleIOException;
|
||||||
import org.apache.hadoop.io.Text;
|
import org.apache.hadoop.io.Text;
|
||||||
|
@ -2278,11 +2276,9 @@ public abstract class FileSystem extends Configured implements Closeable {
|
||||||
*
|
*
|
||||||
* @param path Path to modify
|
* @param path Path to modify
|
||||||
* @param aclSpec List<AclEntry> describing modifications
|
* @param aclSpec List<AclEntry> describing modifications
|
||||||
* @param flags EnumSet<AclWriteFlag> containing flags (such as recursive)
|
|
||||||
* @throws IOException if an ACL could not be modified
|
* @throws IOException if an ACL could not be modified
|
||||||
*/
|
*/
|
||||||
public void modifyAclEntries(Path path, List<AclEntry> aclSpec,
|
public void modifyAclEntries(Path path, Iterable<AclEntry> aclSpec) throws IOException {
|
||||||
EnumSet<AclWriteFlag> flags) throws IOException {
|
|
||||||
throw new UnsupportedOperationException(getClass().getSimpleName()
|
throw new UnsupportedOperationException(getClass().getSimpleName()
|
||||||
+ " doesn't support modifyAclEntries");
|
+ " doesn't support modifyAclEntries");
|
||||||
}
|
}
|
||||||
|
@ -2293,11 +2289,9 @@ public abstract class FileSystem extends Configured implements Closeable {
|
||||||
*
|
*
|
||||||
* @param path Path to modify
|
* @param path Path to modify
|
||||||
* @param aclSpec List<AclEntry> describing entries to remove
|
* @param aclSpec List<AclEntry> describing entries to remove
|
||||||
* @param flags EnumSet<AclWriteFlag> containing flags (such as recursive)
|
|
||||||
* @throws IOException if an ACL could not be modified
|
* @throws IOException if an ACL could not be modified
|
||||||
*/
|
*/
|
||||||
public void removeAclEntries(Path path, List<AclEntry> aclSpec,
|
public void removeAclEntries(Path path, Iterable<AclEntry> aclSpec) throws IOException {
|
||||||
EnumSet<AclWriteFlag> flags) throws IOException {
|
|
||||||
throw new UnsupportedOperationException(getClass().getSimpleName()
|
throw new UnsupportedOperationException(getClass().getSimpleName()
|
||||||
+ " doesn't support removeAclEntries");
|
+ " doesn't support removeAclEntries");
|
||||||
}
|
}
|
||||||
|
@ -2306,10 +2300,9 @@ public abstract class FileSystem extends Configured implements Closeable {
|
||||||
* Removes all default ACL entries from files and directories.
|
* Removes all default ACL entries from files and directories.
|
||||||
*
|
*
|
||||||
* @param path Path to modify
|
* @param path Path to modify
|
||||||
* @param flags EnumSet<AclWriteFlag> containing flags (such as recursive)
|
|
||||||
* @throws IOException if an ACL could not be modified
|
* @throws IOException if an ACL could not be modified
|
||||||
*/
|
*/
|
||||||
public void removeDefaultAcl(Path path, EnumSet<AclWriteFlag> flags)
|
public void removeDefaultAcl(Path path)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
throw new UnsupportedOperationException(getClass().getSimpleName()
|
throw new UnsupportedOperationException(getClass().getSimpleName()
|
||||||
+ " doesn't support removeDefaultAcl");
|
+ " doesn't support removeDefaultAcl");
|
||||||
|
@ -2321,10 +2314,9 @@ public abstract class FileSystem extends Configured implements Closeable {
|
||||||
* bits.
|
* bits.
|
||||||
*
|
*
|
||||||
* @param path Path to modify
|
* @param path Path to modify
|
||||||
* @param flags EnumSet<AclWriteFlag> containing flags (such as recursive)
|
|
||||||
* @throws IOException if an ACL could not be removed
|
* @throws IOException if an ACL could not be removed
|
||||||
*/
|
*/
|
||||||
public void removeAcl(Path path, EnumSet<AclWriteFlag> flags)
|
public void removeAcl(Path path)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
throw new UnsupportedOperationException(getClass().getSimpleName()
|
throw new UnsupportedOperationException(getClass().getSimpleName()
|
||||||
+ " doesn't support removeAcl");
|
+ " doesn't support removeAcl");
|
||||||
|
@ -2337,11 +2329,9 @@ public abstract class FileSystem extends Configured implements Closeable {
|
||||||
* @param path Path to modify
|
* @param path Path to modify
|
||||||
* @param aclSpec List<AclEntry> describing modifications, must include entries
|
* @param aclSpec List<AclEntry> describing modifications, must include entries
|
||||||
* for user, group, and others for compatibility with permission bits.
|
* for user, group, and others for compatibility with permission bits.
|
||||||
* @param flags EnumSet<AclWriteFlag> containing flags (such as recursive)
|
|
||||||
* @throws IOException if an ACL could not be modified
|
* @throws IOException if an ACL could not be modified
|
||||||
*/
|
*/
|
||||||
public void setAcl(Path path, List<AclEntry> aclSpec,
|
public void setAcl(Path path, Iterable<AclEntry> aclSpec) throws IOException {
|
||||||
EnumSet<AclWriteFlag> flags) throws IOException {
|
|
||||||
throw new UnsupportedOperationException(getClass().getSimpleName()
|
throw new UnsupportedOperationException(getClass().getSimpleName()
|
||||||
+ " doesn't support setAcl");
|
+ " doesn't support setAcl");
|
||||||
}
|
}
|
||||||
|
@ -2350,14 +2340,12 @@ public abstract class FileSystem extends Configured implements Closeable {
|
||||||
* Gets the ACLs of files and directories.
|
* Gets the ACLs of files and directories.
|
||||||
*
|
*
|
||||||
* @param path Path to get
|
* @param path Path to get
|
||||||
* @param flags EnumSet<AclReadFlag> containing flags (such as recursive)
|
|
||||||
* @return RemoteIterator<AclStatus> which returns each AclStatus
|
* @return RemoteIterator<AclStatus> which returns each AclStatus
|
||||||
* @throws IOException if an ACL could not be read
|
* @throws IOException if an ACL could not be read
|
||||||
*/
|
*/
|
||||||
public RemoteIterator<AclStatus> listAclStatus(Path path,
|
public AclStatus getAclStatus(Path path) throws IOException {
|
||||||
EnumSet<AclReadFlag> flags) throws IOException {
|
|
||||||
throw new UnsupportedOperationException(getClass().getSimpleName()
|
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
|
// making it volatile to be able to do a double checked locking
|
||||||
|
|
|
@ -22,14 +22,12 @@ import java.io.*;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.permission.AclEntry;
|
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.AclStatus;
|
||||||
import org.apache.hadoop.fs.permission.AclWriteFlag;
|
|
||||||
import org.apache.hadoop.fs.permission.FsPermission;
|
import org.apache.hadoop.fs.permission.FsPermission;
|
||||||
import org.apache.hadoop.fs.ContentSummary;
|
import org.apache.hadoop.fs.ContentSummary;
|
||||||
import org.apache.hadoop.fs.Options.ChecksumOpt;
|
import org.apache.hadoop.fs.Options.ChecksumOpt;
|
||||||
|
@ -514,38 +512,34 @@ public class FilterFileSystem extends FileSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyAclEntries(Path path, List<AclEntry> aclSpec,
|
public void modifyAclEntries(Path path, Iterable<AclEntry> aclSpec) throws IOException {
|
||||||
EnumSet<AclWriteFlag> flags) throws IOException {
|
fs.modifyAclEntries(path, aclSpec);
|
||||||
fs.modifyAclEntries(path, aclSpec, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeAclEntries(Path path, List<AclEntry> aclSpec,
|
public void removeAclEntries(Path path, Iterable<AclEntry> aclSpec) throws IOException {
|
||||||
EnumSet<AclWriteFlag> flags) throws IOException {
|
fs.removeAclEntries(path, aclSpec);
|
||||||
fs.removeAclEntries(path, aclSpec, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeDefaultAcl(Path path, EnumSet<AclWriteFlag> flags)
|
public void removeDefaultAcl(Path path)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
fs.removeDefaultAcl(path, flags);
|
fs.removeDefaultAcl(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeAcl(Path path, EnumSet<AclWriteFlag> flags)
|
public void removeAcl(Path path)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
fs.removeAcl(path, flags);
|
fs.removeAcl(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAcl(Path path, List<AclEntry> aclSpec,
|
public void setAcl(Path path, Iterable<AclEntry> aclSpec) throws IOException {
|
||||||
EnumSet<AclWriteFlag> flags) throws IOException {
|
fs.setAcl(path, aclSpec);
|
||||||
fs.setAcl(path, aclSpec, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RemoteIterator<AclStatus> listAclStatus(Path path,
|
public AclStatus getAclStatus(Path path) throws IOException {
|
||||||
EnumSet<AclReadFlag> flags) throws IOException {
|
return fs.getAclStatus(path);
|
||||||
return fs.listAclStatus(path, flags);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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<AclEntry> 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<AclEntry> unmodifiable ordered list of all ACL entries
|
|
||||||
*/
|
|
||||||
public List<AclEntry> 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<AclEntry> entries = new ArrayList<AclEntry>();
|
|
||||||
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<AclEntry> list of all ACL entries
|
|
||||||
* @param boolean sticky bit
|
|
||||||
*/
|
|
||||||
private Acl(List<AclEntry> entries, boolean stickyBit) {
|
|
||||||
List<AclEntry> entriesCopy = new ArrayList<AclEntry>(entries);
|
|
||||||
Collections.sort(entriesCopy);
|
|
||||||
this.entries = Collections.unmodifiableList(entriesCopy);
|
|
||||||
this.stickyBit = stickyBit;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -17,33 +17,26 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.fs.permission;
|
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.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
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 AclStatus contains the ACL information of a specific file. AclStatus
|
||||||
* an {@link Acl}. AclStatus instances are immutable. Use a {@link Builder} to
|
* instances are immutable. Use a {@link Builder} to create a new instance.
|
||||||
* create a new instance.
|
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Evolving
|
@InterfaceStability.Evolving
|
||||||
public class AclStatus {
|
public class AclStatus {
|
||||||
private final Path file;
|
|
||||||
private final String owner;
|
private final String owner;
|
||||||
private final String group;
|
private final String group;
|
||||||
private final Acl acl;
|
private final boolean stickyBit;
|
||||||
|
private final Iterable<AclEntry> entries;
|
||||||
/**
|
|
||||||
* Returns the file associated to this ACL.
|
|
||||||
*
|
|
||||||
* @return Path file associated to this ACL
|
|
||||||
*/
|
|
||||||
public Path getFile() {
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the file owner.
|
* Returns the file owner.
|
||||||
|
@ -64,12 +57,21 @@ public class AclStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ACL.
|
* Returns the sticky bit.
|
||||||
*
|
*
|
||||||
* @return Acl the ACL
|
* @return boolean sticky bit
|
||||||
*/
|
*/
|
||||||
public Acl getAcl() {
|
public boolean isStickyBit() {
|
||||||
return acl;
|
return stickyBit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the list of all ACL entries, ordered by their natural ordering.
|
||||||
|
*
|
||||||
|
* @return Iterable<AclEntry> unmodifiable ordered list of all ACL entries
|
||||||
|
*/
|
||||||
|
public Iterable<AclEntry> getEntries() {
|
||||||
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,24 +83,26 @@ public class AclStatus {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
AclStatus other = (AclStatus)o;
|
AclStatus other = (AclStatus)o;
|
||||||
return Objects.equal(file, other.file) &&
|
return Objects.equal(owner, other.owner)
|
||||||
Objects.equal(owner, other.owner) &&
|
&& Objects.equal(group, other.group)
|
||||||
Objects.equal(group, other.group) &&
|
&& stickyBit == other.stickyBit
|
||||||
Objects.equal(acl, other.acl);
|
&& Objects.equal(entries, other.entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(file, owner, group, acl);
|
return Objects.hashCode(owner, group, stickyBit, entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new StringBuilder()
|
return new StringBuilder()
|
||||||
.append("file: ").append(file)
|
.append("owner: ").append(owner)
|
||||||
.append(", owner: ").append(owner)
|
|
||||||
.append(", group: ").append(group)
|
.append(", group: ").append(group)
|
||||||
.append(", acl: {").append(acl).append('}')
|
.append(", acl: {")
|
||||||
|
.append("entries: ").append(entries)
|
||||||
|
.append(", stickyBit: ").append(stickyBit)
|
||||||
|
.append('}')
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,21 +110,10 @@ public class AclStatus {
|
||||||
* Builder for creating new Acl instances.
|
* Builder for creating new Acl instances.
|
||||||
*/
|
*/
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private Path file;
|
|
||||||
private String owner;
|
private String owner;
|
||||||
private String group;
|
private String group;
|
||||||
private Acl acl;
|
private boolean stickyBit;
|
||||||
|
private List<AclEntry> entries = Lists.newArrayList();
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the file owner.
|
* Sets the file owner.
|
||||||
|
@ -128,7 +121,7 @@ public class AclStatus {
|
||||||
* @param owner String file owner
|
* @param owner String file owner
|
||||||
* @return Builder this builder, for call chaining
|
* @return Builder this builder, for call chaining
|
||||||
*/
|
*/
|
||||||
public Builder setOwner(String owner) {
|
public Builder owner(String owner) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -139,29 +132,54 @@ public class AclStatus {
|
||||||
* @param group String file group
|
* @param group String file group
|
||||||
* @return Builder this builder, for call chaining
|
* @return Builder this builder, for call chaining
|
||||||
*/
|
*/
|
||||||
public Builder setGroup(String group) {
|
public Builder group(String group) {
|
||||||
this.group = group;
|
this.group = group;
|
||||||
return this;
|
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
|
* @return Builder this builder, for call chaining
|
||||||
*/
|
*/
|
||||||
public Builder setAcl(Acl acl) {
|
public Builder addEntry(AclEntry e) {
|
||||||
this.acl = acl;
|
this.entries.add(e);
|
||||||
return this;
|
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<AclEntry> 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() {
|
public AclStatus build() {
|
||||||
return new AclStatus(file, owner, group, acl);
|
return new AclStatus(owner, group, stickyBit, entries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,12 +189,16 @@ public class AclStatus {
|
||||||
* @param file Path file associated to this ACL
|
* @param file Path file associated to this ACL
|
||||||
* @param owner String file owner
|
* @param owner String file owner
|
||||||
* @param group String file group
|
* @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) {
|
private AclStatus(String owner, String group, boolean stickyBit,
|
||||||
this.file = file;
|
Iterable<AclEntry> entries) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.group = group;
|
this.group = group;
|
||||||
this.acl = acl;
|
this.stickyBit = stickyBit;
|
||||||
|
List<AclEntry> entriesCopy = Lists.newArrayList(entries);
|
||||||
|
Collections.sort(entriesCopy);
|
||||||
|
this.entries = entriesCopy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -20,7 +20,6 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
|
@ -37,11 +36,8 @@ import org.apache.hadoop.fs.FilterFileSystem;
|
||||||
import org.apache.hadoop.fs.FsServerDefaults;
|
import org.apache.hadoop.fs.FsServerDefaults;
|
||||||
import org.apache.hadoop.fs.FsStatus;
|
import org.apache.hadoop.fs.FsStatus;
|
||||||
import org.apache.hadoop.fs.Path;
|
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.AclEntry;
|
||||||
import org.apache.hadoop.fs.permission.AclReadFlag;
|
|
||||||
import org.apache.hadoop.fs.permission.AclStatus;
|
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.permission.FsPermission;
|
||||||
import org.apache.hadoop.util.Progressable;
|
import org.apache.hadoop.util.Progressable;
|
||||||
|
|
||||||
|
@ -285,39 +281,35 @@ class ChRootedFileSystem extends FilterFileSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyAclEntries(Path path, List<AclEntry> aclSpec,
|
public void modifyAclEntries(Path path, Iterable<AclEntry> aclSpec) throws IOException {
|
||||||
EnumSet<AclWriteFlag> flags) throws IOException {
|
super.modifyAclEntries(fullPath(path), aclSpec);
|
||||||
super.modifyAclEntries(fullPath(path), aclSpec, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeAclEntries(Path path, List<AclEntry> aclSpec,
|
public void removeAclEntries(Path path, Iterable<AclEntry> aclSpec) throws IOException {
|
||||||
EnumSet<AclWriteFlag> flags) throws IOException {
|
super.removeAclEntries(fullPath(path), aclSpec);
|
||||||
super.removeAclEntries(fullPath(path), aclSpec, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeDefaultAcl(Path path, EnumSet<AclWriteFlag> flags)
|
public void removeDefaultAcl(Path path)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
super.removeDefaultAcl(fullPath(path), flags);
|
super.removeDefaultAcl(fullPath(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeAcl(Path path, EnumSet<AclWriteFlag> flags)
|
public void removeAcl(Path path)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
super.removeAcl(fullPath(path), flags);
|
super.removeAcl(fullPath(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAcl(Path path, List<AclEntry> aclSpec,
|
public void setAcl(Path path, Iterable<AclEntry> aclSpec) throws IOException {
|
||||||
EnumSet<AclWriteFlag> flags) throws IOException {
|
super.setAcl(fullPath(path), aclSpec);
|
||||||
super.setAcl(fullPath(path), aclSpec, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RemoteIterator<AclStatus> listAclStatus(Path path,
|
public AclStatus getAclStatus(Path path) throws IOException {
|
||||||
EnumSet<AclReadFlag> flags) throws IOException {
|
return super.getAclStatus(fullPath(path));
|
||||||
return super.listAclStatus(fullPath(path), flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,6 @@ import java.util.EnumSet;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.StringTokenizer;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
|
@ -45,14 +44,10 @@ import org.apache.hadoop.fs.FileStatus;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
import org.apache.hadoop.fs.FsConstants;
|
import org.apache.hadoop.fs.FsConstants;
|
||||||
import org.apache.hadoop.fs.FsServerDefaults;
|
import org.apache.hadoop.fs.FsServerDefaults;
|
||||||
import org.apache.hadoop.fs.InvalidPathException;
|
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.fs.RemoteIterator;
|
|
||||||
import org.apache.hadoop.fs.UnsupportedFileSystemException;
|
import org.apache.hadoop.fs.UnsupportedFileSystemException;
|
||||||
import org.apache.hadoop.fs.permission.AclEntry;
|
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.AclStatus;
|
||||||
import org.apache.hadoop.fs.permission.AclWriteFlag;
|
|
||||||
import org.apache.hadoop.fs.permission.FsPermission;
|
import org.apache.hadoop.fs.permission.FsPermission;
|
||||||
import org.apache.hadoop.fs.viewfs.InodeTree.INode;
|
import org.apache.hadoop.fs.viewfs.InodeTree.INode;
|
||||||
import org.apache.hadoop.fs.viewfs.InodeTree.INodeLink;
|
import org.apache.hadoop.fs.viewfs.InodeTree.INodeLink;
|
||||||
|
@ -479,51 +474,47 @@ public class ViewFileSystem extends FileSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyAclEntries(Path path, List<AclEntry> aclSpec,
|
public void modifyAclEntries(Path path, Iterable<AclEntry> aclSpec) throws IOException {
|
||||||
EnumSet<AclWriteFlag> flags) throws IOException {
|
|
||||||
InodeTree.ResolveResult<FileSystem> res =
|
InodeTree.ResolveResult<FileSystem> res =
|
||||||
fsState.resolve(getUriPath(path), true);
|
fsState.resolve(getUriPath(path), true);
|
||||||
res.targetFileSystem.modifyAclEntries(res.remainingPath, aclSpec, flags);
|
res.targetFileSystem.modifyAclEntries(res.remainingPath, aclSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeAclEntries(Path path, List<AclEntry> aclSpec,
|
public void removeAclEntries(Path path, Iterable<AclEntry> aclSpec) throws IOException {
|
||||||
EnumSet<AclWriteFlag> flags) throws IOException {
|
|
||||||
InodeTree.ResolveResult<FileSystem> res =
|
InodeTree.ResolveResult<FileSystem> res =
|
||||||
fsState.resolve(getUriPath(path), true);
|
fsState.resolve(getUriPath(path), true);
|
||||||
res.targetFileSystem.removeAclEntries(res.remainingPath, aclSpec, flags);
|
res.targetFileSystem.removeAclEntries(res.remainingPath, aclSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeDefaultAcl(Path path, EnumSet<AclWriteFlag> flags)
|
public void removeDefaultAcl(Path path)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
InodeTree.ResolveResult<FileSystem> res =
|
InodeTree.ResolveResult<FileSystem> res =
|
||||||
fsState.resolve(getUriPath(path), true);
|
fsState.resolve(getUriPath(path), true);
|
||||||
res.targetFileSystem.removeDefaultAcl(res.remainingPath, flags);
|
res.targetFileSystem.removeDefaultAcl(res.remainingPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeAcl(Path path, EnumSet<AclWriteFlag> flags)
|
public void removeAcl(Path path)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
InodeTree.ResolveResult<FileSystem> res =
|
InodeTree.ResolveResult<FileSystem> res =
|
||||||
fsState.resolve(getUriPath(path), true);
|
fsState.resolve(getUriPath(path), true);
|
||||||
res.targetFileSystem.removeAcl(res.remainingPath, flags);
|
res.targetFileSystem.removeAcl(res.remainingPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAcl(Path path, List<AclEntry> aclSpec,
|
public void setAcl(Path path, Iterable<AclEntry> aclSpec) throws IOException {
|
||||||
EnumSet<AclWriteFlag> flags) throws IOException {
|
|
||||||
InodeTree.ResolveResult<FileSystem> res =
|
InodeTree.ResolveResult<FileSystem> res =
|
||||||
fsState.resolve(getUriPath(path), true);
|
fsState.resolve(getUriPath(path), true);
|
||||||
res.targetFileSystem.setAcl(res.remainingPath, aclSpec, flags);
|
res.targetFileSystem.setAcl(res.remainingPath, aclSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RemoteIterator<AclStatus> listAclStatus(Path path,
|
public AclStatus getAclStatus(Path path) throws IOException {
|
||||||
EnumSet<AclReadFlag> flags) throws IOException {
|
|
||||||
InodeTree.ResolveResult<FileSystem> res =
|
InodeTree.ResolveResult<FileSystem> res =
|
||||||
fsState.resolve(getUriPath(path), true);
|
fsState.resolve(getUriPath(path), true);
|
||||||
return res.targetFileSystem.listAclStatus(res.remainingPath, flags);
|
return res.targetFileSystem.getAclStatus(res.remainingPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,9 +22,7 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.permission.AclEntry;
|
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.AclStatus;
|
||||||
import org.apache.hadoop.fs.permission.AclWriteFlag;
|
|
||||||
import org.apache.hadoop.fs.permission.FsPermission;
|
import org.apache.hadoop.fs.permission.FsPermission;
|
||||||
import org.apache.hadoop.security.Credentials;
|
import org.apache.hadoop.security.Credentials;
|
||||||
import org.apache.hadoop.security.token.Token;
|
import org.apache.hadoop.security.token.Token;
|
||||||
|
@ -37,7 +35,6 @@ import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.apache.hadoop.fs.Options.ChecksumOpt;
|
import static org.apache.hadoop.fs.Options.ChecksumOpt;
|
||||||
import static org.apache.hadoop.fs.Options.CreateOpts;
|
import static org.apache.hadoop.fs.Options.CreateOpts;
|
||||||
|
@ -170,18 +167,12 @@ public class TestHarFileSystem {
|
||||||
String snapshotNewName) throws IOException;
|
String snapshotNewName) throws IOException;
|
||||||
public void deleteSnapshot(Path path, String snapshotName)
|
public void deleteSnapshot(Path path, String snapshotName)
|
||||||
throws IOException;
|
throws IOException;
|
||||||
public void modifyAclEntries(Path path, List<AclEntry> aclSpec,
|
public void modifyAclEntries(Path path, Iterable<AclEntry> aclSpec) throws IOException;
|
||||||
EnumSet<AclWriteFlag> flags) throws IOException;
|
public void removeAclEntries(Path path, Iterable<AclEntry> aclSpec) throws IOException;
|
||||||
public void removeAclEntries(Path path, List<AclEntry> aclSpec,
|
public void removeDefaultAcl(Path path) throws IOException;
|
||||||
EnumSet<AclWriteFlag> flags) throws IOException;
|
public void removeAcl(Path path) throws IOException;
|
||||||
public void removeDefaultAcl(Path path, EnumSet<AclWriteFlag> flags)
|
public void setAcl(Path path, Iterable<AclEntry> aclSpec) throws IOException;
|
||||||
throws IOException;
|
public AclStatus getAclStatus(Path path) throws IOException;
|
||||||
public void removeAcl(Path path, EnumSet<AclWriteFlag> flags)
|
|
||||||
throws IOException;
|
|
||||||
public void setAcl(Path path, List<AclEntry> aclSpec,
|
|
||||||
EnumSet<AclWriteFlag> flags) throws IOException;
|
|
||||||
public RemoteIterator<AclStatus> listAclStatus(Path path,
|
|
||||||
EnumSet<AclReadFlag> flags) throws IOException;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -21,20 +21,21 @@ import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.apache.hadoop.fs.Path;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests covering basic functionality of the ACL objects.
|
* Tests covering basic functionality of the ACL objects.
|
||||||
*/
|
*/
|
||||||
public class TestAcl {
|
public class TestAcl {
|
||||||
private static final Acl ACL1, ACL2, ACL3, ACL4;
|
private static AclEntry ENTRY1, ENTRY2, ENTRY3, ENTRY4, ENTRY5, ENTRY6,
|
||||||
private static final AclEntry ENTRY1, ENTRY2, ENTRY3, ENTRY4, ENTRY5, ENTRY6,
|
|
||||||
ENTRY7, ENTRY8, ENTRY9, ENTRY10, ENTRY11, ENTRY12, ENTRY13;
|
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
|
// named user
|
||||||
AclEntry.Builder aclEntryBuilder = new AclEntry.Builder()
|
AclEntry.Builder aclEntryBuilder = new AclEntry.Builder()
|
||||||
.setType(AclEntryType.USER)
|
.setType(AclEntryType.USER)
|
||||||
|
@ -107,31 +108,21 @@ public class TestAcl {
|
||||||
.setScope(AclEntryScope.DEFAULT)
|
.setScope(AclEntryScope.DEFAULT)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Acl.Builder aclBuilder = new Acl.Builder()
|
AclStatus.Builder aclStatusBuilder = new AclStatus.Builder()
|
||||||
|
.owner("owner1")
|
||||||
|
.group("group1")
|
||||||
.addEntry(ENTRY1)
|
.addEntry(ENTRY1)
|
||||||
.addEntry(ENTRY3)
|
.addEntry(ENTRY3)
|
||||||
.addEntry(ENTRY4);
|
.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();
|
STATUS1 = aclStatusBuilder.build();
|
||||||
STATUS2 = aclStatusBuilder.build();
|
STATUS2 = aclStatusBuilder.build();
|
||||||
STATUS3 = new AclStatus.Builder()
|
STATUS3 = new AclStatus.Builder()
|
||||||
.setFile(new Path("file2"))
|
.owner("owner2")
|
||||||
.setOwner("owner2")
|
.group("group2")
|
||||||
.setGroup("group2")
|
.stickyBit(true)
|
||||||
.setAcl(ACL3)
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ACL4 = new Acl.Builder()
|
STATUS4 = new AclStatus.Builder()
|
||||||
.addEntry(ENTRY1)
|
.addEntry(ENTRY1)
|
||||||
.addEntry(ENTRY3)
|
.addEntry(ENTRY3)
|
||||||
.addEntry(ENTRY4)
|
.addEntry(ENTRY4)
|
||||||
|
@ -147,39 +138,6 @@ public class TestAcl {
|
||||||
.build();
|
.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<AclEntry> entries = ACL1.getEntries();
|
|
||||||
try {
|
|
||||||
entries.add(entry);
|
|
||||||
fail("expected adding ACL entry to fail");
|
|
||||||
} catch (UnsupportedOperationException e) {
|
|
||||||
// expected
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEntryEquals() {
|
public void testEntryEquals() {
|
||||||
assertNotSame(ENTRY1, ENTRY2);
|
assertNotSame(ENTRY1, ENTRY2);
|
||||||
|
@ -223,7 +181,7 @@ public class TestAcl {
|
||||||
ENTRY10, // default mask
|
ENTRY10, // default mask
|
||||||
ENTRY4 // default other
|
ENTRY4 // default other
|
||||||
};
|
};
|
||||||
List<AclEntry> actual = ACL4.getEntries();
|
List<AclEntry> actual = Lists.newArrayList(STATUS4.getEntries());
|
||||||
assertNotNull(actual);
|
assertNotNull(actual);
|
||||||
assertEquals(expected.length, actual.size());
|
assertEquals(expected.length, actual.size());
|
||||||
for (int i = 0; i < expected.length; ++i) {
|
for (int i = 0; i < expected.length; ++i) {
|
||||||
|
@ -267,25 +225,19 @@ public class TestAcl {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToString() {
|
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", ENTRY1.toString());
|
||||||
assertEquals("user:user1:rwx", ENTRY2.toString());
|
assertEquals("user:user1:rwx", ENTRY2.toString());
|
||||||
assertEquals("group:group2:rw-", ENTRY3.toString());
|
assertEquals("group:group2:rw-", ENTRY3.toString());
|
||||||
assertEquals("default:other::---", ENTRY4.toString());
|
assertEquals("default:other::---", ENTRY4.toString());
|
||||||
|
|
||||||
assertEquals(
|
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());
|
STATUS1.toString());
|
||||||
assertEquals(
|
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());
|
STATUS2.toString());
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"file: file2, owner: owner2, group: group2, acl: {entries: [], stickyBit: true}",
|
"owner: owner2, group: group2, acl: {entries: [], stickyBit: true}",
|
||||||
STATUS3.toString());
|
STATUS3.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
@ -33,8 +32,6 @@ import org.apache.hadoop.fs.FilterFileSystem;
|
||||||
import org.apache.hadoop.fs.FsConstants;
|
import org.apache.hadoop.fs.FsConstants;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.fs.permission.AclEntry;
|
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.apache.hadoop.fs.viewfs.ChRootedFileSystem;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -378,26 +375,24 @@ public class TestChRootedFileSystem {
|
||||||
Path chrootPath = new Path("/c");
|
Path chrootPath = new Path("/c");
|
||||||
Path rawPath = new Path("/a/b/c");
|
Path rawPath = new Path("/a/b/c");
|
||||||
List<AclEntry> entries = Collections.emptyList();
|
List<AclEntry> entries = Collections.emptyList();
|
||||||
EnumSet<AclWriteFlag> writeFlags = EnumSet.noneOf(AclWriteFlag.class);
|
|
||||||
EnumSet<AclReadFlag> readFlags = EnumSet.noneOf(AclReadFlag.class);
|
|
||||||
|
|
||||||
chrootFs.modifyAclEntries(chrootPath, entries, writeFlags);
|
chrootFs.modifyAclEntries(chrootPath, entries);
|
||||||
verify(mockFs).modifyAclEntries(rawPath, entries, writeFlags);
|
verify(mockFs).modifyAclEntries(rawPath, entries);
|
||||||
|
|
||||||
chrootFs.removeAclEntries(chrootPath, entries, writeFlags);
|
chrootFs.removeAclEntries(chrootPath, entries);
|
||||||
verify(mockFs).removeAclEntries(rawPath, entries, writeFlags);
|
verify(mockFs).removeAclEntries(rawPath, entries);
|
||||||
|
|
||||||
chrootFs.removeDefaultAcl(chrootPath, writeFlags);
|
chrootFs.removeDefaultAcl(chrootPath);
|
||||||
verify(mockFs).removeDefaultAcl(rawPath, writeFlags);
|
verify(mockFs).removeDefaultAcl(rawPath);
|
||||||
|
|
||||||
chrootFs.removeAcl(chrootPath, writeFlags);
|
chrootFs.removeAcl(chrootPath);
|
||||||
verify(mockFs).removeAcl(rawPath, writeFlags);
|
verify(mockFs).removeAcl(rawPath);
|
||||||
|
|
||||||
chrootFs.setAcl(chrootPath, entries, writeFlags);
|
chrootFs.setAcl(chrootPath, entries);
|
||||||
verify(mockFs).setAcl(rawPath, entries, writeFlags);
|
verify(mockFs).setAcl(rawPath, entries);
|
||||||
|
|
||||||
chrootFs.listAclStatus(chrootPath, readFlags);
|
chrootFs.getAclStatus(chrootPath);
|
||||||
verify(mockFs).listAclStatus(rawPath, readFlags);
|
verify(mockFs).getAclStatus(rawPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class MockFileSystem extends FilterFileSystem {
|
static class MockFileSystem extends FilterFileSystem {
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.apache.hadoop.fs.viewfs;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
|
@ -30,8 +29,6 @@ import org.apache.hadoop.fs.FsConstants;
|
||||||
import org.apache.hadoop.fs.LocalFileSystem;
|
import org.apache.hadoop.fs.LocalFileSystem;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.fs.permission.AclEntry;
|
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.apache.hadoop.fs.viewfs.TestChRootedFileSystem.MockFileSystem;
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
@ -103,38 +100,36 @@ public class TestViewFileSystemDelegation { //extends ViewFileSystemTestSetup {
|
||||||
Path viewFsPath2 = new Path("/mounts/mockfs2/d/e/f");
|
Path viewFsPath2 = new Path("/mounts/mockfs2/d/e/f");
|
||||||
Path mockFsPath2 = new Path("/d/e/f");
|
Path mockFsPath2 = new Path("/d/e/f");
|
||||||
List<AclEntry> entries = Collections.emptyList();
|
List<AclEntry> entries = Collections.emptyList();
|
||||||
EnumSet<AclWriteFlag> writeFlags = EnumSet.noneOf(AclWriteFlag.class);
|
|
||||||
EnumSet<AclReadFlag> readFlags = EnumSet.noneOf(AclReadFlag.class);
|
|
||||||
|
|
||||||
viewFs.modifyAclEntries(viewFsPath1, entries, writeFlags);
|
viewFs.modifyAclEntries(viewFsPath1, entries);
|
||||||
verify(mockFs1).modifyAclEntries(mockFsPath1, entries, writeFlags);
|
verify(mockFs1).modifyAclEntries(mockFsPath1, entries);
|
||||||
viewFs.modifyAclEntries(viewFsPath2, entries, writeFlags);
|
viewFs.modifyAclEntries(viewFsPath2, entries);
|
||||||
verify(mockFs2).modifyAclEntries(mockFsPath2, entries, writeFlags);
|
verify(mockFs2).modifyAclEntries(mockFsPath2, entries);
|
||||||
|
|
||||||
viewFs.removeAclEntries(viewFsPath1, entries, writeFlags);
|
viewFs.removeAclEntries(viewFsPath1, entries);
|
||||||
verify(mockFs1).removeAclEntries(mockFsPath1, entries, writeFlags);
|
verify(mockFs1).removeAclEntries(mockFsPath1, entries);
|
||||||
viewFs.removeAclEntries(viewFsPath2, entries, writeFlags);
|
viewFs.removeAclEntries(viewFsPath2, entries);
|
||||||
verify(mockFs2).removeAclEntries(mockFsPath2, entries, writeFlags);
|
verify(mockFs2).removeAclEntries(mockFsPath2, entries);
|
||||||
|
|
||||||
viewFs.removeDefaultAcl(viewFsPath1, writeFlags);
|
viewFs.removeDefaultAcl(viewFsPath1);
|
||||||
verify(mockFs1).removeDefaultAcl(mockFsPath1, writeFlags);
|
verify(mockFs1).removeDefaultAcl(mockFsPath1);
|
||||||
viewFs.removeDefaultAcl(viewFsPath2, writeFlags);
|
viewFs.removeDefaultAcl(viewFsPath2);
|
||||||
verify(mockFs2).removeDefaultAcl(mockFsPath2, writeFlags);
|
verify(mockFs2).removeDefaultAcl(mockFsPath2);
|
||||||
|
|
||||||
viewFs.removeAcl(viewFsPath1, writeFlags);
|
viewFs.removeAcl(viewFsPath1);
|
||||||
verify(mockFs1).removeAcl(mockFsPath1, writeFlags);
|
verify(mockFs1).removeAcl(mockFsPath1);
|
||||||
viewFs.removeAcl(viewFsPath2, writeFlags);
|
viewFs.removeAcl(viewFsPath2);
|
||||||
verify(mockFs2).removeAcl(mockFsPath2, writeFlags);
|
verify(mockFs2).removeAcl(mockFsPath2);
|
||||||
|
|
||||||
viewFs.setAcl(viewFsPath1, entries, writeFlags);
|
viewFs.setAcl(viewFsPath1, entries);
|
||||||
verify(mockFs1).setAcl(mockFsPath1, entries, writeFlags);
|
verify(mockFs1).setAcl(mockFsPath1, entries);
|
||||||
viewFs.setAcl(viewFsPath2, entries, writeFlags);
|
viewFs.setAcl(viewFsPath2, entries);
|
||||||
verify(mockFs2).setAcl(mockFsPath2, entries, writeFlags);
|
verify(mockFs2).setAcl(mockFsPath2, entries);
|
||||||
|
|
||||||
viewFs.listAclStatus(viewFsPath1, readFlags);
|
viewFs.getAclStatus(viewFsPath1);
|
||||||
verify(mockFs1).listAclStatus(mockFsPath1, readFlags);
|
verify(mockFs1).getAclStatus(mockFsPath1);
|
||||||
viewFs.listAclStatus(viewFsPath2, readFlags);
|
viewFs.getAclStatus(viewFsPath2);
|
||||||
verify(mockFs2).listAclStatus(mockFsPath2, readFlags);
|
verify(mockFs2).getAclStatus(mockFsPath2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkVerifyChecksum(boolean flag) {
|
void checkVerifyChecksum(boolean flag) {
|
||||||
|
|
|
@ -9,6 +9,9 @@ HDFS-4685 (Unreleased)
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
HDFS-5594. FileSystem API for ACLs. (cnauroth)
|
HDFS-5594. FileSystem API for ACLs. (cnauroth)
|
||||||
|
|
||||||
|
HDFS-5650. Remove AclReadFlag and AclWriteFlag in FileSystem API.
|
||||||
|
(Haohui Mai via cnauroth)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
Loading…
Reference in New Issue