Skip to content

Commit 0c9e0df

Browse files
authored
feature: posix bucket support acl (#183)
1 parent db4f4af commit 0c9e0df

File tree

3 files changed

+67
-12
lines changed

3 files changed

+67
-12
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.qcloud.cos</groupId>
88
<artifactId>hadoop-cos</artifactId>
9-
<version>8.3.26</version>
9+
<version>8.3.27</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Apache Hadoop Tencent Cloud COS Support</name>

src/main/java/org/apache/hadoop/fs/CosFileSystem.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import org.apache.hadoop.conf.Configuration;
88
import org.apache.hadoop.fs.cosn.Constants;
99
import org.apache.hadoop.fs.cosn.OperationCancellingStatusProvider;
10+
import org.apache.hadoop.fs.permission.AclEntry;
11+
import org.apache.hadoop.fs.permission.AclStatus;
1012
import org.apache.hadoop.fs.permission.FsPermission;
1113
import org.apache.hadoop.security.AccessControlException;
1214
import org.apache.hadoop.security.UserGroupInformation;
@@ -484,6 +486,54 @@ public void setTimes(Path p, long mtime, long atime) throws IOException {
484486
this.actualImplFS.setTimes(p, mtime, atime);
485487
}
486488

489+
@Override
490+
public void setAcl(Path path, List<AclEntry> aclSpec) throws IOException {
491+
LOG.debug("set acl, path: {}, aclSpec: {}", path, aclSpec);
492+
checkInitialized();
493+
checkPermission(path, RangerAccessType.WRITE);
494+
this.actualImplFS.setAcl(path, aclSpec);
495+
}
496+
497+
@Override
498+
public AclStatus getAclStatus(Path path) throws IOException {
499+
LOG.debug("getAclStatus, path: {}", path);
500+
checkInitialized();
501+
checkPermission(path, RangerAccessType.READ);
502+
return this.actualImplFS.getAclStatus(path);
503+
}
504+
505+
@Override
506+
public void modifyAclEntries(Path path, List<AclEntry> aclSpec) throws IOException {
507+
LOG.debug("modifyAclEntries, path: {}, aclSpec: {}", path, aclSpec);
508+
checkInitialized();
509+
checkPermission(path, RangerAccessType.WRITE);
510+
this.actualImplFS.modifyAclEntries(path, aclSpec);
511+
}
512+
513+
@Override
514+
public void removeAclEntries(Path path, List<AclEntry> aclSpec) throws IOException {
515+
LOG.debug("removeAclEntries, path: {}, aclSpec: {}", path, aclSpec);
516+
checkInitialized();
517+
checkPermission(path, RangerAccessType.WRITE);
518+
this.actualImplFS.removeAclEntries(path, aclSpec);
519+
}
520+
521+
@Override
522+
public void removeDefaultAcl(Path path) throws IOException {
523+
LOG.debug("removeDefaultAcl, path: {}", path);
524+
checkInitialized();
525+
checkPermission(path, RangerAccessType.WRITE);
526+
this.actualImplFS.removeDefaultAcl(path);
527+
}
528+
529+
@Override
530+
public void removeAcl(Path path) throws IOException {
531+
LOG.debug("removeAcl, path: {}", path);
532+
checkInitialized();
533+
checkPermission(path, RangerAccessType.WRITE);
534+
this.actualImplFS.removeAcl(path);
535+
}
536+
487537
public NativeFileSystemStore getStore() {
488538
return this.nativeStore;
489539
}

src/main/java/org/apache/hadoop/fs/CosNFileReadTask.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,23 @@ private void retrieveBlock() throws IOException, CancelledException {
128128
byte[] dataBuf = readBuffer.getBuffer();
129129
checkStreamClosed();
130130
Objects.requireNonNull(dataBuf);
131-
InputStream inputStream;
132-
inputStream = this.store.retrieveBlock(
133-
this.key, this.readBuffer.getStart(), this.readBuffer.getEnd());
134-
IOUtils.readFully(
135-
inputStream, dataBuf, 0,
136-
dataBuf.length);
137-
int readEof = inputStream.read();
138-
if (readEof != -1) {
139-
LOG.error("Expect to read the eof, but the return is not -1. key: {}.", this.key);
131+
InputStream inputStream = null;
132+
try {
133+
inputStream = this.store.retrieveBlock(
134+
this.key, this.readBuffer.getStart(), this.readBuffer.getEnd());
135+
IOUtils.readFully(
136+
inputStream, dataBuf, 0,
137+
dataBuf.length);
138+
int readEof = inputStream.read();
139+
if (readEof != -1) {
140+
LOG.error("Expect to read the eof, but the return is not -1. key: {}.", this.key);
141+
}
142+
this.readBuffer.setStatus(CosNFSInputStream.ReadBuffer.SUCCESS);
143+
} finally {
144+
if (inputStream != null) {
145+
inputStream.close();
146+
}
140147
}
141-
inputStream.close();
142-
this.readBuffer.setStatus(CosNFSInputStream.ReadBuffer.SUCCESS);
143148
}
144149

145150
private void checkStreamClosed() throws CancelledException {

0 commit comments

Comments
 (0)