gpt4 book ai didi

java - 如何在Java应用程序中的Hive Shell上添加jar

转载 作者:行者123 更新时间:2023-12-02 19:13:11 25 4
gpt4 key购买 nike

我正在尝试在 hive 壳上添加jar。我知道服务器上的全局选项,但是我的要求是在配置单元 shell 上的每个 session 中添加它们。
我已将这个class用于hdfs dfs命令,将jar添加到hdfs文件系统中

这是我尝试过的:

在hdfs / tmp上创建一个文件夹
使用FileSystem.copyFromLocalFile method将文件添加到hdfs文件系统
(相当于hdfs dfs -put myjar.jar / tmp

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

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

使用listFiles在fs FileSystem上列出文件,以确认 jar 在那里。

这有效,我将jar加载到hdfs,但是我无法将jar添加到配置单元 session

当我尝试将其添加到配置单元 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;

结果错误。

列出 jar 的命令有效(无结果)
query = "list jars";
ResultSet rs = statement.executeQuery(query);

最佳答案

我设法解决了这个问题

由于FileSystem的配置,该过程失败。
该对象是我们在 jar 中添加 jar 之前将其添加到 session 中的位置。

这是您初始化文件系统的方式FileSystem fs = FileSystem.newInstance(conf);
对象conf应该具有配置单元服务器的属性。

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

关于java - 如何在Java应用程序中的Hive Shell上添加jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61621122/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com