-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDFS-14856. Fetch file ACLs while mounting external store. #1478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ebb7286
7ad6623
04d0a8b
85c8328
84df44c
e12a30f
5f1b53d
3afebac
c148e4e
f2f3287
1bd5ee0
0a3d262
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
|
||
import java.io.IOException; | ||
|
||
import com.google.common.annotations.VisibleForTesting; | ||
import com.google.protobuf.ByteString; | ||
|
||
import org.apache.hadoop.classification.InterfaceAudience; | ||
|
@@ -27,6 +28,7 @@ | |
import org.apache.hadoop.fs.FileSystem; | ||
import org.apache.hadoop.fs.Options; | ||
import org.apache.hadoop.fs.PathHandle; | ||
import org.apache.hadoop.fs.permission.AclStatus; | ||
import org.apache.hadoop.hdfs.protocol.HdfsConstants; | ||
import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockProto; | ||
import org.apache.hadoop.hdfs.server.common.FileRegion; | ||
|
@@ -52,32 +54,47 @@ public class TreePath { | |
private final FileStatus stat; | ||
private final TreeWalk.TreeIterator i; | ||
private final FileSystem fs; | ||
private final AclStatus acls; | ||
|
||
protected TreePath(FileStatus stat, long parentId, TreeWalk.TreeIterator i, | ||
FileSystem fs) { | ||
@VisibleForTesting | ||
public TreePath(FileStatus stat, long parentId, TreeWalk.TreeIterator i) { | ||
this(stat, parentId, i, null, null); | ||
} | ||
|
||
public TreePath(FileStatus stat, long parentId, TreeWalk.TreeIterator i, | ||
FileSystem fs, AclStatus acls) { | ||
this.i = i; | ||
this.stat = stat; | ||
this.parentId = parentId; | ||
this.fs = fs; | ||
this.acls = acls; | ||
} | ||
|
||
public FileStatus getFileStatus() { | ||
return stat; | ||
} | ||
|
||
public AclStatus getAclStatus() { | ||
return acls; | ||
} | ||
|
||
public long getParentId() { | ||
return parentId; | ||
} | ||
|
||
public TreeWalk.TreeIterator getIterator() { | ||
return i; | ||
} | ||
|
||
public long getId() { | ||
if (id < 0) { | ||
throw new IllegalStateException(); | ||
} | ||
return id; | ||
} | ||
|
||
void accept(long id) { | ||
this.id = id; | ||
public void accept(long pathId) { | ||
this.id = pathId; | ||
i.onAccept(this, id); | ||
} | ||
|
||
|
@@ -121,14 +138,14 @@ void writeBlock(long blockId, long offset, long length, long genStamp, | |
INode toFile(UGIResolver ugi, BlockResolver blk, | ||
BlockAliasMap.Writer<FileRegion> out) throws IOException { | ||
final FileStatus s = getFileStatus(); | ||
ugi.addUser(s.getOwner()); | ||
ugi.addGroup(s.getGroup()); | ||
final AclStatus aclStatus = getAclStatus(); | ||
long permissions = ugi.getPermissionsProto(s, aclStatus); | ||
INodeFile.Builder b = INodeFile.newBuilder() | ||
.setReplication(blk.getReplication(s)) | ||
.setModificationTime(s.getModificationTime()) | ||
.setAccessTime(s.getAccessTime()) | ||
.setPreferredBlockSize(blk.preferredBlockSize(s)) | ||
.setPermission(ugi.resolve(s)) | ||
.setPermission(permissions) | ||
.setStoragePolicyID(HdfsConstants.PROVIDED_STORAGE_POLICY_ID); | ||
|
||
// pathhandle allows match as long as the file matches exactly. | ||
|
@@ -141,7 +158,11 @@ INode toFile(UGIResolver ugi, BlockResolver blk, | |
"Exact path handle not supported by filesystem " + fs.toString()); | ||
} | ||
} | ||
// TODO: storage policy should be configurable per path; use BlockResolver | ||
if (aclStatus != null) { | ||
throw new UnsupportedOperationException( | ||
"ACLs not supported by ImageWriter"); | ||
} | ||
//TODO: storage policy should be configurable per path; use BlockResolver | ||
virajith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
long off = 0L; | ||
for (BlockProto block : blk.resolve(s)) { | ||
b.addBlocks(block); | ||
|
@@ -159,13 +180,17 @@ INode toFile(UGIResolver ugi, BlockResolver blk, | |
|
||
INode toDirectory(UGIResolver ugi) { | ||
final FileStatus s = getFileStatus(); | ||
ugi.addUser(s.getOwner()); | ||
ugi.addGroup(s.getGroup()); | ||
final AclStatus aclStatus = getAclStatus(); | ||
long permissions = ugi.getPermissionsProto(s, aclStatus); | ||
INodeDirectory.Builder b = INodeDirectory.newBuilder() | ||
.setModificationTime(s.getModificationTime()) | ||
.setNsQuota(DEFAULT_NAMESPACE_QUOTA) | ||
.setDsQuota(DEFAULT_STORAGE_SPACE_QUOTA) | ||
.setPermission(ugi.resolve(s)); | ||
.setPermission(permissions); | ||
if (aclStatus != null) { | ||
throw new UnsupportedOperationException( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, this is not currently written to the image? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I am proposing to fix the scanner in the PR which is independent of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make this explicit (e.g,, add javadoc for this method)? |
||
"ACLs not supported by ImageWriter"); | ||
} | ||
INode.Builder ib = INode.newBuilder() | ||
.setType(INode.Type.DIRECTORY) | ||
.setId(id) | ||
|
Uh oh!
There was an error while loading. Please reload this page.