Skip to content

Commit 828f285

Browse files
committed
HIVE-29284 Remove tight yarn-registry coupling from hive-exec
1 parent 770e70c commit 828f285

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

ql/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,6 @@
301301
<version>${hadoop.version}</version>
302302
<optional>true</optional>
303303
</dependency>
304-
<dependency>
305-
<groupId>org.apache.hadoop</groupId>
306-
<artifactId>hadoop-yarn-registry</artifactId>
307-
</dependency>
308304
<dependency>
309305
<groupId>org.apache.hadoop</groupId>
310306
<artifactId>hadoop-mapreduce-client-core</artifactId>

ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4136,7 +4136,7 @@ public static boolean isPerfOrAboveLogging(HiveConf conf) {
41364136
}
41374137

41384138
/**
4139-
* Returns the full path to the Jar containing the class. It always return a JAR.
4139+
* Returns the full path to the Jar containing the class. It always returns a JAR.
41404140
*
41414141
* @param klass
41424142
* class.
@@ -4147,8 +4147,22 @@ public static boolean isPerfOrAboveLogging(HiveConf conf) {
41474147
public static String jarFinderGetJar(Class klass) {
41484148
Preconditions.checkNotNull(klass, "klass");
41494149
ClassLoader loader = klass.getClassLoader();
4150+
return jarFinderGetJar(loader, klass.getName());
4151+
}
4152+
4153+
/**
4154+
* Returns the full path to the Jar containing the class.
4155+
*
4156+
* @param loader
4157+
* the classloader instance to scan for jars.
4158+
* @param className
4159+
* the name of the class to look for.
4160+
*
4161+
* @return path to the Jar containing the class.
4162+
*/
4163+
public static String jarFinderGetJar(ClassLoader loader, String className) {
41504164
if (loader != null) {
4151-
String class_file = klass.getName().replaceAll("\\.", "/") + ".class";
4165+
String class_file = className.replaceAll("\\.", "/") + ".class";
41524166
try {
41534167
for (Enumeration itr = loader.getResources(class_file); itr.hasMoreElements();) {
41544168
URL url = (URL) itr.nextElement();

ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionState.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.hadoop.hive.ql.exec.tez;
1919

2020
import org.apache.hadoop.hive.common.JavaVersionUtils;
21-
import org.apache.hadoop.registry.client.api.RegistryOperations;
2221

2322
import java.io.File;
2423
import java.io.IOException;
@@ -308,7 +307,11 @@ protected void openInternal(String[] additionalFilesNotFromConf,
308307
addJarLRByClass(LlapTaskSchedulerService.class, commonLocalResources);
309308
addJarLRByClass(LlapProtocolClientImpl.class, commonLocalResources);
310309
addJarLRByClass(LlapProtocolClientProxy.class, commonLocalResources);
311-
addJarLRByClass(RegistryOperations.class, commonLocalResources);
310+
addJarLRByClassName(
311+
getClass().getClassLoader(),
312+
"org.apache.hadoop.registry.client.api.RegistryOperations",
313+
commonLocalResources
314+
);
312315
}
313316

314317
// Create environment for AM.
@@ -852,15 +855,27 @@ private String getKey(final FileStatus fileStatus) {
852855
return fileStatus.getPath() + ":" + fileStatus.getLen() + ":" + fileStatus.getModificationTime();
853856
}
854857

858+
private void addJarLRByPath(String jarPath, final Map<String, LocalResource> lrMap) throws IOException {
859+
final File jar = new File(jarPath);
860+
final String localJarPath = jar.toURI().toURL().toExternalForm();
861+
final LocalResource jarLr = createJarLocalResource(localJarPath);
862+
lrMap.put(DagUtils.getBaseName(jarLr), jarLr);
863+
}
864+
855865
private void addJarLRByClass(Class<?> clazz, final Map<String, LocalResource> lrMap) throws IOException {
856866
String jarPath = Utilities.jarFinderGetJar(clazz);
857867
if (jarPath == null) {
858868
throw new IOException("Can't find jar for: " + clazz);
859869
}
860-
final File jar = new File(jarPath);
861-
final String localJarPath = jar.toURI().toURL().toExternalForm();
862-
final LocalResource jarLr = createJarLocalResource(localJarPath);
863-
lrMap.put(DagUtils.getBaseName(jarLr), jarLr);
870+
addJarLRByPath(jarPath, lrMap);
871+
}
872+
873+
private void addJarLRByClassName(ClassLoader loader, String className, final Map<String, LocalResource> lrMap) throws IOException {
874+
String jarPath = Utilities.jarFinderGetJar(loader, className);
875+
if (jarPath == null) {
876+
throw new IOException("Can't find jar for: " + className);
877+
}
878+
addJarLRByPath(jarPath, lrMap);
864879
}
865880

866881
private String getSha(final Path localFile) throws IOException, IllegalArgumentException {

0 commit comments

Comments
 (0)