Skip to content

Commit

Permalink
s3 rename verify delete and write; posix rename verify double write (#…
Browse files Browse the repository at this point in the history
…108)

Co-authored-by: vinsonruan <[email protected]>
  • Loading branch information
iabetor and vinsonruan authored Feb 15, 2023
1 parent 963d7a4 commit d4cb465
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.qcloud.cos</groupId>
<artifactId>hadoop-cos</artifactId>
<version>8.2.4</version>
<version>8.2.5</version>
<packaging>jar</packaging>

<name>Apache Hadoop Tencent Cloud COS Support</name>
Expand Down
23 changes: 17 additions & 6 deletions src/main/java/org/apache/hadoop/fs/CosFileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void initialize(URI uri, Configuration originalConf) throws IOException {
this.rangerCredentialsClient = this.nativeStore.getRangerCredentialsClient();
this.isPosixUseOFSRanger = this.getConf().
getBoolean(CosNConfigKeys.COSN_POSIX_BUCKET_USE_OFS_RANGER_ENABLED,
CosNConfigKeys.DEFAULT_COSN_POSIX_BUCKET_USE_OFS_RANGER_ENABLED);
CosNConfigKeys.DEFAULT_COSN_POSIX_BUCKET_USE_OFS_RANGER_ENABLED);

// required checkCustomAuth if ranger is enabled and custom authentication is enabled
checkCustomAuth(conf);
Expand All @@ -121,7 +121,7 @@ public void initialize(URI uri, Configuration originalConf) throws IOException {
}

LOG.info("The posix bucket [{}] use the class [{}] as the filesystem implementation, " +
"use each ranger [{}]", bucket, posixBucketFSImpl, this.isPosixUseOFSRanger);
"use each ranger [{}]", bucket, posixBucketFSImpl, this.isPosixUseOFSRanger);
// if ofs impl.
// network version start from the 2.7.
// sdk version start from the 1.0.4.
Expand Down Expand Up @@ -272,11 +272,22 @@ public FSDataInputStream open(Path f, int bufferSize) throws IOException {
public boolean rename(Path src, Path dst) throws IOException {
LOG.debug("Rename the source path [{}] to the dest path [{}].", src, dst);
checkInitialized();
checkPermission(src, RangerAccessType.DELETE);
renameCheckPermission(src);
checkPermission(dst, RangerAccessType.WRITE);
return this.actualImplFS.rename(src, dst);
}

private void renameCheckPermission(Path src) throws IOException {
if (useOFSRanger()) {
return;
}
if (this.isPosixImpl) {
checkPermission(src, RangerAccessType.WRITE);
} else {
checkPermission(src, RangerAccessType.DELETE);
}
}

@Override
public long getDefaultBlockSize() {
return this.actualImplFS.getDefaultBlockSize();
Expand Down Expand Up @@ -440,7 +451,7 @@ public ContentSummary getContentSummary(Path f) throws IOException {

@Override
public void setOwner(Path p, String userName, String groupName) throws IOException {
LOG.debug("set owner, path: {}, userName: {}, groupName: {}",p, userName, groupName);
LOG.debug("set owner, path: {}, userName: {}, groupName: {}", p, userName, groupName);
checkInitialized();
checkPermission(p, RangerAccessType.WRITE);
this.actualImplFS.setOwner(p, userName, groupName);
Expand Down Expand Up @@ -497,7 +508,7 @@ private void passThroughRangerConfig() {
}
}

private HashMap<String, String> getPOSIXBucketConfigMap() {
private HashMap<String, String> getPOSIXBucketConfigMap() {
HashMap<String, String> configMap = new HashMap<>();
configMap.put(CosNConfigKeys.COSN_APPID_KEY, Constants.COSN_POSIX_BUCKET_APPID_CONFIG);
configMap.put(CosNConfigKeys.COSN_REGION_KEY, Constants.COSN_POSIX_BUCKET_REGION_CONFIG);
Expand All @@ -510,7 +521,7 @@ private HashMap<String, String> getPOSIXBucketConfigMap() {
// exclude the ofs original config, filter the ofs config with COSN_CONFIG_TRANSFER_PREFIX
private void transferOfsConfig() {
// cosn config -> ofs config -> trsf ofs config
HashMap<String, String> configMap = getPOSIXBucketConfigMap();
HashMap<String, String> configMap = getPOSIXBucketConfigMap();
for (String org : configMap.keySet()) {
String content = this.getConf().get(org);
if (null != content && !content.isEmpty()) {
Expand Down

0 comments on commit d4cb465

Please sign in to comment.