From c08301645467690223d2e81456c8359c8039d8d2 Mon Sep 17 00:00:00 2001 From: vintmd <61688729+vintmd@users.noreply.github.com> Date: Thu, 2 Feb 2023 11:56:24 +0800 Subject: [PATCH] remove StringUtils of lang3 (#104) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * remove StringUtils of lang3 * change version to v8.2.3 and release --------- Co-authored-by: alantong(佟明达) --- pom.xml | 2 +- .../java/org/apache/hadoop/fs/CosFileSystem.java | 4 ++-- src/main/java/org/apache/hadoop/fs/CosNUtils.java | 12 +++++------- .../apache/hadoop/fs/CosNativeFileSystemStore.java | 7 ++++++- .../org/apache/hadoop/fs/NativeFileSystemStore.java | 4 +++- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index d905699f..8a4ade17 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.qcloud.cos hadoop-cos - 8.2.2 + 8.2.3 jar Apache Hadoop Tencent Cloud COS Support diff --git a/src/main/java/org/apache/hadoop/fs/CosFileSystem.java b/src/main/java/org/apache/hadoop/fs/CosFileSystem.java index c1571028..370f6edc 100644 --- a/src/main/java/org/apache/hadoop/fs/CosFileSystem.java +++ b/src/main/java/org/apache/hadoop/fs/CosFileSystem.java @@ -127,7 +127,7 @@ public void initialize(URI uri, Configuration originalConf) throws IOException { // judge normal impl first, skip the class nodef error when only use normal bucket if (this.actualImplFS instanceof CosNFileSystem) { - this.nativeStore.isPosixBucket(true); + this.nativeStore.setPosixBucket(true); ((CosNFileSystem) this.actualImplFS).withStore(this.nativeStore).withBucket(bucket) .withPosixBucket(isPosixFSStore).withRangerCredentialsClient(rangerCredentialsClient); } else if (this.actualImplFS instanceof CHDFSHadoopFileSystemAdapter) { @@ -145,7 +145,7 @@ public void initialize(URI uri, Configuration originalConf) throws IOException { } } else { // normal cos hadoop file system implements this.actualImplFS = getActualFileSystemByClassName("org.apache.hadoop.fs.CosNFileSystem"); - this.nativeStore.isPosixBucket(false); + this.nativeStore.setPosixBucket(false); ((CosNFileSystem) this.actualImplFS).withStore(this.nativeStore).withBucket(bucket) .withPosixBucket(this.isPosixFSStore).withRangerCredentialsClient(rangerCredentialsClient); } diff --git a/src/main/java/org/apache/hadoop/fs/CosNUtils.java b/src/main/java/org/apache/hadoop/fs/CosNUtils.java index f23b86ee..3d7c6228 100644 --- a/src/main/java/org/apache/hadoop/fs/CosNUtils.java +++ b/src/main/java/org/apache/hadoop/fs/CosNUtils.java @@ -1,7 +1,6 @@ package org.apache.hadoop.fs; import com.qcloud.cos.auth.COSCredentialsProvider; -import org.apache.commons.lang3.StringUtils; import com.google.common.base.Preconditions; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.auth.*; @@ -279,8 +278,9 @@ public static void buildAndSaveAsymKeyPair(String pubKeyPath, String priKeyPath) } public static Configuration propagateBucketOptions(Configuration source, String bucket) { - Preconditions.checkArgument(StringUtils.isNotEmpty(bucket), - "bucket is null or empty"); + if (null == bucket || 0 == bucket.length()) { + Preconditions.checkArgument(false, "bucket is null or empty"); + } final String bucketPrefix = FS_COSN_BUCKET_PREFIX + bucket +'.'; LOG.debug("propagating entries under {}", bucketPrefix); final Configuration dest = new Configuration(source); @@ -301,11 +301,9 @@ public static Configuration propagateBucketOptions(Configuration source, String // propagate the value, building a new origin field. // to track overwrites, the generic key is overwritten even if // already matches the new one. - String origin = "[" + StringUtils.join( - source.getPropertySources(key), ", ") +"]"; final String generic = FS_COSN_PREFIX + stripped; - LOG.debug("Updating {} from {}", generic, origin); - dest.set(generic, value, key + " via " + origin); + LOG.debug("Updating {} from origin", generic); + dest.set(generic, value, key); } } return dest; diff --git a/src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java b/src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java index 49160866..b25484cd 100644 --- a/src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java +++ b/src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java @@ -1493,7 +1493,7 @@ private void preClose() { } @Override - public void isPosixBucket(boolean isPosixBucket) { + public void setPosixBucket(boolean isPosixBucket) { this.isPosixBucket = isPosixBucket; } @@ -1545,6 +1545,11 @@ public CosNPartListing listParts(String key, String uploadId) throws IOException return new CosNPartListing(partSummaries); } + @Override + public boolean isPosixBucket() { + return this.isPosixBucket; + } + private PartETag isPartExist(CosNPartListing partListing, int partNum, long partSize) { PartETag ret = null; if (null == partListing) { diff --git a/src/main/java/org/apache/hadoop/fs/NativeFileSystemStore.java b/src/main/java/org/apache/hadoop/fs/NativeFileSystemStore.java index f04d96cf..17e9f45e 100644 --- a/src/main/java/org/apache/hadoop/fs/NativeFileSystemStore.java +++ b/src/main/java/org/apache/hadoop/fs/NativeFileSystemStore.java @@ -140,7 +140,9 @@ CosNPartialListing list(String prefix, int maxListingLength, * if you use the CosNFileSystem gateway mode, * must set native store to posix process */ - void isPosixBucket(boolean isPosixBucket); + void setPosixBucket(boolean isPosixBucket); + + boolean isPosixBucket(); RangerCredentialsClient getRangerCredentialsClient();