This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi-shaded.git
The following commit(s) were added to refs/heads/master by this push:
new b8cfda7 [KYUUBI-SHADED #42] Prune classes and add NOTICE for shaded
hive metastore client
b8cfda7 is described below
commit b8cfda7586f75680b23e6c8df011fe21077ff146
Author: Cheng Pan <[email protected]>
AuthorDate: Mon Mar 4 11:36:42 2024 +0800
[KYUUBI-SHADED #42] Prune classes and add NOTICE for shaded hive metastore
client
### _Why are the changes needed?_
Remove unused classes, remove dependency of commons-lang3, add NOTICE
### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including
negative and positive cases if possible
- [ ] Add screenshots for manual tests if appropriate
- [ ] [Run
test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests)
locally before make a pull request
Closes #42 from pan3793/prune.
4e54c00 [Cheng Pan] scope
db69c47 [Cheng Pan] Prune classes and add NOTICE for shaded hive metastore
client
Authored-by: Cheng Pan <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
---
kyuubi-relocated-hive-metastore-client/pom.xml | 32 +++++++---
.../shaded/hive/metastore/utils/ClassUtils.java | 68 +++++++++++++++++++++
.../shaded/hive/metastore/utils/JavaUtils.java | 28 ++-------
.../kyuubi/shaded/hive/metastore/utils/Retry.java | 69 ----------------------
.../src/main/resources/META-INF/NOTICE | 11 ++++
5 files changed, 110 insertions(+), 98 deletions(-)
diff --git a/kyuubi-relocated-hive-metastore-client/pom.xml
b/kyuubi-relocated-hive-metastore-client/pom.xml
index 367da4b..08ece4c 100644
--- a/kyuubi-relocated-hive-metastore-client/pom.xml
+++ b/kyuubi-relocated-hive-metastore-client/pom.xml
@@ -33,9 +33,9 @@ under the License.
<properties>
<!-- Dependency versions -->
- <commons-lang3.version>3.12.0</commons-lang3.version>
<hadoop.version>3.3.6</hadoop.version>
- <httpcomponents.core.version>4.5.14</httpcomponents.core.version>
+ <httpclient.version>4.5.14</httpclient.version>
+ <httpcore.version>4.4.16</httpcore.version>
<libfb303.version>0.9.3</libfb303.version>
<libthrift.version>0.16.0</libthrift.version>
<slf4j.version>1.7.36</slf4j.version>
@@ -52,12 +52,24 @@ under the License.
<artifactId>kyuubi-relocated-thrift</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.kyuubi</groupId>
<artifactId>kyuubi-relocated-zookeeper-34</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@@ -74,14 +86,20 @@ under the License.
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
- <version>${httpcomponents.core.version}</version>
+ <version>${httpclient.version}</version>
<scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
- <!-- TODO: remove this dependency -->
<dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>${commons-lang3.version}</version>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>${httpcore.version}</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
diff --git
a/kyuubi-relocated-hive-metastore-client/src/main/java/org/apache/kyuubi/shaded/hive/metastore/utils/ClassUtils.java
b/kyuubi-relocated-hive-metastore-client/src/main/java/org/apache/kyuubi/shaded/hive/metastore/utils/ClassUtils.java
new file mode 100644
index 0000000..ed051a8
--- /dev/null
+++
b/kyuubi-relocated-hive-metastore-client/src/main/java/org/apache/kyuubi/shaded/hive/metastore/utils/ClassUtils.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kyuubi.shaded.hive.metastore.utils;
+
+import java.util.*;
+
+/**
+ * Operates on classes without using reflection.
+ *
+ * <p>This class handles invalid {@code null} inputs as best it can. Each
method documents its
+ * behavior in more detail.
+ *
+ * <p>The notion of a {@code canonical name} includes the human readable name
for the type, for
+ * example {@code int[]}. The non-canonical method variants work with the JVM
names, such as {@code
+ * [I}.
+ *
+ * @since 2.0
+ */
+// Copied from org.apache.commons:commons-lang3:3.12.0
+public class ClassUtils {
+
+ /** Maps primitive {@code Class}es to their corresponding wrapper {@code
Class}. */
+ private static final Map<Class<?>, Class<?>> primitiveWrapperMap = new
HashMap<>();
+
+ static {
+ primitiveWrapperMap.put(Boolean.TYPE, Boolean.class);
+ primitiveWrapperMap.put(Byte.TYPE, Byte.class);
+ primitiveWrapperMap.put(Character.TYPE, Character.class);
+ primitiveWrapperMap.put(Short.TYPE, Short.class);
+ primitiveWrapperMap.put(Integer.TYPE, Integer.class);
+ primitiveWrapperMap.put(Long.TYPE, Long.class);
+ primitiveWrapperMap.put(Double.TYPE, Double.class);
+ primitiveWrapperMap.put(Float.TYPE, Float.class);
+ primitiveWrapperMap.put(Void.TYPE, Void.TYPE);
+ }
+
+ /**
+ * Converts the specified primitive Class object to its corresponding
wrapper Class object.
+ *
+ * <p>NOTE: From v2.2, this method handles {@code Void.TYPE}, returning
{@code Void.TYPE}.
+ *
+ * @param cls the class to convert, may be null
+ * @return the wrapper class for {@code cls} or {@code cls} if {@code cls}
is not a primitive.
+ * {@code null} if null input.
+ * @since 2.1
+ */
+ public static Class<?> primitiveToWrapper(final Class<?> cls) {
+ Class<?> convertedClass = cls;
+ if (cls != null && cls.isPrimitive()) {
+ convertedClass = primitiveWrapperMap.get(cls);
+ }
+ return convertedClass;
+ }
+}
diff --git
a/kyuubi-relocated-hive-metastore-client/src/main/java/org/apache/kyuubi/shaded/hive/metastore/utils/JavaUtils.java
b/kyuubi-relocated-hive-metastore-client/src/main/java/org/apache/kyuubi/shaded/hive/metastore/utils/JavaUtils.java
index f51bcd8..70eea3c 100644
---
a/kyuubi-relocated-hive-metastore-client/src/main/java/org/apache/kyuubi/shaded/hive/metastore/utils/JavaUtils.java
+++
b/kyuubi-relocated-hive-metastore-client/src/main/java/org/apache/kyuubi/shaded/hive/metastore/utils/JavaUtils.java
@@ -18,15 +18,9 @@
package org.apache.kyuubi.shaded.hive.metastore.utils;
import java.lang.reflect.Constructor;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import org.apache.commons.lang3.ClassUtils;
import org.apache.kyuubi.shaded.hive.metastore.api.MetaException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class JavaUtils {
- public static final Logger LOG = LoggerFactory.getLogger(JavaUtils.class);
/**
* Standard way of getting classloader in Hive code (outside of Hadoop).
@@ -61,39 +55,29 @@ public class JavaUtils {
*
* @param theClass
* @param parameterTypes an array of parameterTypes for the constructor
- * @param initargs the list of arguments for the constructor
+ * @param initArgs the list of arguments for the constructor
*/
- public static <T> T newInstance(Class<T> theClass, Class<?>[]
parameterTypes, Object[] initargs) {
+ public static <T> T newInstance(Class<T> theClass, Class<?>[]
parameterTypes, Object[] initArgs) {
// Perform some sanity checks on the arguments.
- if (parameterTypes.length != initargs.length) {
+ if (parameterTypes.length != initArgs.length) {
throw new IllegalArgumentException(
"Number of constructor parameter types doesn't match number of
arguments");
}
for (int i = 0; i < parameterTypes.length; i++) {
// initargs are boxed to Object, so we need to wrapper primitive types
here.
Class<?> clazz = ClassUtils.primitiveToWrapper(parameterTypes[i]);
- if (initargs[i] != null && !(clazz.isInstance(initargs[i]))) {
+ if (initArgs[i] != null && !(clazz.isInstance(initArgs[i]))) {
throw new IllegalArgumentException(
- "Object : " + initargs[i] + " is not an instance of " + clazz);
+ "Object : " + initArgs[i] + " is not an instance of " + clazz);
}
}
try {
Constructor<T> meth = theClass.getDeclaredConstructor(parameterTypes);
meth.setAccessible(true);
- return meth.newInstance(initargs);
+ return meth.newInstance(initArgs);
} catch (Exception e) {
throw new RuntimeException("Unable to instantiate " +
theClass.getName(), e);
}
}
-
- /** @return name of current host */
- public static String hostname() {
- try {
- return InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException e) {
- LOG.error("Unable to resolve my host name " + e.getMessage());
- throw new RuntimeException(e);
- }
- }
}
diff --git
a/kyuubi-relocated-hive-metastore-client/src/main/java/org/apache/kyuubi/shaded/hive/metastore/utils/Retry.java
b/kyuubi-relocated-hive-metastore-client/src/main/java/org/apache/kyuubi/shaded/hive/metastore/utils/Retry.java
deleted file mode 100644
index e8778d1..0000000
---
a/kyuubi-relocated-hive-metastore-client/src/main/java/org/apache/kyuubi/shaded/hive/metastore/utils/Retry.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.kyuubi.shaded.hive.metastore.utils;
-
-/** Class to implement any retry logic in case of exceptions. */
-public abstract class Retry<T> {
-
- public static final int MAX_RETRIES = 4;
- public static final int DELAY = 30 * 1000;
- private int tries = 0;
- private Class retryExceptionType;
-
- public Retry(Class exceptionClassType) {
- this.retryExceptionType = exceptionClassType;
- }
-
- public abstract T execute() throws Exception;
-
- public T run() throws Exception {
- try {
- return execute();
- } catch (Exception e) {
- if (e.getClass().equals(retryExceptionType)) {
- tries++;
- if (MAX_RETRIES == tries) {
- throw e;
- } else {
- return run();
- }
- } else {
- throw e;
- }
- }
- }
-
- public T runWithDelay() throws Exception {
- try {
- return execute();
- } catch (Exception e) {
- if (e.getClass().equals(retryExceptionType)) {
- tries++;
- if (MAX_RETRIES == tries) {
- throw e;
- } else {
- Thread.sleep((long) DELAY * tries);
- return runWithDelay();
- }
- } else {
- throw e;
- }
- }
- }
-}
diff --git
a/kyuubi-relocated-hive-metastore-client/src/main/resources/META-INF/NOTICE
b/kyuubi-relocated-hive-metastore-client/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000..5e378d0
--- /dev/null
+++ b/kyuubi-relocated-hive-metastore-client/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,11 @@
+kyuubi-relocated-hive-metastore-client
+Copyright 2023-2024 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (https://www.apache.org/).
+
+Apache Commons Lang
+Copyright 2001-2023 The Apache Software Foundation
+
+Apache Hive
+Copyright 2008-2023 The Apache Software Foundation