繁体   English   中英

如何在 hive shell 应用程序中添加 jars

[英]How to add jars on hive shell in a java application

我正在尝试在 hive shell 上添加 jar。 我知道服务器上的全局选项,但我的要求是在 hive shell 上按 session 添加它们。 我已将此class用于 hdfs dfs 命令,将 jars 添加到 ZDFCCFC63F86DED406799FE52A9 文件系统中

这是我尝试过的:

Created a folder on the hdfs /tmp Add the file to hdfs filesystem using FileSystem.copyFromLocalFile method (equivalent to the hdfs dfs -put myjar.jar /tmp

在 fhe fs 文件系统上设置文件的权限

使用 getFileSystem 方法检查 jar 是否已加载到 hdfs

使用listFiles列出 fs 文件系统上的文件以确认 jars 是否存在。

This works and I have the jars loaded to hdfs but i cannot add jars to the hive session

当我尝试将其添加到 hive shell 中时,我正在执行以下操作:

statement = setStmt(createStatement(getConnection()));
query = "add jar " + path;
statement.execute(query);

我收到此错误 [例如 /tmp/myjar.jar 的路径]:

Error while processing statement: /tmp/myjar.jar does not exist

路径上的其他排列,例如

query = "add jar hdfs://<host>:<port>" + path;
query = "add jar <host>:<port>" + path;

结果出错。

命令列出 jars 作品(没有结果)

query = "list jars";
ResultSet rs = statement.executeQuery(query);

我设法解决了这个问题

由于FileSystem的配置,该过程失败。 object 是我们将 jars 上传到的位置,然后将它们添加到 session 上。

这就是你如何初始化 FileSystem FileSystem fs = FileSystem.newInstance(conf);

object conf 应该具有 hive 服务器的属性。

为了使该过程正常工作,我需要在配置属性conf.set("fs.defaultFS", hdfsDstStr);上设置以下参数

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM