org.apache.hadoop.hive.ql.exec.Utilities.jarFinderGetJar()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中org.apache.hadoop.hive.ql.exec.Utilities.jarFinderGetJar()方法的一些代码示例,展示了Utilities.jarFinderGetJar()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utilities.jarFinderGetJar()方法的具体详情如下:
包路径:org.apache.hadoop.hive.ql.exec.Utilities
类名称:Utilities
方法名:jarFinderGetJar

Utilities.jarFinderGetJar介绍

[英]Returns the full path to the Jar containing the class. It always return a JAR.
[中]返回包含类的Jar的完整路径。它总是返回一个罐子。

代码示例

代码示例来源:origin: apache/hive

private void addJarLRByClass(Class<?> clazz, final Map<String, LocalResource> lrMap) throws IOException,
  LoginException {
 final File jar =
   new File(Utilities.jarFinderGetJar(clazz));
 final String localJarPath = jar.toURI().toURL().toExternalForm();
 final LocalResource jarLr = createJarLocalResource(localJarPath);
 lrMap.put(DagUtils.getBaseName(jarLr), jarLr);
}

代码示例来源:origin: apache/drill

private void addJarLRByClass(Class<?> clazz, final Map<String, LocalResource> lrMap) throws IOException,
  LoginException {
 final File jar =
   new File(Utilities.jarFinderGetJar(clazz));
 final LocalResource jarLr =
   createJarLocalResource(jar.toURI().toURL().toExternalForm());
 lrMap.put(utils.getBaseName(jarLr), jarLr);
}

代码示例来源:origin: apache/hive

@SuppressWarnings("SameParameterValue") static void addDependencyJars(Configuration conf, Class<?>... classes)
  throws IOException {
 FileSystem localFs = FileSystem.getLocal(conf);
 Set<String> jars = new HashSet<>(conf.getStringCollection("tmpjars"));
 for (Class<?> clazz : classes) {
  if (clazz == null) {
   continue;
  }
  final String path = Utilities.jarFinderGetJar(clazz);
  if (path == null) {
   throw new RuntimeException("Could not find jar for class " + clazz + " in order to ship it to the cluster.");
  }
  if (!localFs.exists(new Path(path))) {
   throw new RuntimeException("Could not validate jar file " + path + " for class " + clazz);
  }
  jars.add(path);
 }
 if (jars.isEmpty()) {
  return;
 }
 //noinspection ToArrayCallWithZeroLengthArrayArgument
 conf.set("tmpjars", StringUtils.arrayToString(jars.toArray(new String[jars.size()])));
}

代码示例来源:origin: apache/hive

private void localizeJarForClass(FileSystem lfs, Path libDir, String className, boolean doThrow)
  throws IOException {
 String jarPath = null;
 boolean hasException = false;
 try {
  Class<?> auxClass = Class.forName(className);
  jarPath = Utilities.jarFinderGetJar(auxClass);
 } catch (Throwable t) {
  if (doThrow) {
   throw (t instanceof IOException) ? (IOException)t : new IOException(t);
  }
  hasException = true;
  String err = "Cannot find a jar for [" + className + "] due to an exception ("
    + t.getMessage() + "); not packaging the jar";
  LOG.error(err);
  System.err.println(err);
 }
 if (jarPath != null) {
  lfs.copyFromLocalFile(new Path(jarPath), libDir);
 } else if (!hasException) {
  String err = "Cannot find a jar for [" + className + "]; not packaging the jar";
  if (doThrow) {
   throw new IOException(err);
  }
  LOG.error(err);
  System.err.println(err);
 }
}

代码示例来源:origin: apache/hive

@SuppressWarnings("SameParameterValue") static void copyDependencyJars(Configuration conf, Class<?>... classes)
  throws IOException {
 Set<String> jars = new HashSet<>();
 FileSystem localFs = FileSystem.getLocal(conf);
 jars.addAll(conf.getStringCollection("tmpjars"));
 jars.addAll(Arrays.stream(classes)
   .filter(Objects::nonNull)
   .map(clazz -> {
    String path = Utilities.jarFinderGetJar(clazz);
    if (path == null) {
     throw new RuntimeException("Could not find jar for class "
       + clazz
       + " in order to ship it to the cluster.");
    }
    try {
     if (!localFs.exists(new Path(path))) {
      throw new RuntimeException("Could not validate jar file " + path + " for class " + clazz);
     }
    } catch (IOException e) {
     throw new RuntimeException(e);
    }
    return path;
   }).collect(Collectors.toList()));
 if (jars.isEmpty()) {
  return;
 }
 conf.set("tmpjars", StringUtils.arrayToString(jars.toArray(new String[0])));
}

代码示例来源:origin: apache/hive

Path jarPath = new Path(Utilities.jarFinderGetJar(c));
lfs.copyFromLocalFile(jarPath, libDir);
if (LOG.isDebugEnabled()) {

代码示例来源:origin: org.apache.hive/hive-llap-server

private void localizeJarForClass(FileSystem lfs, Path libDir, String className, boolean doThrow)
  throws IOException {
 String jarPath = null;
 boolean hasException = false;
 try {
  Class<?> auxClass = Class.forName(className);
  jarPath = Utilities.jarFinderGetJar(auxClass);
 } catch (Throwable t) {
  if (doThrow) {
   throw (t instanceof IOException) ? (IOException)t : new IOException(t);
  }
  hasException = true;
  String err = "Cannot find a jar for [" + className + "] due to an exception ("
    + t.getMessage() + "); not packaging the jar";
  LOG.error(err);
  System.err.println(err);
 }
 if (jarPath != null) {
  lfs.copyFromLocalFile(new Path(jarPath), libDir);
 } else if (!hasException) {
  String err = "Cannot find a jar for [" + className + "]; not packaging the jar";
  if (doThrow) {
   throw new IOException(err);
  }
  LOG.error(err);
  System.err.println(err);
 }
}

代码示例来源:origin: org.apache.hive/kafka-handler

@SuppressWarnings("SameParameterValue") static void copyDependencyJars(Configuration conf, Class<?>... classes)
  throws IOException {
 Set<String> jars = new HashSet<>();
 FileSystem localFs = FileSystem.getLocal(conf);
 jars.addAll(conf.getStringCollection("tmpjars"));
 jars.addAll(Arrays.stream(classes)
   .filter(Objects::nonNull)
   .map(clazz -> {
    String path = Utilities.jarFinderGetJar(clazz);
    if (path == null) {
     throw new RuntimeException("Could not find jar for class "
       + clazz
       + " in order to ship it to the cluster.");
    }
    try {
     if (!localFs.exists(new Path(path))) {
      throw new RuntimeException("Could not validate jar file " + path + " for class " + clazz);
     }
    } catch (IOException e) {
     throw new RuntimeException(e);
    }
    return path;
   }).collect(Collectors.toList()));
 if (jars.isEmpty()) {
  return;
 }
 conf.set("tmpjars", StringUtils.arrayToString(jars.toArray(new String[0])));
}

代码示例来源:origin: org.apache.hive/hive-llap-server

Path jarPath = new Path(Utilities.jarFinderGetJar(c));
lfs.copyFromLocalFile(jarPath, libDir);
if (LOG.isDebugEnabled()) {

相关文章

Utilities类方法