Skip to content

Commit

Permalink
add reuse config and compatible implements (#83)
Browse files Browse the repository at this point in the history
Co-authored-by: alantong(佟明达) <[email protected]>
  • Loading branch information
vintmd and vintmd authored Oct 27, 2022
1 parent 258d61a commit 3f70428
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
52 changes: 52 additions & 0 deletions src/main/java/org/apache/hadoop/fs/CosFileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,39 @@ public Token<?> getDelegationToken(String renewer) throws IOException {
return super.getDelegationToken(renewer);
}

// some other implements of ofs, for now only support
// for posix bucket. contain the getContentSummary, setOwner,setPermission,setTimes
@Override
public ContentSummary getContentSummary(Path f) throws IOException {
LOG.debug("get content summary: {}.", f);
checkInitialized();
return this.actualImplFS.getContentSummary(f);
}

@Override
public void setOwner(Path p, String userName, String groupName) throws IOException {
LOG.debug("set owner, path: {}, userName: {}, groupName: {}",p, userName, groupName);
checkInitialized();
checkPermission(p, RangerAccessType.WRITE);
this.actualImplFS.setOwner(p, userName, groupName);
}

@Override
public void setPermission(Path p, FsPermission permission) throws IOException {
LOG.debug("set permission, path :{}", p);
checkInitialized();
checkPermission(p, RangerAccessType.WRITE);
this.actualImplFS.setPermission(p, permission);
}

@Override
public void setTimes(Path p, long mtime, long atime) throws IOException {
LOG.debug("set times, path :{}, mtime: {}, atime: {}", p, mtime, atime);
checkInitialized();
checkPermission(p, RangerAccessType.WRITE);
this.actualImplFS.setTimes(p, mtime, atime);
}

public NativeFileSystemStore getStore() {
return this.nativeStore;
}
Expand Down Expand Up @@ -425,12 +458,31 @@ private void passThroughRangerConfig() {

// exclude the ofs original config, filter the ofs config with COSN_CONFIG_TRANSFER_PREFIX
private void transferOfsConfig() {
// 0. re-use the same configuration
String appidStr = this.getConf().get(CosNConfigKeys.COSN_APPID_KEY);
if (null != appidStr && !appidStr.isEmpty()) {
String trsfKey = Constants.COSN_CONFIG_TRANSFER_PREFIX.
concat(Constants.COSN_POSIX_BUCKET_APPID_CONFIG);
this.getConf().set(trsfKey, appidStr);
}

String regionStr = this.getConf().get(CosNConfigKeys.COSN_REGION_KEY);
if (null == regionStr) {
regionStr = this.getConf().get(CosNConfigKeys.COSN_REGION_PREV_KEY);
}
if (null != regionStr && !regionStr.isEmpty()) {
String trsfKey = Constants.COSN_CONFIG_TRANSFER_PREFIX.
concat(Constants.COSN_POSIX_BUCKET_REGION_CONFIG);
this.getConf().set(trsfKey, regionStr);
}

// 1. list to get transfer prefix ofs config
Map<String, String> tmpConf = new HashMap<>();
for (Map.Entry<String, String> entry : this.getConf()) {
if (entry.getKey().startsWith(Constants.COSN_OFS_CONFIG_PREFIX)) {
this.getConf().unset(entry.getKey());
}

if (entry.getKey().startsWith(Constants.COSN_CONFIG_TRANSFER_PREFIX)) {
int pos = Constants.COSN_CONFIG_TRANSFER_PREFIX.length();
String subConfigKey = entry.getKey().substring(pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ public PartETag call() throws Exception {
currentThread.setContextClassLoader(this.getClass().getClassLoader());

try {
LOG.info("Start to upload the part: {}", uploadPart);
LOG.debug("Start to upload the part: {}", uploadPart);
PartETag partETag = (nativeStore).uploadPart(
new BufferInputStream(uploadPart.getCosNByteBuffer()),
this.localKey,
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/apache/hadoop/fs/cosn/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ private Constants() {
public static final String COSN_POSIX_BUCKET_RANGER_POLICY_URL = "fs.ofs.cosn.ranger.policy.url";
public static final String COSN_POSIX_BUCKET_RANGER_AUTH_JAR_MD5 = "fs.ofs.cosn.ranger.auth.jar.md5";
public static final String COSN_POSIX_BUCKCET_OFS_RANGER_FLAG = "fs.ofs.ranger.enable.flag";

public static final String COSN_POSIX_BUCKET_APPID_CONFIG = "fs.ofs.user.appid";
public static final String COSN_POSIX_BUCKET_REGION_CONFIG = "fs.ofs.bucket.region";
}

0 comments on commit 3f70428

Please sign in to comment.