Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions ql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,6 @@
<version>${hadoop.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-registry</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-mapreduce-client-core</artifactId>
Expand Down
22 changes: 18 additions & 4 deletions ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -4136,7 +4136,7 @@ public static boolean isPerfOrAboveLogging(HiveConf conf) {
}

/**
* Returns the full path to the Jar containing the class. It always return a JAR.
* Returns the full path to the Jar containing the class. It always returns a JAR.
*
* @param klass
* class.
Expand All @@ -4147,11 +4147,25 @@ public static boolean isPerfOrAboveLogging(HiveConf conf) {
public static String jarFinderGetJar(Class klass) {
Preconditions.checkNotNull(klass, "klass");
ClassLoader loader = klass.getClassLoader();
return jarFinderGetJar(loader, klass.getName());
}

/**
* Returns the full path to the Jar containing the class.
*
* @param loader
* the classloader instance to scan for jars.
* @param className
* the name of the class to look for.
*
* @return path to the Jar containing the class.
*/
public static String jarFinderGetJar(ClassLoader loader, String className) {
if (loader != null) {
String class_file = klass.getName().replaceAll("\\.", "/") + ".class";
String classFilePath = className.replace('.', '/') + ".class";
try {
for (Enumeration itr = loader.getResources(class_file); itr.hasMoreElements();) {
URL url = (URL) itr.nextElement();
for (Enumeration<URL> itr = loader.getResources(classFilePath); itr.hasMoreElements();) {
URL url = itr.nextElement();
String path = url.getPath();
if (path.startsWith("file:")) {
path = path.substring("file:".length());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.apache.hadoop.hive.ql.exec.tez;

import org.apache.hadoop.hive.common.JavaVersionUtils;
import org.apache.hadoop.registry.client.api.RegistryOperations;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -308,7 +307,11 @@ protected void openInternal(String[] additionalFilesNotFromConf,
addJarLRByClass(LlapTaskSchedulerService.class, commonLocalResources);
addJarLRByClass(LlapProtocolClientImpl.class, commonLocalResources);
addJarLRByClass(LlapProtocolClientProxy.class, commonLocalResources);
addJarLRByClass(RegistryOperations.class, commonLocalResources);
addJarLRByClassName(
Utilities.getSessionSpecifiedClassLoader(),
"org.apache.hadoop.registry.client.api.RegistryOperations",
commonLocalResources
);
}

// Create environment for AM.
Expand Down Expand Up @@ -852,15 +855,33 @@ private String getKey(final FileStatus fileStatus) {
return fileStatus.getPath() + ":" + fileStatus.getLen() + ":" + fileStatus.getModificationTime();
}

private void addJarLRByPath(String jarPath, final Map<String, LocalResource> lrMap) throws IOException {
final File jar = new File(jarPath);
final String localJarPath = jar.toURI().toURL().toExternalForm();
final LocalResource jarLr = createJarLocalResource(localJarPath);
lrMap.put(DagUtils.getBaseName(jarLr), jarLr);
}

private void addJarLRByClass(Class<?> clazz, final Map<String, LocalResource> lrMap) throws IOException {
String jarPath = Utilities.jarFinderGetJar(clazz);
if (jarPath == null) {
throw new IOException("Can't find jar for: " + clazz);
}
final File jar = new File(jarPath);
final String localJarPath = jar.toURI().toURL().toExternalForm();
final LocalResource jarLr = createJarLocalResource(localJarPath);
lrMap.put(DagUtils.getBaseName(jarLr), jarLr);
addJarLRByPath(jarPath, lrMap);
}

private void addJarLRByClassName(
ClassLoader loader,
String className,
final Map<String, LocalResource> lrMap
) throws IOException {

String jarPath = Utilities.jarFinderGetJar(loader, className);
if (jarPath == null) {
throw new IOException("Can't find jar for: " + className);
}
addJarLRByPath(jarPath, lrMap);

}

private String getSha(final Path localFile) throws IOException, IllegalArgumentException {
Expand Down
4 changes: 4 additions & 0 deletions service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-registry</artifactId>
</dependency>
<dependency>
<groupId>org.pac4j</groupId>
<artifactId>pac4j-saml-opensamlv3</artifactId>
Expand Down